template<class TItem>
ScrollableMenuSection class
Simplifies creation of unified scrollable menu sections.
Base class for menu sections that present a vertically scrollable list of items. It handles selection, keyboard and kinetic touch scrolling, and layout within the clipped middle layer, leaving subclasses to provide and draw the individual items and react to their execution.
Base classes
- class MenuSection
- Base class of a menu section.
Constructors, destructors, conversion operators
Public functions
- auto GetClipRectangle(const Recti& contentBounds) -> Recti override
- Allows to override clip rectangle of the middle layer.
- void OnShow(IMenuContainer* root) override
- Called when the section is shown.
- void OnUpdate(float timeMult) override
- Called when the section should be updated.
- void OnDrawClipped(Canvas* canvas) override
- Called when the section should be drawn — the middle clipped layer.
- void OnTouchEvent(const TouchEvent& event, Vector2i viewSize) override
- Called when a touch event is triggered.
Protected types
- struct ListViewItem
- Generic item in ScrollableMenuSection.
Protected functions
-
void EnsureVisibleSelected(std::
int32_t offset = 0) - Makes currently selected item visible in the viewport.
- void OnExecuteSelected() pure virtual
- Called when the selected item should be executed.
- void OnLayoutItem(Canvas* canvas, ListViewItem& item) virtual
- Called when an item layout should be calculated.
-
void OnDrawEmptyText(Canvas* canvas,
std::
int32_t& charOffset) virtual - Called when an information about empty list should be drawn.
-
void OnDrawItem(Canvas* canvas,
ListViewItem& item,
std::
int32_t& charOffset, bool isSelected) pure virtual - Called when an item should be drawn.
- void OnHandleInput() virtual
- Called when input should be handled.
- void OnBackPressed() virtual
- Called when back button is pressed.
- void OnSelectionChanged(ListViewItem& item) virtual
- Called when selected item is changed.
-
void OnTouchUp(std::
int32_t newIndex, Vector2i viewSize, Vector2i touchPos) virtual - Called when a touch event is released.