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, 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. final static <S extends Drawable> Stoggleable(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.
final static <S extends Drawable> SonToggle(S $self, Function2<S, Boolean, Unit> func)Use this to add a simple listener for the Event.Change.State event. final static <S extends Drawable> SfadeIn(S $self, Long durationNanos)Alias for fade. final static <S extends Drawable> SfadeOut(S $self, Long durationNanos)Alias for fade. final static <S extends Drawable> Sfade(S $self, Boolean in, Long durationNanos)Fade this drawable in or out, with a given duration. 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> SdontScroll(S $self)Instruct this drawable to refuse scrolling even if it needs to be. final static <S extends Drawable> SminimumSize(S $self, Vec2 size)Specify a minimum size for this drawable. 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> SignoreLayout(S $self, Boolean state)Specify that this drawable should be ignored during the layout stage. final static <S extends Drawable> SsetAlpha(S $self, Float alpha)final static <S extends Drawable> Spadded(S $self, Float xPad, Float yPad)final static <S extends Drawable> Spadded(S $self, Float left, Float top, Float right, Float bottom)final static <S extends Drawable> Spadded(S $self, Vec4 padding)final static <S extends Drawable> 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 TextInput> Snumeric(S $self, Float min, Float max, Boolean integral)Make this TextInput only accept numbers between min and max. final static <S extends Drawable> SsetPalette(S $self, Colors.Palette palette)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 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 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 Block> Sradius(S $self, Float radius)final static <S extends Block> Sradii(S $self, FloatArray radii)final static <S extends Block> Sradii(S $self, Float topLeftRadius, Float topRightRadius, Float bottomLeftRadius, Float bottomRightRadius)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 (so visually on top)
receive events first
final static <S extends Drawable> Srelegate(S $self)Relegate this drawable, meaning it will, in relation to its siblings: be drawn first (so visually on the bottom)
receive events last
final static IntegercountChildren(Drawable $self)Returns a count of this drawable's children, including children of children. 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> SonClickZ(S $self, Function2<S, Event.Mouse.Clicked, Boolean> func)final static <S extends Drawable> SonClick(S $self, Function2<S, Event.Mouse.Clicked, Unit> func)final static <S extends Drawable> SonPress(S $self, Function2<S, Event.Mouse.Pressed, Unit> func)final static <S extends Drawable> SonDrag(S $self, Function2<S, Event.Mouse.Dragged, Unit> func)final static <S extends Drawable> Sfix(S $self)final static <S extends Drawable> UnitensureLargerThan(S $self, Vec2 vec)final static <S extends Drawable> Slocate(Drawable $self, String id)Locate a drawable by its name. final static BooleanisChildOf(Drawable $self, Drawable drawable)Returns trueif this drawable is a child of the specified drawable.final static BooleanisRelatedTo(Drawable $self, Drawable drawable)Returns trueif this drawable is a child of the specified drawable, or if the drawable is a child of this.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, 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. -
-
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, 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
-
onToggle
final static <S extends Drawable> S onToggle(S $self, Function2<S, Boolean, Unit> func)
Use this to add a simple listener for the Event.Change.State event.
- Since:
1.5.0
-
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
-
dontScroll
final static <S extends Drawable> S dontScroll(S $self)
Instruct this drawable to refuse scrolling even if it needs to be.
-
minimumSize
final static <S extends Drawable> S minimumSize(S $self, Vec2 size)
Specify a minimum size for this drawable. Note that this will also disable scrolling due to optimizations.
- Since:
1.4.4
-
ignoreLayout
final static <S extends Drawable> S ignoreLayout(S $self, Boolean state)
Specify that this drawable 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 drawable 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
-
padded
final static <S extends Drawable> S padded(S $self, Float left, Float top, Float right, Float bottom)
-
onChangeString
final static <S extends Drawable> 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
-
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, Colors.Palette palette)
-
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
-
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)
-
radii
final static <S extends Block> S radii(S $self, FloatArray radii)
-
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 Drawable> S prioritize(S $self)
Prioritize this drawable, 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 Drawable> S relegate(S $self)
Relegate this drawable, 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(Drawable $self)
Returns a count of this drawable's children, including children of children.
- Since:
1.0.1
-
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.
-
onClickZ
final static <S extends Drawable> S onClickZ(S $self, Function2<S, Event.Mouse.Clicked, Boolean> func)
-
onClick
final static <S extends Drawable> S onClick(S $self, Function2<S, Event.Mouse.Clicked, Unit> func)
-
onPress
final static <S extends Drawable> S onPress(S $self, Function2<S, Event.Mouse.Pressed, Unit> func)
-
onDrag
final static <S extends Drawable> S onDrag(S $self, Function2<S, Event.Mouse.Dragged, Unit> func)
-
ensureLargerThan
final static <S extends Drawable> Unit ensureLargerThan(S $self, Vec2 vec)
-
locate
final static <S extends Drawable> S locate(Drawable $self, String id)
Locate a drawable by its name.
This method is recursive, meaning it will search through all children of this drawable.
- Parameters:
id- the name of the drawable to locate.- Returns:
the drawable with the given name, or
nullif it was not found.- Since:
1.1.72
-
isChildOf
final static Boolean isChildOf(Drawable $self, Drawable drawable)
Returns
trueif this drawable is a child of the specified drawable.- Since:
1.4.2
-
isRelatedTo
final static Boolean isRelatedTo(Drawable $self, Drawable drawable)
Returns
trueif this drawable is a child of the specified drawable, or if the drawable 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.
-
-
-