Class SelectionBoxBase<TChain, TContainer, TElement>
- Namespace
- RichHudFramework.UI
- Assembly
- RichHudClient.dll
Core abstract base class for selection box controls. Manages a list of entries, keyboard/mouse selection, highlighting, and visual feedback (selection box + highlight box).
public abstract class SelectionBoxBase<TChain, TContainer, TElement> : HudElementBase, IReadOnlyHudElement, IReadOnlyHudNode, IReadOnlyHudParent, IEntryBox<TContainer, TElement>, IEnumerable<TContainer>, IEnumerable, IValueControl<TContainer>, IValueControl, IClickableElement, IFocusableElement where TChain : HudChain<TContainer, TElement>, new() where TContainer : class, ISelectionBoxEntry<TElement>, new() where TElement : HudElementBase, IMinLabelElement
Type Parameters
TChainThe concrete HudChain<TElementContainer, TElement> type used as the list container (e.g. HudChain<TElementContainer, TElement> or ScrollBox<TElementContainer, TElement>)
TContainerContainer type wrapping each entry
TElementUI element type displayed inside each container
- Inheritance
-
SelectionBoxBase<TChain, TContainer, TElement>
- Implements
-
IEntryBox<TContainer, TElement>IEnumerable<TContainer>IValueControl<TContainer>
- Derived
- Inherited Members
Remarks
SelectionBoxBase is the foundational abstract class for all selection-style list controls. It combines standardized input handling with a ListInputElement<TElementContainer, TElement> component to deliver core functionality. This includes features such as highlighting, selection management, and entry hiding.
The list's layout and scrolling behavior are governed by the generic TChain parameter, which defines the underlying container. This container is typically a HudChain<TElementContainer, TElement> for non-scrolling lists or a ScrollBox<TElementContainer, TElement> for scrollable lists. In both cases, the container manages the collection of elements through a HudCollection<TElementContainer, TElement>.
Concrete Implementations
To simplify usage, each concrete implementation of SelectionBoxBase provides aliases for its default generic parameters (TElementContainer and TElement).
The primary specialization, SelectionBox<TChain, TContainer, TElement, TValue>, forms the basis for selection boxes that use reusable and uniform pooled entries. It offers two main variants based on the container type:
- ChainSelectionBox<TContainer, TElement, TValue>: The non-scrolling variant.
- ScrollSelectionBox<TContainer, TElement, TValue>: The scrolling variant.
Additional derived types include:
- ListBox<TContainer, TElement, TValue>: A non-collapsing, scrolling list derived from
ScrollSelectionBox. - Dropdown<TContainer, TElement, TValue>: A collapsible scrolling list that incorporates
ListBoxinternally. - TreeBox<TContainer, TElement>: A non-scrolling, indented, collapsible list suited for heterogeneous, non-pooled entries.
- TreeList<TContainer, TElement, TValue>: A non-scrolling, indented, collapsible list optimized for uniform, pooled entries.
Properties
Count
Number of entries in the list.
public int Count { get; }
Property Value
EntryList
Read-only access to the list of entry containers.
public IReadOnlyList<TContainer> EntryList { get; }
Property Value
- IReadOnlyList<TContainer>
FocusColor
Background color of the selection overlay when the list has input focus.
public Color FocusColor { get; set; }
Property Value
FocusHandler
Handles keyboard/mouse focus for the entire control.
public IFocusHandler FocusHandler { get; }
Property Value
FocusTextColor
Text color used for the currently focused entry (keyboard navigation).
public Color FocusTextColor { get; set; }
Property Value
Format
Default text format applied to entry labels.
public GlyphFormat Format { get; set; }
Property Value
HighlightColor
Default background color of the highlight/selection overlay when not focused.
public Color HighlightColor { get; set; }
Property Value
HighlightPadding
Additional padding applied inside the highlight/selection overlay.
public Vector2 HighlightPadding { get; set; }
Property Value
IsMousedOver
True when the mouse cursor is over any part of the list.
public override bool IsMousedOver { get; }
Property Value
ListContainer
Allows nested collection-initializer syntax (e.g., new MyListBox { ListContainer = { entry1, entry2 } });
public SelectionBoxBase<TChain, TContainer, TElement> ListContainer { get; }
Property Value
- SelectionBoxBase<TChain, TContainer, TElement>
MouseInput
Mouse input handler for the list (used for hover/click detection).
public IMouseInput MouseInput { get; }
Property Value
SelectionIndex
Index of the currently selected entry (-1 if none).
public int SelectionIndex { get; }
Property Value
TabColor
Color of the small vertical tab drawn on the left side of the highlight/selection box.
public Color TabColor { get; set; }
Property Value
UpdateValueCallback
Convenience property for adding a selection callback during object initialization.
public EventHandler UpdateValueCallback { set; }
Property Value
Value
Currently selected entry, or null if nothing is selected.
public TContainer Value { get; }
Property Value
- TContainer
Methods
ClearSelection()
Clears the current selection
public void ClearSelection()
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<TContainer> GetEnumerator()
Returns
- IEnumerator<TContainer>
An enumerator that can be used to iterate through the collection.
GetRangeSize(int, int)
Calculates the combined size of the list entries within the given index range.
public virtual Vector2 GetRangeSize(int start = 0, int end = -1)
Parameters
Returns
- Vector2
Total size vector (Width, Height) required to fit the range.
OffsetSelectionIndex(int, bool)
Offsets selection index in the direction of the offset. If wrap == true, the index will wrap around if the offset places it out of range.
public void OffsetSelectionIndex(int offset, bool wrap = false)
Parameters
SetSelection(TContainer)
Sets the selection to the specified entry.
public void SetSelection(TContainer member)
Parameters
memberTContainer
SetSelectionAt(int)
Sets the selection to the member associated with the given object.
public void SetSelectionAt(int index)
Parameters
indexint
Events
ValueChanged
Raised when the selected entry changes.
public event EventHandler ValueChanged
Event Type
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
IEnumerator IEnumerable.GetEnumerator()
Returns
- IEnumerator
An IEnumerator object that can be used to iterate through the collection.