Class ExtensionsKt
-
- All Implemented Interfaces:
public final class ExtensionsKt
-
-
Method Summary
Modifier and Type Method Description final static <S extends Drawable> Sdraggable(S $self, Boolean withX, Boolean withY, Boolean free, Function1<S, Unit> onStart, Function1<S, Unit> onDrag, Function1<S, Unit> onDrop)Make this component draggable. final static <S extends Drawable> SaddHoverInfo(S $self, String text)Add some text that is shown when the mouse is left still over this drawable for 1 second or more. final static <S extends Drawable> SnamedId(S $self, String name)final static <S extends Drawable> Snamed(S $self, String name)final static <S extends Drawable> Sdisable(S $self, Boolean state)final static <S extends Drawable> Shide(S $self, Boolean state)final static <S extends Drawable> SsetAlpha(S $self, Float alpha)final static <S extends Text> SonChangeString(S $self, Function2<S, String, Boolean> func)Add a listener for changes to the given String-type property. final static <S extends Drawable> SonChangeState(S $self, Function2<S, Boolean, Boolean> func)Add a listener for changes to the given Boolean-type property. final static <S extends Drawable> SonChangeIndex(S $self, Function2<S, Integer, Boolean> func)Add a listener for changes to the given Int-type property. final static <S extends Drawable> SonChangeNumber(S $self, Function2<S, Float, Boolean> func)Add a listener for changes to the given Float-type property. final static <S extends Drawable> SsetPalette(S $self, Function1<Colors, Colors.Palette> palette)Set the color palette of this drawable during initialization, using the PolyUI colors instance. final static <S extends Drawable> SignoreLayout(S $self)Call this function to ignore this drawable during the calculation of the parent's positioning and size. final static <S extends Text> SsetFont(S $self, Function1<FontFamily, Font> font)Set the font of this text component during initialization, using the PolyUI fonts instance. final static <S extends Text> Ssecondary(S $self)final static <S extends Text> SaddValidationFunction(S $self, Function2<S, String, Boolean> func)Add a validation function to this text component. final static <S extends Drawable> SsetDestructivePalette(S $self)final static <S extends Drawable> SwithStates(S $self)final static <S extends Drawable> SwithStates(S $self, Boolean consume, Boolean showClicker, Function0<Animation> animation)final static <S extends Drawable> SwithCursor(S $self, Cursor cursor)final static <S extends Block> SwithBoarder(S $self, PolyColor color, Float width)final static <S extends Block> SwithBoarder(S $self, Float width, Function1<Colors, PolyColor> color)final static <S extends Drawable> SsetState(S $self, Byte state)Set the palette of this drawable according to one of the three possible component states in PolyUI. final static <S extends Drawable> Sprioritize(S $self)Prioritize this drawable, meaning it will, in relation to its siblings: be drawn last
receive events first
final static IntegercountChildren(Drawable $self)Returns a count of this drawable's children, including children of children. final static BooleanhasParentOf(Drawable $self, Drawable drawable)Returns trueif this drawable has a parent that is the provided drawable.final static BooleanhasChildIn(Drawable $self, Float x, Float y, Float width, Float height)final static <S extends Drawable> SonInit(S $self, Function2<S, Event.Lifetime.Init, Unit> function)final static <S extends Drawable> SafterInit(S $self, Function2<S, Event.Lifetime.PostInit, Unit> function)final static <S extends Drawable> SafterParentInit(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). final static <S extends Drawable> Sevents(S $self, Function1<EventDSL<S>, Unit> dsl)final static <S extends Drawable> SonClick(S $self, Function2<S, Event.Mouse.Clicked, Unit> func)final static <S extends Drawable> DrawableOpmakeChroma(PolyColor $self, Ref.LongRef speedNanos)Make the given color chroma, meaning it will change its hue over time. final static UnitanimateBy(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. final static UnitanimateTo(Drawable $self, Float tx, Float ty, 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. -
-
Method Detail
-
draggable
final static <S extends Drawable> 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 Drawable> S addHoverInfo(S $self, String text)
Add some text that is shown when the mouse is left still over this drawable for 1 second or more.
- Since:
1.0.3
-
onChangeString
final static <S extends Text> S onChangeString(S $self, Function2<S, String, Boolean> func)
Add a listener for changes to the given String-type property.
- Since:
1.0.6
-
onChangeState
final static <S extends Drawable> 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 Drawable> 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 Drawable> 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
-
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.
-
ignoreLayout
final static <S extends Drawable> S ignoreLayout(S $self)
Call this function to ignore this drawable during the calculation of the parent's positioning and size. It is equivalent to the following:
renders = false afterParentInit { renders = true }- Since:
1.1.4
-
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
-
addValidationFunction
final static <S extends Text> S addValidationFunction(S $self, Function2<S, String, Boolean> func)
Add a validation function to this text component.
The given func will have the text that is requested as the argument. Return
falseto cancel the change, meaning the text will not be set.
-
setDestructivePalette
final static <S extends Drawable> S setDestructivePalette(S $self)
-
withStates
final static <S extends Drawable> S withStates(S $self)
-
withStates
final static <S extends Drawable> S withStates(S $self, Boolean consume, Boolean showClicker, Function0<Animation> animation)
-
withCursor
final static <S extends Drawable> S withCursor(S $self, Cursor cursor)
-
withBoarder
final static <S extends Block> S withBoarder(S $self, PolyColor color, Float width)
-
withBoarder
final static <S extends Block> S withBoarder(S $self, Float width, Function1<Colors, PolyColor> color)
-
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 Drawable> S prioritize(S $self)
Prioritize this drawable, meaning it will, in relation to its siblings:
be drawn last
receive events first
- Since:
1.0.0
-
countChildren
final static Integer countChildren(Drawable $self)
Returns a count of this drawable's children, including children of children.
- Since:
1.0.1
-
hasParentOf
final static Boolean hasParentOf(Drawable $self, Drawable drawable)
Returns
trueif this drawable has a parent that is the provided drawable.
-
hasChildIn
final static Boolean hasChildIn(Drawable $self, Float x, Float y, Float width, Float height)
- Returns:
trueif this drawable has a child that intersects the provided rectangle.- Since:
1.0.4
-
onInit
final static <S extends Drawable> S onInit(S $self, Function2<S, Event.Lifetime.Init, Unit> function)
-
afterInit
final static <S extends Drawable> S afterInit(S $self, Function2<S, Event.Lifetime.PostInit, Unit> function)
-
afterParentInit
final static <S extends Drawable> 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.
-
onClick
final static <S extends Drawable> S onClick(S $self, Function2<S, Event.Mouse.Clicked, Unit> func)
-
makeChroma
@ApiStatus.Experimental() final static <S extends Drawable> DrawableOp makeChroma(PolyColor $self, Ref.LongRef speedNanos)
Make the given color chroma, meaning it will change its hue over time.
If you wish to change the speed of the color, you can change the value of the LongRef returned by toChromaSpeed:
// apply the chroma to the color of this Drawable val speed = 5.seconds.toChromaSpeed() this.color.applyChroma(speed) // now you can mutate the speed at any point you like speed.element = 10.seconds- Parameters:
speedNanos- the speed of the chroma, in nanoseconds.- Returns:
the DrawableOp that was applied to this drawable, so you can remove it later to stop the chroma.
- Since:
1.0.5
-
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, Float tx, Float ty, 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.
-
-
-