Class Drawable
-
-
Field Summary
Fields Modifier and Type Field Description private Vec2sizeprivate Vec2visibleSizeprivate final transient Drawableparentprivate Vec2atprivate BooleanrawResizeprivate transient StringsimpleNameprivate final LinkedList<Drawable>childrenprivate final transient PolyUIpolyUIprivate final Rendererrendererprivate Framebufferframebufferprivate PolyColor.Animatedcolorprivate final transient Colors.Palettepaletteprivate Floatxprivate Floatyprivate Floatwidthprivate Floatheightprivate FloatvisibleWidthprivate FloatvisibleHeightprivate transient BooleanneedsRedrawprivate transient BooleanacceptsInputprivate final transient Booleaninitializedprivate transient ByteinputStateprivate transient Booleanrendersprivate final BooleanconsumesHoverprivate Booleanenabledprivate Doublerotationprivate DoubleskewXprivate DoubleskewYprivate FloatscaleXprivate FloatscaleYprivate Floatalphaprivate Alignalignmentprivate final Booleanfocusable
-
Method Summary
Modifier and Type Method Description final Vec2getSize()final UnitsetSize(Vec2 size)final Vec2getVisibleSize()final UnitsetVisibleSize(Vec2 visibleSize)final DrawablegetParent()final Vec2getAt()final UnitsetAt(Vec2 at)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 FramebuffergetFramebuffer()final UnitsetFramebuffer(Framebuffer framebuffer)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 FloatgetX()final UnitsetX(Float x)final FloatgetY()final UnitsetY(Float y)final FloatgetWidth()final UnitsetWidth(Float width)final FloatgetHeight()final UnitsetHeight(Float height)final FloatgetVisibleWidth()final UnitsetVisibleWidth(Float visibleWidth)final FloatgetVisibleHeight()final UnitsetVisibleHeight(Float visibleHeight)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()UnitsetRenders(Boolean renders)weather or not this drawable should be rendered. BooleangetConsumesHover()final BooleangetEnabled()final UnitsetEnabled(Boolean enabled)final DoublegetRotation()current rotation of this drawable (radians). final UnitsetRotation(Double rotation)current rotation of this drawable (radians). final DoublegetSkewX()current skew in x dimension of this drawable (radians). final UnitsetSkewX(Double skewX)current skew in x dimension of this drawable (radians). final DoublegetSkewY()current skew in y dimension of this drawable (radians). final UnitsetSkewY(Double skewY)current skew in y dimension of this drawable (radians). final FloatgetScaleX()current scale in x dimension of this drawable. final UnitsetScaleX(Float scaleX)current scale in x dimension of this drawable. final FloatgetScaleY()current scale in y dimension of this drawable. final UnitsetScaleY(Float scaleY)current scale in y dimension of this drawable. final FloatgetAlpha()The alpha value of this drawable. final UnitsetAlpha(Float alpha)The alpha value of this drawable. final AligngetAlignment()final UnitsetAlignment(Align alignment)final BooleangetFocusable()final UnitsetPalette(Colors.Palette palette)For some reason, you can't have custom setters on lateinit properties, so this is a workaround. final Unitdraw()Unitrescale(Float scaleX, Float scaleY)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. Unitsetup(PolyUI polyUI)give this a PolyUI reference. UnitdebugPrint()debug print for this drawable. Unitreset()final UnitrepositionChildren()Reposition all the children of this drawable. 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()final UnitaddOperation(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)final UnitaddChild(Drawable children)final UnitremoveChild(Drawable child)final UnitremoveChild(Integer index)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 IntegercountChildren()final <E extends Event, S extends Drawable> SaddEventhandler(S $self, E event, Function2<S, E, Unit> handler)final <E extends Event, S extends Drawable> SaddEventHandler(S $self, E event, Function2<S, E, Boolean> handler)-
-
Method Detail
-
getVisibleSize
final Vec2 getVisibleSize()
-
setVisibleSize
final Unit setVisibleSize(Vec2 visibleSize)
-
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()
-
getFramebuffer
final Framebuffer getFramebuffer()
-
setFramebuffer
final Unit setFramebuffer(Framebuffer framebuffer)
-
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.Internal() 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()
-
getVisibleWidth
final Float getVisibleWidth()
-
setVisibleWidth
final Unit setVisibleWidth(Float visibleWidth)
-
getVisibleHeight
final Float getVisibleHeight()
-
setVisibleHeight
final Unit setVisibleHeight(Float visibleHeight)
-
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:
2.0.0
-
setInputState
final Unit setInputState(Byte inputState)
-
getRenders
Boolean getRenders()
-
setRenders
Unit setRenders(Boolean renders)
weather or not 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
-
getConsumesHover
Boolean getConsumesHover()
-
getEnabled
final Boolean getEnabled()
-
setEnabled
final Unit setEnabled(Boolean enabled)
-
getRotation
final Double getRotation()
current rotation of this drawable (radians).
-
setRotation
final Unit setRotation(Double rotation)
current rotation of this drawable (radians).
-
getAlignment
final Align getAlignment()
-
setAlignment
final Unit setAlignment(Align alignment)
-
getFocusable
final Boolean getFocusable()
-
setPalette
final Unit setPalette(Colors.Palette palette)
For some reason, you can't have custom setters on lateinit properties, so this is a workaround.
- Since:
1.0.1
-
rescale
Unit rescale(Float scaleX, Float scaleY)
Method that is called when the physical size of the total window area changes.
-
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
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
Unit 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.
-
debugPrint
Unit debugPrint()
debug print for this drawable.
-
repositionChildren
final Unit repositionChildren()
Reposition all the children of this drawable.
- Since:
1.0.2
-
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
-
clone
Drawable clone()
Implement this function to enable cloning of your Drawable.
If this function is not implemented, attempts to clone the drawable will not compile due to type erasure, but if this is ignored a CloneNotSupportedException will be thrown.
- Since:
0.19.0
-
addOperation
final Unit addOperation(DrawableOp drawableOp)
Add a DrawableOp to this drawable.
-
addOperation
final Unit addOperation(DrawableOp drawableOps)
-
removeOperation
final Unit removeOperation(DrawableOp drawableOp)
Remove an operation from this drawable.
-
removeChild
final Unit removeChild(Drawable child)
-
removeChild
final Unit removeChild(Integer index)
-
set
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
-
countChildren
final Integer countChildren()
-
addEventhandler
final <E extends Event, S extends Drawable> S addEventhandler(S $self, E event, Function2<S, E, Unit> handler)
-
-
-
-