Class Switch
-
- All Implemented Interfaces:
-
kotlin.Cloneable
public final class Switch extends StateBlock
A simple switch component, which can be on or off.
-
-
Field Summary
Fields Modifier and Type Field Description private FloatfontSizeprivate Translator.Textlabelprivate final SwitchPropertiespropertiesprivate 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
-
Method Summary
Modifier and Type Method Description final FloatgetFontSize()final UnitsetFontSize(Float fontSize)final Translator.TextgetLabel()final UnitsetLabel(Translator.Text label)SwitchPropertiesgetProperties()UnitpreRender(Long deltaTimeNanos)pre-render functions, such as applying transforms. Unitrender()draw script for this drawable. UnitonStateChanged(Boolean state)This function is called when the state of the component changes. Unitsetup(Renderer renderer, PolyUI polyUI)give this a renderer reference and a PolyUI reference. UnitcalculateBounds()Calculate the position and size of this drawable. Unitrescale(Float scaleX, Float scaleY)Method that is called when the physical size of the total window area changes. UnitonInitComplete()This function is called when initialization of a drawable is complete, so it has been fully calculated. UnitonColorsChanged(Colors colors)Function that is called when the colors attached to this drawable change. -
Methods inherited from class org.polyfrost.polyui.component.impl.StateBlock
accept, getActive, setActive -
Methods inherited from class org.polyfrost.polyui.component.impl.Block
getCornerRadii, setCornerRadii -
Methods inherited from class org.polyfrost.polyui.component.Component
addKeyframes, addOperation, canBeRemoved, debugRender, draggable, every, getColor, getConsumesHover, getDisabled, getLayout, getParent, getSize, onFontsChanged, 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, onParentInitComplete, postRender, removeOperation, 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
-
-
Method Detail
-
getFontSize
final Float getFontSize()
-
setFontSize
final Unit setFontSize(Float fontSize)
-
getLabel
final Translator.Text getLabel()
-
setLabel
final Unit setLabel(Translator.Text label)
-
getProperties
SwitchProperties getProperties()
-
preRender
Unit preRender(Long deltaTimeNanos)
pre-render functions, such as applying transforms. In this method, you should set needsRedraw to true if you have something to redraw for the next frame.
- Parameters:
deltaTimeNanos- the time in nanoseconds since the last frame.
-
onStateChanged
Unit onStateChanged(Boolean state)
This function is called when the state of the component changes.
- Parameters:
state- The new state of the component.
-
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.
-
calculateBounds
Unit calculateBounds()
Calculate the position and size of this drawable. Make sure to call doDynamicSize in this method to avoid issues with sizing.
This method is called once the layout is populated for children and component, and when a recalculation is requested.
The value of layout's bounds will be updated after this method is called, so do not use layout's bounds as an updated value in this method.
-
rescale
Unit rescale(Float scaleX, Float scaleY)
Method that is called when the physical size of the total window area changes.
-
onInitComplete
Unit onInitComplete()
This function is called when initialization of a drawable is complete, so it has been fully calculated.
This function is called once, and only once.
-
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!
-
-
-
-