Class GUICycler<T>
java.lang.Object
com.blackrook.gui.GUIObject
com.blackrook.gui.object.GUILabel
com.blackrook.gui.object.GUICycler<T>
- Type Parameters:
T- the object type in the cycler.
- All Implemented Interfaces:
GUISelectable<T>, GUIValueField<T>
Option cycler abstract.
A cycler changes its value each click.
An
GUIValueField.EVENT_VALUE_CHANGE event is fired each value change.-
Nested Class Summary
Nested classes/interfaces inherited from class GUILabel
GUILabel.Alignment, GUILabel.Justification, GUILabel.ResizeMode, GUILabel.TextPieceNested classes/interfaces inherited from class GUIObject
GUIObject.ScaleType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final GUIActionprotected intThe current choice index.protected IndexedModel<T> The model to use.Fields inherited from class GUIObject
absoluteBounds, EVENT_BLUR, EVENT_CHANGE_ENABLE_STATE, EVENT_CHANGE_VISIBLE_STATE, EVENT_FOCUS, EVENT_GAMEPAD_AXIS, EVENT_GAMEPAD_PRESS, EVENT_GAMEPAD_RELEASE, EVENT_GAMEPAD_TAP_PRESS, EVENT_GAMEPAD_TAP_RELEASE, EVENT_GENERIC_INPUT, EVENT_KEY_PRESS, EVENT_KEY_RELEASE, EVENT_KEY_TYPE, EVENT_MOUSE_CLICK, EVENT_MOUSE_DRAG, EVENT_MOUSE_LEAVE, EVENT_MOUSE_MOVE, EVENT_MOUSE_OVER, EVENT_MOUSE_PRESS, EVENT_MOUSE_RELEASE, EVENT_MOUSE_WHEEL, EVENT_NAMED, EVENT_UNKNOWNFields inherited from interface GUISelectable
NO_SELECTIONFields inherited from interface GUIValueField
EVENT_VALUE_CHANGE -
Constructor Summary
ConstructorsConstructorDescriptionGUICycler(IndexedModel<T> model) Creates a new cycler with a set of items to cycle through. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdvances the cycler's selected index.intGets the selected index on the object.getValue()protected voidReverses the cycler's selected index.setSelectedIndex(int index) Sets the selected index on the object.Sets this field's value.Methods inherited from class GUILabel
getAlignment, getFont, getJustification, getMaxWidth, getResizeMode, getSize, getStartingLine, getText, getTextPiece, getTextPieceCount, getTexture, getThemeKey, isWordWrapping, onGUIChange, setAlignment, setBounds, setFont, setJustification, setMaxWidth, setResizeMode, setSize, setStartingLine, setText, setTheme, setThemeKey, setWordWrapping, stretchMethods inherited from class GUIObject
addChild, addChild, addName, addToRenderSet, animate, animate, animate, animateAbort, animateDelay, animateFinish, bindAction, callAction, correctPosition, fireEvent, getAbsoluteBounds, getAsQuery, getBounds, getChildrenAsQuery, getColor, getColorNotInherited, getDescendantsAsQuery, getFinalOpacity, getGeneration, getGUI, getLayout, getLayoutAttrib, getNativeBounds, getOpacity, getParent, getParentAsQuery, getRenderAlpha, getRenderBlue, getRendered, getRenderGreen, getRenderHeight, getRenderPositionX, getRenderPositionY, getRenderRadius, getRenderRed, getRenderRotationZ, getRenderTextureScaleS, getRenderTextureScaleT, getRenderWidth, getScaleType, getSiblingsAsQuery, getTheme, getVisible, hasAction, hasName, hasNamePattern, isAnimating, isConstrainedToParent, isEnabled, isFocused, isInert, isVisible, moveDown, moveToBack, moveToFront, moveUp, releaseFocus, remove, removeChild, removeName, requestFocus, resizeChildren, rotate, setBounds, setBoundsByChildren, setColor, setColor, setColorNotInherited, setConstrainToParent, setDimensions, setEnabled, setInert, setLayout, setLayoutAttrib, setOpacity, setPosition, setRendered, setRotationZ, setScaleType, setTexture, setVisible, toString, translate, unbindAction, unbindAllActions, updateDirty, updateScenePosition, useRenderRadius
-
Field Details
-
model
The model to use. -
currentIndex
protected int currentIndexThe current choice index. -
BASIC_ACTION
-
-
Constructor Details
-
GUICycler
Creates a new cycler with a set of items to cycle through.- Parameters:
model- the model that this cycler uses for values.
-
-
Method Details
-
setSelectedIndex
Description copied from interface:GUISelectableSets the selected index on the object. If the index is out of bounds, it should be set to -1, meaning nothing selected.- Specified by:
setSelectedIndexin interfaceGUISelectable<T>- Parameters:
index- the new selected index.- Returns:
- this selectable.
-
getSelectedIndex
public int getSelectedIndex()Description copied from interface:GUISelectableGets the selected index on the object.- Specified by:
getSelectedIndexin interfaceGUISelectable<T>- Returns:
- the current selected index.
-
getSelectedValue
- Specified by:
getSelectedValuein interfaceGUISelectable<T>- Returns:
- the current selected value, or null if no value selected.
-
getValue
- Specified by:
getValuein interfaceGUIValueField<T>- Returns:
- this field's current value.
-
setValue
Description copied from interface:GUIValueFieldSets this field's value. This must accept any object, and attempt to set the correct value based on it. This object must fire anGUIValueField.EVENT_VALUE_CHANGEevent if it changes from its current value.- Specified by:
setValuein interfaceGUIValueField<T>- Parameters:
value- the value to set.- Returns:
- itself, to chain calls.
-
advanceSelection
protected void advanceSelection()Advances the cycler's selected index. -
reverseSelection
protected void reverseSelection()Reverses the cycler's selected index.
-