Class Dropdown
-
- All Implemented Interfaces:
-
kotlin.Cloneable,org.polyfrost.polyui.component.Focusable
public final class Dropdown extends ContainingComponent implements Focusable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classDropdown.Entry
-
Field Summary
Fields Modifier and Type Field Description private final DropdownPropertiespropertiesprivate final transient Dropdown.Entryselectedprivate final transient Layoutdropdownprivate final transient Booleanactiveprivate final Integerdefaultprivate 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 Dropdown(DropdownProperties properties, Vec2<Unit> at, Vec2<Unit> size, Unit.Pixel heightBeforeScrolls, Integer default, Dropdown.Entry entries)
-
Method Summary
Modifier and Type Method Description DropdownPropertiesgetProperties()final Dropdown.EntrygetSelected()final LayoutgetDropdown()final BooleangetActive()final IntegergetDefault()Booleanaccept(FocusedEvent event)Accept a FocusedEvent and handle it. Booleanaccept(Event event)called when this drawable receives an event. Unitsetup(Renderer renderer, PolyUI polyUI)give this a renderer reference and a PolyUI reference. final Unitclose()final Unitopen()Unitrender()Render the children of this component. Vec2<Unit>calculateSize()Implement this function to return the size of this drawable, if no size is specified during construction. UnitcalculateBounds()Calculate the position and size of this drawable. UnitonInitComplete()This function is called when initialization of a drawable is complete, so it has been fully calculated. final Unitdefault()final static Array<out Dropdown.Entry>from(Class<?> enumClass)Constructs a dropdown from an enum class. final static Array<out Dropdown.Entry>from(Array<out Object> values)Constructs a dropdown from an array of values. -
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 org.polyfrost.polyui.component.Focusable
accept -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
Dropdown
Dropdown(DropdownProperties properties, Vec2<Unit> at, Vec2<Unit> size, Unit.Pixel heightBeforeScrolls, Integer default, Dropdown.Entry entries)
-
-
Method Detail
-
getProperties
DropdownProperties getProperties()
-
getSelected
final Dropdown.Entry getSelected()
-
getDropdown
final Layout getDropdown()
-
getDefault
final Integer getDefault()
-
accept
Boolean accept(FocusedEvent event)
Accept a FocusedEvent and handle it.
- Returns:
trueto consume the event (only applicable to FocusedEvent.Gained and FocusedEvent.Lost
-
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.
-
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.
-
render
Unit render()
Render the children of this component.
you must call super.render()!
-
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.
-
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.
-
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
-
from
final static Array<out Dropdown.Entry> from(Class<?> enumClass)
Constructs a dropdown from an enum class. This method will look at the first field in the enum entries, and if it is a String it will extract that; and use that as the name.
Otherwise, it will use the name of the enum entry as it is declared in the source code.
- Since:
0.19.0
-
from
final static Array<out Dropdown.Entry> from(Array<out Object> values)
Constructs a dropdown from an array of values. This method will call Any.toString on each value to get the name.
- Since:
0.19.0
-
-
-
-