#include <GGUI/Public/UI.h>
template<typename T>
WidgetScope class
WidgetScope<T>: a widget's node while it is being built, plus its state.
Returned by ui.Widget<T>. The node is open for content while the scope lives. Handlers set here receive the widget's state and host, so they need no captures:
box.OnPress([](LogView& view, WidgetHost<LogView>& host, const PointerEvent& event) { ... });
Constructors, destructors, conversion operators
- WidgetScope(UI& ui, NodeHandle node, T* state)
- Made by ui.Widget<T>.
- ~WidgetScope()
- Closes the widget's node.
- WidgetScope(const WidgetScope&) deleted
- operator bool() const explicit
- Always true, so it can open an
if.
Public functions
- auto operator=(const WidgetScope&) -> WidgetScope& deleted
- auto operator*() const -> T&
- The widget's state.
- auto operator->() const -> T*
- The widget's state.
- auto Node() const -> NodeHandle
- The widget's node.
- auto Host() const -> WidgetHost<T>
- The widget's host, as its hooks get it.
- void Layout(const LayoutInput& layout)
- Its layout inputs.
- void Class(std::string_view name)
- Its style classes.
- void Access(GGRole role, uint8_t state = 0)
- Accessibility role and AccessState bits.
- void AccessName(std::string_view name)
- Its accessible name.
- void Focusable()
- It takes keyboard focus.
- void React(GGReaction reaction, const GGHandler& handler)
- Forward a ready-made handler (the author's) for
reaction. - void Disabled(bool bDisabled)
- Disable it and its subtree. Declare only while true.
-
void Value(const UI::
ValueSpec& spec, float min, float max, float step, uint8_t decimals, UI:: Where where) - What it shows and what an edit does (UIValues.h), with range and step.
- void Cursor(CursorShape shape)
- The cursor shown over it.
-
template<typename TFn>void OnPress(TFn fn)
- A button went down over it:
fn(state, host, event). -
template<typename TFn>void OnDrag(TFn fn)
- The pointer moved while captured:
fn(state, host, event). -
template<typename TFn>void OnRelease(TFn fn)
- The captured button came up:
fn(state, host, event). -
template<typename TFn>void OnClick(TFn fn)
- It was clicked:
fn(state, host, event). -
template<typename TFn>void OnKey(TFn fn)
- A key handler that runs before the widget's own Key hook. Consumes unless it passes.