freya_core/
event_loop_messages.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use cursor_icon::CursorIcon;
use torin::prelude::{
    Area,
    CursorPoint,
};
#[cfg(feature = "winit")]
use winit::window::Window;
use winit::window::WindowId;

#[cfg(feature = "winit")]
use crate::window_config;
use crate::{
    accessibility::AccessibilityFocusStrategy,
    events::PlatformEvent,
};

pub struct TextGroupMeasurement {
    pub text_id: usize,
    pub cursor_id: usize,
    pub cursor_position: Option<CursorPoint>,
    pub cursor_selection: Option<(CursorPoint, CursorPoint)>,
}

pub enum EventLoopMessageAction {
    /// Poll the VirtualDOM
    PollVDOM,
    /// Request a rerender
    RequestRerender,
    /// Request a full rerender
    RequestFullRerender,
    /// Invalidate a certain drawing area
    InvalidateArea(Area),
    /// Remeasure a text elements group
    RemeasureTextGroup(TextGroupMeasurement),
    /// Change the cursor icon
    SetCursorIcon(CursorIcon),
    /// Focus with the given strategy
    FocusAccessibilityNode(AccessibilityFocusStrategy),
    /// Close the window
    CloseWindow,
    /// Raw platform event, this are low level events.
    PlatformEvent(PlatformEvent),
    /// Accessibility Window Event
    #[cfg(feature = "winit")]
    Accessibility(accesskit_winit::WindowEvent),
    /// Callback to access the Window.
    #[cfg(feature = "winit")]
    WithWindow(Box<dyn FnOnce(&Window) + Send + Sync>),
    /// Create a new Window.
    #[cfg(feature = "winit")]
    NewWindow(window_config::WindowConfig),
}

/// Message for Freya's event loop
pub struct EventLoopMessage {
    pub window_id: Option<WindowId>,
    pub action: EventLoopMessageAction,
}