Class ExtensionsKt

  • All Implemented Interfaces:

    
    public final class ExtensionsKt
    
                        
    • Constructor Detail

    • Method Detail

      • draggable

         final static <S extends Inputtable> S draggable(S $self, Boolean withX, Boolean withY, Boolean free, Function1<S, Unit> onStart, Function1<S, Unit> onDrag, Function1<S, Unit> onDrop)

        Make this component draggable.

        Parameters:
        free - if this is true, the component will be able to be dragged outside its parent.
      • addHoverInfo

         final static <S extends Inputtable> S addHoverInfo(S $self, Drawable drawables, Vec2 size, Align align, Point position)

        Add some text that is shown when the mouse is left still over this drawable for 1 second or more.

        Since:

        1.0.3

      • toggleable

         final static <S extends Drawable> S toggleable(S $self, Boolean default)

        Make this drawable toggleable, meaning that, when clicked:

        • it will change its palette to the brand foreground color if it is toggled on, and to the component background color if it is toggled off.

        • it will emit a Event.Change.State event. you can use the onToggle function to easily listen to this event.

        Since:

        1.5.0

      • fadeIn

         final static <S extends Drawable> S fadeIn(S $self, Long durationNanos)

        Alias for fade.

      • fadeOut

         final static <S extends Drawable> S fadeOut(S $self, Long durationNanos)

        Alias for fade.

      • fade

         final static <S extends Drawable> S fade(S $self, Boolean in, Long durationNanos)

        Fade this drawable in or out, with a given duration.

        If it is not initialized, it applies the fade instantly.

        Since:

        1.5.0

      • add3dEffect

         final static <S extends Drawable> S add3dEffect(S $self, Double xIntensity, Double yIntensity)

        Add a 3D hover effect to the specified drawable which slightly skews the object as the mouse moves across it, giving the appearance of it popping off the screen.

        Since:

        1.6.01

      • dontScroll

         final static <S extends Scrollable> S dontScroll(S $self)

        Instruct this component to refuse scrolling even if it needs to be.

      • minimumSize

         final static <S extends Scrollable> S minimumSize(S $self, Vec2 size)

        Specify a minimum size for this component. Note that this will also disable scrolling due to optimizations.

        Since:

        1.4.4

      • getTargetPosition

         final static <S extends Component> Vec2 getTargetPosition(S $self)

        Return the position that this drawable is currently moving to, or its current position if it is not moving.

        Since:

        1.6.02

      • getTargetSize

         final static <S extends Component> Vec2 getTargetSize(S $self)

        Return the size that this drawable is currently resizing to, or its current size if it is not resizing.

        Since:

        1.6.02

      • ignoreLayout

         final static <S extends Component> S ignoreLayout(S $self, Boolean state)

        Specify that this component should be ignored during the layout stage.

        This means that it will not be placed automatically by the positioner.

        Additionally, this will ignore if there is no size set on this component and no way to infer it.** This means that, if you use this incorrectly it will not be visible and may break things if your renderer doesn't like zero sizes.

        Since:

        1.4.4

      • onChangeState

         final static <S extends Inputtable> S onChangeState(S $self, Function2<S, Boolean, Boolean> func)

        Add a listener for changes to the given Boolean-type property.

        In PolyUI, this is for Checkbox and Switch only.

        Since:

        1.0.6

      • onChangeIndex

         final static <S extends Inputtable> S onChangeIndex(S $self, Function2<S, Integer, Boolean> func)

        Add a listener for changes to the given Int-type property.

        In PolyUI, this is for Radiobutton, and Dropdown only.

        Since:

        1.0.6

      • onChangeNumber

         final static <S extends Inputtable> S onChangeNumber(S $self, Function2<S, Float, Boolean> func)

        Add a listener for changes to the given Float-type property.

        In PolyUI, this is for Slider only.

        Since:

        1.0.6

      • numeric

         final static <S extends TextInput> S numeric(S $self, Float min, Float max, Boolean integral)

        Make this TextInput only accept numbers between min and max. It will then dispatch a Event.Change.Number event.

        If integral is true, it will only accept integers.

        Since:

        1.5.0

      • setPalette

         final static <S extends Drawable> S setPalette(S $self, Function1<Colors, Colors.Palette> palette)

        Set the color palette of this drawable during initialization, using the PolyUI colors instance.

      • setFont

         final static <S extends Text> S setFont(S $self, Function1<FontFamily, Font> font)

        Set the font of this text component during initialization, using the PolyUI fonts instance.

        Since:

        1.1.3

      • radii

         final static <S extends Block> S radii(S $self, Float topLeftRadius, Float topRightRadius, Float bottomLeftRadius, Float bottomRightRadius)
      • setState

         final static <S extends Drawable> S setState(S $self, Byte state)

        Set the palette of this drawable according to one of the three possible component states in PolyUI.

        Parameters:
        state - the state to set.
      • prioritize

         final static <S extends Component> S prioritize(S $self)

        Prioritize this component, meaning it will, in relation to its siblings:

        • be drawn last (so visually on top)

        • receive events first

        this method is experimental as it may interfere with statically-typed references to children.

        Since:

        1.0.0

      • relegate

         final static <S extends Component> S relegate(S $self)

        Relegate this component, meaning it will, in relation to its siblings:

        • be drawn first (so visually on the bottom)

        • receive events last

        this method is experimental as it may interfere with statically-typed references to children.

        Since:

        1.1.71

      • countChildren

         final static Integer countChildren(Component $self)

        Returns a count of this component's children, including children of children.

        Since:

        1.0.1

      • afterParentInit

         final static <S extends Inputtable> S afterParentInit(S $self, Integer depth, Function1<S, Unit> handler)

        Add an event handler to this drawable's parent, and (optionally) it's parent's parent (depth).

        This is used to run functions that may move or resize this drawable, as if they were ran under this Event.Lifetime.PostInit they would be overwritten by the positioning logic.

      • locate

         final static <S extends Component> S locate(Component $self, String id)

        Locate a component by its name.

        This method is recursive, meaning it will search through all children of this component.

        Parameters:
        id - the name of the drawable to locate.
        Returns:

        the drawable with the given name, or null if it was not found.

        Since:

        1.1.72

      • isRelatedTo

         final static Boolean isRelatedTo(Component $self, Component component)

        Returns true if this component is a child of the specified component, or if the component is a child of this.

        Since:

        1.4.2

      • animateBy

         final static Unit animateBy(Drawable $self, Vec2 at, Vec2 size, Double rotation, Float scaleX, Float scaleY, Double skewX, Double skewY, PolyColor color, Animation animation)

        Bulk add method for all the builtin drawable operations in PolyUI.

        The default values of this method are all zeroes, meaning that nothing is done.

        This is the "by" version of this method, meaning that each value is added to the current one of this drawable. See the animateTo method for the "to" equivalent, which sets each value to the provided one.

      • animateTo

         final static Unit animateTo(Drawable $self, Vec2 at, Vec2 size, Double rotation, Double skewX, Double skewY, Float scaleX, Float scaleY, PolyColor color, Animation animation)

        Bulk add method for all the builtin drawable operations in PolyUI.

        The default values of this method are all the current ones of this drawable, meaning that nothing is done.

        This is the "to" version of this method, meaning that each value is set to the provided one. See the animateBy method for the "by" equivalent, which adds each value to the current one of this drawable.