std1.0.0-beta-7 SafeC docs

std :: gui::gui_app

Struct std::GuiApp

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

struct GuiApp {
    struct Vec<&GuiAppWindow> windows;
    struct Vec<struct GuiTimer> timers;
    unsigned int nextTimer;
    int quitting;
    int exitCode;
    double frameMs;
    double lastFrame;
}

Fields

§struct Vec<&GuiAppWindow> windowssource
§struct Vec<struct GuiTimer> timerssource
§unsigned int nextTimersource
§int quittingsource
§int exitCodesource
§double frameMssource
§double lastFramesource

Methods

§static struct GuiApp new()source · definition
§?&GuiWindow open_window(const &char title, int width, int height)source · definition

Opens a window (hiDpi). null if there's no display / it failed.

§void close_window(&GuiWindow win)source · definition

Destroys the window (and its widget tree, if any) now.

§unsigned long window_count() constsource · definition
§?&GuiWindow window_at(unsigned long i) constsource · definition
§?&GuiWindow find_window(unsigned int id) constsource · definition
§&GuiUi set_root(&GuiWindow win, &Widget root)source · definition

Shows 'root' in the window (the window owns the tree from now on: closing the window frees it). Returns the window's GuiUi.

§?&GuiUi ui_of(const &GuiWindow win) constsource · definition
§void redraw(&GuiWindow win)source · definition

Repaint the window on the next iteration.

§generic<T> void on_event( &GuiWindow win, fn int(&GuiApp, &GuiWindow, &GuiEvent, ?&T) cb, ?&T data, )source · definition

Every event for the window (after its widgets saw it): return 1 if you handled it (the window is repainted).

§generic<T> void on_draw( &GuiWindow win, fn void(&GuiApp, &GuiWindow, &GuiCanvas, ?&T) cb, ?&T data, )source · definition

Custom drawing, each repaint.

§generic<T> void on_frame( &GuiWindow win, fn int(&GuiApp, &GuiWindow, double, ?&T) cb, ?&T data, )source · definition

Animation: called every frame with the time in ms while it returns 1.

§generic<T> unsigned int set_timeout( double ms, fn void(&GuiApp, unsigned int, ?&T) cb, ?&T data, )source · definition
§generic<T> unsigned int set_interval( double ms, fn void(&GuiApp, unsigned int, ?&T) cb, ?&T data, )source · definition
§void cancel_timer(unsigned int id)source · definition
§int pump(int timeoutMs)source · definition

One iteration: wait up to 'timeoutMs' (0 = don't wait, negative = as long as nothing is due) for events, route them, run due timers and frame callbacks, repaint and present what changed. Returns 0 once the app should stop (quit() was called or no window is left).

§int run()source · definition

pump() until it returns 0; returns the exit code given to quit() (0 when the last window closed).

§void quit(int exitCode)source · definition
§double now_ms() constsource · definition

gui_time_ms()

§void set_frame_interval(double ms)source · definition
§double frame_interval() constsource · definition
§void drop()source · definition

Closes every window and frees the app's state.

§void free() consumesource · definition

= drop()