Package tripleplay.ui
Class HistoryGroup<T,W extends Element<?>>
- Type Parameters:
T
- The type of item backing this historyW
- The type of element or widget stored in this history
- Direct Known Subclasses:
HistoryGroup.Labels
A scrolling vertical display, optimized for showing potentially very long lists such as a chat
log. Supports:
- addition of new elements on the end
- pruning old elements from the beginning
- progressive rendering of newly visible items in the list
- automatically keeping the last item visible
- purging of old rendered elements that are no longer visible
render(tripleplay.ui.HistoryGroup.Entry)
. Entries that are not visible
use an estimated size for layout purposes. This of course may produce some artifacts during
scrolling, which is the penalty of not computing the exact size.
NOTE: The elements in the UI (type W
) must not be mutated after rendering and must
have a constant size given a particular item and width. See render(tripleplay.ui.HistoryGroup.Entry)
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
History group of just labels.static class
A label that exposes the width hint and preferred size.Nested classes/interfaces inherited from class tripleplay.ui.Container
Container.Mutable<T extends Container.Mutable<T>>
Nested classes/interfaces inherited from class tripleplay.ui.Element
Element.Take
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new item to the end of the history.boolean
atBottom()
Tests if the history is currently at the bottom.void
pruneOld
(int adjustment) Prunes the given number of entries from the beginning of the history.void
Issues a request to scroll to the bottom of the list of history elements.void
setVerticalGap
(int vgap) Sets the vertical gap between history elements.Methods inherited from class tripleplay.ui.Composite
childAt, childCount, iterator, setStylesheet, stylesheet
Methods inherited from class tripleplay.ui.Container
removeFromParent
Methods inherited from class tripleplay.ui.Element
addStyles, addStyles, bindEnabled, bindVisible, bounds, constraint, enabledSlot, hierarchyChanged, isAdded, isEnabled, isShowing, isVisible, location, parent, setConstraint, setEnabled, setStyles, setStyles, setVisible, size, styles, visibleSlot, x, y
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
atBottom
public boolean atBottom()Tests if the history is currently at the bottom. If the history is at the bottom, then subsequent additions will cause automatic scrolling. By default, new groups are at the bottom. Subsequent upward scrolling will clear this and scrolling to the bottom will set it again. -
scrollToBottom
public void scrollToBottom()Issues a request to scroll to the bottom of the list of history elements. -
pruneOld
public void pruneOld(int adjustment) Prunes the given number of entries from the beginning of the history. -
addItem
Adds a new item to the end of the history. If the history is at the bottom, the item will be rendered immediately, otherwise the message group is invalidated so that the scroll bounds will be updated. -
setVerticalGap
public void setVerticalGap(int vgap) Sets the vertical gap between history elements. By default, the gap is set to 1.
-