Package com.prineside.tdi2.scene2d.ui
Class List<T>
java.lang.Object
com.prineside.tdi2.scene2d.Actor
com.prineside.tdi2.scene2d.ui.Widget
com.prineside.tdi2.scene2d.ui.List<T>
A list (aka list box) displays textual items and highlights the currently selected item.
ChangeListener.ChangeEvent
is fired when the list selection changes.
The preferred size of the list is determined by the text bounds of the items and the size of the List.ListStyle.selection
.
- Author:
- mzechner, Nathan Sweet
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
If this method is overridden, the super method orWidget.validate()
should be called to ensure the widget is laid out.int
getItemAt
(float y) float
int
getItemIndexAt
(float y) getItems()
Returns the internal items array.float
float
Returns the first selected item, or null.int
getStyle()
Returns the list's style.void
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child.void
setAlignment
(int alignment) Sets the horizontal alignment of the list items.void
setCullingArea
(Rectangle cullingArea) void
Sets the items visible in the list, clearing the selection if it is no longer valid.void
void
setSelected
(T item) Sets the selection to only the passed item, if it is a possible choice.void
setSelectedIndex
(int index) Sets the selection to only the selected index.void
setSelection
(ArraySelection<T> selection) void
setStyle
(List.ListStyle style) void
setTypeToSelect
(boolean typeToSelect) Methods inherited from class com.prineside.tdi2.scene2d.ui.Widget
getMaxHeight, getMaxHeightValue, getMaxWidth, getMaxWidthValue, getMinHeight, getMinHeightValue, getMinWidth, getMinWidthValue, getPrefHeightValue, getPrefWidthValue, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setPrefHeight, setPrefHeight, setPrefWidth, setPrefWidth, validate
Methods inherited from class com.prineside.tdi2.scene2d.Actor
act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront, toString
-
Constructor Details
-
List
-
-
Method Details
-
setStyle
-
getStyle
Returns the list's style. Modifying the returned style may not have an effect untilsetStyle(ListStyle)
is called. -
layout
public void layout()Description copied from interface:Layout
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child. This method should almost never be called directly, insteadLayout.validate()
should be used. -
draw
Description copied from class:Widget
If this method is overridden, the super method orWidget.validate()
should be called to ensure the widget is laid out. -
getSelection
-
setSelection
-
getSelected
Returns the first selected item, or null. -
setSelected
Sets the selection to only the passed item, if it is a possible choice.- Parameters:
item
- May be null.
-
getSelectedIndex
public int getSelectedIndex()- Returns:
- The index of the first selected item. The top item has an index of 0. Nothing selected has an index of -1.
-
setSelectedIndex
public void setSelectedIndex(int index) Sets the selection to only the selected index.- Parameters:
index
- -1 to clear the selection.
-
getOverItem
- Returns:
- May be null.
-
getPressedItem
- Returns:
- May be null.
-
getItemAt
- Returns:
- null if not over an item.
-
getItemIndexAt
public int getItemIndexAt(float y) - Returns:
- -1 if not over an item.
-
setItems
-
setItems
Sets the items visible in the list, clearing the selection if it is no longer valid. If a selection isSelection.getRequired()
, the first item is selected. This can safely be called with a (modified) array returned fromgetItems()
. -
clearItems
public void clearItems() -
getItems
Returns the internal items array. If modified,setItems(Array)
must be called to reflect the changes. -
getItemHeight
public float getItemHeight() -
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidth
in interfaceLayout
- Overrides:
getPrefWidth
in classWidget
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeight
in interfaceLayout
- Overrides:
getPrefHeight
in classWidget
-
toString
-
setCullingArea
- Specified by:
setCullingArea
in interfaceCullable
- Parameters:
cullingArea
- The culling area in the child actor's coordinates.
-
getCullingArea
- Returns:
- May be null.
- See Also:
-
setAlignment
public void setAlignment(int alignment) Sets the horizontal alignment of the list items.- Parameters:
alignment
- SeeAlign
.
-
getAlignment
public int getAlignment() -
setTypeToSelect
public void setTypeToSelect(boolean typeToSelect) -
getKeyListener
-