UIValues.h file
Value widgets: widgets that show a value and let the user change it.
All take the same two things: what to show, then what an edit does.
ui.Toggle("Slow Brain", GGBind(stats, load > 0.0f), [](bool bOn) { SlowBrain(bOn); }); ui.Slider({ .Max = 8, .Step = 0.25f }, GGBind(stats, load), [](float ms) { SetBrainDelay(ms); });
"What to show" is a plain value, a binding, a ui.State, or an Editable. The widget never writes to it; it reports the edit and the owner decides. The second argument is omitted only when the first can write itself:
auto bAdvanced = ui.State<bool>(false); ui.Toggle("Advanced", bAdvanced); // the widget sets the state ui.Slider({ .Max = 100 }, HealthOf(entity)); // an Editable carries its own writes
An edit has phases. Dragging a slider is one edit with many changes; clicking a toggle is one edit with one. The form of the second argument picks which phases it hears:
[](float value) { ... } every change OnCommit([](float value) { ... }) only the final value GGEdits<float>{ .Begin = ..., .Change = ..., .Commit = ..., .Cancel = ... } everything
While the user is holding a widget it shows its own value, not the bound one, so a value that arrives late (next frame, over the network) doesn't fight the drag. After release it keeps the chosen value until the bound value next changes.
Namespaces
- namespace GGUI
Classes
-
template<typename T>struct GGUI::GGEdits
- Handlers for every phase of an edit. Each takes the value, or nothing.
-
template<typename T>struct GGUI::CommitOnly
OnCommit([](float value) { ... }): only the final value.-
template<typename T>class GGUI::GGDoes
- The second argument of a value widget: what an edit does.
-
template<typename T>struct GGUI::Editable
- A value bundled with how to write it. Return one from a helper when there is one correct way to change something (a reflected field, a setting).
-
template<typename T>class GGUI::GGShows
- The first argument of a value widget: what it shows.
- struct GGUI::ToggleProps
- Properties of ui.Toggle.
- struct GGUI::SliderProps
- Properties of ui.Slider.
- struct GGUI::NumberProps
- ui.Number: a numeric field that can be typed or dragged.
-
template<NumberType T>struct GGUI::VectorChange
- Vector edit callback:
[](int axis, float value) { ... }, value in the components' type. -
template<NumberType T>class GGUI::GGVectorDoes
- What a ui.Vector's edit does: a lambda taking the component's index and new value.
- struct GGUI::VectorProps
- ui.Vector: labelled numeric fields side by side (position, size, rotation).