ui/desktop
lib/ui/desktop.vklib/ui/desktop.vk
First-class declarative MVU desktop UI framework layered over ui/view and ui/native:
- Zero top-level mut globals; all state lives in owned Context / Session values.
- Keyed native reconciler preserving OS widget handles & keyboard focus across updates.
- Intrinsic-measured Flex / Grid / Form / SplitView / Tabs layout solver (DeferWindowPos).
- Hybrid dispatch: supports BOTH pure data/enum actions in update AND inline closure handlers.
- Zero-poll async spawn-task bridge waking the native UI event loop over chan + thread wake.
- .secret firewall: password-field contents never enter state; read-secret returns secret str.
window = fn [title str, props map, children block[v/Node]] v/Node
toolbar = fn [props map, children block[v/Node]] v/Node
status-bar = fn [segments block] v/Node
split-view = fn [props map, first v/Node, second v/Node] v/Node
tabs = fn [id str, active_id str, action any, children block[v/Node]] v/Node
tab = fn [id str, label str, children block[v/Node]] v/Node
vstack = fn [props map, children block[v/Node]] v/Node
hstack = fn [props map, children block[v/Node]] v/Node
grid = fn [cols i64, gap i64, children block[v/Node]] v/Node
form = fn [props map, children block[v/Node]] v/Node
scroll = fn [props map, children block[v/Node]] v/Node
group-box = fn [title str, props map, children block[v/Node]] v/Node
card = fn [title str, props map, children block[v/Node]] v/Node
section = fn [title str, children block[v/Node]] v/Node
row = fn [props map, children block[v/Node]] v/Node
heading = fn [content str] v/Node
label = fn [content str, props map] v/Node
text = fn [content str] v/Node
text-styled = fn [content str, props map] v/Node
banner = fn [tone enum, message str, visible bool] v/Node
badge = fn [label str, tone enum] v/Node
stat = fn [label str, value str, delta str, tone enum] v/Node
button = fn [label str, action any] v/Node
button-styled = fn [label str, props map, action any] v/Node
text-field = fn [id str, placeholder str, value str, action any] v/Node
text-area = fn [id str, placeholder str, value str, action any] v/Node
password-field = fn [id str, placeholder str] v/Node
checkbox = fn [label str, checked bool, action any] v/Node
toggle-switch = fn [label str, is_on bool, action any] v/Node
radio-group = fn [id str, options block, selected str, action any] v/Node
select = fn [id str, options block, selected str, action any] v/Node
slider = fn [id str, min_v i64, max_v i64, val i64, action any] v/Node
progress = fn [pct i64, label str, tone enum] v/Node
list-box = fn [id str, items block, selected str, action any] v/Node
tree-view = fn [id str, roots block, selected_id str, action any] v/Node
table-view = fn [id str, columns block, rows block, selected_row i64, action any] v/Node
canvas-slot = fn [id str, props map] v/Node
webview = fn [id str, props map] v/Node
native-slot = fn [id str, handle i64, props map] v/Node
divider = fn [] v/Node
spacer = fn [height i64] v/Node
empty = fn [] v/Node
secret-field-badge = fn [label str] v/Node
Event = struct { kind enum = ..., action any = ..., widget_id str = ..., text str = ..., value str = ..., value_n i64 = ..., flag bool = ..., w i64 = ..., h i64 = ... }
Context = struct { app nat/NativeApp, win_id str = ..., inbox any = ..., running bool = ..., mounted map = ..., actions map = ..., menu_actions map = ..., tray_click_action any = ..., tray_menu_actions map = ..., shortcut_actions map = ..., webview_ipc_actions map = ..., last_rects map = ..., dpi_scale i64 = ..., frame_count i64 = ... }
read-secret = fn [ctx Context, wid str] secret str
Extracts masked password-field input as a .secret-protected secret str.
focus = fn [ctx Context, wid str]
native-handle = fn [ctx Context, wid str] i64
open-file-dialog = fn [mut ctx Context, title str, filters block] str
save-file-dialog = fn [mut ctx Context, title str, filters block] str
pick-folder-dialog = fn [mut ctx Context, title str] str
alert = fn [mut ctx Context, title str, body str, kind enum] enum
quit = fn [mut ctx Context]
enable-remote-webview = fn [mut ctx Context, grant any] any
Unlocks remote (http://, https://, ws://, wss://) navigation in webview widgets.
Requires an authentic NetGrant witness produced by ui/webview_net/grant-net (.net capability).
system-tray = fn [mut ctx Context, tooltip str, icon_canvas any, menu_items block, click_action any] bool
update-tray = fn [mut ctx Context, tooltip str, icon_canvas any, menu_items block] bool
remove-tray = fn [mut ctx Context]
notify = fn [mut ctx Context, title str, body str] bool
notify-styled = fn [mut ctx Context, title str, body str, tone enum] bool
register-shortcut = fn [mut ctx Context, chord str, action any] any
unregister-shortcut = fn [mut ctx Context, chord str] bool
eval-js = fn [mut ctx Context, wid str, js str] any
post-webview-message = fn [mut ctx Context, wid str, msg str] any
webview-set-html = fn [mut ctx Context, wid str, html str] any
task-channel = fn [ctx Context] map
Captures the thread-safe result channel & wake handle of ctx so native spawn [...] workers
without closure captures can push results back into ctx.inbox via post-task-result.
post-task-result = fn [tch map, action_tag any, val any]
Sends a background task completion message onto tch (task-channel) and wakes the UI thread if live.
spawn-task = fn [ctx Context, action_tag any, work_fn fn[->any]]
Spawns an isolated background worker and pushes { action = action_tag, value = res }
directly into ctx.inbox, waking the OS UI loop immediately with zero polling.
On Track C --native (where spawn enforces zero closure captures across OS threads),
falls back cleanly to executing work_fn and posting { action = action_tag, value = res }.
reconcile-and-layout = fn [mut ctx Context, root v/Node]
Reconciles the native widget tree against root and applies DPI-scaled DeferWindowPos layout.
init-context = fn [title str, props map] Context
init-session = fn [init_state any, view_fn fn[any->v/Node]] Context
Initializes Context from the root window node of view_fn(state).
step-frame = fn [mut st any, mut ctx Context, view_fn fn[any->v/Node], update_fn fn[any,Event,mut Context->any]] any
Executes a single reconcile -> layout -> poll/drain -> dispatch frame deterministically.
run = fn [init_state any, view_fn fn[any->v/Node], update_fn fn[any,Event,mut Context->any]] any
Runs the native desktop application event loop until closed or desktop/quit is called.