Class StateBlock
-
- All Implemented Interfaces:
-
kotlin.Cloneable
public abstract class StateBlock extends Block
-
-
Field Summary
Fields Modifier and Type Field Description private final StatedPropertiespropertiesprivate Booleanactiveprivate transient FloatArraycornerRadiiprivate transient Color.Animatedcolorprivate transient Drawableparentprivate transient Layoutlayoutprivate transient BooleanconsumesHoverprivate Booleandisabledprivate Vec2<Unit>sizeprivate final transient HashMap<Event, Function2<Drawable, Event, Boolean>>eventHandlersprivate transient StringsimpleNameprivate transient Rendererrendererprivate transient PolyUIpolyUIprivate BooleanacceptsInputprivate final transient ByteinitStageprivate final transient BooleanmouseOverprivate Booleanrendersprivate Floatxprivate Floatyprivate Floatwidthprivate Floatheightprivate Booleanexistsprivate transient FloattrueXprivate transient FloattrueYprivate final Unit.TypeatTypeprivate final Unit.TypesizeTypeprivate final BooleanisDynamicprivate Doublerotationprivate DoubleskewXprivate DoubleskewYprivate FloatscaleXprivate FloatscaleYprivate Floatalphaprivate transient Floatacxprivate transient Floatacyprivate final Vec2<Unit>atprivate final BooleanrawResize
-
Constructor Summary
Constructors Constructor Description StateBlock(StatedProperties properties, Vec2<Unit> at, Vec2<Unit> size, Boolean rawResize, Boolean defaultState, Function2<StateBlock, Boolean, Unit> onStateChange, Function1<EventDSL<StateBlock>, Unit> events)
-
Method Summary
Modifier and Type Method Description StatedPropertiesgetProperties()final BooleangetActive()This is the variable which holds what state the component is in. final UnitsetActive(Boolean active)Booleanaccept(Event event)called when this drawable receives an event. Unitsetup(Renderer renderer, PolyUI polyUI)give this a renderer reference and a PolyUI reference. UnitonStateChanged(Boolean state)This function is called when the state of the component changes. UnitonColorsChanged(Colors colors)Function that is called when the colors attached to this drawable change. -
Methods inherited from class org.polyfrost.polyui.component.impl.Block
getCornerRadii, render, setCornerRadii -
Methods inherited from class org.polyfrost.polyui.component.Component
addKeyframes, addOperation, calculateBounds, canBeRemoved, debugRender, draggable, every, getColor, getConsumesHover, getDisabled, getLayout, getParent, getSize, onFontsChanged, preRender, recolor, setColor, setConsumesHover, setDisabled, setLayout, setParent, setProperties, setSize, toString, trueX, trueY, wantRedraw -
Methods inherited from class org.polyfrost.polyui.component.Drawable
addEventHandler, addEventhandler, animateBy, animateTo, calculateSize, clone, debugPrint, doDynamicSize, events, fadeBy, fadeTo, getAcceptsInput, getAcx, getAcy, getAlpha, getAt, getAtType, getContainingLayout, getEventHandlers, getExists, getHeight, getInitStage, getMouseOver, getPolyUI, getRawResize, getRenderer, getRenders, getRotation, getScaleX, getScaleY, getSimpleName, getSizeType, getSkewX, getSkewY, getTrueX, getTrueY, getWidth, getX, getY, intersects, isDynamic, isInside, isInside, moveBy, moveTo, onInitComplete, onParentInitComplete, postRender, removeOperation, rescale, reset, resize, rotateBy, rotateTo, scaleBy, scaleTo, setAcceptsInput, setAcx, setAcy, setAlpha, setExists, setHeight, setPolyUI, setRenderer, setRenders, setRotation, setScaleX, setScaleY, setSimpleName, setSkewX, setSkewY, setTrueX, setTrueY, setWidth, setX, setY, skewBy, skewTo -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
StateBlock
StateBlock(StatedProperties properties, Vec2<Unit> at, Vec2<Unit> size, Boolean rawResize, Boolean defaultState, Function2<StateBlock, Boolean, Unit> onStateChange, Function1<EventDSL<StateBlock>, Unit> events)
-
-
Method Detail
-
getProperties
StatedProperties getProperties()
-
getActive
final Boolean getActive()
This is the variable which holds what state the component is in.
-
accept
Boolean accept(Event event)
called when this drawable receives an event.
make sure to call Drawable.accept!
-
setup
Unit setup(Renderer renderer, PolyUI polyUI)
give this a renderer reference and a PolyUI reference.
You can also use this method to do some calculations (such as text widths) that are not dependent on other sizes.
If you need a method that has access to component's sizes, see here or here (if you are operating on yourself only).
this method is called once, and only once.
-
onStateChanged
Unit onStateChanged(Boolean state)
This function is called when the state of the component changes.
- Parameters:
state- The new state of the component.
-
onColorsChanged
Unit onColorsChanged(Colors colors)
Function that is called when the colors attached to this drawable change.
If this is a layout, the colors will change, and all its children and components will be notified and updated accordingly.
Make sure to call super.onColorsChanged() if you override this!
-
-
-
-