plat/consts.rs#
Source: lib/plat/consts.rs
consts -- the platform constants of jfgui.inc / ui.inc shared by every OS layer and the UI
[ASMLIB/inc/jfgui.inc, ui.inc]
events (Event::typ)
E_NONE: u8 = 0
E_MOVE: u8 = 1
E_DOWN: u8 = 2 // btn
E_UP: u8 = 3 // btn
E_WHEEL: u8 = 4 // data = (i16 dy) | (i16 dx << 16), 120 per notch, up / right positive; btn = WHEEL_*
E_KEY_DOWN: u8 = 5 // data = VK | (repeat << 31); (E2) x = scancode, y = key_y(KL_* location, character)
E_KEY_UP: u8 = 6 // data = VK; (E2) x = scancode, y = key_y(KL_* location, character)
E_TEXT: u8 = 7 // data = Unicode codepoint
E_RESIZE: u8 = 8 // x = width, y = height (physical pixels)
E_DPI: u8 = 9 // data = dpi (96 = 100 %)
E_FOCUS_IN: u8 = 10
E_FOCUS_OUT: u8 = 11
E_LEAVE: u8 = 12 // pointer left the window
E_CLOSE: u8 = 13 // user asked to close the window
E_WAKE: u8 = 14 // generic wake-up (timer, repaint request)
E_PAINT: u8 = 15 // the OS needs the window content again
E_WINPOS: u8 = 16 // window moved: x, y = client origin in screen px
E_DROP: u8 = 17 // files dropped: x, y = position, data = count (drop_take)
E_PREEDIT: u8 = 18 // ime_preedit(win), uncommitted text
E_IME_COMMIT: u8 = 19 // data = bounded ime_commit_take token
E_POWER: u8 = 20 // data = 1: the system goes to sleep, 0: it woke up
E_SESSION_END: u8 = 21 // the user logs off, the system shuts down, SIGTERM: save and end
E_SETTINGS: u8 = 22 // data = SET_* bits: system settings changed
E_DRAG: u8 = 23 // a drag over the window: x, y, data = DT_* | DE_* << 8 (0: it left; dnd.rs)
E_DRAG_END: u8 = 24 // our outgoing drag (drag_start) ended: data = DE_* effect, 0 = none
/// (G7a) raw relative motion of the pointer waits for win_raw_motion_take(win) while the window
/// holds the pointer lock (one event until it is taken, however much motion comes)
E_RAW_MOTION: u8 = 25
/// (G7a) the pointer lock of the window changed (win_pointer_lock_state): data 1 locked now, 0 not
E_POINTER_LOCK: u8 = 26
/// (G7a) a game pad came, went or changed (pad.rs): data = the pad's index | PADEV_* << 8; the
/// pads belong to the app (win 0); a state change is one event until plat::pads() is called
E_GAMEPAD: u8 = 27
// E_SETTINGS: what changed
SET_THEME: u32 = 1 // light / dark, accent colour
SET_LOCALE: u32 = 2 // language, regional format
SET_CONTRAST: u32 = 4 // high contrast, system colours
SET_FONTS: u32 = 8 // fonts, text scaling
SET_OTHER: u32 = 16
SET_MONITORS: u32 = 32 // monitors added, removed, moved, rescaled; work areas (screen::monitors)
EVQ_CAP: usize = 256 // event ring capacity (power of two)
E_WHEEL's btn: what kind of turn (0: a wheel's notches, 120 each)
/// the 120 per notch come in fine steps: a device without notches or with finer ones (Windows: a
/// precision touchpad's two fingers, a high-resolution wheel -- deltas that are no multiple of
/// 120; Wayland: axis_value120 of such a wheel)
WHEEL_FINE: u8 = 1
/// data holds physical pixels of the window (the same i16 dy | i16 dx << 16, up / right
/// positive) from a device that scrolls by pixels: Wayland's fingers and continuous axes, the
/// trackpad and Magic Mouse on macOS
WHEEL_PIXELS: u8 = 2
pointer types, buttons, modifiers
PTR_MOUSE: u32 = 0
PTR_PEN: u32 = 1 // pen tip
PTR_ERASER: u32 = 2 // eraser end of a pen
PTR_TOUCH: u32 = 3
BTN_LEFT: u8 = 1
BTN_RIGHT: u8 = 2
BTN_MIDDLE: u8 = 3
BTN_X1: u8 = 4
BTN_X2: u8 = 5
MOD_SHIFT: u8 = 1
MOD_CTRL: u8 = 2
MOD_ALT: u8 = 4
MOD_SUPER: u8 = 8
MOD_ALTGR: u8 = 16
MOD_CAPS: u8 = 32
MOD_NUM: u8 = 64
(E2) where a key sits (key_location of Event::y of E_KEY_DOWN / E_KEY_UP; Event::x is its scancode:
// Windows' scan code (0xE0.. for extended keys), Linux's evdev code, (G7a) the USB HID usage on macOS,
// iOS and in the browser, 0 where unknown; keycode.rs key_code turns it into the same KC_* everywhere)
KL_STANDARD: u32 = 0
KL_LEFT: u32 = 1 // the left Shift, Ctrl, Alt, Windows key
KL_RIGHT: u32 = 2
KL_NUMPAD: u32 = 3 // the keys of the number block
(E2) the character of a key: Event::y of E_KEY_DOWN / E_KEY_UP holds the KL_* location in
// bits 0..7, the character the keyboard layout gives the key in bits 8..28 (key_char) and
// KEY_DEAD. The character is the one the key types with Shift, Caps Lock and AltGr as they are
// but without Ctrl, Alt and the Windows / Super key -- what a browser names the key: "z" for
// Ctrl+Z on a German keyboard (whose Z sits at the US layout's Y), "+" for Ctrl++ there, "@" for
// AltGr+Q; 0 for a key that types nothing (Enter, Tab, Esc, Backspace, the arrows, F1 ...: control
// characters are none) and where the platform does not say (the browser, Android, iOS)
/// the key is a dead key; key_char is its spacing character (´ ^ ~ ...)
KEY_DEAD: i32 = 1 << 29
const fn key_y(location: u32, ch: u32, dead: bool) -> i32(E2) Event::y of a key event: its KL_* location and character (0: none)const fn key_location(y: i32) -> u32(E2) the KL_* location of a key event's yconst fn key_char(y: i32) -> u32(E2) the character of a key event's y (0: none)const fn key_dead(y: i32) -> bool(E2) a key event's y says a dead keyconst fn evdev_location(code: u32) -> u32(E2) the KL_* location of a Linux evdev key code (both sides' modifiers, the number block)
cursors (CUR_*: system shapes; CUR_USER0.. custom cursors of cursor_create)
CUR_ARROW: u32 = 0
CUR_IBEAM: u32 = 1
CUR_HAND: u32 = 2
CUR_CROSS: u32 = 3
CUR_MOVE: u32 = 4
CUR_WAIT: u32 = 5
CUR_SIZE_NS: u32 = 6
CUR_SIZE_WE: u32 = 7
CUR_SIZE_NWSE: u32 = 8
CUR_SIZE_NESW: u32 = 9
CUR_NONE: u32 = 10
CUR_COUNT: u32 = 11
CUR_CUSTOM: u32 = 15 // hit boxes only: the cursor chosen with the UI's custom call
CUR_USER0: u32 = 16
CUR_USER_MAX: u32 = 32
CUR_TABLE: u32 = CUR_USER0 + CUR_USER_MAX
CUR_MAX_PX: i32 = 256 // cursor_create: largest width / height
(E3) more system shapes: CSS's cursor names, past the custom cursors (CUR_X0 ..
// CUR_X_END); a platform without one shows cursor_fallback's
CUR_X0: u32 = 64
CUR_NOT_ALLOWED: u32 = 64 // not-allowed
CUR_NO_DROP: u32 = 65 // no-drop
CUR_GRAB: u32 = 66 // grab: an open hand
CUR_GRABBING: u32 = 67 // grabbing: a closed hand
CUR_HELP: u32 = 68 // help: the arrow with a question mark
CUR_PROGRESS: u32 = 69 // progress: the arrow with a busy sign (work in the background)
CUR_ZOOM_IN: u32 = 70 // zoom-in
CUR_ZOOM_OUT: u32 = 71 // zoom-out
CUR_CELL: u32 = 72 // cell: a thick cross (tables)
CUR_VTEXT: u32 = 73 // vertical-text
CUR_ALIAS: u32 = 74 // alias: a link will be made
CUR_COPY: u32 = 75 // copy: a copy will be made
CUR_CONTEXT_MENU: u32 = 76 // context-menu
CUR_ALL_SCROLL: u32 = 77 // all-scroll
CUR_COL_RESIZE: u32 = 78 // col-resize
CUR_ROW_RESIZE: u32 = 79 // row-resize
CUR_SIZE_N: u32 = 80 // n-resize: one edge or corner
CUR_SIZE_S: u32 = 81
CUR_SIZE_E: u32 = 82
CUR_SIZE_W: u32 = 83
CUR_SIZE_NE: u32 = 84
CUR_SIZE_NW: u32 = 85
CUR_SIZE_SE: u32 = 86
CUR_SIZE_SW: u32 = 87
CUR_X_END: u32 = 88
const fn cursor_fallback(shape: u32) -> u32(E3) the nearest of the first shapes (CUR_ARROW .. CUR_NONE) to a shape of CUR_X0 .. CUR_X_END, for the platforms and cursor themes without it; other shapes unchanged
window edges, commands, states
EDGE_TOP: u32 = 1
EDGE_BOTTOM: u32 = 2
EDGE_LEFT: u32 = 4
EDGE_RIGHT: u32 = 8
WCMD_MINIMIZE: u32 = 1
WCMD_MAXIMIZE: u32 = 2
WCMD_RESTORE: u32 = 3
WCMD_CLOSE: u32 = 4
WST_MAXIMIZED: u32 = 1
WST_FULLSCREEN: u32 = 2
WST_ACTIVE: u32 = 4 // one of the APP's windows is active
WST_TILED: u32 = 8
WST_MINIMIZED: u32 = 16
WST_CSD: u32 = 32 // no system frame: the app must draw its own title bar
/// the window is drawn inside its owner (a Wayland subsurface): win_get_rect / win_set_rect /
/// E_WINPOS use positions relative to the owner's surface origin (px), the owner carries it
WST_CHILD: u32 = 64
/// with WST_TILED: which edges touch the tiling (EDGE_* << WST_TILED_SHIFT; Wayland's
/// xdg_toplevel tiled_* states, X11 the edges of a one-direction maximize); the UI keeps its
/// resize band off them, as from a maximized window
WST_TILED_SHIFT: u32 = 7
WST_TILED_TOP: u32 = EDGE_TOP << WST_TILED_SHIFT
WST_TILED_BOTTOM: u32 = EDGE_BOTTOM << WST_TILED_SHIFT
WST_TILED_LEFT: u32 = EDGE_LEFT << WST_TILED_SHIFT
WST_TILED_RIGHT: u32 = EDGE_RIGHT << WST_TILED_SHIFT
/// (Windows) the window is not shown, whoever hid it: the system hides a tool window while its owner
/// is minimised
WST_HIDDEN: u32 = 1 << 11
// gpu_out_state: how the UI's output through the GPU came up
/// nothing known, nothing to remember
GPU_STATE_UNKNOWN: u32 = 2
/// the first start is about to run a driver
GPU_STATE_TRYING: u32 = 3
/// a window showed through the GPU
GPU_STATE_OK: u32 = 4
/// this system cannot: the CPU path for good
GPU_STATE_NEVER: u32 = 5
clipboard formats
CLIP_TEXT: u32 = 1 // UTF-8
CLIP_PNG: u32 = 2 // PNG file bytes
CLIP_IMAGE: u32 = 3 // get: image file bytes (PNG, or DIB as BMP); set: PNG + DIB
/// UTF-8 HTML fragment (Windows CF_HTML framing is handled by the platform).
CLIP_HTML: u32 = 4
/// Rich Text Format document bytes.
CLIP_RTF: u32 = 5
/// Private document fragment bytes, MIME application/x-jfgui-docx-fragment.
CLIP_DOCX: u32 = 6
platform windows (window-indexed API, docs/modules/WINDOWS_PLATFORM.md)
PW_MAX: usize = 8 // index 0 = the main window
PW_DEFAULT: i32 = i32::MIN // win_create x / y: the system (or owner-relative) default
PW_KEEP: i32 = i32::MIN // win_set_rect: leave this field unchanged
PW_NOOWNER: i32 = -1 // win_create owner: a top-level window
PWF_TOOL: u32 = 1 // win_create flags (the same bits as the UI's WF_*)
PWF_DIALOG: u32 = 2
PWF_MODAL: u32 = 4
PWF_RESIZABLE: u32 = 8
PWF_NOCLOSE: u32 = 16
PWF_SYSFRAME: u32 = 32 // system caption / border (else the app draws the frame)
PWF_NOACTIVATE: u32 = 64
PWF_MASK: u32 = 127
PWS_HIDE: u32 = 0 // win_show modes
PWS_SHOW: u32 = 1
PWS_SHOWNA: u32 = 2 // show without activating
PPW_MAX: u32 = 4 // popup slots (popup())
// popup_anchor kinds: how a popup hangs at its anchor when the platform places it (Wayland's
// xdg_positioner; the compositor keeps it on screen)
PA_FREE: u32 = 0 // where it is (slides to stay on screen)
PA_BELOW: u32 = 1 // below the anchor; above it when there is no room
PA_ABOVE: u32 = 2 // above the anchor; below it when there is no room
PA_SIDE: u32 = 3 // beside the anchor (submenus); on its other side when there is no room
PA_POINT: u32 = 4 // at a point (context menus): flips both ways
file dialog (file_dialog flags)
FD_OPEN: u32 = 0
FD_SAVE: u32 = 1
FD_FOLDER: u32 = 2 // choose a folder (Android: a document tree; Windows: the own dialog)
FD_MULTI: u32 = 4 // (E8) FD_OPEN: several files; all of them in file_dialog_paths()
FD_EXT_SHIFT: u32 = 8 // bits 8..15: initially selected extension (index)
/// file_dialog's answer when the system answers later (Android's picker): file_dialog_poll
FD_PENDING: i32 = -2
UI hit-box flags the platform asks through the hit hook (HB_*)
HB_FOCUS: u32 = 1
HB_BLOCK: u32 = 2
HB_DRAG: u32 = 4 // window drag region (title bar)
HB_TEXT: u32 = 8 // text input
HB_MOVES: u32 = 16
HB_DISABLED: u32 = 32
HB_MIN: u32 = 64 // caption buttons (snap layouts, ...)
HB_MAX: u32 = 128
HB_CLOSE: u32 = 256
HB_CURSOR_SHIFT: u32 = 12
(L7) full screen: win_cmd commands; win_state reports WST_FULLSCREEN
WCMD_FULLSCREEN: u32 = 5 // the window covers its monitor without a frame
WCMD_WINDOWED: u32 = 6 // back to the place and frame it had before
// below the other windows (a title bar action, TB_ACT_LOWER: X11 and Windows; Wayland has no
// such request: nothing)
WCMD_LOWER: u32 = 7