Class Switch

  • All Implemented Interfaces:
    kotlin.Cloneable

    
    public final class Switch
    extends StateBlock
                        

    A simple switch component, which can be on or off.

    • Method Detail

      • 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.
      • render

         Unit render()

        draw script for this drawable.

      • onStateChanged

         Unit onStateChanged(Boolean state)

        This function is called when the state of the component changes.

        Parameters:
        state - The new state of the component.
      • 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.

      • 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.

      • rescale

         Unit rescale(Float scaleX, Float scaleY)

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

      • onInitComplete

         Unit onInitComplete()

        This function is called when initialization of a drawable is complete, so it has been fully calculated.

        This function is called once, and only once.

      • 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!