Jazz2::UI::Menu::ChoiceItem class

Setting row that cycles through values.

Draws a label with the current value (and < > arrows) below it. Left/Right/Fire change the value through the OnChange callback (a no-op when read-only). Used for boolean toggles and multi-value options.

Base classes

class Widget
Base class of a menu widget.

Constructors, destructors, conversion operators

ChoiceItem(StringView label, Function<StringView()> value, Function<void(std::int32_t)> onChange, bool readOnly = false)

Public functions

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.
void Draw(IMenuContainer* root, Canvas* canvas, const Rectf& bounds, std::int32_t& charOffset) override
Draws the widget within the given bounds.
auto OnNavigate(const WidgetInput& input, IMenuContainer* root) -> bool override
Handles navigation input; returns true if it was consumed.
auto OnTouchEvent(const nCine::TouchEvent& event, Vector2i viewSize, IMenuContainer* root) -> bool override
Handles a touch event; returns true if it was consumed.
void OnSelected() override
Called when the widget becomes selected.

Public variables

String Label
Setting label.
bool ReadOnly
Whether the value can be changed.
Function<StringView()> Value
Returns the current value text.
Function<void(std::int32_t)> OnChange
Changes the value (direction is -1 for left, +1 for right/fire).
AnimatedValue Animation
Selection animation progress.
float ArrowSpacing
Extra horizontal spacing of the < > arrows, for rows with wider values.
float Height
Height of the item row.