Context
slikui::Context owns the tree, routes input, lays out, animates and paints.
One context per thread; drive it with
handle -> tick -> render.
Tree
| API |
Notes |
set_root<T>(args...) -> T& |
construct + own the root |
set_root(std::unique_ptr<Widget>) |
take ownership of a pre-built tree |
root() |
current root or nullptr |
find(id) |
search the tree for Widget::id |
clear_tree() |
destroy the tree now (releases callbacks) |
Frame
| API |
Notes |
handle(const Event&) |
route one event; popups close at the end, never mid-dispatch |
tick(Time{now, dt}) |
attach -> measure -> arrange -> animation |
render(bool clear = true) |
paint the tree + popups + shells into the sink |
set_frame_size(Vec2) |
logical frame size (backends derive it from resize events) |
Owned by the context; destroyed at the end of the event that closes them.
| API |
Notes |
push_popup(widget, pos) |
unique_ptr or borrowed reference overload (Python: kept alive while open) |
push_popup(widget, anchor, PopupDir) |
anchored popups (Below, Right, ...) |
open_context_menu(widget, pos) |
open a Menu as a floating popup |
close_popups() / close_topmost_popup() / close_popups_above(widget) |
dismissal |
hold_while_open(widget, std::shared_ptr<void>) |
keep a token alive while a popup/dialog is open; released after it closes (the Python bindings pin borrowed widgets with it) |
has_popups() / popup_count() / popup(i) / popup_open(w) |
inspection |
Dialogs, toasts
The shell layer between the tree and popups - see
Shells & dialogs. Layers, bottom to top: tree, toasts,
modal dim, dialogs, popups. A Dropdown, popover or tooltip opened inside a
dialog therefore shows over it. Opening or closing a dialog closes the popup
stack, and Escape closes the topmost popup before the topmost dialog. While a
modal dialog is open, presses outside it and its popups are ignored, and Tab
cycles only through it, the dialogs above it and the popups.
| API |
Notes |
open_dialog(unique_ptr<D>) |
owned dialog |
open_dialog(D&) |
borrowed; in Python the context keeps it alive while open |
close_dialog(widget) |
explicit close |
dialog_count() / dialog(i) |
inspection |
push_toast(widget, seconds) |
auto-dismissing corner notice; returns the widget |
toast_count() / toast(i) |
inspection |
Toasts are their own passive layer (above the tree, below dialogs and
popups): never
hit-tested, so clicks pass through them, and they neither close nor are
closed by the popup stack. Several toasts stack upward from the
bottom-right corner, newest lowest.
Focus, capture, shortcuts
| API |
Notes |
focused() / set_focus(widget*) |
key/text routing target |
focus_visible() / set_focus_visible(bool) |
whether focus rings show: true after keyboard navigation (Tab, arrows, Home/End, PageUp/PageDown), false after a mouse press |
open_menu_bar() |
what F10 does: open the active layer's MenuBar with focus on its title; focus returns when the menus close. False without a menu bar |
reveal_rect(widget, rect) |
scroll widget's scrolling ancestors so rect is in view |
capture_mouse(widget*) / release_mouse(widget*) |
receive every move/release while dragging |
add_shortcut(Key, mods, fn) |
global accelerator; fires before widget dispatch, modifier required |
clear_shortcuts() |
|
Theme, font, clipboard, cursor
| API |
Notes |
theme() -> Theme& |
mutate freely; widgets read it every paint (Theming) |
load_font_file(path) / load_font_memory(data, len) |
the body font (Text & fonts) |
add_font(family, path, style, face) / add_font_memory(...) / has_font(family) |
more faces by family name: "heading", "mono", your own |
text_size(s, opts) / text_metrics(opts) |
measure text for measure() (Drawing text) |
text_layout(s, wrap_width, opts) -> TextBlock |
a kept layout: draw, hit-test, caret, selection |
set_clipboard_source(fn) / set_clipboard_sink(fn) |
host clipboard for text fields |
clipboard_text() / set_clipboard_text(str) |
direct clipboard access |
set_cursor_host(fn) |
map set_cursor requests to system cursors |
next_texture_id() |
ids for custom TexUploads - never reused for different content |
Tooltips need no context API: any widget's set_tooltip (or tooltip_at
override) makes the context show a popup after a ~0.6 s hover.
tooltip_text() returns the text of the tooltip showing now ("" if none).