ui#
the immediate-mode UI: runtime, layout, widgets, windows, style contract -- crate root lib/ui/lib.rs
ui -- the immediate-mode runtime: one Ui context instead of ASMLIB's g_* globals [src/ui]
run(desc, app, style) -> exit code command line, headless (--shot / --script) or window
App: init(ui) / frame(ui) builds the UI every pass / command(ui, id, arg) -> handled
Style: how widgets look (style.rs, the contract of ASMLIB/inc/style.inc); the app
passes the style crate it was linked with (build_rs.py --style)
main!(expr): the app's entry point (jfgui_main, called by plat's process entry)
Modules (one per ASMLIB file): ctx (ui_ctx.s: input, hit testing, behaviour, slots,
timers, commands, semantics, clip, layers, passes), layout (ui_layout.s), cmd (ui_cmd.s:
draw command lists and their replay), dirty (ui_dirty.s), theme (ui_theme.s; app themes
over the style and the run-time style switch, theme_app.rs: Theme and its file), basic
(ui_basic.s), auto (ui_auto.s: scripts and the widget dump), runtime (ui_main.s), cursor
(ui_cursor.s), drop (ui_drop.s), dnd (drag and drop between widgets and programs), dock
(docking: panels at the sides in tab groups, floating tool windows), kbnav (keyboard
navigation between widgets, panes and windows), clipimg
(ui_clipimg.s), style (style.inc); the widget families popup, edit, list, value, color, win,
chrome, filedlg (R5 agents); rtl (the right-to-left mirror of the recorded commands and the
input); ids (widget ids from names), settings_page (the page of a base::settings schema),
winstate (window placement kept between runs, AF_SAVE_STATE); fontpick (system fonts: loading
a choice, the font picker and dialog); tasks (async tasks on the UI thread: ui.spawn, run
between passes; plat::task).
State: ASMLIB keeps every window's UI state in per-module blocks (`*_wb0` .. `*_wb1`)
that ui_win.s swaps when it builds another window. Here that state is `WinParts` (the
live window's part of every module: `ui.wp.ctx`, `ui.wp.lay`, `ui.wp.cmd`, `ui.wp.dirty`,
`ui.wp.rt`, `ui.wp.popup`, ...); win.rs swaps it with a window's saved WinParts
(core::mem::swap). State shared by all windows lives in `Ui` itself (core) and in
`ui.m` (the widget families' shared state).
For the widget families (R5): the asm globals map to fields -- g_mx / g_my / g_focus /
g_hot / g_active / g_last_rect / g_keyq ... are `self.wp.ctx.*`, g_boxes / g_next_* are
`self.wp.lay.*`, g_dcol / the command lists `self.wp.cmd.*`, g_fb / g_ui_dpi
`self.wp.rt.fb` / `.dpi`; g_frame / g_now_ms / g_repass / g_mods / g_sems / slots / timers /
g_uiw_cur are fields of Ui. A family's per-window state goes into its `W` (in WinParts),
its shared state into its `S` (in Mods). Style calls: `let st = self.style; let mut sp =
Sp { .. }; let (w, h) = st.xxx_size(self, &mut sp); self.place(w, h); let ev =
self.behave(id, hb); self.sp_placed(&mut sp, ev); st.xxx(self, &sp);
self.focus_ring_draw(ev); self.sem(K_*, id, label, value)` (basic.rs shows every pattern).
The core calls into the families through these functions (all ported, R5): win.rs uiw_*,
chrome.rs titlebar_begin / titlebar_end / edge_grips (ui-win), popup.rs accel_dispatch /
tooltip / popup_count (ui-popup), edit.rs text_key_filter, clip_set / clip_get /
hclip_text_* / open_folder / open_url (ui-edit).
Ui methods by area (signatures and descriptions in the sections below):
- App, AppDesc, Ui, run, async tasks:
fb,client_size,anim_off,set_anim_off,headless,invalidate,quit,set_title,title,spawn,spawner,tasks_live - Layout:
next_size,next_rect,next_rect_px,box_offset,next_flags,take_flags,next_icon,take_icon,last_rect,box_id,box_rect,box_flags,place,avail_width,box_begin,box_end,spacer,dp,px2dip,dpi,set_dpi,dp_fx - Context: input, focus, timers, commands, semantics:
now,mods,mouse,pen,pointer_lock,pointer_lock_state,pointer_motion,key_code_down,focus,focus_quiet,focused,key,capture_shortcut,key_peek,key_down,key_first,key_take,key_event_take,text_take,cursor_at,hit_flags_at,hit,behave,hit_rect,focus_ring,slot,anim,anim_ex,anim_color,cmd_run,timer,last_reset,last_set,last_state,mbtn,pressed,released,sem,sem_rect,clip_push,clip_pop,layer_set,begin_pass,end_pass,repass,modal,modal_active,disabled_push,disabled_pop,warn - Keyboard: Tab order, focus groups, panes and windows (F6), splitters (F8):
focus_group_begin,focus_group_end,focus_pane_begin,focus_pane_end,group_arrived,splitter_keys - Widgets:
hair,focus_ring_draw,text,heading,button,label_button,link,accent_button,icon_button,toggle_button,tool_button,checkbox,checkbox_wrap,radio_wrap,radio,switch,slider,progress,separator,icon,image,canvas,canvas_label - Popups, menus, command table, tooltips:
accel_run,popup_is_open,popup_count,popup_open,popup_open_at,popup_close,popup_close_id,flyout_begin,popup_ext,popup_rect,flyout_end,cmd_find,cmd_state,cmd_flags,cmd_label,accel_text,accel_order_set,cmd_button,menu_item,menu_item_keys,key_text,menu_cmd,menu_sep,menu_list_empty,menu_list,menu_list_flags,menubar,menu_popup,menu_popup_at,context_menu,context_target,dropdown_button,split_button,combobox,tooltip,tooltip_part,tooltips_set,tooltips_on - Text boxes and the clipboard:
textbox_selection,textbox_select,textbox,textbox_icon,textbox_presented,ime_preedit,ime_enable,ime_pos,clip_set_many,clip_set,clip_get,open_folder,open_url,number_box,number_box_f,nb_live,nb_live_f,spell_enable,spell_language,spell_sources,spell_set,spell_suggest_async,spell_state,speller,spell_errors - Rich-text and code editors:
richtext,richtext_link,richtext_link_dialog,richtext_toolbar,code_theme,code_theme_set,code_font_size,code_find,code_reveal,code_status,code_diag,code_events,code_popup_item,code_editor,code_editor_with - Lists, scrolling, tabs, expanders:
scroll_begin,scroll_end,scroll_to,scroll_pos,scroll_extent,scrollbar,list_begin,list_item,list_item_begin,list_sel,list_item_end,list_end,list_end_full,tabs_scrolling,tabs,expander_begin,expander_end - Data views: grid, tree, badges, meters:
grid_begin,grid_row,grid_cell,grid_text,grid_text_ts,grid_end,tree,badge,status_dot,meter - Shell parts: navigation, command bar, splitter, breadcrumb, wizard steps:
nav_begin,nav_toggle,nav_section,nav_item,nav_footer,nav_end,command_bar,split_begin,split_next,split_end,breadcrumb,segmented,wizard_steps,page_header,key_value,empty_state - Docking: panels at the sides, tab groups, floating tool windows:
dock_begin,dock_next,dock_end - Charts:
sparkline,bar_chart,donut,legend,line_chart - Toasts, spinners, progress:
toast,toast_dismiss,toast_clear,toasts,toast_host,spinner,progress_indeterminate - Date and time input:
time_box,weekday_toggles,date_picker,calendar - Values and colours:
cmd_track,decimal_sep,set_decimal_sep,fmt_f64,parse_f64,slider_f,track_slider,prop_slider,prop_slider_f,angle,pan,swatch,color_picker,color_picker_ex,color_wheel,color_menu - Windows:
window_title_height,window_begin,window_end,sync_hook_set,window_place,window_snap,window_rect,window_state,window_fullscreen,window_activate,window_destroy,window_current,window_modal,window_pw - Chrome: title bar, dialogs, info and status bars:
dialog_begin,dialog_buttons,dialog_end,infobar,statusbar_begin,statusbar_end,titlebar_begin,titlebar_begin_opt,titlebar_begin_overlay,titlebar_end,titlebar_open - File dialog:
filedlg,filedlg_paths - Drawing commands:
cmd_layer,draw_color,draw_color_get,draw_rect,draw_rrect,draw_frame,cmd_rrect,cmd_panel_fx,draw_text,cmd_text,emit_text,draw_icon,draw_circle,draw_line,draw_image,draw_clip,draw_unclip,icon_hook,cmd_custom,cmd_shadow - Scripts and the widget dump:
dump - Theme:
theme_set,theme_dark,accent_set,high_contrast,set_contrast,set_reduced_motion,text_scale,font_prefs,wheel_lines,wheel_chars,wheel_notch_px,set_text_scale,color,ts_font,ts_line,set_theme,clear_theme,app_theme,load_theme,styles_add,style_names,style_name,set_style,dp_text,ts_base - Cursors, drag and drop, clipboard images, dirty regions:
cursor_new,cursor_custom,cursor_current,cursor_next,cursor_replace,cursor_free,cursor_render,drop_count,drop_path,open_take,drop_list,drop_pos,drop_pos_px,drop_window,drop_data,drop_types,drop_text,clip_has,drag_source,drag_set,drag_out,drag_effect,dragging,drop_target,drop_effect_set,drop_accept,drag_over,drag_over_px,drag_allowed,drop_defer,drop_finish,drop_effect,clip_set_image,clip_get_image,dirty_force_full,canvas_damage
Sections
- App, AppDesc, Ui, run, async tasks
- Layout
- Context: input, focus, timers, commands, semantics
- Keyboard: Tab order, focus groups, panes and windows (F6), splitters (F8)
- Widgets
- Popups, menus, command table, tooltips
- Text boxes and the clipboard
- Rich-text and code editors
- Lists, scrolling, tabs, expanders
- Data views: grid, tree, badges, meters
- Shell parts: navigation, command bar, splitter, breadcrumb, wizard steps
- Docking: panels at the sides, tab groups, floating tool windows
- Charts
- Toasts, spinners, progress
- Date and time input
- Languages
- Vector icons
- Values and colours
- Windows
- Chrome: title bar, dialogs, info and status bars
- File dialog
- Drawing commands
- Scripts and the widget dump
- Theme
- Cursors, drag and drop, clipboard images, dirty regions
- Style contract
- Stock painters of the data and shell parts
- Constants
- Key codes
- Other modules