Skip to main content

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
46// ------------------------------------------------------------------ the finger (touch.rs)
47// ui.touch_take(flags) after a widget, instead of what its hit box says by itself: TF_V / TF_H a
48// finger moving along this axis is the widget's (not the scroll view's around it); with both the
49// press comes with the touch, unless TF_SLOP (only once the finger moved) or TF_HOLD (only after
50// resting for the long-press time: a panel that starts to move then, until then the finger goes
51// to what is around it); TF_HOLD_LONG the same after 600 ms (a panel's title bar; ui.touch_hold_part
52// shows it); TF_REST a finger that rests presses like one that moved, no context menu (a canvas); TF_TWO
53// a second finger is the widget's: no press, no click, it reads ui.touch_two or ui.touch_fingers (pan and
54// zoom); TF_DECLINE no drag at all, a tap still clicks.  0: nothing special (the finger rolls what is
55// around it, with nothing to roll it drags the widget).
56pub const TF_V: u32 = 1;
57pub const TF_H: u32 = 2;
58pub const TF_BOTH: u32 = 3;
59pub const TF_HOLD: u32 = 4;
60pub const TF_TWO: u32 = 8;
61pub const TF_SLOP: u32 = 16;
62pub const TF_DECLINE: u32 = 32;
63pub const TF_REST: u32 = 64;
64pub const TF_HOLD_LONG: u32 = 128;
65
66// ------------------------------------------------------------------ semantic kinds and states
67pub const K_BOX: u16 = 0;
68pub const K_TEXT: u16 = 1;
69pub const K_BUTTON: u16 = 2;
70pub const K_CHECKBOX: u16 = 3;
71pub const K_RADIO: u16 = 4;
72pub const K_SWITCH: u16 = 5;
73pub const K_SLIDER: u16 = 6;
74pub const K_PROGRESS: u16 = 7;
75pub const K_TEXTBOX: u16 = 8;
76pub const K_MENU: u16 = 9;
77pub const K_MENUITEM: u16 = 10;
78pub const K_LIST: u16 = 11;
79pub const K_LISTITEM: u16 = 12;
80pub const K_TAB: u16 = 13;
81pub const K_CANVAS: u16 = 14;
82pub const K_ICON: u16 = 15;
83pub const K_IMAGE: u16 = 16;
84pub const K_COMBO: u16 = 17;
85pub const K_DIALOG: u16 = 18;
86pub const K_TITLEBAR: u16 = 19;
87pub const K_SWATCH: u16 = 20;
88pub const K_LINK: u16 = 21;
89/// a heading of a document or section (value: its level, 1 the top; md_view.rs, Ui::heading)
90pub const K_HEADING: u16 = 22;
91pub const K_KIND_COUNT: u16 = 23;
92pub const SS_HOVER: u16 = 1;
93pub const SS_PRESSED: u16 = 2;
94pub const SS_FOCUSED: u16 = 4;
95pub const SS_CHECKED: u16 = 8;
96pub const SS_DISABLED: u16 = 16;
97pub const SS_SELECTED: u16 = 32;
98pub const SS_OPEN: u16 = 64;
99
100/// names of the K_* kinds (dump, selectors kind:"Label")
101pub const KIND_NAMES: [&str; 23] = [
102    "box", "text", "button", "checkbox", "radio", "switch", "slider", "progress", "textbox",
103    "menu", "menuitem", "list", "listitem", "tab", "canvas", "icon", "image", "combo", "dialog",
104    "titlebar", "swatch", "link", "heading",
105];
106/// names of the SS_* state bits (dump)
107pub const STATE_NAMES: [&str; 7] = ["hover", "pressed", "focused", "checked", "disabled", "selected", "open"];
108
109// ------------------------------------------------------------------ layers
110pub const L_BASE: u32 = 0;
111pub const L_DIALOG: u32 = 1;
112pub const L_POPUP: u32 = 2;
113pub const L_TIP: u32 = 3;
114pub const L_COUNT: usize = 4;
115
116// ------------------------------------------------------------------ box flags (box_begin)
117pub const BOX_H: u32 = 0; // children left to right
118pub const BOX_V: u32 = 1; // children top to bottom
119pub const BOX_CENTER: u32 = 2; // centre children along the main axis
120pub const BOX_END: u32 = 4; // align children to the end of the main axis
121pub const BOX_XCENTER: u32 = 8; // cross axis: centre children (default: stretch)
122pub const BOX_XSTART: u32 = 16; // cross axis: natural size at the start
123pub const BOX_XEND: u32 = 32; // cross axis: natural size at the end
124pub const BOX_CARD: u32 = 64; // draw a card (fill + stroke, 8 DIP corners)
125pub const BOX_BG: u32 = 128; // fill with the window background colour
126pub const BOX_CLIP: u32 = 256; // clip children to the box
127pub const BOX_BLOCK: u32 = 512; // swallow pointer input over the box
128pub const BOX_DISABLED: u32 = 1024; // disable every widget inside
129pub const BOX_LAYER: u32 = 2048; // fill with the layer colour (command bars)
130pub const BOX_WRAP: u32 = 4096; // (horizontal) start a new row when full
131pub const BOX_FIXED: u32 = 8192; // the box's size never depends on its content
132// grid flags (gridbox_begin, with the box decorations and padding): the children's alignment
133pub const GRID_H_START: u32 = 2; // horizontal (default: stretched across the cell)
134pub const GRID_H_CENTER: u32 = 4;
135pub const GRID_H_END: u32 = 6;
136pub const GRID_V_START: u32 = 8; // vertical (default: centred)
137pub const GRID_V_END: u32 = 16;
138pub const GRID_V_STRETCH: u32 = 24;
139// next_align(h, v): one grid child's alignment
140pub const AL_DEFAULT: u32 = 0; // the grid's
141pub const AL_START: u32 = 1;
142pub const AL_CENTER: u32 = 2;
143pub const AL_END: u32 = 3;
144pub const AL_STRETCH: u32 = 4;
145pub const PAD_SHIFT: u32 = 16; // padding in DIP: flags | N << PAD_SHIFT
146pub const PAD_2: u32 = 2 << 16;
147pub const PAD_4: u32 = 4 << 16;
148pub const PAD_8: u32 = 8 << 16;
149pub const PAD_12: u32 = 12 << 16;
150pub const PAD_16: u32 = 16 << 16;
151pub const PAD_20: u32 = 20 << 16;
152pub const PAD_24: u32 = 24 << 16;
153pub const PAD_32: u32 = 32 << 16;
154
155/// padding in DIP for box_begin flags: BOX_V | pad(24)
156pub const fn pad(dip: u32) -> u32 {
157    dip << PAD_SHIFT
158}
159
160// easing curves (ease, anim_ex, anim_color)
161pub const EASE_OUT: u32 = 0; // fast start, soft stop (quadratic; anim's)
162pub const EASE_LINEAR: u32 = 1;
163pub const EASE_IN: u32 = 2; // soft start (quadratic)
164pub const EASE_IN_OUT: u32 = 3; // soft start and stop (cubic)
165pub const EASE_OUT_CUBIC: u32 = 4; // a softer stop than EASE_OUT
166pub const EASE_OUT_BACK: u32 = 5; // overshoots a little, then settles
167
168// next_size values: > 0 fixed DIP, 0 = natural size, < 0 = fill weight
169pub const SIZE_AUTO: i32 = 0;
170pub const SIZE_FILL: i32 = -1;
171
172// ------------------------------------------------------------------ text styles (text)
173pub const TS_CAPTION: u32 = 0; // 12 / 16
174pub const TS_BODY: u32 = 1; // 14 / 20
175pub const TS_BODY_STRONG: u32 = 2; // 14 / 20 semibold
176pub const TS_SUBTITLE: u32 = 3; // 20 / 28 semibold
177pub const TS_TITLE: u32 = 4; // 28 / 36 semibold
178pub const TS_TITLE_LARGE: u32 = 5; // 40 / 52 semibold
179pub const TS_DISPLAY: u32 = 6; // 68 / 92 semibold
180pub const TS_COUNT: u32 = 7;
181pub const TX_SECONDARY: u32 = 0x100; // secondary text colour
182pub const TX_TERTIARY: u32 = 0x200;
183pub const TX_ACCENT: u32 = 0x400; // accent text colour
184pub const TX_WRAP: u32 = 0x800; // wrap at the box width
185pub const TX_ELLIPSIS: u32 = 0x1000; // cut with "…" when too long
186pub const TX_CENTER: u32 = 0x2000; // horizontal alignment
187pub const TX_RIGHT: u32 = 0x4000;
188pub const TX_DISABLED: u32 = 0x8000;
189pub const TX_ON_ACCENT: u32 = 0x10000; // text on an accent fill (T_ON_ACCENT)
190pub const TX_HYPHENATE: u32 = 0x20000; // with TX_WRAP: hyphenate words that do not fit (hyph.rs)
191
192// ------------------------------------------------------------------ widget style flags (next_flags)
193pub const ST_DISABLED: u32 = 1;
194pub const ST_LARGE: u32 = 2; // icon button: big icon above the label
195pub const ST_SUBTLE: u32 = 4; // transparent button (toolbar style)
196pub const ST_ACCENT: u32 = 8; // accent button
197pub const ST_CHECKED: u32 = 16; // toggle / tool buttons: checked look
198pub const ST_COMPACT: u32 = 32; // smaller height
199pub const ST_NOFOCUS: u32 = 64; // not reachable with Tab
200pub const ST_ICON_ONLY: u32 = 128; // hide the label (tooltip only)
201pub const ST_ALIGN_START: u32 = 256; // start-aligned button content; styles may ellipsize long labels
202/// Button displayed on an accent-colored surface, using its on-accent foreground.
203pub const ST_ON_ACCENT: u32 = 512;
204/// Button with a menu indicator beside its label; use the normal popup API for behavior.
205pub const ST_MENU: u32 = 1024;
206/// Rounded identity/action button; supporting styles use a circular or pill surface.
207pub const ST_ROUND: u32 = 2048;
208
209// ------------------------------------------------------------------ built-in commands (App::command ids)
210pub const UIC_CLOSE: u32 = 0x7FFF_0001; // window close requested: return true to keep the window
211pub const UIC_THEME: u32 = 0x7FFF_0002; // theme changed
212pub const UIC_DPI: u32 = 0x7FFF_0003; // dpi changed
213pub const UIC_ESCAPE: u32 = 0x7FFF_0004; // Esc not consumed by any widget
214pub const UIC_TIMER: u32 = 0x7FFF_0005; // arg = timer id
215pub const UIC_WINCLOSE: u32 = 0x7FFF_0006; // arg = window id: close requested; true keeps it
216pub const UIC_DROP: u32 = 0x7FFF_0007; // arg = window id: files dropped (drop_*)
217pub const UIC_JOB: u32 = 0x7FFF_0008; // arg = job id finished
218pub const UIC_WAKE: u32 = 0x7FFF_0009; // plat::wake() from another thread
219pub const UIC_EXIT: u32 = 0x7FFF_000A; // the window loop ends (only after a real window ran)
220pub const UIC_OPEN: u32 = 0x7FFF_000B; // arg = requests: later starts of the app (AF_SINGLE_INSTANCE, open_take)
221pub const UIC_TRAY: u32 = 0x7FFF_000C; // the notification-area symbol: arg = TRAY_ACTIVATE / TRAY_SECONDARY (tray_set)
222pub const UIC_NOTE: u32 = 0x7FFF_000D; // arg = id: a system notification was clicked (notify)
223pub const UIC_NOTE_GONE: u32 = 0x7FFF_000E; // arg = id: a notification went away unclicked
224// lifecycle (runtime.rs)
225pub const UIC_ACTIVE: u32 = 0x7FFF_000F; // arg 1: one of the app's windows got the keyboard, 0: none has it
226pub 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
227pub const UIC_SESSION_END: u32 = 0x7FFF_0011; // logout / shutdown / SIGTERM: save now; UIC_EXIT and the end follow
228pub const UIC_SETTINGS: u32 = 0x7FFF_0012; // arg = plat::SET_* bits: system settings changed (theme and format already applied)
229// drag and drop (dnd.rs)
230pub const UIC_DRAG_END: u32 = 0x7FFF_0013; // arg = DE_* effect (0 = cancelled / refused): a drag of the app ended
231// permissions (perm.rs)
232pub const UIC_PERMISSION: u32 = 0x7FFF_0014; // arg 1 allowed, 0 refused: the user answered a permission question (try the access again)
233// the screen and global shortcuts (screen.rs)
234pub const UIC_HOTKEY: u32 = 0x7FFF_0015; // arg = id: a global shortcut was pressed (hotkey_register)
235pub const UIC_HOTKEY_LOST: u32 = 0x7FFF_0016; // arg = id: the desktop dropped the shortcut (hotkey_error tells why)
236pub const UIC_PICK: u32 = 0x7FFF_0017; // arg 1: a colour was picked (picked_color), 0: cancelled / failed (pick_color)
237pub const UIC_SCREENSHOT: u32 = 0x7FFF_0018; // arg 1: the picture is there (screenshot_take), 0: failed (screen_error)
238pub const UIC_RECENT: u32 = 0x7FFF_0019; // arg 1: the file of recent_open is readable now (recent_reopened), 0: refused or gone
239pub const UIC_SENSOR: u32 = 0x7FFF_001B; // arg = plat::sensors::SENSOR_* bits: new readings or another state (plat::sensors::read, state)
240pub const UIC_LOCATION: u32 = 0x7FFF_001C; // arg = plat::sensors::LocationState: a new fix or another state (location_fix)
241pub const TRAY_ACTIVATE: u32 = 1; // UIC_TRAY: the symbol was clicked
242pub const TRAY_SECONDARY: u32 = 2; // UIC_TRAY: double click (Windows) / middle click (Linux)
243
244// ------------------------------------------------------------------ drag and drop (dnd.rs)
245// drag_source / drop_target states; the kinds DT_* and effects DE_* come from plat (dnd.rs)
246pub const DS_START: u32 = 1; // drag_source: the widget starts being dragged (call drag_set now)
247pub const DS_ACTIVE: u32 = 2; // drag_source: the widget's content is being dragged
248pub const DS_END: u32 = 4; // drag_source: the drag ended (once; drag_effect() tells how)
249pub const DS_HOVER: u32 = 8; // drop_target: a matching drag is over the widget (highlighted)
250pub const DS_DROP: u32 = 16; // drop_target: dropped onto the widget (drop_data(), drop_effect())
251
252// ------------------------------------------------------------------ app flags (AppDesc)
253pub const AF_CUSTOM_TITLEBAR: u32 = 1;
254pub const AF_RESIZABLE: u32 = 2;
255pub const AF_DARK: u32 = 4; // force dark theme
256pub const AF_LIGHT: u32 = 8; // force light theme
257pub const AF_SINGLE_INSTANCE: u32 = 16; // one window per user: later starts hand their command line over (UIC_OPEN)
258pub const AF_LOG_FILE: u32 = 32; // window mode: the log also goes to logs://APP.log (1 MiB, 3 older files)
259pub const AF_SAVE_STATE: u32 = 64; // window mode: the main and tool windows' placement kept in config://windows.ini
260
261// ------------------------------------------------------------------ theme tokens (color)
262// byte offsets as in ASMLIB; index = token / 4
263pub const T_BG: u32 = 0; // window background (Mica fallback)
264pub const T_BG_ALT: u32 = 4;
265pub const T_LAYER: u32 = 8; // layer fill (command bars, panels)
266pub const T_LAYER_STROKE: u32 = 12;
267pub const T_CARD: u32 = 16;
268pub const T_CARD_STROKE: u32 = 20;
269pub const T_CTRL: u32 = 24; // control fill: rest, hover, pressed, disabled (24..36)
270pub const T_CTRL_HOVER: u32 = 28;
271pub const T_CTRL_PRESSED: u32 = 32;
272pub const T_CTRL_DISABLED: u32 = 36;
273pub const T_CTRL_STROKE: u32 = 40; // control border
274pub const T_CTRL_STROKE2: u32 = 44; // control border, bottom edge
275pub const T_STRONG_STROKE: u32 = 48; // checkbox / radio border
276pub const T_SUBTLE: u32 = 52; // transparent button: rest, hover, pressed, disabled (52..64)
277pub const T_SUBTLE_HOVER: u32 = 56;
278pub const T_SUBTLE_PRESSED: u32 = 60;
279pub const T_SUBTLE_DISABLED: u32 = 64;
280pub const T_TEXT: u32 = 68; // text: primary, secondary, tertiary, disabled (68..80)
281pub const T_TEXT2: u32 = 72;
282pub const T_TEXT3: u32 = 76;
283pub const T_TEXT_DISABLED: u32 = 80;
284pub const T_ACCENT: u32 = 84; // accent fill: rest, hover, pressed, disabled (84..96)
285pub const T_ACCENT_HOVER: u32 = 88;
286pub const T_ACCENT_PRESSED: u32 = 92;
287pub const T_ACCENT_DISABLED: u32 = 96;
288pub const T_ON_ACCENT: u32 = 100; // text on accent
289pub const T_ON_ACCENT_DIS: u32 = 104;
290pub const T_ACCENT_TEXT: u32 = 108; // accent-coloured text / links
291pub const T_FOCUS_OUT: u32 = 112;
292pub const T_FOCUS_IN: u32 = 116;
293pub const T_FLYOUT: u32 = 120; // menus, popups
294pub const T_FLYOUT_STROKE: u32 = 124;
295pub const T_SMOKE: u32 = 128; // dim behind dialogs
296pub const T_DIVIDER: u32 = 132;
297pub const T_INPUT_ACTIVE: u32 = 136; // focused text box fill
298pub const T_CRIT: u32 = 140;
299pub const T_OK: u32 = 144;
300pub const T_WARN: u32 = 148;
301pub const T_INFO: u32 = 152;
302pub const T_CRIT_BG: u32 = 156;
303pub const T_OK_BG: u32 = 160;
304pub const T_WARN_BG: u32 = 164;
305pub const T_INFO_BG: u32 = 168;
306pub const T_CLOSE_HOVER: u32 = 172;
307pub const T_SHADOW: u32 = 176;
308pub const T_SCROLL: u32 = 180; // scroll bar thumb
309pub const T_TRACK: u32 = 184; // slider / progress track
310pub const T_KNOB: u32 = 188; // solid control fill (slider thumb, toggle knob)
311pub const T_ALT_FILL: u32 = 192; // toggle off background
312pub const T_STRONG_FILL: u32 = 196; // toggle off knob / strong fill
313pub const T_COUNT: usize = 50;
314
315// ------------------------------------------------------------------ records
316/// RANGE min, max, step, flags -- slider / number box descriptor
317#[derive(Clone, Copy, Default, Debug)]
318pub struct Range {
319    pub min: i32,
320    pub max: i32,
321    pub step: i32,
322    pub flags: u32,
323}
324
325impl Range {
326    pub const fn new(min: i32, max: i32, step: i32, flags: u32) -> Range {
327        Range { min, max, step, flags }
328    }
329}
330
331pub const RG_VERT: u32 = 1; // vertical slider
332pub const RG_TICKS: u32 = 2;
333pub const RG_TIP: u32 = 4; // value tooltip while dragging
334/// Logarithmic pointer/paint mapping for integer sliders with positive bounds.
335/// Keyboard increments, semantic values and range endpoints retain their units.
336pub const RG_LOG: u32 = 8;
337pub const LF_REORDER: u32 = 0x10000; // list_begin: rows can be dragged to a new place
338
339// decimal values, colour tracks, angle, pan, colour wheel (ui_value.s, ui_wheel.s)
340pub const TK_CHECKER: u32 = 1; // draw the gradient over a checkerboard (alpha tracks)
341pub const TK_CUSTOM: u32 = 2; // the track is drawn by a custom function (no stops)
342pub const TK_RECT: u32 = 4; // square ends, the gradient spans the whole rectangle
343pub const TK_MAXN: usize = 16;
344pub const ANG_360: u32 = 1; // angle: 0 .. 360 instead of -180 .. 180
345pub const PAN_UNIT: u32 = 1; // pan: coordinates 0 .. 1 instead of -1 .. 1
346pub const CW_HSV: u32 = 1; // color_wheel: an HSV record instead of 0xAARRGGBB
347pub const CP_ALPHA: u32 = 1; // color_picker_ex: alpha (transparency) track
348pub const CP_FIELDS: u32 = 2; // ... number boxes R G B (A) H S V and a hex text box
349pub const CP_PIPETTE: u32 = 4; // ... a pipette button: a colour from anywhere on the screen (only where possible)
350pub const PART_BASE: u32 = 0x6000_0000; // part_id(id, k): ids of the parts of composite widgets
351
352/// UIINPUT -- pointer state handed to custom widgets (canvas)
353#[derive(Clone, Default)]
354pub struct UiInput {
355    pub ev: u32,          // EV_* flags
356    pub btn: u32,         // buttons held (bit 1 << BTN_*)
357    pub pressed: u32,     // buttons pressed this frame
358    pub released: u32,    // buttons released this frame
359    pub x: i32,           // pointer x relative to the widget (px)
360    pub y: i32,
361    pub press_x: i32,     // position of the last press (px, relative)
362    pub press_y: i32,
363    pub wheel_x: i32,     // wheel delta (120 per notch)
364    pub wheel_y: i32,
365    pub mods: u32,
366    pub pts: alloc::vec::Vec<[i32; 2]>, // move points since the last frame (relative px)
367    pub rect: [i32; 4],   // widget rectangle (absolute px)
368    pub dpi: i32,
369    pub key: u32,         // first unconsumed key this frame (VK | mods << 16) or 0
370    pub pressure: u32,    // pen pressure now: 0 = none (mouse), 1..UI_PRESSURE_ONE
371    pub ptype: u32,       // PTR_MOUSE / PTR_PEN / PTR_ERASER / PTR_TOUCH
372    pub ppress: alloc::vec::Vec<u32>, // pressure per move point
373    pub tilt_x: i32,      // pen tilt in degrees (-63..63), 0 without tilt
374    pub tilt_y: i32,
375}
376
377pub const UI_PRESSURE_ONE: u32 = 65535;
378
379// ------------------------------------------------------------------ containers
380pub const SC_V: u32 = 0x0100_0000; // vertical scrolling, children top to bottom (default)
381pub const SC_H: u32 = 0x0200_0000; // horizontal scrolling, children left to right
382pub const SC_NOBAR: u32 = 0x0400_0000; // no scroll bars
383pub const SC_NOWHEEL: u32 = 0x0800_0000; // ignore the mouse wheel
384pub const IB_INFO: u32 = 0;
385pub const IB_SUCCESS: u32 = 1;
386pub const IB_WARNING: u32 = 2;
387pub const IB_ERROR: u32 = 3;
388pub const DLG_NONE: u32 = 0;
389pub const DLG_PRIMARY: u32 = 1;
390pub const DLG_SECONDARY: u32 = 2;
391pub const DLG_CLOSE: u32 = 3;
392
393// ------------------------------------------------------------------ text input
394pub const TB_CAP_MASK: u32 = 0x007F_FFFF; // the capacity in bytes (at most 8 MB)
395pub const TB_HYPHENATE: u32 = 0x0080_0000; // with TB_MULTI | TB_WRAP: hyphenate words that do not fit (hyph.rs)
396pub const TB_PASSWORD: u32 = 0x0100_0000; // a dot per character; no copy / cut
397pub const TB_READONLY: u32 = 0x0200_0000; // selectable and copyable, not editable
398pub const TB_DIGITS: u32 = 0x0400_0000; // accept only 0-9
399pub const TB_MULTI: u32 = 0x0800_0000; // multi-line
400pub const TB_SIGNED: u32 = 0x1000_0000; // with TB_DIGITS: also '-'
401pub const TB_DECIMAL: u32 = 0x2000_0000; // with TB_DIGITS: also ',' and '.'
402pub const TB_WRAP: u32 = 0x4000_0000; // with TB_MULTI: wrap long lines at the box width
403pub const TB_SPELL: u32 = 0x8000_0000; // spell checking: misspelled words underlined, suggestions (edit_spell.rs)
404pub const UIT_CARET: u32 = 0x7FFE_0001; // timer id of the caret blink
405
406// ------------------------------------------------------------------ popups, menus, commands
407pub const UIT_TOOLTIP: u32 = 0x7FFE_0010; // timer id of the tooltip delay
408pub const FL_BELOW: u32 = 0;
409pub const FL_ABOVE: u32 = 1;
410pub const FL_RIGHT: u32 = 2;
411pub const FL_ALIGN_END: u32 = 4;
412pub const FL_MINW: u32 = 8;
413pub const FL_POINT: u32 = 16;
414pub const FL_OVER: u32 = 32;
415pub const CF_DISABLED: u32 = 1;
416pub const CF_CHECKED: u32 = 2;
417pub const CF_HIDDEN: u32 = 4;
418pub const FD_OPEN: u32 = 0;
419pub const FD_SAVE: u32 = 1;
420pub const FD_FOLDER: u32 = 2;
421pub const FD_EXT_SHIFT: u32 = 8;
422
423// ------------------------------------------------------------------ windows (win.rs)
424// windows including the main window (index 0); fixed: the index is a bit in u32 masks and
425// Event::win, plat keeps PW_MAX windows; one more warns (window_begin)
426pub const WIN_MAX: usize = 8;
427pub const WF_TOOL: u32 = 1;
428pub const WF_DIALOG: u32 = 2;
429pub const WF_MODAL: u32 = 4;
430pub const WF_RESIZABLE: u32 = 8;
431pub const WF_NOCLOSE: u32 = 16;
432pub const WF_SYSFRAME: u32 = 32;
433pub const WF_NOACTIVATE: u32 = 64;
434pub const WF_AUTOHEIGHT: u32 = 128;
435pub const WF_KEYS: u32 = 256;
436pub const WF_TOUCH_HOLD: u32 = 512; // a finger moves it by the title bar only after resting there (TF_HOLD)
437pub const UWS_OPEN: u32 = 1;
438pub const UWS_VISIBLE: u32 = 2;
439pub const UWS_ACTIVE: u32 = 4;
440pub const UWS_MINIMIZED: u32 = 8;
441
442/// WINRECT -- window placement, owned by the app (DIP; see ui.inc)
443#[derive(Clone, Copy, Default, Debug, PartialEq, Eq)]
444pub struct WinRect {
445    pub x: i32,
446    pub y: i32,
447    pub w: i32,
448    pub h: i32,
449    pub flags: u32,
450}
451
452impl WinRect {
453    pub const fn new(x: i32, y: i32, w: i32, h: i32, flags: u32) -> WinRect {
454        WinRect { x, y, w, h, flags }
455    }
456}
457
458pub const WRF_POS: u32 = 1;
459pub const WRF_MAX: u32 = 2;
460pub const WRF_CHANGED: u32 = 4;
461pub const WRF_ABS: u32 = 8;
462
463// ------------------------------------------------------------------ input (jfgui.inc)
464pub const BTN_LEFT: u32 = 1;
465pub const BTN_RIGHT: u32 = 2;
466pub const BTN_MIDDLE: u32 = 3;
467pub const BTN_X1: u32 = 4;
468pub const BTN_X2: u32 = 5;
469pub const MOD_SHIFT: u32 = 1;
470pub const MOD_CTRL: u32 = 2;
471pub const MOD_ALT: u32 = 4;
472pub const MOD_SUPER: u32 = 8;
473pub const MOD_ALTGR: u32 = 16;
474pub const MOD_CAPS: u32 = 32;
475pub const MOD_NUM: u32 = 64;
476pub const PTR_MOUSE: u32 = 0;
477pub const PTR_PEN: u32 = 1;
478pub const PTR_ERASER: u32 = 2;
479pub const PTR_TOUCH: u32 = 3;
480
481// cursors (CUR_*)
482pub const CUR_ARROW: u32 = 0;
483pub const CUR_IBEAM: u32 = 1;
484pub const CUR_HAND: u32 = 2;
485pub const CUR_CROSS: u32 = 3;
486pub const CUR_MOVE: u32 = 4;
487pub const CUR_WAIT: u32 = 5;
488pub const CUR_SIZE_NS: u32 = 6;
489pub const CUR_SIZE_WE: u32 = 7;
490pub const CUR_SIZE_NWSE: u32 = 8;
491pub const CUR_SIZE_NESW: u32 = 9;
492pub const CUR_NONE: u32 = 10;
493pub const CUR_COUNT: u32 = 11;
494pub const CUR_CUSTOM: u32 = 15; // hit boxes only: the cursor of cursor_custom
495pub const CUR_USER_MAX: u32 = 32; // fixed handle range; cursor_new answers 0 when it is full
496pub const CUR_MAX_PX: i32 = 256;
497
498// fonts
499pub const FONT_REG: u32 = 0;
500pub const FONT_SEMI: u32 = 1;
501pub const FONT_BOLD: u32 = 2;
502pub const FONT_ICON: u32 = 3;
503
504// clipboard formats
505pub const CLIP_TEXT: u32 = 1;
506pub const CLIP_PNG: u32 = 2;
507pub const CLIP_IMAGE: u32 = 3;
508/// UTF-8 HTML fragment; CF_HTML framing is handled by the platform.
509pub const CLIP_HTML: u32 = 4;
510/// Rich Text Format document bytes.
511pub const CLIP_RTF: u32 = 5;
512/// Private document fragment bytes, MIME application/x-jfgui-docx-fragment.
513pub const CLIP_DOCX: u32 = 6;
514
515// ------------------------------------------------------------------ style metrics (style.inc)
516pub const SM_DLG_MIN: u32 = 0;
517pub const SM_DLG_MAX: u32 = 1;
518pub const SM_DLG_MARGIN: u32 = 2;
519pub const SM_DLG_CONTENT_BOX: u32 = 3;
520pub const SM_DLG_CONTENT_GAP: u32 = 4;
521pub const SM_DLG_TITLE_TS: u32 = 5;
522pub const SM_DLG_FOOTER_BOX: u32 = 6;
523pub const SM_DLG_FOOTER_GAP: u32 = 7;
524pub const SM_SB_H: u32 = 8;
525pub const SM_SB_PAD: u32 = 9;
526pub const SM_SB_GAP: u32 = 10;
527pub const SM_TB_H: u32 = 11;
528pub const SM_TB_H_LARGE: u32 = 12;
529pub const SM_TB_PAD: u32 = 13;
530pub const SM_TB_ICON: u32 = 14;
531pub const SM_TB_TITLE_TS: u32 = 15;
532pub const SM_CAP_W: u32 = 16;
533pub const SM_CAP_W_TOOL: u32 = 17;
534pub const SM_WC_TITLE_PAD: u32 = 18;
535pub const SM_WC_TITLE_GAP: u32 = 19;
536pub const SM_GRIP: u32 = 20;
537pub const SM_GRIP_CORNER: u32 = 21;
538pub const SM_WIN_TBH_TOOL: u32 = 22;
539pub const SM_WIN_TBH_DIALOG: u32 = 23;
540pub const SM_CAP_LEFT: u32 = 24;
541pub const SM_DLG_BTN_ORDER: u32 = 25;
542pub const SM_DOCK_HDR: u32 = 26; // tab strip of a dock group (dock.rs; 0 = 32)
543pub const SM_DOCK_BTN: u32 = 27; // its buttons (0 = 28)
544pub const SM_COUNT: u32 = 28;
545// menu / list rows of flyouts (menu_item*: Sp::flags)
546pub const MIF_DISABLED: u32 = 1;
547pub const MIF_CHECKED: u32 = 2;
548pub const MIF_SUB: u32 = 4;
549pub const MIF_OPEN: u32 = 8;
550pub const MIF_SELECTED: u32 = 16;
551pub const MIF_LIST: u32 = 32;
552pub const MIF_TWOCOL: u32 = 64;
553
554// ------------------------------------------------------------------ data views (data.rs, chart.rs)
555// badge / status dot / meter kinds (StyleData::badge flags)
556pub const BADGE_NEUTRAL: u32 = 0;
557pub const BADGE_INFO: u32 = 1;
558pub const BADGE_OK: u32 = 2;
559pub const BADGE_WARN: u32 = 3;
560pub const BADGE_CRIT: u32 = 4;
561pub const BADGE_ACCENT: u32 = 5;
562// grid column flags (GridCol::flags)
563pub const GC_RIGHT: u32 = 1; // cell content right-aligned (numbers)
564pub const GC_CENTER: u32 = 2;
565pub const GC_NOSORT: u32 = 4; // the header does not sort
566pub const GC_FILL: u32 = 8; // the column takes the width the others leave (at least its width)
567// grid header cell paint flags (StyleData::grid_header Sp::flags)
568pub const GH_SORT_ASC: u32 = 1;
569pub const GH_SORT_DESC: u32 = 2;
570pub const GH_LAST: u32 = 4; // the last column (no divider)
571pub const GH_RIGHT: u32 = 8; // label right-aligned
572// grid row paint flags (StyleData::grid_row Sp::flags)
573pub const GR_FOCUS: u32 = 1; // the focused row of a focused grid (focus visual)
574pub const GR_STRIPE: u32 = 2; // an odd row of a striped grid
575pub const GR_CURRENT: u32 = 4; // the current (focused) row, focus not visible
576// ------------------------------------------------------------------ shell (shell.rs, notify.rs)
577pub const NAV_COMPACT: u32 = 1; // nav_item / nav_section: the pane shows icons only
578pub const SEG_FIRST: u32 = 1; // segment: the first / last item of the control
579pub const SEG_LAST: u32 = 2;
580pub const WS_TODO: i32 = 0; // wizard step states
581pub const WS_CURRENT: i32 = 1;
582pub const WS_DONE: i32 = 2;
583pub const WS_ERROR: i32 = 3;
584pub const CBI_SEP: u32 = 0x1_0000; // command bar item: a separator before it
585pub const CBI_END: u32 = 0x2_0000; // command bar item: starts the end-aligned group
586pub const UIT_TOAST: u32 = 0x7FFE_0020; // timer id of toast expiry
587pub const UIT_SPIN: u32 = 0x7FFE_0021; // (reserved) spinner frame timer
588pub const UIT_SPELL: u32 = 0x7FFE_0030; // timer id: spell checking continues in the next frame
589// spell_state(): the checker of the text boxes (edit_spell.rs)
590pub const SPELL_OFF: u32 = 0; // spell_enable(false), or no TB_SPELL box asked yet
591pub const SPELL_LOADING: u32 = 1; // its dictionary is being read (window mode)
592pub const SPELL_READY: u32 = 2; // checking (the marks are up to date or follow on the timer)
593pub const SPELL_NONE: u32 = 3; // no checker for the language
594// (L7) full screen (win.rs window_fullscreen): window_state's bit, the event when the platform
595// or the user changed it
596pub const UWS_FULLSCREEN: u32 = 16;
597pub const UIC_FULLSCREEN: u32 = 0x7FFF_001A; // arg = window id (0 main): the platform or the user left (or entered) full screen