ui/consts.rs
1// consts -- public constants of the immediate-mode UI (ASMLIB/inc/ui.inc)
2//
3// Widget calls return event flags. Bit 0 (EV_ACT) always means "the primary action
4// happened" (clicked, changed, selected, closed). Sizes and positions given to the UI are
5// DIP (device independent pixels, 96 dpi = 100 %); drawing calls and last_rect use
6// physical pixels.
7
8// ------------------------------------------------------------------ widget events
9pub const EV_ACT: u32 = 1; // primary action (click / change / select / close)
10pub const EV_COMMIT: u32 = 2; // value committed (drag released, Enter, focus lost)
11pub const EV_HOVER: u32 = 4; // pointer is over the widget
12pub const EV_HELD: u32 = 8; // pressed and still held
13pub const EV_FOCUS: u32 = 16; // widget has keyboard focus
14pub const EV_DOUBLE: u32 = 32; // double click
15pub const EV_RCLICK: u32 = 64; // right click (released over the widget)
16pub const EV_OPEN: u32 = 128; // a popup / dropdown opened
17pub const EV_DRAG: u32 = 256; // being dragged (moved while held)
18
19// ------------------------------------------------------------------ hit box flags (behave)
20pub const HB_FOCUS: u32 = 1; // reachable with Tab, takes focus on click
21pub const HB_BLOCK: u32 = 2; // swallows the pointer (panels, popups)
22pub const HB_DRAG: u32 = 4; // window drag region (title bar)
23pub const HB_TEXT: u32 = 8; // text input (gets all keys while focused)
24pub const HB_MOVES: u32 = 16; // wants a frame on every pointer move while hovered
25pub const HB_DISABLED: u32 = 32; // disabled: visible to the dump, no input
26pub const HB_MIN: u32 = 64; // caption buttons (for the OS: snap layouts, etc.)
27pub const HB_MAX: u32 = 128;
28pub const HB_CLOSE: u32 = 256;
29// keyboard (kbnav.rs): a focusable box that is not a Tab stop (focus(id), arrows of its group
30// reach it); the current member of a focus group (Tab enters the group there: the checked
31// radio / tool button, the selected swatch); a splitter grip (F8 reaches it, arrows move it)
32pub const HB_NOTAB: u32 = 512;
33pub const HB_CURRENT: u32 = 1024;
34pub const HB_SPLITTER: u32 = 2048;
35pub const HB_CURSOR_SHIFT: u32 = 12; // cursor shape: flags | CUR_* << HB_CURSOR_SHIFT
36// behave only (not kept in the hit list): Space acts, Enter does not (check boxes, radios,
37// switches: Enter belongs to the dialog's default button); Space and Enter are the widget's
38// own (lists, grids, trees: behave gives no EV_ACT for them)
39pub const HB_SPACE: u32 = 0x10000;
40pub const HB_OWNKEYS: u32 = 0x20000;
41// behave only: a finger moving along this axis belongs to the widget, not to the scroll view
42// around it (touch.rs; the cursors of splitters, text and crosshairs say so by themselves)
43pub const HB_GRAB_H: u32 = 0x40000;
44pub const HB_GRAB_V: u32 = 0x80000;
45// every key is the widget's while it has the focus and no popup of the window is open (a menu
46// keeps its keys), Ctrl + letter, Tab and the arrows too: no accelerator, no keyboard
47// navigation, no Enter / Space action and no ui.undo_keys takes one (a canvas that shows a web
48// page takes them with ui.key_take; ui.accel_run hands one back to the command table). Unlike
49// HB_TEXT no text box rules: no reserved keys, no input method, no on-screen keyboard. A
50// canvas takes it from next_flags.
51pub const HB_KEYS: u32 = 0x10_0000;
52// canvas only (next_flags): its cursor bits as given, CUR_ARROW (0) included; without it 0 is the
53// crosshair
54pub const HB_CURSOR_SET: u32 = 0x20_0000;
55
56// ------------------------------------------------------------------ the finger (touch.rs)
57// ui.touch_take(flags) after a widget, instead of what its hit box says by itself: TF_V / TF_H a
58// finger moving along this axis is the widget's (not the scroll view's around it); with both the
59// press comes with the touch, unless TF_SLOP (only once the finger moved) or TF_HOLD (only after
60// resting for the long-press time: a panel that starts to move then, until then the finger goes
61// to what is around it); TF_HOLD_LONG the same after 600 ms (a panel's title bar; ui.touch_hold_part
62// shows it); TF_REST a finger that rests presses like one that moved, no context menu (a canvas); TF_TWO
63// a second finger is the widget's: no press, no click, it reads ui.touch_two or ui.touch_fingers (pan and
64// zoom); TF_DECLINE no drag at all, a tap still clicks. 0: nothing special (the finger rolls what is
65// around it, with nothing to roll it drags the widget).
66pub const TF_V: u32 = 1;
67pub const TF_H: u32 = 2;
68pub const TF_BOTH: u32 = 3;
69pub const TF_HOLD: u32 = 4;
70pub const TF_TWO: u32 = 8;
71pub const TF_SLOP: u32 = 16;
72pub const TF_DECLINE: u32 = 32;
73pub const TF_REST: u32 = 64;
74pub const TF_HOLD_LONG: u32 = 128;
75
76// ------------------------------------------------------------------ the device (form.rs)
77// ui.form_factor(): what the app runs on -- a desktop (however small its window), a tablet, a phone
78pub const FF_DESKTOP: u32 = 0;
79pub const FF_TABLET: u32 = 1;
80pub const FF_PHONE: u32 = 2;
81
82// ------------------------------------------------------------------ semantic kinds and states
83pub const K_BOX: u16 = 0;
84pub const K_TEXT: u16 = 1;
85pub const K_BUTTON: u16 = 2;
86pub const K_CHECKBOX: u16 = 3;
87pub const K_RADIO: u16 = 4;
88pub const K_SWITCH: u16 = 5;
89pub const K_SLIDER: u16 = 6;
90pub const K_PROGRESS: u16 = 7;
91pub const K_TEXTBOX: u16 = 8;
92pub const K_MENU: u16 = 9;
93pub const K_MENUITEM: u16 = 10;
94pub const K_LIST: u16 = 11;
95pub const K_LISTITEM: u16 = 12;
96pub const K_TAB: u16 = 13;
97pub const K_CANVAS: u16 = 14;
98pub const K_ICON: u16 = 15;
99pub const K_IMAGE: u16 = 16;
100pub const K_COMBO: u16 = 17;
101pub const K_DIALOG: u16 = 18;
102pub const K_TITLEBAR: u16 = 19;
103pub const K_SWATCH: u16 = 20;
104pub const K_LINK: u16 = 21;
105/// a heading of a document or section (value: its level, 1 the top; md_view.rs, Ui::heading)
106pub const K_HEADING: u16 = 22;
107/// the number of KIND_NAMES (the kinds K_BOX ..= K_HEADING); the kinds of web content K_TABLE ..=
108/// K_FIGURE follow it (KIND_NAMES_MORE, kind_name names them all)
109pub const K_KIND_COUNT: u16 = 23;
110// (section 19 of the guide) the kinds of a web page's accessibility tree; a screen reader gets
111// each with a role of its own where the platform has one (UI Automation, AT-SPI2, the browser)
112/// a table or grid (Sem::grid: its rows and columns) and a row of it
113pub const K_TABLE: u16 = 23;
114pub const K_ROW: u16 = 24;
115/// a cell (label: what it says; Sem::cell: its row and column), a column header, a row header
116pub const K_CELL: u16 = 25;
117pub const K_COLHEADER: u16 = 26;
118pub const K_ROWHEADER: u16 = 27;
119/// a landmark of a page (value: LM_*; label: its name)
120pub const K_LANDMARK: u16 = 28;
121/// a tree and one of its items (Sem::level: its depth; AS_COLLAPSED / SS_OPEN: closed / open)
122pub const K_TREE: u16 = 29;
123pub const K_TREEITEM: u16 = 30;
124/// a group of radio buttons, a tool bar, a tooltip (label: its text), a separator
125pub const K_RADIOGROUP: u16 = 31;
126pub const K_TOOLBAR: u16 = 32;
127pub const K_TOOLTIP: u16 = 33;
128pub const K_SEPARATOR: u16 = 34;
129/// live regions: an alert (said at once), a status line and a log (said when the person is
130/// idle); label: their text (Sem::live changes how they speak)
131pub const K_ALERT: u16 = 35;
132pub const K_STATUS: u16 = 36;
133pub const K_LOG: u16 = 37;
134/// a meter (value of min ..= max, as a progress bar), a spin button and a scroll bar (value, min,
135/// max as a slider; Sem::range for fractions)
136pub const K_METER: u16 = 38;
137pub const K_SPIN: u16 = 39;
138pub const K_SCROLLBAR: u16 = 40;
139/// an article, a figure (label: their names)
140pub const K_ARTICLE: u16 = 41;
141pub const K_FIGURE: u16 = 42;
142/// the end of the K_* kinds (one past K_FIGURE)
143pub const K_KIND_END: u16 = 43;
144pub const SS_HOVER: u16 = 1;
145pub const SS_PRESSED: u16 = 2;
146pub const SS_FOCUSED: u16 = 4;
147pub const SS_CHECKED: u16 = 8;
148pub const SS_DISABLED: u16 = 16;
149pub const SS_SELECTED: u16 = 32;
150pub const SS_OPEN: u16 = 64;
151
152/// names of the K_* kinds (dump, selectors kind:"Label")
153pub const KIND_NAMES: [&str; 23] = [
154 "box", "text", "button", "checkbox", "radio", "switch", "slider", "progress", "textbox",
155 "menu", "menuitem", "list", "listitem", "tab", "canvas", "icon", "image", "combo", "dialog",
156 "titlebar", "swatch", "link", "heading",
157];
158/// names of the kinds K_TABLE ..= K_FIGURE (dump, selectors kind:"Label")
159pub const KIND_NAMES_MORE: [&str; 20] = [
160 "table", "row", "cell", "colheader", "rowheader", "landmark", "tree", "treeitem", "radiogroup",
161 "toolbar", "tooltip", "separator", "alert", "status", "log", "meter", "spin", "scrollbar",
162 "article", "figure",
163];
164
165/// the name of a K_* kind (dump, selectors kind:"Label"); "box" for an unknown one
166pub fn kind_name(kind: u16) -> &'static str {
167 if kind < K_KIND_COUNT {
168 KIND_NAMES[kind as usize]
169 } else if kind < K_KIND_END {
170 KIND_NAMES_MORE[(kind - K_KIND_COUNT) as usize]
171 } else {
172 KIND_NAMES[0]
173 }
174}
175
176/// names of the SS_* state bits (dump)
177pub const STATE_NAMES: [&str; 7] = ["hover", "pressed", "focused", "checked", "disabled", "selected", "open"];
178
179// K_LANDMARK's value: the kind of landmark (0: a named region)
180pub const LM_REGION: i32 = 0;
181pub const LM_BANNER: i32 = 1;
182pub const LM_MAIN: i32 = 2;
183pub const LM_NAVIGATION: i32 = 3;
184pub const LM_COMPLEMENTARY: i32 = 4;
185/// the content information (a page's footer)
186pub const LM_CONTENTINFO: i32 = 5;
187pub const LM_SEARCH: i32 = 6;
188pub const LM_FORM: i32 = 7;
189
190// Sem::states: what a record is beyond its kind and SS_* state (section 19 of the guide)
191/// a field that must be filled in
192pub const AS_REQUIRED: u32 = 1;
193/// a field whose content is not valid
194pub const AS_INVALID: u32 = 2;
195/// its content is being changed (a live region says nothing meanwhile)
196pub const AS_BUSY: u32 = 4;
197/// it opens a popup (a menu, a list, a dialog)
198pub const AS_HASPOPUP: u32 = 8;
199/// a link to an address that was visited
200pub const AS_VISITED: u32 = 16;
201/// a modal dialog
202pub const AS_MODAL: u32 = 32;
203/// a list, tree or table that allows several selected items
204pub const AS_MULTISELECT: u32 = 64;
205/// it can be expanded and is closed now (SS_OPEN: it is open)
206pub const AS_COLLAPSED: u32 = 128;
207/// outside the visible area (scrolled away, clipped by its scroll box): a screen reader's
208/// browse mode reaches it, the pointer does not
209pub const AS_OFFSCREEN: u32 = 256;
210/// it takes the keyboard focus (a kind that does not anyway: a cell of a grid, an element with a
211/// tabindex)
212pub const AS_FOCUSABLE: u32 = 512;
213/// a click does something (a kind that does not say so: a cell, a row, an element with a click
214/// handler)
215pub const AS_CLICKABLE: u32 = 1024;
216/// it can be selected (rows and cells of a grid; list rows, tree items and tabs are anyway)
217pub const AS_SELECTABLE: u32 = 2048;
218/// a text box: read-only / with several lines / a password (as TB_* of a built-in box)
219pub const AS_READONLY: u32 = 4096;
220pub const AS_MULTILINE: u32 = 8192;
221pub const AS_PASSWORD: u32 = 16384;
222
223// Sem::live and ui.announce: how a live region / an announcement is said (0 for Sem::live: as
224// its kind says -- K_ALERT assertive, K_STATUS and K_LOG polite, the others not at all)
225pub const LIVE_POLITE: u32 = 1;
226pub const LIVE_ASSERTIVE: u32 = 2;
227/// (Sem::live) not a live region (an app that announces its changes itself, ui.announce)
228pub const LIVE_OFF: u32 = 3;
229
230// ------------------------------------------------------------------ layers
231pub const L_BASE: u32 = 0;
232pub const L_DIALOG: u32 = 1;
233pub const L_POPUP: u32 = 2;
234pub const L_TIP: u32 = 3;
235pub const L_COUNT: usize = 4;
236
237// ------------------------------------------------------------------ box flags (box_begin)
238pub const BOX_H: u32 = 0; // children left to right
239pub const BOX_V: u32 = 1; // children top to bottom
240pub const BOX_CENTER: u32 = 2; // centre children along the main axis
241pub const BOX_END: u32 = 4; // align children to the end of the main axis
242pub const BOX_XCENTER: u32 = 8; // cross axis: centre children (default: stretch)
243pub const BOX_XSTART: u32 = 16; // cross axis: natural size at the start
244pub const BOX_XEND: u32 = 32; // cross axis: natural size at the end
245pub const BOX_CARD: u32 = 64; // draw a card (fill + stroke, 8 DIP corners)
246pub const BOX_BG: u32 = 128; // fill with the window background colour
247pub const BOX_CLIP: u32 = 256; // clip children to the box
248pub const BOX_BLOCK: u32 = 512; // swallow pointer input over the box
249pub const BOX_DISABLED: u32 = 1024; // disable every widget inside
250pub const BOX_LAYER: u32 = 2048; // fill with the layer colour (command bars)
251pub const BOX_WRAP: u32 = 4096; // (horizontal) start a new row when full
252pub const BOX_FIXED: u32 = 8192; // the box's size never depends on its content
253// grid flags (gridbox_begin, with the box decorations and padding): the children's alignment
254pub const GRID_H_START: u32 = 2; // horizontal (default: stretched across the cell)
255pub const GRID_H_CENTER: u32 = 4;
256pub const GRID_H_END: u32 = 6;
257pub const GRID_V_START: u32 = 8; // vertical (default: centred)
258pub const GRID_V_END: u32 = 16;
259pub const GRID_V_STRETCH: u32 = 24;
260// next_align(h, v): one grid child's alignment
261pub const AL_DEFAULT: u32 = 0; // the grid's
262pub const AL_START: u32 = 1;
263pub const AL_CENTER: u32 = 2;
264pub const AL_END: u32 = 3;
265pub const AL_STRETCH: u32 = 4;
266pub const PAD_SHIFT: u32 = 16; // padding in DIP: flags | N << PAD_SHIFT
267pub const PAD_2: u32 = 2 << 16;
268pub const PAD_4: u32 = 4 << 16;
269pub const PAD_8: u32 = 8 << 16;
270pub const PAD_12: u32 = 12 << 16;
271pub const PAD_16: u32 = 16 << 16;
272pub const PAD_20: u32 = 20 << 16;
273pub const PAD_24: u32 = 24 << 16;
274pub const PAD_32: u32 = 32 << 16;
275
276/// padding in DIP for box_begin flags: BOX_V | pad(24)
277pub const fn pad(dip: u32) -> u32 {
278 dip << PAD_SHIFT
279}
280
281// easing curves (ease, anim_ex, anim_color)
282pub const EASE_OUT: u32 = 0; // fast start, soft stop (quadratic; anim's)
283pub const EASE_LINEAR: u32 = 1;
284pub const EASE_IN: u32 = 2; // soft start (quadratic)
285pub const EASE_IN_OUT: u32 = 3; // soft start and stop (cubic)
286pub const EASE_OUT_CUBIC: u32 = 4; // a softer stop than EASE_OUT
287pub const EASE_OUT_BACK: u32 = 5; // overshoots a little, then settles
288
289// next_size values: > 0 fixed DIP, 0 = natural size, < 0 = fill weight
290pub const SIZE_AUTO: i32 = 0;
291pub const SIZE_FILL: i32 = -1;
292
293// ------------------------------------------------------------------ text styles (text)
294pub const TS_CAPTION: u32 = 0; // 12 / 16
295pub const TS_BODY: u32 = 1; // 14 / 20
296pub const TS_BODY_STRONG: u32 = 2; // 14 / 20 semibold
297pub const TS_SUBTITLE: u32 = 3; // 20 / 28 semibold
298pub const TS_TITLE: u32 = 4; // 28 / 36 semibold
299pub const TS_TITLE_LARGE: u32 = 5; // 40 / 52 semibold
300pub const TS_DISPLAY: u32 = 6; // 68 / 92 semibold
301pub const TS_COUNT: u32 = 7;
302pub const TX_SECONDARY: u32 = 0x100; // secondary text colour
303pub const TX_TERTIARY: u32 = 0x200;
304pub const TX_ACCENT: u32 = 0x400; // accent text colour
305pub const TX_WRAP: u32 = 0x800; // wrap at the box width
306pub const TX_ELLIPSIS: u32 = 0x1000; // cut with "…" when too long
307pub const TX_CENTER: u32 = 0x2000; // horizontal alignment
308pub const TX_RIGHT: u32 = 0x4000;
309pub const TX_DISABLED: u32 = 0x8000;
310pub const TX_ON_ACCENT: u32 = 0x10000; // text on an accent fill (T_ON_ACCENT)
311pub const TX_HYPHENATE: u32 = 0x20000; // with TX_WRAP: hyphenate words that do not fit (hyph.rs)
312
313// ------------------------------------------------------------------ widget style flags (next_flags)
314pub const ST_DISABLED: u32 = 1;
315pub const ST_LARGE: u32 = 2; // icon button: big icon above the label
316pub const ST_SUBTLE: u32 = 4; // transparent button (toolbar style)
317pub const ST_ACCENT: u32 = 8; // accent button
318pub const ST_CHECKED: u32 = 16; // toggle / tool buttons: checked look
319pub const ST_COMPACT: u32 = 32; // smaller height
320pub const ST_NOFOCUS: u32 = 64; // not reachable with Tab
321pub const ST_ICON_ONLY: u32 = 128; // hide the label (tooltip only)
322pub const ST_ALIGN_START: u32 = 256; // start-aligned button content; styles may ellipsize long labels
323/// Button displayed on an accent-colored surface, using its on-accent foreground.
324pub const ST_ON_ACCENT: u32 = 512;
325/// Button with a menu indicator beside its label; use the normal popup API for behavior.
326pub const ST_MENU: u32 = 1024;
327/// Rounded identity/action button; supporting styles use a circular or pill surface.
328pub const ST_ROUND: u32 = 2048;
329
330// ------------------------------------------------------------------ built-in commands (App::command ids)
331pub const UIC_CLOSE: u32 = 0x7FFF_0001; // window close requested: return true to keep the window
332pub const UIC_THEME: u32 = 0x7FFF_0002; // theme changed
333pub const UIC_DPI: u32 = 0x7FFF_0003; // dpi changed
334pub const UIC_ESCAPE: u32 = 0x7FFF_0004; // Esc not consumed by any widget
335pub const UIC_TIMER: u32 = 0x7FFF_0005; // arg = timer id
336pub const UIC_WINCLOSE: u32 = 0x7FFF_0006; // arg = window id: close requested; true keeps it
337pub const UIC_DROP: u32 = 0x7FFF_0007; // arg = window id: files dropped (drop_*)
338pub const UIC_JOB: u32 = 0x7FFF_0008; // arg = job id finished
339pub const UIC_WAKE: u32 = 0x7FFF_0009; // plat::wake() from another thread
340pub const UIC_EXIT: u32 = 0x7FFF_000A; // the window loop ends (only after a real window ran)
341pub const UIC_OPEN: u32 = 0x7FFF_000B; // arg = requests: later starts of the app (AF_SINGLE_INSTANCE, open_take)
342pub const UIC_TRAY: u32 = 0x7FFF_000C; // the notification-area symbol: arg = TRAY_ACTIVATE / TRAY_SECONDARY (tray_set)
343pub const UIC_NOTE: u32 = 0x7FFF_000D; // arg = id: a system notification was clicked (notify)
344pub const UIC_NOTE_GONE: u32 = 0x7FFF_000E; // arg = id: a notification went away unclicked
345// lifecycle (runtime.rs)
346pub const UIC_ACTIVE: u32 = 0x7FFF_000F; // arg 1: one of the app's windows got the keyboard, 0: none has it
347pub const UIC_SUSPEND: u32 = 0x7FFF_0010; // arg 1: the system goes to sleep, 2: the app went to the background (browser, Android), 0: it woke up / is back
348pub const UIC_SESSION_END: u32 = 0x7FFF_0011; // logout / shutdown / SIGTERM: save now; UIC_EXIT and the end follow
349pub const UIC_SETTINGS: u32 = 0x7FFF_0012; // arg = plat::SET_* bits: system settings changed (theme and format already applied)
350// drag and drop (dnd.rs)
351pub const UIC_DRAG_END: u32 = 0x7FFF_0013; // arg = DE_* effect (0 = cancelled / refused): a drag of the app ended
352// permissions (perm.rs)
353pub const UIC_PERMISSION: u32 = 0x7FFF_0014; // arg 1 allowed, 0 refused: the user answered a permission question (try the access again)
354// the screen and global shortcuts (screen.rs)
355pub const UIC_HOTKEY: u32 = 0x7FFF_0015; // arg = id: a global shortcut was pressed (hotkey_register)
356pub const UIC_HOTKEY_LOST: u32 = 0x7FFF_0016; // arg = id: the desktop dropped the shortcut (hotkey_error tells why)
357pub const UIC_PICK: u32 = 0x7FFF_0017; // arg 1: a colour was picked (picked_color), 0: cancelled / failed (pick_color)
358pub const UIC_SCREENSHOT: u32 = 0x7FFF_0018; // arg 1: the picture is there (screenshot_take), 0: failed (screen_error)
359pub const UIC_RECENT: u32 = 0x7FFF_0019; // arg 1: the file of recent_open is readable now (recent_reopened), 0: refused or gone
360pub const UIC_SENSOR: u32 = 0x7FFF_001B; // arg = plat::sensors::SENSOR_* bits: new readings or another state (plat::sensors::read, state)
361pub const UIC_LOCATION: u32 = 0x7FFF_001C; // arg = plat::sensors::LocationState: a new fix or another state (location_fix)
362pub const UIC_A11Y: u32 = 0x7FFF_001D; // arg 1: a screen reader (an accessibility client) came, 0: it left (ui.a11y_active), also while the app is idle
363pub const TRAY_ACTIVATE: u32 = 1; // UIC_TRAY: the symbol was clicked
364pub const TRAY_SECONDARY: u32 = 2; // UIC_TRAY: double click (Windows) / middle click (Linux)
365
366// ------------------------------------------------------------------ drag and drop (dnd.rs)
367// drag_source / drop_target states; the kinds DT_* and effects DE_* come from plat (dnd.rs)
368pub const DS_START: u32 = 1; // drag_source: the widget starts being dragged (call drag_set now)
369pub const DS_ACTIVE: u32 = 2; // drag_source: the widget's content is being dragged
370pub const DS_END: u32 = 4; // drag_source: the drag ended (once; drag_effect() tells how)
371pub const DS_HOVER: u32 = 8; // drop_target: a matching drag is over the widget (highlighted)
372pub const DS_DROP: u32 = 16; // drop_target: dropped onto the widget (drop_data(), drop_effect())
373/// drop_defer: how long a drop's answer to its source may wait for drop_finish (ms); then it goes
374/// as the drop was delivered
375pub const DROP_DEFER_MS: u32 = 3000;
376
377// ------------------------------------------------------------------ app flags (AppDesc)
378pub const AF_CUSTOM_TITLEBAR: u32 = 1;
379pub const AF_RESIZABLE: u32 = 2;
380pub const AF_DARK: u32 = 4; // force dark theme
381pub const AF_LIGHT: u32 = 8; // force light theme
382pub const AF_SINGLE_INSTANCE: u32 = 16; // one window per user: later starts hand their command line over (UIC_OPEN)
383pub const AF_LOG_FILE: u32 = 32; // window mode: the log also goes to logs://APP.log (1 MiB, 3 older files)
384pub const AF_SAVE_STATE: u32 = 64; // window mode: the main and tool windows' placement kept in config://windows.ini
385pub const AF_GPU_3D: u32 = 128; // the app shows 3D views (ui.gpu_view): the UI's GPU device at level Voll on the fastest adapter
386
387// ------------------------------------------------------------------ theme tokens (color)
388// byte offsets as in ASMLIB; index = token / 4
389pub const T_BG: u32 = 0; // window background (Mica fallback)
390pub const T_BG_ALT: u32 = 4;
391pub const T_LAYER: u32 = 8; // layer fill (command bars, panels)
392pub const T_LAYER_STROKE: u32 = 12;
393pub const T_CARD: u32 = 16;
394pub const T_CARD_STROKE: u32 = 20;
395pub const T_CTRL: u32 = 24; // control fill: rest, hover, pressed, disabled (24..36)
396pub const T_CTRL_HOVER: u32 = 28;
397pub const T_CTRL_PRESSED: u32 = 32;
398pub const T_CTRL_DISABLED: u32 = 36;
399pub const T_CTRL_STROKE: u32 = 40; // control border
400pub const T_CTRL_STROKE2: u32 = 44; // control border, bottom edge
401pub const T_STRONG_STROKE: u32 = 48; // checkbox / radio border
402pub const T_SUBTLE: u32 = 52; // transparent button: rest, hover, pressed, disabled (52..64)
403pub const T_SUBTLE_HOVER: u32 = 56;
404pub const T_SUBTLE_PRESSED: u32 = 60;
405pub const T_SUBTLE_DISABLED: u32 = 64;
406pub const T_TEXT: u32 = 68; // text: primary, secondary, tertiary, disabled (68..80)
407pub const T_TEXT2: u32 = 72;
408pub const T_TEXT3: u32 = 76;
409pub const T_TEXT_DISABLED: u32 = 80;
410pub const T_ACCENT: u32 = 84; // accent fill: rest, hover, pressed, disabled (84..96)
411pub const T_ACCENT_HOVER: u32 = 88;
412pub const T_ACCENT_PRESSED: u32 = 92;
413pub const T_ACCENT_DISABLED: u32 = 96;
414pub const T_ON_ACCENT: u32 = 100; // text on accent
415pub const T_ON_ACCENT_DIS: u32 = 104;
416pub const T_ACCENT_TEXT: u32 = 108; // accent-coloured text / links
417pub const T_FOCUS_OUT: u32 = 112;
418pub const T_FOCUS_IN: u32 = 116;
419pub const T_FLYOUT: u32 = 120; // menus, popups
420pub const T_FLYOUT_STROKE: u32 = 124;
421pub const T_SMOKE: u32 = 128; // dim behind dialogs
422pub const T_DIVIDER: u32 = 132;
423pub const T_INPUT_ACTIVE: u32 = 136; // focused text box fill
424pub const T_CRIT: u32 = 140;
425pub const T_OK: u32 = 144;
426pub const T_WARN: u32 = 148;
427pub const T_INFO: u32 = 152;
428pub const T_CRIT_BG: u32 = 156;
429pub const T_OK_BG: u32 = 160;
430pub const T_WARN_BG: u32 = 164;
431pub const T_INFO_BG: u32 = 168;
432pub const T_CLOSE_HOVER: u32 = 172;
433pub const T_SHADOW: u32 = 176;
434pub const T_SCROLL: u32 = 180; // scroll bar thumb
435pub const T_TRACK: u32 = 184; // slider / progress track
436pub const T_KNOB: u32 = 188; // solid control fill (slider thumb, toggle knob)
437pub const T_ALT_FILL: u32 = 192; // toggle off background
438pub const T_STRONG_FILL: u32 = 196; // toggle off knob / strong fill
439pub const T_COUNT: usize = 50;
440
441// ------------------------------------------------------------------ records
442/// RANGE min, max, step, flags -- slider / number box descriptor
443#[derive(Clone, Copy, Default, Debug)]
444pub struct Range {
445 pub min: i32,
446 pub max: i32,
447 pub step: i32,
448 pub flags: u32,
449}
450
451impl Range {
452 pub const fn new(min: i32, max: i32, step: i32, flags: u32) -> Range {
453 Range { min, max, step, flags }
454 }
455}
456
457pub const RG_VERT: u32 = 1; // vertical slider
458pub const RG_TICKS: u32 = 2;
459pub const RG_TIP: u32 = 4; // value tooltip while dragging
460/// Logarithmic pointer/paint mapping for integer sliders with positive bounds.
461/// Keyboard increments, semantic values and range endpoints retain their units.
462pub const RG_LOG: u32 = 8;
463pub const LF_REORDER: u32 = 0x10000; // list_begin: rows can be dragged to a new place
464
465// decimal values, colour tracks, angle, pan, colour wheel (ui_value.s, ui_wheel.s)
466pub const TK_CHECKER: u32 = 1; // draw the gradient over a checkerboard (alpha tracks)
467pub const TK_CUSTOM: u32 = 2; // the track is drawn by a custom function (no stops)
468pub const TK_RECT: u32 = 4; // square ends, the gradient spans the whole rectangle
469pub const TK_MAXN: usize = 16;
470pub const ANG_360: u32 = 1; // angle: 0 .. 360 instead of -180 .. 180
471pub const PAN_UNIT: u32 = 1; // pan: coordinates 0 .. 1 instead of -1 .. 1
472pub const CW_HSV: u32 = 1; // color_wheel: an HSV record instead of 0xAARRGGBB
473pub const CP_ALPHA: u32 = 1; // color_picker_ex: alpha (transparency) track
474pub const CP_FIELDS: u32 = 2; // ... number boxes R G B (A) H S V and a hex text box
475pub const CP_PIPETTE: u32 = 4; // ... a pipette button: a colour from anywhere on the screen (only where possible)
476pub const PART_BASE: u32 = 0x6000_0000; // part_id(id, k): ids of the parts of composite widgets
477
478/// UIINPUT -- pointer state handed to custom widgets (canvas)
479#[derive(Clone, Default)]
480pub struct UiInput {
481 pub ev: u32, // EV_* flags
482 pub btn: u32, // buttons held (bit 1 << BTN_*)
483 pub pressed: u32, // buttons pressed this frame
484 pub released: u32, // buttons released this frame
485 pub x: i32, // pointer x relative to the widget (px)
486 pub y: i32,
487 pub press_x: i32, // position of the last press (px, relative)
488 pub press_y: i32,
489 pub wheel_x: i32, // wheel delta (120 per notch)
490 pub wheel_y: i32,
491 pub mods: u32,
492 pub pts: alloc::vec::Vec<[i32; 2]>, // move points since the last frame (relative px)
493 pub rect: [i32; 4], // widget rectangle (absolute px)
494 pub dpi: i32,
495 pub key: u32, // first unconsumed key this frame (VK | mods << 16) or 0
496 pub pressure: u32, // pen pressure now: 0 = none (mouse), 1..UI_PRESSURE_ONE
497 pub ptype: u32, // PTR_MOUSE / PTR_PEN / PTR_ERASER / PTR_TOUCH
498 pub ppress: alloc::vec::Vec<u32>, // pressure per move point
499 pub tilt_x: i32, // pen tilt in degrees (-63..63), 0 without tilt
500 pub tilt_y: i32,
501}
502
503pub const UI_PRESSURE_ONE: u32 = 65535;
504
505// ------------------------------------------------------------------ containers
506pub const SC_V: u32 = 0x0100_0000; // vertical scrolling, children top to bottom (default)
507pub const SC_H: u32 = 0x0200_0000; // horizontal scrolling, children left to right
508pub const SC_NOBAR: u32 = 0x0400_0000; // no scroll bars
509pub const SC_NOWHEEL: u32 = 0x0800_0000; // ignore the mouse wheel
510pub const IB_INFO: u32 = 0;
511pub const IB_SUCCESS: u32 = 1;
512pub const IB_WARNING: u32 = 2;
513pub const IB_ERROR: u32 = 3;
514pub const DLG_NONE: u32 = 0;
515pub const DLG_PRIMARY: u32 = 1;
516pub const DLG_SECONDARY: u32 = 2;
517pub const DLG_CLOSE: u32 = 3;
518
519// ------------------------------------------------------------------ text input
520pub const TB_CAP_MASK: u32 = 0x007F_FFFF; // the capacity in bytes (at most 8 MB)
521pub const TB_HYPHENATE: u32 = 0x0080_0000; // with TB_MULTI | TB_WRAP: hyphenate words that do not fit (hyph.rs)
522pub const TB_PASSWORD: u32 = 0x0100_0000; // a dot per character; no copy / cut; the input method's purpose IP_PASSWORD while it has the keyboard
523pub const TB_READONLY: u32 = 0x0200_0000; // selectable and copyable, not editable
524pub const TB_DIGITS: u32 = 0x0400_0000; // accept only 0-9
525pub const TB_MULTI: u32 = 0x0800_0000; // multi-line
526pub const TB_SIGNED: u32 = 0x1000_0000; // with TB_DIGITS: also '-'
527pub const TB_DECIMAL: u32 = 0x2000_0000; // with TB_DIGITS: also ',' and '.'
528pub const TB_WRAP: u32 = 0x4000_0000; // with TB_MULTI: wrap long lines at the box width
529pub const TB_SPELL: u32 = 0x8000_0000; // spell checking: misspelled words underlined, suggestions (edit_spell.rs)
530pub const UIT_CARET: u32 = 0x7FFE_0001; // timer id of the caret blink
531
532// ------------------------------------------------------------------ popups, menus, commands
533pub const UIT_TOOLTIP: u32 = 0x7FFE_0010; // timer id of the tooltip delay
534pub const FL_BELOW: u32 = 0;
535pub const FL_ABOVE: u32 = 1;
536pub const FL_RIGHT: u32 = 2;
537pub const FL_ALIGN_END: u32 = 4;
538pub const FL_MINW: u32 = 8;
539pub const FL_POINT: u32 = 16;
540pub const FL_OVER: u32 = 32;
541pub const CF_DISABLED: u32 = 1;
542pub const CF_CHECKED: u32 = 2;
543pub const CF_HIDDEN: u32 = 4;
544pub const FD_OPEN: u32 = 0;
545pub const FD_SAVE: u32 = 1;
546pub const FD_FOLDER: u32 = 2;
547/// (E8) open several files at once (with FD_OPEN): ui.filedlg_paths() has all of them, `path` the first
548pub const FD_MULTI: u32 = 4;
549pub const FD_EXT_SHIFT: u32 = 8;
550
551// ------------------------------------------------------------------ windows (win.rs)
552// windows including the main window (index 0); fixed: the index is a bit in u32 masks and
553// Event::win, plat keeps PW_MAX windows; one more warns (window_begin)
554pub const WIN_MAX: usize = 8;
555pub const WF_TOOL: u32 = 1;
556pub const WF_DIALOG: u32 = 2;
557pub const WF_MODAL: u32 = 4;
558pub const WF_RESIZABLE: u32 = 8;
559pub const WF_NOCLOSE: u32 = 16;
560pub const WF_SYSFRAME: u32 = 32;
561pub const WF_NOACTIVATE: u32 = 64;
562pub const WF_AUTOHEIGHT: u32 = 128;
563pub const WF_KEYS: u32 = 256;
564pub const WF_TOUCH_HOLD: u32 = 512; // a finger moves it by the title bar only after resting there (TF_HOLD)
565/// (E7) an independent app window (a browser's second or private window): a top-level window of
566/// its own on Windows (its own taskbar button, not minimized or hidden with the main window),
567/// without the library's title bar -- the app draws one with titlebar_begin / titlebar_end
568/// (its own widgets in it, the caption buttons at its end); X11 and Wayland too (a top-level
569/// window without WM_TRANSIENT_FOR / an xdg_toplevel without a parent); macOS gives it an owned
570/// window for now
571pub const WF_APP: u32 = 1024;
572pub const UWS_OPEN: u32 = 1;
573pub const UWS_VISIBLE: u32 = 2;
574pub const UWS_ACTIVE: u32 = 4;
575pub const UWS_MINIMIZED: u32 = 8;
576
577/// WINRECT -- window placement, owned by the app (DIP; see ui.inc)
578#[derive(Clone, Copy, Default, Debug, PartialEq, Eq)]
579pub struct WinRect {
580 pub x: i32,
581 pub y: i32,
582 pub w: i32,
583 pub h: i32,
584 pub flags: u32,
585}
586
587impl WinRect {
588 pub const fn new(x: i32, y: i32, w: i32, h: i32, flags: u32) -> WinRect {
589 WinRect { x, y, w, h, flags }
590 }
591}
592
593pub const WRF_POS: u32 = 1;
594pub const WRF_MAX: u32 = 2;
595pub const WRF_CHANGED: u32 = 4;
596pub const WRF_ABS: u32 = 8;
597
598// ------------------------------------------------------------------ input (jfgui.inc)
599pub const BTN_LEFT: u32 = 1;
600pub const BTN_RIGHT: u32 = 2;
601pub const BTN_MIDDLE: u32 = 3;
602pub const BTN_X1: u32 = 4;
603pub const BTN_X2: u32 = 5;
604pub const MOD_SHIFT: u32 = 1;
605pub const MOD_CTRL: u32 = 2;
606pub const MOD_ALT: u32 = 4;
607pub const MOD_SUPER: u32 = 8;
608pub const MOD_ALTGR: u32 = 16;
609pub const MOD_CAPS: u32 = 32;
610pub const MOD_NUM: u32 = 64;
611pub const PTR_MOUSE: u32 = 0;
612pub const PTR_PEN: u32 = 1;
613pub const PTR_ERASER: u32 = 2;
614pub const PTR_TOUCH: u32 = 3;
615
616// (E2) where a key sits (KeyEvent::location)
617pub const KL_STANDARD: u32 = 0;
618pub const KL_LEFT: u32 = 1;
619pub const KL_RIGHT: u32 = 2;
620pub const KL_NUMPAD: u32 = 3;
621
622// cursors (CUR_*)
623pub const CUR_ARROW: u32 = 0;
624pub const CUR_IBEAM: u32 = 1;
625pub const CUR_HAND: u32 = 2;
626pub const CUR_CROSS: u32 = 3;
627pub const CUR_MOVE: u32 = 4;
628pub const CUR_WAIT: u32 = 5;
629pub const CUR_SIZE_NS: u32 = 6;
630pub const CUR_SIZE_WE: u32 = 7;
631pub const CUR_SIZE_NWSE: u32 = 8;
632pub const CUR_SIZE_NESW: u32 = 9;
633pub const CUR_NONE: u32 = 10;
634pub const CUR_COUNT: u32 = 11;
635pub const CUR_CUSTOM: u32 = 15; // hit boxes only: the cursor of cursor_custom
636pub const CUR_USER_MAX: u32 = 32; // fixed handle range; cursor_new answers 0 when it is full
637pub const CUR_MAX_PX: i32 = 256;
638
639// ---- (E3) more system shapes: CSS's cursor names, past the custom cursors (CUR_X0 ..
640// CUR_X_END); a platform without one shows cursor_fallback's
641pub const CUR_X0: u32 = 64;
642pub const CUR_NOT_ALLOWED: u32 = 64; // not-allowed
643pub const CUR_NO_DROP: u32 = 65; // no-drop
644pub const CUR_GRAB: u32 = 66; // grab: an open hand
645pub const CUR_GRABBING: u32 = 67; // grabbing: a closed hand
646pub const CUR_HELP: u32 = 68; // help: the arrow with a question mark
647pub const CUR_PROGRESS: u32 = 69; // progress: the arrow with a busy sign (work in the background)
648pub const CUR_ZOOM_IN: u32 = 70; // zoom-in
649pub const CUR_ZOOM_OUT: u32 = 71; // zoom-out
650pub const CUR_CELL: u32 = 72; // cell: a thick cross (tables)
651pub const CUR_VTEXT: u32 = 73; // vertical-text
652pub const CUR_ALIAS: u32 = 74; // alias: a link will be made
653pub const CUR_COPY: u32 = 75; // copy: a copy will be made
654pub const CUR_CONTEXT_MENU: u32 = 76; // context-menu
655pub const CUR_ALL_SCROLL: u32 = 77; // all-scroll
656pub const CUR_COL_RESIZE: u32 = 78; // col-resize
657pub const CUR_ROW_RESIZE: u32 = 79; // row-resize
658pub const CUR_SIZE_N: u32 = 80; // n-resize: one edge or corner
659pub const CUR_SIZE_S: u32 = 81;
660pub const CUR_SIZE_E: u32 = 82;
661pub const CUR_SIZE_W: u32 = 83;
662pub const CUR_SIZE_NE: u32 = 84;
663pub const CUR_SIZE_NW: u32 = 85;
664pub const CUR_SIZE_SE: u32 = 86;
665pub const CUR_SIZE_SW: u32 = 87;
666pub const CUR_X_END: u32 = 88;
667
668// fonts
669pub const FONT_REG: u32 = 0;
670pub const FONT_SEMI: u32 = 1;
671pub const FONT_BOLD: u32 = 2;
672pub const FONT_ICON: u32 = 3;
673
674// clipboard formats
675pub const CLIP_TEXT: u32 = 1;
676pub const CLIP_PNG: u32 = 2;
677pub const CLIP_IMAGE: u32 = 3;
678/// UTF-8 HTML fragment; CF_HTML framing is handled by the platform.
679pub const CLIP_HTML: u32 = 4;
680/// Rich Text Format document bytes.
681pub const CLIP_RTF: u32 = 5;
682/// Private document fragment bytes, MIME application/x-jfgui-docx-fragment.
683pub const CLIP_DOCX: u32 = 6;
684
685// ------------------------------------------------------------------ style metrics (style.inc)
686pub const SM_DLG_MIN: u32 = 0;
687pub const SM_DLG_MAX: u32 = 1;
688pub const SM_DLG_MARGIN: u32 = 2;
689pub const SM_DLG_CONTENT_BOX: u32 = 3;
690pub const SM_DLG_CONTENT_GAP: u32 = 4;
691pub const SM_DLG_TITLE_TS: u32 = 5;
692pub const SM_DLG_FOOTER_BOX: u32 = 6;
693pub const SM_DLG_FOOTER_GAP: u32 = 7;
694pub const SM_SB_H: u32 = 8;
695pub const SM_SB_PAD: u32 = 9;
696pub const SM_SB_GAP: u32 = 10;
697pub const SM_TB_H: u32 = 11;
698pub const SM_TB_H_LARGE: u32 = 12;
699pub const SM_TB_PAD: u32 = 13;
700pub const SM_TB_ICON: u32 = 14;
701pub const SM_TB_TITLE_TS: u32 = 15;
702pub const SM_CAP_W: u32 = 16;
703pub const SM_CAP_W_TOOL: u32 = 17;
704pub const SM_WC_TITLE_PAD: u32 = 18;
705pub const SM_WC_TITLE_GAP: u32 = 19;
706pub const SM_GRIP: u32 = 20;
707pub const SM_GRIP_CORNER: u32 = 21;
708pub const SM_WIN_TBH_TOOL: u32 = 22;
709pub const SM_WIN_TBH_DIALOG: u32 = 23;
710pub const SM_CAP_LEFT: u32 = 24;
711pub const SM_DLG_BTN_ORDER: u32 = 25;
712pub const SM_DOCK_HDR: u32 = 26; // tab strip of a dock group (dock.rs; 0 = 32)
713pub const SM_DOCK_BTN: u32 = 27; // its buttons (0 = 28)
714pub const SM_COUNT: u32 = 28;
715// menu / list rows of flyouts (menu_item*: Sp::flags)
716pub const MIF_DISABLED: u32 = 1;
717pub const MIF_CHECKED: u32 = 2;
718pub const MIF_SUB: u32 = 4;
719pub const MIF_OPEN: u32 = 8;
720pub const MIF_SELECTED: u32 = 16;
721pub const MIF_LIST: u32 = 32;
722pub const MIF_TWOCOL: u32 = 64;
723
724// ------------------------------------------------------------------ data views (data.rs, chart.rs)
725// badge / status dot / meter kinds (StyleData::badge flags)
726pub const BADGE_NEUTRAL: u32 = 0;
727pub const BADGE_INFO: u32 = 1;
728pub const BADGE_OK: u32 = 2;
729pub const BADGE_WARN: u32 = 3;
730pub const BADGE_CRIT: u32 = 4;
731pub const BADGE_ACCENT: u32 = 5;
732// grid column flags (GridCol::flags)
733pub const GC_RIGHT: u32 = 1; // cell content right-aligned (numbers)
734pub const GC_CENTER: u32 = 2;
735pub const GC_NOSORT: u32 = 4; // the header does not sort
736pub const GC_FILL: u32 = 8; // the column takes the width the others leave (at least its width)
737// grid header cell paint flags (StyleData::grid_header Sp::flags)
738pub const GH_SORT_ASC: u32 = 1;
739pub const GH_SORT_DESC: u32 = 2;
740pub const GH_LAST: u32 = 4; // the last column (no divider)
741pub const GH_RIGHT: u32 = 8; // label right-aligned
742// grid row paint flags (StyleData::grid_row Sp::flags)
743pub const GR_FOCUS: u32 = 1; // the focused row of a focused grid (focus visual)
744pub const GR_STRIPE: u32 = 2; // an odd row of a striped grid
745pub const GR_CURRENT: u32 = 4; // the current (focused) row, focus not visible
746// ------------------------------------------------------------------ shell (shell.rs, notify.rs)
747pub const NAV_COMPACT: u32 = 1; // nav_item / nav_section: the pane shows icons only
748pub const SEG_FIRST: u32 = 1; // segment: the first / last item of the control
749pub const SEG_LAST: u32 = 2;
750pub const WS_TODO: i32 = 0; // wizard step states
751pub const WS_CURRENT: i32 = 1;
752pub const WS_DONE: i32 = 2;
753pub const WS_ERROR: i32 = 3;
754pub const CBI_SEP: u32 = 0x1_0000; // command bar item: a separator before it
755pub const CBI_END: u32 = 0x2_0000; // command bar item: starts the end-aligned group
756pub const UIT_TOAST: u32 = 0x7FFE_0020; // timer id of toast expiry
757pub const UIT_SPIN: u32 = 0x7FFE_0021; // (reserved) spinner frame timer
758pub const UIT_SPELL: u32 = 0x7FFE_0030; // timer id: spell checking continues in the next frame
759// spell_state(): the checker of the text boxes (edit_spell.rs)
760pub const SPELL_OFF: u32 = 0; // spell_enable(false), or no TB_SPELL box asked yet
761pub const SPELL_LOADING: u32 = 1; // its dictionary is being read (window mode)
762pub const SPELL_READY: u32 = 2; // checking (the marks are up to date or follow on the timer)
763pub const SPELL_NONE: u32 = 3; // no checker for the language
764// (L7) full screen (win.rs window_fullscreen): window_state's bit, the event when the platform
765// or the user changed it
766pub const UWS_FULLSCREEN: u32 = 16;
767pub const UIC_FULLSCREEN: u32 = 0x7FFF_001A; // arg = window id (0 main): the platform or the user left (or entered) full screen