plat/consts.rs
1// consts -- the platform constants of jfgui.inc / ui.inc shared by every OS layer and the UI
2// [ASMLIB/inc/jfgui.inc, ui.inc]
3
4// ---- events (Event::typ)
5pub const E_NONE: u8 = 0;
6pub const E_MOVE: u8 = 1;
7pub const E_DOWN: u8 = 2; // btn
8pub const E_UP: u8 = 3; // btn
9pub const E_WHEEL: u8 = 4; // data = (i16 dy) | (i16 dx << 16), 120 per notch, up / right positive
10pub const E_KEY_DOWN: u8 = 5; // data = VK | (repeat << 31)
11pub const E_KEY_UP: u8 = 6; // data = VK
12pub const E_TEXT: u8 = 7; // data = Unicode codepoint
13pub const E_RESIZE: u8 = 8; // x = width, y = height (physical pixels)
14pub const E_DPI: u8 = 9; // data = dpi (96 = 100 %)
15pub const E_FOCUS_IN: u8 = 10;
16pub const E_FOCUS_OUT: u8 = 11;
17pub const E_LEAVE: u8 = 12; // pointer left the window
18pub const E_CLOSE: u8 = 13; // user asked to close the window
19pub const E_WAKE: u8 = 14; // generic wake-up (timer, repaint request)
20pub const E_PAINT: u8 = 15; // the OS needs the window content again
21pub const E_WINPOS: u8 = 16; // window moved: x, y = client origin in screen px
22pub const E_DROP: u8 = 17; // files dropped: x, y = position, data = count (drop_take)
23pub const E_PREEDIT: u8 = 18; // ime_preedit(win), uncommitted text
24pub const E_IME_COMMIT: u8 = 19; // data = bounded ime_commit_take token
25pub const E_POWER: u8 = 20; // data = 1: the system goes to sleep, 0: it woke up
26pub const E_SESSION_END: u8 = 21; // the user logs off, the system shuts down, SIGTERM: save and end
27pub const E_SETTINGS: u8 = 22; // data = SET_* bits: system settings changed
28pub const E_DRAG: u8 = 23; // a drag over the window: x, y, data = DT_* | DE_* << 8 (0: it left; dnd.rs)
29pub const E_DRAG_END: u8 = 24; // our outgoing drag (drag_start) ended: data = DE_* effect, 0 = none
30
31// E_SETTINGS: what changed
32pub const SET_THEME: u32 = 1; // light / dark, accent colour
33pub const SET_LOCALE: u32 = 2; // language, regional format
34pub const SET_CONTRAST: u32 = 4; // high contrast, system colours
35pub const SET_FONTS: u32 = 8; // fonts, text scaling
36pub const SET_OTHER: u32 = 16;
37pub const SET_MONITORS: u32 = 32; // monitors added, removed, moved, rescaled; work areas (screen::monitors)
38pub const EVQ_CAP: usize = 256; // event ring capacity (power of two)
39
40// ---- pointer types, buttons, modifiers
41pub const PTR_MOUSE: u32 = 0;
42pub const PTR_PEN: u32 = 1; // pen tip
43pub const PTR_ERASER: u32 = 2; // eraser end of a pen
44pub const PTR_TOUCH: u32 = 3;
45pub const BTN_LEFT: u8 = 1;
46pub const BTN_RIGHT: u8 = 2;
47pub const BTN_MIDDLE: u8 = 3;
48pub const BTN_X1: u8 = 4;
49pub const BTN_X2: u8 = 5;
50pub const MOD_SHIFT: u8 = 1;
51pub const MOD_CTRL: u8 = 2;
52pub const MOD_ALT: u8 = 4;
53pub const MOD_SUPER: u8 = 8;
54pub const MOD_ALTGR: u8 = 16;
55pub const MOD_CAPS: u8 = 32;
56pub const MOD_NUM: u8 = 64;
57
58// ---- cursors (CUR_*: system shapes; CUR_USER0.. custom cursors of cursor_create)
59pub const CUR_ARROW: u32 = 0;
60pub const CUR_IBEAM: u32 = 1;
61pub const CUR_HAND: u32 = 2;
62pub const CUR_CROSS: u32 = 3;
63pub const CUR_MOVE: u32 = 4;
64pub const CUR_WAIT: u32 = 5;
65pub const CUR_SIZE_NS: u32 = 6;
66pub const CUR_SIZE_WE: u32 = 7;
67pub const CUR_SIZE_NWSE: u32 = 8;
68pub const CUR_SIZE_NESW: u32 = 9;
69pub const CUR_NONE: u32 = 10;
70pub const CUR_COUNT: u32 = 11;
71pub const CUR_CUSTOM: u32 = 15; // hit boxes only: the cursor chosen with the UI's custom call
72pub const CUR_USER0: u32 = 16;
73pub const CUR_USER_MAX: u32 = 32;
74pub const CUR_TABLE: u32 = CUR_USER0 + CUR_USER_MAX;
75pub const CUR_MAX_PX: i32 = 256; // cursor_create: largest width / height
76
77// ---- window edges, commands, states
78pub const EDGE_TOP: u32 = 1;
79pub const EDGE_BOTTOM: u32 = 2;
80pub const EDGE_LEFT: u32 = 4;
81pub const EDGE_RIGHT: u32 = 8;
82pub const WCMD_MINIMIZE: u32 = 1;
83pub const WCMD_MAXIMIZE: u32 = 2;
84pub const WCMD_RESTORE: u32 = 3;
85pub const WCMD_CLOSE: u32 = 4;
86pub const WST_MAXIMIZED: u32 = 1;
87pub const WST_FULLSCREEN: u32 = 2;
88pub const WST_ACTIVE: u32 = 4; // one of the APP's windows is active
89pub const WST_TILED: u32 = 8;
90pub const WST_MINIMIZED: u32 = 16;
91pub const WST_CSD: u32 = 32; // no system frame: the app must draw its own title bar
92/// the window is drawn inside its owner (a Wayland subsurface): win_get_rect / win_set_rect /
93/// E_WINPOS use positions relative to the owner's surface origin (px), the owner carries it
94pub const WST_CHILD: u32 = 64;
95/// with WST_TILED: which edges touch the tiling (EDGE_* << WST_TILED_SHIFT; Wayland's
96/// xdg_toplevel tiled_* states, X11 the edges of a one-direction maximize); the UI keeps its
97/// resize band off them, as from a maximized window
98pub const WST_TILED_SHIFT: u32 = 7;
99pub const WST_TILED_TOP: u32 = EDGE_TOP << WST_TILED_SHIFT;
100pub const WST_TILED_BOTTOM: u32 = EDGE_BOTTOM << WST_TILED_SHIFT;
101pub const WST_TILED_LEFT: u32 = EDGE_LEFT << WST_TILED_SHIFT;
102pub const WST_TILED_RIGHT: u32 = EDGE_RIGHT << WST_TILED_SHIFT;
103/// (Windows) the window is not shown, whoever hid it: the system hides a tool window while its owner
104/// is minimised
105pub const WST_HIDDEN: u32 = 1 << 11;
106
107// gpu_out_state: how the UI's output through the GPU came up
108/// nothing known, nothing to remember
109pub const GPU_STATE_UNKNOWN: u32 = 2;
110/// the first start is about to run a driver
111pub const GPU_STATE_TRYING: u32 = 3;
112/// a window showed through the GPU
113pub const GPU_STATE_OK: u32 = 4;
114/// this system cannot: the CPU path for good
115pub const GPU_STATE_NEVER: u32 = 5;
116
117// ---- clipboard formats
118pub const CLIP_TEXT: u32 = 1; // UTF-8
119pub const CLIP_PNG: u32 = 2; // PNG file bytes
120pub const CLIP_IMAGE: u32 = 3; // get: image file bytes (PNG, or DIB as BMP); set: PNG + DIB
121/// UTF-8 HTML fragment (Windows CF_HTML framing is handled by the platform).
122pub const CLIP_HTML: u32 = 4;
123/// Rich Text Format document bytes.
124pub const CLIP_RTF: u32 = 5;
125/// Private document fragment bytes, MIME application/x-jfgui-docx-fragment.
126pub const CLIP_DOCX: u32 = 6;
127
128// ---- platform windows (window-indexed API, docs/modules/WINDOWS_PLATFORM.md)
129pub const PW_MAX: usize = 8; // index 0 = the main window
130pub const PW_DEFAULT: i32 = i32::MIN; // win_create x / y: the system (or owner-relative) default
131pub const PW_KEEP: i32 = i32::MIN; // win_set_rect: leave this field unchanged
132pub const PW_NOOWNER: i32 = -1; // win_create owner: a top-level window
133pub const PWF_TOOL: u32 = 1; // win_create flags (the same bits as the UI's WF_*)
134pub const PWF_DIALOG: u32 = 2;
135pub const PWF_MODAL: u32 = 4;
136pub const PWF_RESIZABLE: u32 = 8;
137pub const PWF_NOCLOSE: u32 = 16;
138pub const PWF_SYSFRAME: u32 = 32; // system caption / border (else the app draws the frame)
139pub const PWF_NOACTIVATE: u32 = 64;
140pub const PWF_MASK: u32 = 127;
141pub const PWS_HIDE: u32 = 0; // win_show modes
142pub const PWS_SHOW: u32 = 1;
143pub const PWS_SHOWNA: u32 = 2; // show without activating
144pub const PPW_MAX: u32 = 4; // popup slots (popup())
145// popup_anchor kinds: how a popup hangs at its anchor when the platform places it (Wayland's
146// xdg_positioner; the compositor keeps it on screen)
147pub const PA_FREE: u32 = 0; // where it is (slides to stay on screen)
148pub const PA_BELOW: u32 = 1; // below the anchor; above it when there is no room
149pub const PA_ABOVE: u32 = 2; // above the anchor; below it when there is no room
150pub const PA_SIDE: u32 = 3; // beside the anchor (submenus); on its other side when there is no room
151pub const PA_POINT: u32 = 4; // at a point (context menus): flips both ways
152
153// ---- file dialog (file_dialog flags)
154pub const FD_OPEN: u32 = 0;
155pub const FD_SAVE: u32 = 1;
156pub const FD_FOLDER: u32 = 2; // choose a folder (Android: a document tree; Windows: the own dialog)
157pub const FD_EXT_SHIFT: u32 = 8; // bits 8..15: initially selected extension (index)
158/// file_dialog's answer when the system answers later (Android's picker): file_dialog_poll
159pub const FD_PENDING: i32 = -2;
160
161// ---- UI hit-box flags the platform asks through the hit hook (HB_*)
162pub const HB_FOCUS: u32 = 1;
163pub const HB_BLOCK: u32 = 2;
164pub const HB_DRAG: u32 = 4; // window drag region (title bar)
165pub const HB_TEXT: u32 = 8; // text input
166pub const HB_MOVES: u32 = 16;
167pub const HB_DISABLED: u32 = 32;
168pub const HB_MIN: u32 = 64; // caption buttons (snap layouts, ...)
169pub const HB_MAX: u32 = 128;
170pub const HB_CLOSE: u32 = 256;
171pub const HB_CURSOR_SHIFT: u32 = 12;
172
173// ---- (L7) full screen: win_cmd commands; win_state reports WST_FULLSCREEN
174pub const WCMD_FULLSCREEN: u32 = 5; // the window covers its monitor without a frame
175pub const WCMD_WINDOWED: u32 = 6; // back to the place and frame it had before
176// below the other windows (a title bar action, TB_ACT_LOWER: X11 and Windows; Wayland has no
177// such request: nothing)
178pub const WCMD_LOWER: u32 = 7;