WidgetHostBase class
#include <GGUI/Public/UIWidget.h>
The document API available to every widget. WidgetHost<T> adds the typed state.
Derived classes
-
template<typename T>class WidgetHost
- What a widget's hooks are given: its node, its typed state, and the document services it may use.
Constructors, destructors, conversion operators
- WidgetHostBase(UIContext& context, NodeHandle node)
- The host of widget node
nodeofcontext. - WidgetHostBase(const UIContext& context, NodeHandle node)
- The same, for const hooks; only const calls may be made.
Public functions
- auto Node() const -> NodeHandle
- The widget's node.
- auto Rect() const -> GGRect
- The node's rect.
- auto RectOf(NodeHandle node) const -> GGRect
- The rect of a node the widget built.
- auto IsFocused() const -> bool
- Whether the node has keyboard focus.
- auto IsCommandKey(uint16_t code, uint16_t mods) const -> bool
- True if a command at this node is bound to the chord, so the widget should leave the key alone.
- auto Focused() const -> NodeHandle
- The focused node; null if none.
- void SetFocusTo(NodeHandle node)
- Focus
node, one the widget built. - auto ScrollX() const -> float
- Horizontal scroll offset of the node's content.
- auto ScrollY() const -> float
- Vertical scroll offset of the node's content.
- void SetScroll(float x, float y)
- Scroll the node's content, clamped to the scrollable range.
- auto Layout() const -> LayoutInput
- The node's layout inputs.
- auto LayoutOf(NodeHandle node) const -> LayoutInput
- The layout inputs of a node the widget built.
- auto FirstChild() const -> NodeHandle
- The node's first child.
- auto NextOf(NodeHandle node) const -> NodeHandle
- The sibling after
node. - void InvalidatePaint()
- Appearance changed; size and position did not.
- void InvalidateLayout()
- Size or content changed.
- void Rerun(NodeHandle component)
- Re-run
component:in the current build if not reached yet, otherwise at the next update. - void SetChildAlign(NodeHandle child, GGAlign align)
- Cross-axis alignment of
child'schildren. - void Watch(const GGRevision& source)
- Call Woken when
sourceis bumped. Stays until ClearWatches. - void ClearWatches()
- Stop every Watch.
- void WakeNextUpdate()
- Call Woken once, at the start of the next update.
- void WakeAfter(float seconds)
- Call Woken after
secondsof document time (UIContext::AdvanceTime). - auto Time() const -> double
- Document time, in seconds.
- void AfterLayout()
- Call Laid after the next layout pass, when positions are known.
- void SetText(NodeHandle node, std::string_view text)
- Set the text of a text node the widget built. Triggers layout if it changed.
- void SetNodeClass(NodeHandle node, uint64_t classID)
- Set the style class (by ID) of a node the widget built.
- void SetMinHeight(NodeHandle node, float height)
- Set the minimum height of a node the widget built.
- void SetSize(NodeHandle node, const GGSize* width, const GGSize* height)
- Size of a node the widget built. Pass null to leave an axis unchanged.
- void SetChecked(NodeHandle node, bool bChecked)
- Set or clear StateChecked on a node the widget built.
- void SetPlace(NodeHandle node, float x, float y)
- Offset of an overlay the widget built (ui.Place), as PlaceProps::
X and Y. - void SetPan(NodeHandle node, float x, float y, float zoom)
- Pan and zoom of an Overflow::
Pan box the widget built (UIContext:: SetPan). - void SetDrawing(NodeHandle canvas, GGCanvas& drawing)
- Replace the drawing of a canvas the widget built, without running the code that built it.
- auto PointerX() const -> float
- Where the pointer was last seen, document space.
- auto PointerY() const -> float
- Where the pointer was last seen, document space.
- auto Lookup(std::string_view key) const -> std::string_view
- Localised text for
key. - void WantTyped(const GGRect& around)
- While focused, receive typed text through Text without becoming a text field (type-to-find).
- auto FirstChildOf(NodeHandle node) const -> NodeHandle
- The first child of a node the widget built.
- auto FocusFirstInside(NodeHandle node) -> bool
- Focus the first focusable node inside
node. False if nothing inside takes focus. - auto Actions() -> GGActionMap&
- The document's action map.
- auto ChordText(GGChord chord) const -> std::string
- A chord's localised display text ("Ctrl+O").
- auto Measure(uint64_t classID, std::string_view text) const -> TextMetrics
- Single-line size of
textin a class's font. - auto ClassID(std::string_view name) -> uint64_t
- ID of a style class. Also records the name for tools.
- auto Copy(std::string_view text) -> bool
- Put
texton the clipboard. False if there is no clipboard. - auto StateOf(NodeHandle node, const WidgetDef& definition) const -> void*
- State of
nodeif it is this kind of widget, else null. Typed version: WidgetHost<T>::Find.