Class ContainingComponent

  • All Implemented Interfaces:
    kotlin.Cloneable

    
    public abstract class ContainingComponent
    extends Component
                        

    This component is used to contain other components.

    You need to implement the render functions as usual (ensure to call super!), and you will need to place the components yourself either in calculateSize or calculateBounds, depending on your needs (if it always infers its size, pass null to size and use calculateSize).

    This is used for situations where there is a component with multiple parts, for example Button which contains two images and a text as well as itself. It allows for them to share rotation, skew, etc.

    Since:

    0.17.4

    • Method Detail

      • trueX

         Float trueX()

        Note that this method will return the x if this method is called before the component is added to a layout.

      • trueY

         Float trueY()

        Note that this method will return the y if this method is called before the component is added to a layout.

      • preRender

         Unit preRender(Long deltaTimeNanos)

        pre-render functions, such as applying transforms. In this method, you should set needsRedraw to true if you have something to redraw for the next frame.

        Parameters:
        deltaTimeNanos - the time in nanoseconds since the last frame.
      • reset

         Unit reset()

        Use this function to reset your drawable's PolyText if it is using one.

      • debugRender

         Unit debugRender()

        add a debug render overlay for this drawable. This is always rendered regardless of the layout re-rendering if debug mode is on.

      • setup

         Unit setup(Renderer renderer, PolyUI polyUI)

        give this a renderer reference and a PolyUI reference.

        You can also use this method to do some calculations (such as text widths) that are not dependent on other sizes.

        If you need a method that has access to component's sizes, see here or here (if you are operating on yourself only).

        this method is called once, and only once.

      • rescale

         Unit rescale(Float scaleX, Float scaleY)

        Method that is called when the physical size of the total window area changes.

      • recolor

         Unit recolor(Color toColor, Animation.Type animation, Long durationNanos, Function1<Component, Unit> onFinish)

        Changes the color of the component to the specified color. Supports animation and callback function on finish.

        If the color is a Color.Gradient, this component's color will be changed to a gradient between the current color and the specified color.

        If the color is a Color.Chroma, this component's color will be changed to a chroma color, keeping its current hue for consistency. Note: This will look wierd if the current color is a gradient, and the brightness, saturation and alpha are NOT animated, so will change instantly.

        Parameters:
        toColor - The color to change the component to.
        animation - The type of animation to use.
        durationNanos - The duration of the animation in nanoseconds.
        onFinish - The callback function to execute when the color change animation finishes.
        Since:

        0.19.1

      • calculateBounds

         Unit calculateBounds()

        Calculate the position and size of this drawable. Make sure to call doDynamicSize in this method to avoid issues with sizing.

        This method is called once the layout is populated for children and component, and when a recalculation is requested.

        The value of layout's bounds will be updated after this method is called, so do not use layout's bounds as an updated value in this method.

      • onColorsChanged

         Unit onColorsChanged(Colors colors)

        Function that is called when the colors attached to this drawable change.

        If this is a layout, the colors will change, and all its children and components will be notified and updated accordingly.

        Make sure to call super.onColorsChanged() if you override this!

        Since:

        0.17.5

      • onFontsChanged

         Unit onFontsChanged(FontFamily fonts)

        Function that is called when the fonts attached to this drawable change.

        If this is a layout, the fonts will change, and all its children and components will be notified and updated accordingly.

        Make sure to call super.onFontsChanged() if you override this!

        Since:

        0.22.0

      • onParentInitComplete

         Unit onParentInitComplete()

        This function is called when initialization of this parent is complete.

        This function is called once, and only once.

        Since:

        0.19.0