Class GUISlider<T>
java.lang.Object
com.blackrook.gui.GUIObject
com.blackrook.gui.object.GUIPanel
com.blackrook.gui.object.GUIGlassPanel
com.blackrook.gui.object.GUISlider<T>
- Type Parameters:
T- the value type.
- All Implemented Interfaces:
GUIValueField<T>
A slider class that alters an internal value depending on where
the slider sits on the slider bar.
This object already contains its own layout and a child object, its movement constrained to that of its parent, that acts as the slider thumb.
This object fires an EVENT_VALUE_CHANGE event when the slider changes.
This object and its descendants return specific theme keys depending on the current state of the slider.
Thumb:
| Enabled | THEME_KEY_SLIDER_THUMB |
| Focused | THEME_KEY_SLIDER_THUMB_FOCUSED |
| Disabled | THEME_KEY_SLIDER_THUMB_DISABLED |
Track:
| Horizontal, Enabled | THEME_KEY_SLIDER_HORIZONTAL_TRACK |
| Horizontal, Focused | THEME_KEY_SLIDER_HORIZONTAL_TRACK_FOCUSED |
| Horizontal, Disabled | THEME_KEY_SLIDER_HORIZONTAL_TRACK_DISABLED |
| Vertical, Enabled | THEME_KEY_SLIDER_VERTICAL_TRACK |
| Vertical, Focused | THEME_KEY_SLIDER_VERTICAL_TRACK_FOCUSED |
| Vertical, Disabled | THEME_KEY_SLIDER_VERTICAL_TRACK_DISABLED |
Track Start:
| Horizontal, Enabled | THEME_KEY_SLIDER_HORIZONTAL_TRACK_START |
| Horizontal, Focused | THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_FOCUSED |
| Horizontal, Disabled | THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_DISABLED |
| Vertical, Enabled | THEME_KEY_SLIDER_VERTICAL_TRACK_START |
| Vertical, Focused | THEME_KEY_SLIDER_VERTICAL_TRACK_START_FOCUSED |
| Vertical, Disabled | THEME_KEY_SLIDER_VERTICAL_TRACK_START_DISABLED |
Track End:
| Horizontal, Enabled | THEME_KEY_SLIDER_HORIZONTAL_TRACK_END |
| Horizontal, Focused | THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_FOCUSED |
| Horizontal, Disabled | THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_DISABLED |
| Vertical, Enabled | THEME_KEY_SLIDER_VERTICAL_TRACK_END |
| Vertical, Focused | THEME_KEY_SLIDER_VERTICAL_TRACK_END_FOCUSED |
| Vertical, Disabled | THEME_KEY_SLIDER_VERTICAL_TRACK_END_DISABLED |
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class GUIObject
GUIObject.ScaleType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TCurrent value.protected RangeModel<T> Slider model.protected GUISlider.StyleSlider style.static final StringTheme key for horizontal slider track.static final StringTheme key for horizontal slider track, disabled.static final StringTheme key for horizontal slider track end.static final StringTheme key for horizontal slider track end, disabled.static final StringTheme key for horizontal slider track end, focused.static final StringTheme key for horizontal slider track, focused.static final StringTheme key for horizontal slider track start.static final StringTheme key for horizontal slider track start, disabled.static final StringTheme key for horizontal slider track start, focused.static final StringTheme key for slider thumb.static final StringTheme key for slider thumb, disabled.static final StringTheme key for slider thumb, focused.static final StringTheme key for vertical slider track.static final StringTheme key for vertical slider track, disabled.static final StringTheme key for vertical slider track end.static final StringTheme key for vertical slider track end, disabled.static final StringTheme key for vertical slider track end, focused.static final StringTheme key for vertical slider track, focused.static final StringTheme key for vertical slider track start.static final StringTheme key for vertical slider track start, disabled.static final StringTheme key for vertical slider track start, focused.protected static final GUIActionMouse drag event on the thumb.protected static final GUIActionMouse press event on the thumb.static final StringThe name given to the thumb object.protected static final GUIActionKey press event on the thumb.protected GUIObjectInternal object for the thumb.protected floatThumb scalar.static final StringThe name given to the track end object.static final StringThe name given to the track object.static final StringThe name given to the track start object.protected GUIObjectInternal object for the track end.protected GUIObjectInternal object for the track.protected GUIObjectInternal object for the track start.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 GUIValueField
EVENT_VALUE_CHANGE -
Constructor Summary
ConstructorsConstructorDescriptionGUISlider(RangeModel<T> model) Creates a new GUI Slider object in horizontal style.GUISlider(RangeModel<T> model, GUISlider.Style style) Creates a new GUI Slider object.GUISlider(RangeModel<T> model, GUISlider.Style style, float thumbScalar) Creates a new GUI Slider object. -
Method Summary
Modifier and TypeMethodDescriptionprotected floatgetStyle()getThumb()floatGets the current thumb scalar.getTrack()getValue()This uses a special layout; to preserve it, this throws UnsupportedOperationException.voidsetThumbScalar(float thumbScalar) Sets the current thumb scalar.Sets this field's value.protected voidSets the internal values by the thumb position.Methods inherited from class GUIGlassPanel
getRenderedMethods inherited from class GUIPanel
getThemeKey, setThemeKeyMethods 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, getRenderGreen, getRenderHeight, getRenderPositionX, getRenderPositionY, getRenderRadius, getRenderRed, getRenderRotationZ, getRenderTextureScaleS, getRenderTextureScaleT, getRenderWidth, getScaleType, getSiblingsAsQuery, getTexture, getTheme, getVisible, hasAction, hasName, hasNamePattern, isAnimating, isConstrainedToParent, isEnabled, isFocused, isInert, isVisible, moveDown, moveToBack, moveToFront, moveUp, onGUIChange, releaseFocus, remove, removeChild, removeName, requestFocus, resizeChildren, rotate, setBounds, setBounds, setBoundsByChildren, setColor, setColor, setColorNotInherited, setConstrainToParent, setDimensions, setEnabled, setInert, setLayoutAttrib, setOpacity, setPosition, setRendered, setRotationZ, setScaleType, setTexture, setTheme, setVisible, stretch, toString, translate, unbindAction, unbindAllActions, updateDirty, updateScenePosition, useRenderRadius
-
Field Details
-
THEME_KEY_SLIDER_THUMB
-
THEME_KEY_SLIDER_THUMB_DISABLED
Theme key for slider thumb, disabled.- See Also:
-
THEME_KEY_SLIDER_THUMB_FOCUSED
Theme key for slider thumb, focused.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK
Theme key for horizontal slider track.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK_START
Theme key for horizontal slider track start.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK_END
Theme key for horizontal slider track end.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK_DISABLED
Theme key for horizontal slider track, disabled.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_DISABLED
Theme key for horizontal slider track start, disabled.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_DISABLED
Theme key for horizontal slider track end, disabled.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK_FOCUSED
Theme key for horizontal slider track, focused.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK_START_FOCUSED
Theme key for horizontal slider track start, focused.- See Also:
-
THEME_KEY_SLIDER_HORIZONTAL_TRACK_END_FOCUSED
Theme key for horizontal slider track end, focused.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK
Theme key for vertical slider track.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK_START
Theme key for vertical slider track start.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK_END
Theme key for vertical slider track end.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK_DISABLED
Theme key for vertical slider track, disabled.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK_START_DISABLED
Theme key for vertical slider track start, disabled.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK_END_DISABLED
Theme key for vertical slider track end, disabled.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK_FOCUSED
Theme key for vertical slider track, focused.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK_START_FOCUSED
Theme key for vertical slider track start, focused.- See Also:
-
THEME_KEY_SLIDER_VERTICAL_TRACK_END_FOCUSED
Theme key for vertical slider track end, focused.- See Also:
-
THUMB_NAME
-
TRACK_NAME
-
TRACK_START_NAME
-
TRACK_END_NAME
-
THUMB_PRESS
Key press event on the thumb. -
THUMB_MOUSE_PRESS
Mouse press event on the thumb. -
THUMB_MOUSE_DRAG
Mouse drag event on the thumb. -
style
Slider style. -
model
Slider model. -
thumbObject
Internal object for the thumb. -
trackObject
Internal object for the track. -
trackStartObject
Internal object for the track start. -
trackEndObject
Internal object for the track end. -
thumbScalar
protected float thumbScalarThumb scalar. -
currentValue
Current value.
-
-
Constructor Details
-
GUISlider
Creates a new GUI Slider object in horizontal style.- Parameters:
model- the range model to use for defining values.
-
GUISlider
Creates a new GUI Slider object.- Parameters:
model- the range model to use for defining values.style- the slider's style.
-
GUISlider
Creates a new GUI Slider object.- Parameters:
model- the range model to use for defining values.style- the slider's style.thumbScalar- the thumb scalar (from 0 to 1).
-
-
Method Details
-
setLayout
This uses a special layout; to preserve it, this throws UnsupportedOperationException.- Overrides:
setLayoutin classGUIObject- Parameters:
layout- the layout to use.- Returns:
- itself, to chain calls.
- Throws:
UnsupportedOperationException- if called.
-
getStyle
- Returns:
- the current slider style.
-
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.
-
getValue
- Specified by:
getValuein interfaceGUIValueField<T>- Returns:
- this field's current value.
-
getThumb
- Returns:
- the reference to the thumb object.
-
getTrackStart
- Returns:
- the reference to the track start object.
-
getTrackEnd
- Returns:
- the reference to the track end object.
-
getTrack
- Returns:
- the reference to the track object.
-
getThumbScalar
public float getThumbScalar()Gets the current thumb scalar. It's a value from 0 to 1 that describes the width of the thumb relative to the width/height of the entire slider. Affected by slider style.- Returns:
- the current scalar.
-
setThumbScalar
public void setThumbScalar(float thumbScalar) Sets the current thumb scalar. It's a value from 0 to 1 that describes the width of the thumb relative to the width/height of the entire slider. Affected by slider style.- Parameters:
thumbScalar- the new scalar.
-
getPositionScalar
protected float getPositionScalar()- Returns:
- the interpolation value between 0 and 1 using the position of the slider.
-
setValuesByThumbBounds
protected void setValuesByThumbBounds()Sets the internal values by the thumb position.
-