Skip to main content

argui_platform/
event.rs

1#[derive(Clone, Copy, Debug, Eq, PartialEq)]
2pub enum ButtonState {
3    Pressed,
4    Released,
5}
6
7#[derive(Clone, Debug, PartialEq)]
8pub enum PlatformEvent {
9    Opened {
10        width: u32,
11        height: u32,
12        scale_factor: f64,
13        capabilities: crate::WindowCapabilities,
14    },
15    Suspended,
16    VisibilityChanged(bool),
17    Closed,
18    Resized {
19        width: u32,
20        height: u32,
21    },
22    ScaleFactorChanged(f64),
23    SafeAreaChanged(crate::Insets),
24    PreferencesChanged(crate::SystemPreferences),
25    Pointer(PointerEvent),
26    PointerScrolled(ScrollDelta),
27    Keyboard(KeyInput),
28    Ime(ImeInput),
29    Focused(bool),
30    RedrawRequested,
31    CloseRequested,
32    WindowCreationFailed(String),
33}
34
35impl PlatformEvent {
36    #[must_use]
37    pub const fn requires_redraw(&self) -> bool {
38        matches!(
39            self,
40            Self::Opened { .. }
41                | Self::Resized { .. }
42                | Self::ScaleFactorChanged(_)
43                | Self::SafeAreaChanged(_)
44                | Self::Focused(true)
45                | Self::VisibilityChanged(true)
46        )
47    }
48
49    #[must_use]
50    pub const fn closes_window(&self) -> bool {
51        matches!(self, Self::CloseRequested | Self::WindowCreationFailed(_))
52    }
53}
54pub use argui_core::{ImeInput, Key, KeyInput, KeyState, Modifiers, PointerEvent, ScrollDelta};