Class Drawable
-
-
Field Summary
-
Method Summary
Modifier and Type Method Description final Vec2getSize()final UnitsetSize(Vec2 size)final Vec2get_visibleSize()internal field for visibleSize. final Unitset_visibleSize(@ApiStatus.Internal() Vec2 _visibleSize)internal field for visibleSize. final Vec2getVisibleSize()final UnitsetVisibleSize(Vec2 visibleSize)final BooleangetHasVisibleSize()final Drawableget_parent()final Unitset_parent(@ApiStatus.Internal() Drawable _parent)final DrawablegetParent()final UnitsetParent(Drawable parent)final BooleangetRawResize()This property controls weather this drawable resizes "raw", meaning it will not respect the aspect ratio. final UnitsetRawResize(Boolean rawResize)This property controls weather this drawable resizes "raw", meaning it will not respect the aspect ratio. 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 LinkedList<Drawable>getChildren()final PolyUIgetPolyUI()final RenderergetRenderer()final BooleangetOperating()final FramebuffergetFramebuffer()final PolyColor.AnimatedgetColor()Setting of this value could have undesirable results, and the PolyColor.Animated.recolor method should be used instead. final UnitsetColor(PolyColor.Animated color)Setting of this value could have undesirable results, and the PolyColor.Animated.recolor method should be used instead. final Colors.PalettegetPalette()final UnitsetPalette(Colors.Palette palette)final Floatget_x()Internal x position of this drawable. final Unitset_x(@ApiStatus.Internal() Float _x)Internal x position of this drawable. final Floatget_y()Internal y position of this drawable. final Unitset_y(@ApiStatus.Internal() Float _y)Internal y position of this drawable. final FloatgetX()final UnitsetX(Float x)final FloatgetY()final UnitsetY(Float y)final FloatgetWidth()final UnitsetWidth(Float width)final FloatgetHeight()final UnitsetHeight(Float height)final BooleangetSizeValid()final BooleangetAtValid()returns trueif the position of this drawable is valid (has been set)final BooleangetScrolling()final BooleangetNeedsRedraw()final UnitsetNeedsRedraw(Boolean needsRedraw)final BooleangetAcceptsInput()final UnitsetAcceptsInput(Boolean acceptsInput)final BooleangetInitialized()final BytegetInputState()The current input state of this drawable. final UnitsetInputState(Byte inputState)BooleangetRenders()Whether this drawable should be rendered. UnitsetRenders(Boolean renders)final BooleangetEnabled()final UnitsetEnabled(Boolean enabled)final DoublegetRotation()current rotation of this drawable (radians). final UnitsetRotation(@Locking() Double rotation)final DoublegetSkewX()current skew in x dimension of this drawable (radians). final UnitsetSkewX(@Locking() Double skewX)final DoublegetSkewY()current skew in y dimension of this drawable (radians). final UnitsetSkewY(@Locking() 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()The alpha value of this drawable. final UnitsetAlpha(Float alpha)final AligngetAlignment()final BooleangetFocusable()final Floatat(Integer index)Return the position of this drawable as if it were a Vec2. final Unitat(Integer index, Float value)Set the position of this drawable as if it were a Vec2. 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 UnittryMakeScrolling()Unitreset()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 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)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
-
get_visibleSize
final Vec2 get_visibleSize()
internal field for visibleSize.
- Since:
1.1.0
-
set_visibleSize
final Unit set_visibleSize(@ApiStatus.Internal() Vec2 _visibleSize)
internal field for visibleSize.
- Since:
1.1.0
-
getVisibleSize
final Vec2 getVisibleSize()
-
setVisibleSize
final Unit setVisibleSize(Vec2 visibleSize)
-
getHasVisibleSize
final Boolean getHasVisibleSize()
-
get_parent
final Drawable get_parent()
-
set_parent
final Unit set_parent(@ApiStatus.Internal() Drawable _parent)
-
getRawResize
final Boolean getRawResize()
This property controls weather this drawable resizes "raw", meaning it will not respect the aspect ratio.
By default, it is
false, so when resized, the smallest increase is used for both width and height. This means that it will stay at the same aspect ratio.- Since:
0.19.0
-
setRawResize
final Unit setRawResize(Boolean rawResize)
This property controls weather this drawable resizes "raw", meaning it will not respect the aspect ratio.
By default, it is
false, so when resized, the smallest increase is used for both width and height. This means that it will stay at the same aspect ratio.- Since:
0.19.0
-
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 LinkedList<Drawable> getChildren()
-
getRenderer
final Renderer getRenderer()
-
getOperating
final Boolean getOperating()
-
getFramebuffer
final Framebuffer getFramebuffer()
-
getColor
final PolyColor.Animated getColor()
Setting of this value could have undesirable results, and the PolyColor.Animated.recolor method should be used instead.
-
setColor
@ApiStatus.Experimental() final Unit setColor(PolyColor.Animated color)
Setting of this value could have undesirable results, and the PolyColor.Animated.recolor method should be used instead.
-
getPalette
final Colors.Palette getPalette()
-
setPalette
final Unit setPalette(Colors.Palette palette)
-
set_x
final Unit set_x(@ApiStatus.Internal() Float _x)
Internal x position of this drawable.
- Since:
1.1.0
-
set_y
final Unit set_y(@ApiStatus.Internal() Float _y)
Internal y position of this drawable.
- Since:
1.1.0
-
getSizeValid
final Boolean getSizeValid()
-
getAtValid
final Boolean getAtValid()
returns
trueif the position of this drawable is valid (has been set)- Since:
1.1.0
-
getScrolling
final Boolean getScrolling()
-
getNeedsRedraw
final Boolean getNeedsRedraw()
-
setNeedsRedraw
final Unit setNeedsRedraw(Boolean needsRedraw)
-
getAcceptsInput
final Boolean getAcceptsInput()
-
setAcceptsInput
final Unit setAcceptsInput(Boolean acceptsInput)
-
getInitialized
final Boolean getInitialized()
-
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
final Unit setInputState(Byte inputState)
-
getRenders
Boolean getRenders()
Whether this drawable should be rendered.
This is controlled by clipChildren to save resources by not drawing drawables which cannot be seen.
if you are calling render yourself (which you really shouldn't), you should check this value.
- Since:
0.21.4
-
setRenders
Unit setRenders(Boolean renders)
-
getEnabled
final Boolean getEnabled()
-
setEnabled
final Unit setEnabled(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() 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.
-
getAlignment
final Align getAlignment()
-
getFocusable
final Boolean getFocusable()
-
at
final Float at(Integer index)
Return the position of this drawable as if it were a Vec2.
- Since:
1.1.0
-
at
final Unit at(Integer index, Float value)
Set the position of this drawable as if it were a Vec2.
- Since:
1.1.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.
-
tryMakeScrolling
@Locking() final Unit tryMakeScrolling()
-
reset
@ApiStatus.Experimental()@MustBeInvokedByOverriders()@Locking()@Synchronized() Unit reset()
-
repositionChildren
@ApiStatus.Experimental()@Locking()@Synchronized() final Unit repositionChildren()
Reposition all the children of this drawable.
Note that in most circumstances, recalculate is the method that you actually want.
This method is experimental because it may interfere with children that were placed manually with the at property.
- Since:
1.0.2
-
recalculate
@ApiStatus.Experimental()@Locking()@Synchronized() final Unit recalculate()
Fully recalculate this drawable's size, and any of its children's positions.
This method is experimental because it may interfere with children that were placed manually with the at property.
- Since:
1.0.7
-
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()@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()@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)
-
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
-
-
-
-