Skip to main content

euv_core/app/runner/
struct.rs

1use super::*;
2
3/// Top-level cross-platform application configuration.
4#[derive(Clone, Data, Debug, PartialEq)]
5pub struct AppConfig {
6    /// Primary window creation settings.
7    pub(crate) window: WindowConfig,
8    /// Clear background color drawn beneath the root scene node.
9    #[get(type(copy))]
10    pub(crate) clear_color: Color,
11}
12
13/// Unified cross-platform application runtime orchestrating platform events, reactivity, layout, and rendering.
14#[derive(CustomDebug, Data)]
15pub struct App {
16    /// Application configuration.
17    pub(crate) config: AppConfig,
18    /// Active direct OS or headless platform backend.
19    #[debug(skip)]
20    #[get(skip)]
21    pub(crate) platform: Box<dyn PlatformBackend>,
22    /// Primary window live state.
23    #[get(type(copy))]
24    pub(crate) window_state: WindowState,
25    /// Shared scene tree handle.
26    pub(crate) scene: SceneHandle,
27    /// Framework context carrying reactive breakpoint, theme, gesture, and safe-area signals.
28    pub(crate) context: Context,
29    /// Deterministic cross-platform layout engine.
30    #[get(type(copy))]
31    pub(crate) layout_engine: LayoutEngine,
32    /// Multi-mode rendering pipeline (`Auto`, `Software`, `Hardware`, `Hybrid`).
33    pub(crate) renderer: Renderer,
34    /// Queued imperative window commands awaiting dispatch.
35    pub(crate) command_queue: WindowCommandQueue,
36    /// Local key-value storage service.
37    pub(crate) storage: StorageStore,
38    /// Flag indicating whether the application loop should keep running.
39    #[get(type(copy))]
40    pub(crate) running: bool,
41    /// Pending damage region for the next rendered frame.
42    #[get(type(copy))]
43    pub(crate) pending_damage: DamageRegion,
44    /// Real-time polled keyboard, pointer, and scroll state for game loops and interactive viewports.
45    pub(crate) input_state: InputState,
46    /// Fixed-timestep accumulator and FPS telemetry clock for real-time game rendering.
47    #[get(type(copy))]
48    pub(crate) frame_clock: FrameClock,
49    /// Platform-native services hub (permissions, protocol registration, Dynamic Island, haptics, tray, A11y).
50    pub(crate) services: PlatformServiceHub,
51    /// Reactive signal carrying the most recently received custom-scheme or universal deep link.
52    #[get(type(copy))]
53    pub(crate) deep_link: Signal<Option<DeepLinkEvent>>,
54    /// Shared dynamic update hub for live component-level and page-level OTA updates.
55    pub(crate) dynamic_hub: DynamicUpdateHub,
56    /// Last scene revision that was rasterized and presented, enabling zero-cost idle frame skipping.
57    #[get(type(copy))]
58    pub(crate) last_rendered_revision: u64,
59    /// Most recently submitted OS/Web cursor icon to avoid redundant platform cursor calls.
60    #[get(type(copy))]
61    pub(crate) last_cursor: CursorIcon,
62    /// Attached real-time game engine hosts receiving automatic OS input forwarding.
63    #[debug(skip)]
64    pub(crate) game_hosts: Vec<GameEngineHost>,
65    /// Active touch pointer identifier currently driving single-finger pan scrolling.
66    #[get(skip)]
67    pub(crate) touch_drag_pointer_id: Option<u64>,
68    /// Starting touch coordinate for mobile pan-to-scroll detection.
69    #[get(skip)]
70    pub(crate) touch_drag_origin: Option<Point>,
71    /// Previous touch coordinate for incremental mobile scroll deltas.
72    #[get(skip)]
73    pub(crate) touch_drag_last: Option<Point>,
74    /// Whether the active touch gesture has crossed tap slop into pan-scrolling.
75    #[get(type(copy))]
76    pub(crate) touch_dragging: bool,
77    /// Cumulative post-slop drag displacement in logical pixels for the active touch scroll gesture.
78    #[get(type(copy))]
79    pub(crate) touch_drag_travel: f32,
80    /// Locked scroll axis for the active touch drag (`0` = unlocked, `1` = vertical, `2` = horizontal, `3` = free).
81    #[get(type(copy))]
82    pub(crate) touch_scroll_axis: u8,
83    /// Touch pan displacement accumulated during the current frame for jitter-free velocity estimation.
84    #[get(type(copy))]
85    pub(crate) touch_vel_accum_delta: Point,
86    /// Rolling window of recent `(dt_secs, dx, dy)` frame samples preventing thumb-lift backward fling reversals.
87    pub(crate) touch_vel_samples: Vec<(f32, f32, f32)>,
88    /// Elapsed idle seconds since the last touch pan movement while a finger remains held down.
89    #[get(type(copy))]
90    pub(crate) touch_vel_idle_secs: f32,
91    /// Whether the active pointer press grabbed a right-edge scrollbar track for thumb dragging.
92    #[get(type(copy))]
93    pub(crate) scrollbar_dragging: bool,
94    /// Active multi-touch / pointer contact map keyed by `pointer_id` for pinch & swipe recognition.
95    pub(crate) active_pointers: HashMap<u64, Point>,
96    /// Device kind recorded per active `pointer_id` for deterministic touch vs mouse separation.
97    pub(crate) active_pointer_devices: HashMap<u64, PointerDevice>,
98    /// Initial contact point of the active single-pointer gesture stroke.
99    #[get(skip)]
100    pub(crate) gesture_origin: Option<Point>,
101    /// Baseline two-finger distance recorded when a pinch gesture starts.
102    #[get(type(copy))]
103    pub(crate) pinch_base_dist: f32,
104    /// Accumulated hold duration in seconds for long-press gesture detection.
105    #[get(type(copy))]
106    pub(crate) gesture_hold_secs: f32,
107    /// Whether `GestureEventKind::LongPress` has already fired for the current press.
108    #[get(type(copy))]
109    pub(crate) long_press_fired: bool,
110    /// Coordinates of the most recent completed clean tap for double-tap detection.
111    #[get(skip)]
112    pub(crate) last_tap_pos: Option<Point>,
113    /// Elapsed seconds since the most recent completed clean tap.
114    #[get(type(copy))]
115    pub(crate) last_tap_age_secs: f32,
116    /// Monotonic gesture event sequence counter.
117    #[get(type(copy))]
118    pub(crate) gesture_seq: u64,
119    /// Inertial touch-scroll fling velocity in logical pixels per second.
120    #[get(type(copy))]
121    pub(crate) scroll_velocity: Point,
122    /// Pointer coordinates where inertial touch-scroll fling originated for hit-target resolution.
123    #[get(type(copy))]
124    pub(crate) scroll_fling_pos: Point,
125    /// Locked innermost scrollable node captured at touch-down to prevent nested scroll penetration.
126    #[get(skip)]
127    pub(crate) touch_scroll_target: Option<NodeId>,
128    /// Remaining smooth-scroll interpolation delta for discrete mouse-wheel notches.
129    #[get(type(copy))]
130    pub(crate) smooth_scroll_pending: Point,
131    /// Pointer coordinates captured when smooth wheel scrolling started.
132    #[get(type(copy))]
133    pub(crate) smooth_scroll_pos: Point,
134    /// Locked scroll container target for active smooth wheel interpolation.
135    #[get(skip)]
136    pub(crate) smooth_scroll_target: Option<NodeId>,
137    /// Re-entrancy guard preventing nested `step_frame` execution during macOS live-resize callbacks.
138    #[get(type(copy))]
139    pub(crate) in_step_frame: bool,
140    /// Accumulated blink phase timer in seconds for the focused `NodeKind::Input` caret.
141    #[get(type(copy))]
142    pub(crate) caret_blink_secs: f32,
143    /// When `true`, global swipe gestures are suppressed because the active stroke started in a canvas, slider, or isolated region.
144    #[get(type(copy))]
145    pub(crate) gesture_suppressed: bool,
146    /// Elapsed seconds accumulated for smoothed live FPS telemetry publication.
147    #[get(type(copy))]
148    pub(crate) fps_accum_secs: f32,
149    /// Rendered frame count accumulated inside the current FPS sampling window.
150    #[get(type(copy))]
151    pub(crate) fps_accum_frames: u32,
152    /// Accumulated frame time in seconds used to pace frames when an explicit FPS cap is configured.
153    #[get(type(copy))]
154    pub(crate) fps_budget_accum: f32,
155    /// Whether an editable `NodeKind::Input` currently holds focus and requests the system IME keyboard.
156    #[get(type(copy))]
157    pub(crate) last_ime_active: bool,
158    /// Handle of the `NodeKind::Input` that most recently activated the system IME keyboard.
159    #[get(skip)]
160    pub(crate) last_ime_node: Option<NodeId>,
161    /// Damage region rasterized during the most recent rendered frame for partial native surface presentation.
162    #[get(type(copy))]
163    pub(crate) last_frame_damage: DamageRegion,
164}