ListContainer class
#include <Jazz2/UI/Menu/MenuWidgets.h>
Base of vertical lists of selectable children.
Owns the children and the selected index, and implements Up/Down (wrapping) navigation plus Fire activation. Subclasses provide the actual layout/drawing: StackLayout centers a list that fits, while ScrollView scrolls a list that overflows.
Base classes
- class Widget
- Base class of a menu widget.
Derived classes
- class ScrollView
- Vertical list that scrolls when its children overflow the available area.
- class StackLayout
- Vertical list that centers its children within its bounds.
Constructors, destructors, conversion operators
Public functions
-
template<class T, typename... Params>auto Add(Params && ... args) -> T*
- Adds a child widget and returns a pointer to it.
-
auto GetSelectedIndex() const -> std::
int32_t - Returns the index of the selected child, or -1 if none.
-
void SetSelectedIndex(std::
int32_t index, bool centerInView = true) - Selects the focusable child at the given index;
centerInViewreveals it centered (for initial pre-selection), otherwise only scrolls it into view when it passes a viewport edge. - auto GetHeight() const -> float override
- Returns the height the widget occupies in a vertical layout.
- void OnUpdate(float timeMult) override
- Advances the widget's animations.
- auto OnNavigate(const WidgetInput& input, IMenuContainer* root) -> bool override
- Handles navigation input; returns
trueif it was consumed. -
auto OnKeyPressed(const nCine::
KeyboardEvent& event, IMenuContainer* root) -> bool override - Handles a key press while capturing text input; returns
trueif consumed. -
void OnTextInput(const nCine::
TextInputEvent& event) override - Handles a text input event while capturing text input.
- auto IsCapturingInput() const -> bool override
- Returns
truewhile the widget (or a descendant) is capturing raw text input, which restricts navigation.
Protected functions
-
void MoveSelection(std::
int32_t direction, IMenuContainer* root, bool playSound = true) -
void SelectAt(std::
int32_t index, IMenuContainer* root) - void OnSelectionMoved() virtual
- Called when the selection moves, so a scrolling container can keep it visible.
- void OnSelectionSet() virtual
- Called when the selection is set programmatically, so a scrolling container can reveal it.