Class RadioButton
-
- All Implemented Interfaces:
-
kotlin.Cloneable
public final class RadioButton<T extends Object> extends ContainingComponent
A radiobutton component in PolyUI. Supports an array of generic values as options.
- Since:
0.23.0
-
-
Field Summary
Fields Modifier and Type Field Description private final transient Blockblockprivate final RadioButtonPropertiespropertiesprivate List<T>valuesprivate IntegerselectedIndexprivate final transient Function2<RadioButton<T>, T, Unit>onChangeprivate final ArrayList<Component>childrenprivate transient PolyColor.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 transient 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 RadioButton(RadioButtonProperties properties, Vec2<Unit> at, Vec2<Unit> size, Function1<T, String> toStringFunc, Function2<RadioButton<T>, T, Unit> onChange, Integer defaultIndex, Unit fontSize, T values)RadioButton(RadioButtonProperties properties, Vec2<Unit> at, Vec2<Unit> size, Function1<T, String> toStringFunc, Function2<RadioButton<T>, T, Unit> onChange, Integer defaultIndex, Unit fontSize, List<T> values)
-
Method Summary
Modifier and Type Method Description final BlockgetBlock()RadioButtonPropertiesgetProperties()final List<T>getValues()final UnitsetValues(List<T> values)final IntegergetSelectedIndex()final UnitsetSelectedIndex(Integer selectedIndex)final Function2<RadioButton<T>, T, Unit>getOnChange()final Tget()final Unitset(T value)Unitrender()Render the children of this component. UnitonInitComplete()This function is called when initialization of a drawable is complete, so it has been fully calculated. UnitcalculateBounds()Calculate the position and size of this drawable. Booleanaccept(Event event)called when this drawable receives an event. Vec2<Unit>calculateSize()Implement this function to return the size of this drawable, if no size is specified during construction. Unitsetup(Renderer renderer, PolyUI polyUI)give this a renderer reference and a PolyUI reference. -
Methods inherited from class org.polyfrost.polyui.component.ContainingComponent
addComponents, calculateChildBounds, clipDrawables, debugRender, getChildren, isInside, onColorsChanged, onFontsChanged, onParentInitComplete, preRender, recolor, recolorAll, recolorRecolorsAll, removeComponents, rescale, reset, trueX, trueY -
Methods inherited from class org.polyfrost.polyui.component.Component
addKeyframes, addOperation, canBeRemoved, draggable, every, getColor, getConsumesHover, getDisabled, getLayout, getParent, getSize, setColor, setConsumesHover, setDisabled, setLayout, setParent, setProperties, setSize, toString, wantRedraw -
Methods inherited from class org.polyfrost.polyui.component.Drawable
addEventHandler, addEventhandler, animateBy, animateTo, 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, moveBy, moveTo, postRender, removeOperation, 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
-
getProperties
RadioButtonProperties getProperties()
-
getSelectedIndex
final Integer getSelectedIndex()
-
setSelectedIndex
final Unit setSelectedIndex(Integer selectedIndex)
-
getOnChange
final Function2<RadioButton<T>, T, Unit> getOnChange()
-
render
Unit render()
Render the children of this component.
you must call super.render()!
-
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.
- Since:
0.19.0
-
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.
-
accept
Boolean accept(Event event)
called when this drawable receives an event.
make sure to call Drawable.accept!
- Returns:
true if the event should be consumed (cancelled so no more handlers are called), false otherwise.
-
calculateSize
Vec2<Unit> calculateSize()
Implement this function to return the size of this drawable, if no size is specified during construction.
This should be so that if the drawable can determine its own size (for example, it is an image), then the size parameter in the constructor can be omitted using:
size: Vec2<org.polyfrost.polyui.unit.Unit>? = null;and this method needs to be implemented!Otherwise, the size parameter in the constructor must be specified.
-
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.
-
-
-
-