Class: UINumItemSelector
The UINumItemSelector class represents a numeric item selection component for UI systems. Unlike UIItemSelector, this component highlights all items less than or equal to the selected item, creating a cascading visual effect.
The source file for this class is located in os/ui/UIComponents/UINumItemSelector.h.
Constructorβ
UINumItemSelectorβ
UINumItemSelector(Dimension dimension, Color color, T* output, uint16_t count, T* items, std::function<void(T)> callback);
Creates a new numeric item selector UI component.
Template Parameter:
T: The data type of the selectable items.
Parameters:
dimension(Dimension): The grid size of the item selector.colorColor: The color for the selector.output(T*): Pointer to the variable that will store the selected item.count(uint16_t): The number of items in the selector.items(T*): Pointer to the array of items.callback(std::function<void(T)>): A callback function invoked when an item is selected.
Methodsβ
GetColorβ
virtual Color GetColor();
Retrieves the color of the selector.
Returns:
Color: The color of the selector.
SetColorβ
void SetColor(Color color);
Sets the color of the selector.
Parameters:
colorColor: The new color for the selector.
GetSizeβ
virtual Dimension GetSize();
Calculates the dimensions of the selector grid. Override this method to provide custom dimensions.
Returns:
Dimension: The dimensions (widthandheight) of the selector.
Renderβ
virtual bool Render(Point origin);
Renders the selector grid, highlighting items less than or equal to the selected item. Override this method to customize the rendering behavior.
Parameters:
origin(Point): The top-left corner of the rendering area.
Returns:
bool:trueif rendering was successful.
Behavior:
- Items greater than the count are unlit.
 - Items less than or equal to the selected value are fully lit, while others are dimmed.
 
KeyEventβ
virtual bool KeyEvent(Point xy, KeyInfo* keyInfo);
Handles key events for selecting items. Override this method to customize the item selection behavior.
Parameters:
xy(Point): The position of the event relative to the selector grid.keyInfo(KeyInfo*): Information about the key event.
Behavior:
- Pressed: Updates the output value and invokes the callback, if defined.
 
Returns:
bool:trueif the event was handled,falseotherwise.
Comments