Class Drawable
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Drawable(Drawable children, Vec2 at, Align alignment, Vec2 size, Vec2 visibleSize, Colors.Palette palette, Boolean focusable)Drawable(Drawable children, Float x, Float y, Align alignment, Float width, Float height, Float visWidth, Float visHeight, Colors.Palette palette, Boolean focusable)
-
Method Summary
Modifier and Type Method Description final Vec2getAt()final UnitsetAt(Vec2 at)final Vec2getSize()final UnitsetSize(Vec2 size)final Vec2getVisibleSize()final UnitsetVisibleSize(Vec2 visibleSize)final BooleangetHasVisibleSize()final UnitsetHasVisibleSize(Boolean hasVisibleSize)final Vec4getPadding()final UnitsetPadding(Vec4 padding)final DrawablegetParentOrNull()final DrawablegetParent()final BytegetLayoutFlags()Flags that store various states of this drawable regarding the Positioner and resizing. final UnitsetLayoutFlags(@ApiStatus.Internal() Byte layoutFlags)Flags that store various states of this drawable regarding the Positioner and resizing. final BooleanisRawResize()final UnitsetRawResize(Boolean rawResize)final BooleanisLayoutIgnored()final UnitsetLayoutIgnored(Boolean layoutIgnored)final BooleancreatedWithSetPosition()final BooleancreatedWithSetSize()StringgetSimpleName()This is the name of this drawable, and it will be consistent over reboots of the program, so you can use it to get drawables from a layout by ID, e. UnitsetSimpleName(String simpleName)This is the name of this drawable, and it will be consistent over reboots of the program, so you can use it to get drawables from a layout by ID, e. final ArrayList<Drawable>getChildren()final PolyUIgetPolyUI()final RenderergetRenderer()final BooleanisOperating()final FramebuffergetFramebuffer()final PolyColorgetColorOrNull()internal storage for the color. final UnitsetColorInternal(@ApiStatus.Internal() PolyColor _color)internal storage for the color. final BooleanisFocused()focused flag for this drawable. final PolyColorgetColor()final UnitsetColor(PolyColor color)final Colors.PalettegetPalette()final UnitsetPalette(@SideEffects(values = {"color", "palette"}) Colors.Palette palette)final FloatgetXInternal()Internal x position of this drawable. final UnitsetXInternal(@ApiStatus.Internal() Float _x)Internal x position of this drawable. final FloatgetYInternal()Internal y position of this drawable. final UnitsetYInternal(@ApiStatus.Internal() Float _y)Internal y position of this drawable. final FloatgetX()final UnitsetX(@SideEffects(values = {"x", "_x", "atValid", "this.children::x"}, when = "value != x") Float x)final FloatgetY()final UnitsetY(@SideEffects(values = {"y", "_y", "atValid", "this.children::y"}, when = "value != y") Float y)final BooleanisSizeValid()final BooleanisScrolling()final BooleanneedsRedraw()final UnitsetNeedsRedraw(@SideEffects(values = {"_parent.needsRedraw"}, when = "field != value") Boolean needsRedraw)BooleangetShouldScroll()UnitsetShouldScroll(Boolean shouldScroll)final BooleanacceptsInput()final UnitsetAcceptsInput(Boolean acceptsInput)final BooleanisInitialized()final BytegetInputState()The current input state of this drawable. final UnitsetInputState(@Dispatches(event = "Lifetime.Disabled", when = "value == INPUT_DISABLED") @Dispatches(event = "Lifetime.Enabled", when = "value != INPUT_DISABLED") @Dispatches(event = "Mouse.Entered", when = "value > INPUT_NONE") @Dispatches(event = "Mouse.Exited", when = "value == INPUT_NONE") Byte inputState)BooleangetRenders()UnitsetRenders(Boolean renders)final BooleanisEnabled()final UnitsetEnabled(@SideEffects(values = {"inputState"}) Boolean enabled)final DoublegetRotation()current rotation of this drawable (radians). final UnitsetRotation(@Locking(when = "value == 0.0") Double rotation)final DoublegetSkewX()current skew in x dimension of this drawable (radians). final UnitsetSkewX(@Locking(when = "value == 0.0") Double skewX)final DoublegetSkewY()current skew in y dimension of this drawable (radians). final UnitsetSkewY(@Locking(when = "value == 0.0") Double skewY)final FloatgetScaleX()current scale in x dimension of this drawable. final UnitsetScaleX(Float scaleX)final FloatgetScaleY()current scale in y dimension of this drawable. final UnitsetScaleY(Float scaleY)final FloatgetAlpha()final UnitsetAlpha(Float alpha)The alpha value of this drawable. final AligngetAlignment()FloatgetWidth()UnitsetWidth(Float width)FloatgetHeight()UnitsetHeight(Float height)final BooleanisFocusable()final Unitat(Integer index, Float value)Set the position of this drawable programmatically. final Unitsize(Integer index, Float value)Set the size of this drawable programmatically. final Unitdraw()Unitrescale(Float scaleX, Float scaleY, Boolean position)Method that is called when the physical size of the total window area changes. final UnitclipChildren()BooleancanBeRemoved()function that should return true if it is ready to be removed from its parent. final UnitdebugDraw()Vec2calculateSize()Use this function to calculate the size of this drawable. Booleanaccept(Event event)called when this drawable receives an event. Booleansetup(PolyUI polyUI)give this a PolyUI reference. final UnitrepositionChildren()Reposition all the children of this drawable. final Unitrecalculate()Fully recalculate this drawable's size, and any of its children's positions. final UnitfixVisibleSize()final UnitresetScroll()reset the initial scroll position to the current position. final BooleanisInside(Float x, Float y)final Booleanintersects(Float x, Float y, Float width, Float height)Drawableclone()Implement this function to enable cloning of your Drawable. StringtoString()StringdebugString()Override this function to add things to the debug display of this drawable. final BooleanaddOperation(DrawableOp drawableOp)Add a DrawableOp to this drawable. final UnitaddOperation(DrawableOp drawableOps)final UnitremoveOperation(DrawableOp drawableOp)Remove an operation from this drawable. final UnitaddChild(Drawable child, Boolean recalculate)the runtime equivalent of adding children to this drawable during the constructor. final UnitaddChild(Drawable children)final UnitremoveChild(Drawable child, Boolean recalculate)final UnitremoveChild(Integer index, Boolean recalculate)final Drawableget(Integer index)final Drawableget(String id)final Drawableget(Float x, Float y)final Unitset(Drawable old, Drawable new)Replace a child of this drawable with another drawable. final Unitset(Integer old, Drawable new)final <E extends Event, S extends Drawable> Son(S $self, E event, Function2<S, E, Boolean> handler)final <E extends Event, S extends Drawable> SaddEventhandler(S $self, E event, Function2<S, E, Unit> handler)final BooleanhasListenersFor(Class<out Event> event)returns trueif this drawable has any non-specific event handlers registered for it.final BooleanhasListenersFor(Event event)returns trueif this drawable has any specific event handlers registered for it.-
-
Method Detail
-
getVisibleSize
final Vec2 getVisibleSize()
-
setVisibleSize
final Unit setVisibleSize(Vec2 visibleSize)
-
getHasVisibleSize
final Boolean getHasVisibleSize()
-
setHasVisibleSize
final Unit setHasVisibleSize(Boolean hasVisibleSize)
-
getPadding
final Vec4 getPadding()
-
setPadding
final Unit setPadding(Vec4 padding)
-
getParentOrNull
final Drawable getParentOrNull()
-
getLayoutFlags
final Byte getLayoutFlags()
Flags that store various states of this drawable regarding the Positioner and resizing. Currently, the following is stored here:
bit 0: rawResize
bit 1: createdWithSetSize
bit 2: createdWithSetPosition
bit 3: layoutIgnored
this means there are still 4 bits that can be used for simple boolean-type properties. this is protected so you can use it yourself, but more bits may be used internally in the future. In order to maintain forward compatability, you should use the highest indexes for your flags.
- Since:
1.4.4
-
setLayoutFlags
final Unit setLayoutFlags(@ApiStatus.Internal() Byte layoutFlags)
Flags that store various states of this drawable regarding the Positioner and resizing. Currently, the following is stored here:
bit 0: rawResize
bit 1: createdWithSetSize
bit 2: createdWithSetPosition
bit 3: layoutIgnored
this means there are still 4 bits that can be used for simple boolean-type properties. this is protected so you can use it yourself, but more bits may be used internally in the future. In order to maintain forward compatability, you should use the highest indexes for your flags.
- Since:
1.4.4
-
isRawResize
final Boolean isRawResize()
-
setRawResize
final Unit setRawResize(Boolean rawResize)
-
isLayoutIgnored
final Boolean isLayoutIgnored()
-
setLayoutIgnored
final Unit setLayoutIgnored(Boolean layoutIgnored)
-
createdWithSetPosition
final Boolean createdWithSetPosition()
-
createdWithSetSize
final Boolean createdWithSetSize()
-
getSimpleName
String getSimpleName()
This is the name of this drawable, and it will be consistent over reboots of the program, so you can use it to get drawables from a layout by ID, e.g:
val text = myLayout["Text@4cf777e8"] as Text
-
setSimpleName
Unit setSimpleName(String simpleName)
This is the name of this drawable, and it will be consistent over reboots of the program, so you can use it to get drawables from a layout by ID, e.g:
val text = myLayout["Text@4cf777e8"] as Text
-
getChildren
final ArrayList<Drawable> getChildren()
-
getRenderer
final Renderer getRenderer()
-
isOperating
final Boolean isOperating()
-
getFramebuffer
final Framebuffer getFramebuffer()
-
getColorOrNull
final PolyColor getColorOrNull()
internal storage for the color.
-
setColorInternal
final Unit setColorInternal(@ApiStatus.Internal() PolyColor _color)
internal storage for the color.
-
isFocused
final Boolean isFocused()
focused flag for this drawable. Only ever true if focusable is true.
- Since:
1.4.2
-
getPalette
final Colors.Palette getPalette()
-
setPalette
final Unit setPalette(@SideEffects(values = {"color", "palette"}) Colors.Palette palette)
-
getXInternal
final Float getXInternal()
Internal x position of this drawable.
- Since:
1.1.0
-
setXInternal
final Unit setXInternal(@ApiStatus.Internal() Float _x)
Internal x position of this drawable.
- Since:
1.1.0
-
getYInternal
final Float getYInternal()
Internal y position of this drawable.
- Since:
1.1.0
-
setYInternal
final Unit setYInternal(@ApiStatus.Internal() Float _y)
Internal y position of this drawable.
- Since:
1.1.0
-
setX
final Unit setX(@SideEffects(values = {"x", "_x", "atValid", "this.children::x"}, when = "value != x") Float x)
-
setY
final Unit setY(@SideEffects(values = {"y", "_y", "atValid", "this.children::y"}, when = "value != y") Float y)
-
isSizeValid
final Boolean isSizeValid()
-
isScrolling
final Boolean isScrolling()
-
needsRedraw
final Boolean needsRedraw()
-
setNeedsRedraw
final Unit setNeedsRedraw(@SideEffects(values = {"_parent.needsRedraw"}, when = "field != value") Boolean needsRedraw)
-
getShouldScroll
Boolean getShouldScroll()
-
setShouldScroll
Unit setShouldScroll(Boolean shouldScroll)
-
acceptsInput
final Boolean acceptsInput()
-
setAcceptsInput
final Unit setAcceptsInput(Boolean acceptsInput)
-
isInitialized
final Boolean isInitialized()
-
getInputState
final Byte getInputState()
The current input state of this drawable. Note that this value is not responsible for dispatching events such as Event.Mouse.Exited or Event.Mouse.Pressed. It is just here for tracking purposes and for your benefit.
This value will be of INPUT_DISABLED (-1), INPUT_NONE (0), INPUT_HOVERED (1), or INPUT_PRESSED (2).
Do not modify this value!
- Since:
1.0.0
-
setInputState
@ApiStatus.Internal() final Unit setInputState(@Dispatches(event = "Lifetime.Disabled", when = "value == INPUT_DISABLED") @Dispatches(event = "Lifetime.Enabled", when = "value != INPUT_DISABLED") @Dispatches(event = "Mouse.Entered", when = "value > INPUT_NONE") @Dispatches(event = "Mouse.Exited", when = "value == INPUT_NONE") Byte inputState)
-
getRenders
Boolean getRenders()
-
setRenders
Unit setRenders(Boolean renders)
-
setEnabled
final Unit setEnabled(@SideEffects(values = {"inputState"}) Boolean enabled)
-
getRotation
final Double getRotation()
current rotation of this drawable (radians).
note: this method locks due to the fact the object needs to be translated to the center, rotated, and then translated back. It only locks if the value is
0.0.
-
setRotation
final Unit setRotation(@Locking(when = "value == 0.0") Double rotation)
-
getSkewX
final Double getSkewX()
current skew in x dimension of this drawable (radians).
locking if set to
0.0. See rotation.
-
getSkewY
final Double getSkewY()
current skew in y dimension of this drawable (radians).
Locking if set to
0.0. See rotation.
-
setAlpha
final Unit setAlpha(Float alpha)
The alpha value of this drawable.
Note: This value is clamped to the parent's alpha value.
- Since:
0.20.0
-
getAlignment
final Align getAlignment()
-
isFocusable
final Boolean isFocusable()
-
at
final Unit at(Integer index, Float value)
Set the position of this drawable programmatically. use this if you don't want to hardcode x or y (for example in mirroring or flipping).
- Since:
1.1.0
-
size
final Unit size(Integer index, Float value)
Set the size of this drawable programmatically. use this if you don't want to hardcode width or height (for example in mirroring or flipping).
- Since:
1.5.0
-
draw
@Locking()@Synchronized() final Unit draw()
-
rescale
@Locking()@MustBeInvokedByOverriders()@Synchronized() Unit rescale(Float scaleX, Float scaleY, Boolean position)
Method that is called when the physical size of the total window area changes.
- Parameters:
position- weather to scale the at property of this drawable as well.
-
clipChildren
final Unit clipChildren()
-
canBeRemoved
Boolean canBeRemoved()
function that should return true if it is ready to be removed from its parent.
This is used for drawables that need to wait for an animation to finish before being removed.
-
calculateSize
Vec2 calculateSize()
Use this function to calculate the size of this drawable. DO NOT include children in this calculation!
This function is only called if no size is supplied to this drawable at initialization. A return value of
nullindicates this drawable is not able to infer its own size, as it is for example, a Block with no reference. A drawable such as Text on the other hand, is able to infer its own size.
-
accept
@MustBeInvokedByOverriders() Boolean accept(Event event)
called when this drawable receives an event.
- Returns:
true if the event should be consumed (cancelled so no more handlers are called), false otherwise.
-
setup
@MustBeInvokedByOverriders() Boolean setup(PolyUI polyUI)
give this a PolyUI reference.
You can also use this method to do some calculations (such as text widths) that are not dependent on other sizes, or operations that require access to PolyUI things, like PolyUI.settings or PolyUI.translator
this method is called once, and only once.
-
repositionChildren
@Locking(when = "this.children != null")@Synchronized() final Unit repositionChildren()
Reposition all the children of this drawable.
Note that in most circumstances, recalculate is the method that you actually want.
- Since:
1.0.2
-
recalculate
@Locking(when = "this.children != null")@Synchronized() final Unit recalculate()
Fully recalculate this drawable's size, and any of its children's positions.
- Since:
1.0.7
-
fixVisibleSize
final Unit fixVisibleSize()
-
resetScroll
final Unit resetScroll()
reset the initial scroll position to the current position.
This method should be used if you externally modify the position of this drawable with scrolling enabled.
- Since:
1.0.5
-
isInside
final Boolean isInside(Float x, Float y)
- Returns:
trueif the given point is inside this drawable.
-
intersects
final Boolean intersects(Float x, Float y, Float width, Float height)
- Returns:
trueif the drawable has at least one point inside the given box (x, y, width, height).- Since:
0.21.4
-
debugString
String debugString()
Override this function to add things to the debug display of this drawable.
- Since:
1.1.1
-
addOperation
@Locking(when = "drawableOp.verify() == true")@Synchronized() final Boolean addOperation(DrawableOp drawableOp)
Add a DrawableOp to this drawable.
- Returns:
trueif the operation was added,falseif it was replaced.
-
addOperation
@Locking() final Unit addOperation(DrawableOp drawableOps)
-
removeOperation
@Locking(when = "operations != null")@Synchronized() final Unit removeOperation(DrawableOp drawableOp)
Remove an operation from this drawable.
-
addChild
@Locking()@Synchronized() final Unit addChild(Drawable child, Boolean recalculate)
the runtime equivalent of adding children to this drawable during the constructor.
-
removeChild
@Locking() final Unit removeChild(Drawable child, Boolean recalculate)
-
removeChild
@Locking()@Synchronized() final Unit removeChild(Integer index, Boolean recalculate)
-
set
@Locking()@Synchronized() final Unit set(Drawable old, Drawable new)
Replace a child of this drawable with another drawable.
This will add a nice, smooth Fade animation to the transition.
- Since:
1.0.1
-
on
final <E extends Event, S extends Drawable> S on(S $self, E event, Function2<S, E, Boolean> handler)
-
addEventhandler
final <E extends Event, S extends Drawable> S addEventhandler(S $self, E event, Function2<S, E, Unit> handler)
-
hasListenersFor
final Boolean hasListenersFor(Class<out Event> event)
returns
trueif this drawable has any non-specific event handlers registered for it.pass an event instance to this method for specific events.
- Since:
1.1.61
-
hasListenersFor
final Boolean hasListenersFor(Event event)
returns
trueif this drawable has any specific event handlers registered for it.pass a class instance to this method for non-specific events.
- Since:
1.1.71
-
-
-
-