std1.0.0-beta-7 SafeC docs

std :: gui::gui_widget

Struct std::GuiUi

#include <std/gui/gui_widget.h> source

struct GuiUi {
    &Widget root;
    ?&GuiWindow win;
    struct GuiTheme theme;
    float scale;
    struct GuiCanvas canvas;
    int canvasReady;
    struct Vec<&Widget> overlays;
    ?&Widget focus;
    ?&Widget hoverW;
    ?&Widget capture;
    float mouseX;
    float mouseY;
    int mouseInside;
    ?&Widget tipFor;
    double tipSince;
    &Widget tip;
    int tipShown;
    double nowMs;
    int needsLayout;
    int dirty;
    int layoutW;
    int layoutH;
    int cursor;
}

Everything a widget tree needs that isn't a widget: the window it's shown in, the theme and scale, keyboard focus, the pointer, open popups (menus, drop-down lists, tooltips) and modal dialogs, and the canvas it paints with. One per window. GuiApp makes them (GuiApp::set_root); Widget::render/dispatch_event make one on first use for a root that has none; or make one yourself.

Fields

set by attach() / render()

§struct GuiTheme themesource
§float scalesource

the window's scale factor

§struct GuiCanvas canvassource
§int canvasReadysource
§struct Vec<&Widget> overlayssource

popups and dialogs, bottom to top

§?&Widget capturesource

gets the pointer while a button is held

§float mouseXsource
§float mouseYsource
§int mouseInsidesource

tooltip candidate and since when

§double tipSincesource

the tooltip widget

§int tipShownsource
§double nowMssource
§int needsLayoutsource
§int dirtysource
§int layoutWsource
§int layoutHsource

the size the tree was last laid out to

§int cursorsource

Methods

§static &GuiUi new(&Widget root)source · definition

A context for 'root' (attached to it: root.ui() returns it).

§void attach(&GuiWindow win)source · definition

The window it draws into and gets events from.

§void set_theme(struct GuiTheme t)source · definition
§int dispatch(&GuiEvent ev)source · definition

Routes one event (see Widget::dispatch_event). Returns 1 if consumed.

§void render()source · definition

Lays out (if needed) and paints the tree and its overlays into the attached window's buffer.

§void tick(double nowMs)source · definition

Advances time-driven state — tooltips, caret blinking, busy indicators — to 'nowMs' (gui_time_ms()). Marks the UI dirty when something visible changed.

§int animating() constsource · definition

1 while something animates (the next frame will look different).

§int needs_redraw() constsource · definition

1 when the UI needs repainting; render() clears it.

§void invalidate()source · definition
§void request_layout()source · definition
§void set_focus(?&Widget w)source · definition
§void popup(&Widget menu, float x, float y)source · definition

Shows a menu (or any widget) as a popup at window position (x, y), kept on screen. A click outside closes it.

§void close_popups()source · definition
§void show_modal(&Widget dialog)source · definition

Shows 'dialog' centered over the window, blocking input to everything under it until close_modal() (or the dialog's close_dialog()). The UI doesn't own a shown dialog: free it after closing it (or reuse it).

§void close_modal(&Widget dialog)source · definition
§?&Widget modal() constsource · definition

The topmost open dialog, or null.

§void drop()source · definition

Frees the UI and its whole widget tree.

§void free() consumesource · definition

= drop()