Skip to main content

euv_core/window/config/
struct.rs

1use super::*;
2
3/// Unique handle identifying an OS or web window managed by a platform backend.
4#[derive(Clone, Copy, Debug, Default, Eq, Getter, Hash, New, Ord, PartialEq, PartialOrd)]
5pub struct WindowId {
6    /// Monotonic numeric window identifier.
7    #[get(type(copy))]
8    pub(crate) value: u64,
9}
10
11/// Safe-area insets in logical pixels (iOS notch/Dynamic Island, iPadOS Stage Manager, Android cutouts, Web immersive).
12#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
13pub struct SafeAreaInsets {
14    /// Top safe inset (status bar / notch / Dynamic Island).
15    #[get(type(copy))]
16    pub(crate) top: f32,
17    /// Right safe inset (landscape camera cutout / gesture bar).
18    #[get(type(copy))]
19    pub(crate) right: f32,
20    /// Bottom safe inset (home indicator / gesture pill).
21    #[get(type(copy))]
22    pub(crate) bottom: f32,
23    /// Left safe inset (landscape cutout).
24    #[get(type(copy))]
25    pub(crate) left: f32,
26}
27
28/// Physical monitor or mobile screen metadata.
29#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
30pub struct DisplayInfo {
31    /// Physical screen width in pixels.
32    #[get(type(copy))]
33    pub(crate) physical_width: u32,
34    /// Physical screen height in pixels.
35    #[get(type(copy))]
36    pub(crate) physical_height: u32,
37    /// Scale factor mapping logical pixels to physical pixels (DPI / HiDPI).
38    #[get(type(copy))]
39    pub(crate) scale_factor: f32,
40    /// Nominal refresh rate in hertz.
41    #[get(type(copy))]
42    pub(crate) refresh_rate_hz: u32,
43    /// Active display color gamut.
44    #[get(type(copy))]
45    pub(crate) color_space: ColorSpace,
46}
47
48/// Unified declarative window creation settings normalized across desktop, mobile, tablet, and web.
49#[derive(Clone, Data, Debug, PartialEq)]
50pub struct WindowConfig {
51    /// Window or browser document title.
52    pub(crate) title: String,
53    /// Initial logical width in pixels.
54    #[get(type(copy))]
55    pub(crate) width: u32,
56    /// Initial logical height in pixels.
57    #[get(type(copy))]
58    pub(crate) height: u32,
59    /// Optional minimum logical `(width, height)`.
60    #[get(skip)]
61    pub(crate) min_size: Option<(u32, u32)>,
62    /// Optional maximum logical `(width, height)`.
63    #[get(skip)]
64    pub(crate) max_size: Option<(u32, u32)>,
65    /// Optional initial screen `(x, y)` position on desktop platforms.
66    #[get(skip)]
67    pub(crate) position: Option<(i32, i32)>,
68    /// Whether the user can resize the window.
69    #[get(type(copy))]
70    pub(crate) resizable: bool,
71    /// Whether OS window decorations (title bar / borders) are shown.
72    #[get(type(copy))]
73    pub(crate) decorations: bool,
74    /// Whether transparent framebuffer compositing is requested.
75    #[get(type(copy))]
76    pub(crate) transparent: bool,
77    /// Whether the window floats above standard windows.
78    #[get(type(copy))]
79    pub(crate) always_on_top: bool,
80    /// Fullscreen / edge-to-edge presentation mode.
81    #[get(type(copy))]
82    pub(crate) fullscreen: FullscreenMode,
83    /// Whether mobile/web edge-to-edge immersive safe-area mode is active.
84    #[get(type(copy))]
85    pub(crate) immersive: bool,
86    /// Whether window is initially visible.
87    #[get(type(copy))]
88    pub(crate) visible: bool,
89    /// Requested rendering pipeline configuration.
90    #[get(type(copy))]
91    pub(crate) render: RenderConfig,
92    /// Mobile / tablet orientation lock policy.
93    #[get(type(copy))]
94    pub(crate) orientation: OrientationLock,
95    /// Mobile / iPadOS status bar appearance.
96    #[get(type(copy))]
97    pub(crate) status_bar: StatusBarStyle,
98    /// Preferred initial theme mode override.
99    #[get(skip)]
100    pub(crate) preferred_theme: Option<ThemeMode>,
101    /// Optional decoded RGBA8 application/window icon bitmap for native chrome and mobile bundles.
102    #[get(skip)]
103    pub(crate) icon: Option<ImageBuffer>,
104    /// Optional path to a PNG/SVG application icon asset consumed by desktop/iOS/Android packagers.
105    #[get(skip)]
106    pub(crate) icon_path: Option<String>,
107}
108
109/// Live runtime metrics and state of an active window.
110#[derive(Clone, Copy, Data, Debug, PartialEq)]
111pub struct WindowState {
112    /// Window handle.
113    #[get(type(copy))]
114    pub(crate) id: WindowId,
115    /// Current logical width in pixels.
116    #[get(type(copy))]
117    pub(crate) logical_width: f32,
118    /// Current logical height in pixels.
119    #[get(type(copy))]
120    pub(crate) logical_height: f32,
121    /// Current physical framebuffer width in pixels.
122    #[get(type(copy))]
123    pub(crate) physical_width: u32,
124    /// Current physical framebuffer height in pixels.
125    #[get(type(copy))]
126    pub(crate) physical_height: u32,
127    /// Current DPI scale factor.
128    #[get(type(copy))]
129    pub(crate) scale_factor: f32,
130    /// Current safe-area insets in logical pixels.
131    #[get(type(copy))]
132    pub(crate) safe_area: SafeAreaInsets,
133    /// Active display metadata.
134    #[get(type(copy))]
135    pub(crate) display: DisplayInfo,
136    /// Whether window currently has OS input focus.
137    #[get(type(copy))]
138    pub(crate) focused: bool,
139    /// Whether window is minimized or backgrounded.
140    #[get(type(copy))]
141    pub(crate) minimized: bool,
142    /// Whether window is maximized.
143    #[get(type(copy))]
144    pub(crate) maximized: bool,
145    /// Active fullscreen mode.
146    #[get(type(copy))]
147    pub(crate) fullscreen: FullscreenMode,
148    /// Active OS dark/light appearance.
149    #[get(type(copy))]
150    pub(crate) system_theme: ThemeMode,
151}