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 Drawable> Spadded(S $self, Float xPad, Float yPad)final static <S extends Drawable> Spadded(S $self, Vec2 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 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 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> 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 <T extends DrawableOp> BooleanhasOperationOfType(Drawable $self)Returns trueif this drawable has a DrawableOp of the type T.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 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
-
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)
-
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)
-
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
-
hasOperationOfType
final static <T extends DrawableOp> Boolean hasOperationOfType(Drawable $self)
Returns
trueif this drawable has a DrawableOp of the type T.This can be used for operations on which no more than one of the same type can be active at once.
- Since:
1.4.4
-
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.
-
-
-