com.threerings.opengl.gui
Class ScrollingList<V,C extends Component>

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.Container
          extended by com.threerings.opengl.gui.ScrollingList<V,C>
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>

public abstract class ScrollingList<V,C extends Component>
extends Container

Provides a scrollable, lazily instantiated component view of values


Nested Class Summary
protected static class ScrollingList.Entry<V,C extends Component>
          Used to track the total height of our entries.
protected  class ScrollingList.Viewport
          Does all the heavy lifting for the ScrollingList.
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.Container
Container.ChildOp
 
Field Summary
protected  int _lastBottom
           
protected  BoundedRangeModel _model
           
protected  List<ScrollingList.Entry<V,C>> _values
           
protected  ScrollBar _vbar
           
protected  ScrollingList.Viewport _vport
           
protected  MouseWheelListener _wheelListener
           
protected static int EXTENT
           
 
Fields inherited from class com.threerings.opengl.gui.Container
_children, _layout
 
Fields inherited from class com.threerings.opengl.gui.Component
_alpha, _backgrounds, _borders, _colors, _ctx, _cursor, _enabled, _height, _hover, _hoverable, _insets, _listeners, _parent, _preferredSize, _properties, _rect, _styleConfigs, _tipmouse, _tiptext, _tooltipStyle, _transferHandler, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Constructor Summary
ScrollingList(GlContext ctx)
          Instantiates an empty ScrollingList.
ScrollingList(GlContext ctx, Collection<? extends V> values)
          Instantiates a ScrollingList with an initial value collection.
 
Method Summary
 void addValue(int index, V value)
          Inserts a value into our list at the specified position.
protected  void addValue(int index, V value, boolean snap)
          Adds a value to the list and snaps to the bottom of the list if desired.
 void addValue(V value, boolean snapToBottom)
          Appends a value to our list, possibly scrolling our view to display it.
 void addValues(Collection<? extends V> values)
          Inserts a collection of values into our list.
 void addValues(int index, Collection<? extends V> values)
          Inserts a collection of values into our list starting at the specified position.
protected  void computeHeight(ScrollingList.Entry<V,C> entry, Container container)
          Calculates the height of an entry.
protected abstract  C createComponent(V value)
          Must be implemented by subclasses to instantiate the correct Component subclass for a given list value.
 int getIndex(V value)
          Returns the index of a value.
 void removeValues()
          Clears all the current values and any related components.
 void removeValuesAt(int index, int num)
          Removes values starting at a specific index.
 void removeValuesFromTop(int num)
          Removes values from the top of the list.
 void snapToValue(V value)
          Snaps the view so the value is at the top.
 
Methods inherited from class com.threerings.opengl.gui.Container
add, add, add, add, applyOperation, computePreferredSize, getComponent, getComponentCount, getComponentIndex, getDefaultStyleConfig, getFirstDescendantFocus, getHitComponent, getLastDescendantFocus, getLayoutManager, getNextFocus, getPreviousFocus, layout, remove, remove, removeAll, renderComponent, replace, setAlpha, setEnabled, setHoverable, setLayoutManager, validate, wasAdded, wasRemoved
 
Methods inherited from class com.threerings.opengl.gui.Component
acceptsFocus, addListener, boundsToString, changeCursor, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFallbackState, getFocusTarget, getHeight, getInsets, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getWindow, getX, getY, hasFocus, intersectScissor, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, scrollRectToVisible, scrollRectToVisible, setBackground, setBounds, setCursor, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, stateDidChange, updateCursor, updateFromStyleConfig, updateFromStyleConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_wheelListener

protected MouseWheelListener _wheelListener

_model

protected BoundedRangeModel _model

_values

protected List<ScrollingList.Entry<V,C extends Component>> _values

_vport

protected ScrollingList.Viewport _vport

_vbar

protected ScrollBar _vbar

_lastBottom

protected int _lastBottom

EXTENT

protected static final int EXTENT
See Also:
Constant Field Values
Constructor Detail

ScrollingList

public ScrollingList(GlContext ctx)
Instantiates an empty ScrollingList.


ScrollingList

public ScrollingList(GlContext ctx,
                     Collection<? extends V> values)
Instantiates a ScrollingList with an initial value collection.

Method Detail

addValue

public void addValue(V value,
                     boolean snapToBottom)
Appends a value to our list, possibly scrolling our view to display it.


addValue

public void addValue(int index,
                     V value)
Inserts a value into our list at the specified position.


addValues

public void addValues(Collection<? extends V> values)
Inserts a collection of values into our list.


addValues

public void addValues(int index,
                      Collection<? extends V> values)
Inserts a collection of values into our list starting at the specified position.


removeValues

public void removeValues()
Clears all the current values and any related components.


getIndex

public int getIndex(V value)
Returns the index of a value.


removeValuesFromTop

public void removeValuesFromTop(int num)
Removes values from the top of the list.


removeValuesAt

public void removeValuesAt(int index,
                           int num)
Removes values starting at a specific index.


snapToValue

public void snapToValue(V value)
Snaps the view so the value is at the top.


createComponent

protected abstract C createComponent(V value)
Must be implemented by subclasses to instantiate the correct Component subclass for a given list value.


computeHeight

protected void computeHeight(ScrollingList.Entry<V,C> entry,
                             Container container)
Calculates the height of an entry.


addValue

protected void addValue(int index,
                        V value,
                        boolean snap)
Adds a value to the list and snaps to the bottom of the list if desired.