ailloli_ui_runtime/input/
chrome.rs

1//! Platform-window chrome actions produced by input routing.
2
3/// Edge or corner used for an interactive native-window resize.
4///
5/// The compass directions are logical screen directions; they do not change in
6/// right-to-left interfaces.
7///
8/// # Examples
9///
10/// ```
11/// use ailloli_ui_runtime::input::ResizeEdge;
12/// assert_ne!(ResizeEdge::N, ResizeEdge::SE);
13/// ```
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
15pub enum ResizeEdge {
16    /// North/top edge.
17    N,
18    /// South/bottom edge.
19    S,
20    /// East/right edge.
21    E,
22    /// West/left edge.
23    W,
24    /// North-east/top-right corner.
25    NE,
26    /// North-west/top-left corner.
27    NW,
28    /// South-east/bottom-right corner.
29    SE,
30    /// South-west/bottom-left corner.
31    SW,
32}
33
34/// Cursor role requested from a native window backend.
35///
36/// # Examples
37///
38/// ```
39/// use ailloli_ui_runtime::input::{CursorStyle, ResizeEdge};
40/// assert_eq!(CursorStyle::Resize(ResizeEdge::E), CursorStyle::Resize(ResizeEdge::E));
41/// ```
42#[derive(Debug, Clone, Copy, PartialEq, Eq)]
43pub enum CursorStyle {
44    /// Backend default pointer cursor.
45    Default,
46    /// Resize cursor corresponding to one edge or corner.
47    Resize(ResizeEdge),
48}
49
50/// Native-window chrome operation requested by a routed UI event.
51///
52/// Values are host intents only. The runtime does not move, resize, or mutate a
53/// platform window until an adapter consumes the action.
54///
55/// # Examples
56///
57/// ```
58/// use ailloli_ui_runtime::input::{ChromeAction, ResizeEdge};
59/// let action = ChromeAction::StartWindowResize { edge: ResizeEdge::SW };
60/// assert_eq!(action, ChromeAction::StartWindowResize { edge: ResizeEdge::SW });
61/// ```
62#[derive(Debug, Clone, PartialEq, Eq)]
63pub enum ChromeAction {
64    /// Begin an operating-system window drag using the initiating pointer event.
65    StartWindowDrag,
66    /// Begin interactive native resize from `edge`.
67    StartWindowResize {
68        /// Native window edge or corner that follows the pointer.
69        edge: ResizeEdge,
70    },
71    /// Change the native cursor until another request supersedes it.
72    SetCursor {
73        /// Cursor role the native host should display.
74        cursor: CursorStyle,
75    },
76}