pub struct ReposeRuntime {Show 24 fields
pub sched: Scheduler,
pub scale: f32,
pub overlay: OverlayHandle,
pub dnd_context: DndContext,
pub modifiers: Modifiers,
pub mouse_pos_px: (f32, f32),
pub pointer_inside: bool,
pub hover_id: Option<u64>,
pub hover_ancestors: HashSet<u64>,
pub capture_id: Option<u64>,
pub hit_path: Option<Vec<u64>>,
pub touch_paths: HashMap<u64, Vec<u64>>,
pub scroll_capture_id: Option<u64>,
pub pressed_ids: HashSet<u64>,
pub ime_preedit: bool,
pub key_pressed_active: Option<u64>,
pub last_focus: Option<u64>,
pub held_keys: HashSet<String>,
pub held_mouse: HashSet<PointerButton>,
pub frame_cache: Option<Rc<Frame>>,
pub shortcuts: ShortcutState,
pub textfield_states: HashMap<u64, Rc<RefCell<TextFieldState>>>,
pub gamepads: HashMap<u32, GamepadPad>,
pub pending_rumble: Vec<(u32, f32, f32, u32)>,
/* private fields */
}Expand description
Embeddable Repose runtime.
Manages composition scheduling, input routing, text-field state, and pointer/key dispatch. The host owns the event loop and GPU device. This is purely the UI logic layer.
Fields§
§sched: Scheduler§scale: f32§overlay: OverlayHandleAmbient host layer for floating surfaces. Installed around composition each frame; entries render at the root.
dnd_context: DndContext§modifiers: Modifiers§mouse_pos_px: (f32, f32)§pointer_inside: boolWhether the pointer is currently inside the window.
hover_id: Option<u64>§hover_ancestors: HashSet<u64>§capture_id: Option<u64>§hit_path: Option<Vec<u64>>Hit path captured at pointer-down: every region under the pointer, ordered bottom-up (deepest child first, ancestors last).
touch_paths: HashMap<u64, Vec<u64>>Per-finger press table: every concurrent touch owns its own
hit path (unlike the single mouse hit_path/capture_id,
which is the single-primary tap emulation’s). Game viewports
stage per-finger contacts off the dispatched events, so the
second finger’s joystick/button press stages alongside the
first instead of stealing its path. UI press arbitration
(tap/click/scroll) stays single-primary in touch_gesture;
this only routes the per-finger event stream.
scroll_capture_id: Option<u64>Which scroll consumer currently owns the wheel gesture.
pressed_ids: HashSet<u64>§ime_preedit: bool§key_pressed_active: Option<u64>§last_focus: Option<u64>§held_keys: HashSet<String>Polled physical-key state, keyed by debug name (KeyCode::KeyW,
Digit1, …). Platform runners report every KeyboardInput
press/release here so games can poll held keys GML-style
(keyboard_check) instead of reconstructing them from
focus-routed key events, which miss keys when focus moves or
a key-up is swallowed (alt-tab, overlay, layout).
Cleared on window focus loss.
held_mouse: HashSet<PointerButton>Polled mouse-button state. handle_pointer_press/release
maintain this for Primary/Secondary/Tertiary so games can read
held buttons (mouse_check_button) without tracking
press/release edges themselves.
frame_cache: Option<Rc<Frame>>§shortcuts: ShortcutState§textfield_states: HashMap<u64, Rc<RefCell<TextFieldState>>>§gamepads: HashMap<u32, GamepadPad>Connected gamepads by backend id: display name plus live button/axis
state. Fed by ReposeRuntime::handle_gamepad.
pending_rumble: Vec<(u32, f32, f32, u32)>Queued dual-motor rumble requests.
Implementations§
Source§impl ReposeRuntime
impl ReposeRuntime
pub fn new() -> Self
Sourcepub fn with_overlay(overlay: OverlayHandle) -> Self
pub fn with_overlay(overlay: OverlayHandle) -> Self
Create a runtime sharing overlay as the ambient host layer.
Entries posted through this handle render at the root; per-frame
show_guard state can still target other handles as an escape hatch.
pub fn event_dispatchers(&self) -> RuntimeDispatchers
pub fn set_lifecycle_callback( &mut self, callback: Box<dyn Fn(AppLifecycle) + Send>, )
pub fn add_lifecycle_listener( &mut self, callback: Box<dyn Fn(AppLifecycle) + Send>, ) -> u64
pub fn remove_lifecycle_listener(&mut self, id: u64) -> bool
pub fn current_lifecycle(&self) -> Option<AppLifecycle>
pub fn push_lifecycle(&mut self, state: AppLifecycle)
pub fn process_lifecycle(&mut self)
pub fn set_deeplink_callback(&mut self, callback: Box<dyn Fn(Vec<u8>) + Send>)
pub fn add_deeplink_listener( &mut self, callback: Box<dyn Fn(Vec<u8>) + Send>, ) -> u64
pub fn remove_deeplink_listener(&mut self, id: u64) -> bool
pub fn push_deeplink(&mut self, data: Vec<u8>)
pub fn process_deeplinks(&mut self)
Sourcepub fn set_viewport(&mut self, width_px: u32, height_px: u32)
pub fn set_viewport(&mut self, width_px: u32, height_px: u32)
Set the logical viewport size (in device pixels).
Sourcepub fn set_viewport_and_scale(
&mut self,
width_px: u32,
height_px: u32,
scale: f32,
)
pub fn set_viewport_and_scale( &mut self, width_px: u32, height_px: u32, scale: f32, )
Set viewport size and DPI scale factor.
Sourcepub fn tick_animations(&self)
pub fn tick_animations(&self)
Advance animations. Call before compose each frame.
pub fn poll_gesture_timers(&mut self)
Sourcepub fn compose<F>(
&mut self,
root_fn: &mut F,
render_ctx: &RenderContext,
) -> Frame
pub fn compose<F>( &mut self, root_fn: &mut F, render_ctx: &RenderContext, ) -> Frame
Compose and layout a frame, returning the output for rendering.
Call tick_animations before this and cache_frame after (once you
have applied any host-specific overlays like the devtools inspector).
Sourcepub fn frame(
&mut self,
root_fn: impl FnMut(&mut Scheduler, &RenderContext) -> View,
render_ctx: &RenderContext,
) -> FrameOutput
pub fn frame( &mut self, root_fn: impl FnMut(&mut Scheduler, &RenderContext) -> View, render_ctx: &RenderContext, ) -> FrameOutput
Compose a frame and return structured output for the host.
Sourcepub fn cache_frame(&mut self, frame: impl Into<Rc<Frame>>)
pub fn cache_frame(&mut self, frame: impl Into<Rc<Frame>>)
Store the composed frame for event hit testing.
Sourcepub fn after_compose(&mut self, frame: &Frame, scale: f32)
pub fn after_compose(&mut self, frame: &Frame, scale: f32)
Post-compose host-agnostic bookkeeping. this lazy-initializes text-field state for focus-requester paths, reconciles hover against the new hit list, and publishes the frame to the DnD registry. Replaces platform-local copies of this logic.
Sourcepub fn ensure_focused_textfield_state(&mut self)
pub fn ensure_focused_textfield_state(&mut self)
Lazy-init the focused textfield’s persistent state (FocusRequester paths don’t create it until first click). Resets the caret blink.
Sourcepub fn cache_from_output(&mut self, out: &FrameOutput)
pub fn cache_from_output(&mut self, out: &FrameOutput)
Cache a composed FrameOutput for hit-testing: rebuilds the retained
hover-leave map, reconciles hover, lazy-initializes focused textfield
state, and publishes the DnD frame/scale to the input registry.
Sourcepub fn compose_frame_output<F>(
&mut self,
root: &mut F,
render_ctx: &RenderContext,
) -> FrameOutput
pub fn compose_frame_output<F>( &mut self, root: &mut F, render_ctx: &RenderContext, ) -> FrameOutput
One-shot host tick: advance animations, compose a frame, and publish the result (hover reconciliation, focused textfield lazy-init, DnD frame/scale) in a single call.
Sourcepub fn handle_pointer_move(&mut self, pos: Vec2) -> PointerMoveResult
pub fn handle_pointer_move(&mut self, pos: Vec2) -> PointerMoveResult
Process a pointer-move event. Returns cursor suggestion.
Sourcepub fn handle_touch_move(
&mut self,
touch: Option<u64>,
pos: Vec2,
) -> PointerMoveResult
pub fn handle_touch_move( &mut self, touch: Option<u64>, pos: Vec2, ) -> PointerMoveResult
Touch move with a stable finger id (same pairing as
Self::handle_touch_press; hover fallback stays mouse).
Sourcepub fn handle_pointer_press(
&mut self,
pos: Vec2,
button: PointerButton,
) -> PointerButtonResult
pub fn handle_pointer_press( &mut self, pos: Vec2, button: PointerButton, ) -> PointerButtonResult
Process a pointer button press. Returns focus/capture info.
Sourcepub fn handle_touch_press(
&mut self,
touch: Option<u64>,
pos: Vec2,
button: PointerButton,
) -> PointerButtonResult
pub fn handle_touch_press( &mut self, touch: Option<u64>, pos: Vec2, button: PointerButton, ) -> PointerButtonResult
Touch press with a stable finger id: same hit-path dispatch as
the mouse press, but the event carries PointerKind::Touch +
the finger id, so game viewports stage per-finger contacts
instead of one shared mouse point (GML device_mouse_* parity).
Sourcepub fn handle_pointer_release(
&mut self,
pos: Vec2,
button: PointerButton,
) -> PointerButtonResult
pub fn handle_pointer_release( &mut self, pos: Vec2, button: PointerButton, ) -> PointerButtonResult
Process a pointer button release.
Sourcepub fn handle_touch_release(
&mut self,
touch: Option<u64>,
pos: Vec2,
button: PointerButton,
) -> PointerButtonResult
pub fn handle_touch_release( &mut self, touch: Option<u64>, pos: Vec2, button: PointerButton, ) -> PointerButtonResult
Touch release with a stable finger id (same pairing as
Self::handle_touch_press).
pub fn suppress_touch_click(&mut self, tid: u64)
Sourcepub fn touch_owns_drag(&self, tid: u64) -> bool
pub fn touch_owns_drag(&self, tid: u64) -> bool
Does the touch captured by tid drive the gesture through pointer
moves, so an ancestor scroll container must not also scroll?
True while a drag session is live (long-press drag and drop) or when
the pressed region handles on_pointer_move (splitters, sliders,
swipes, draggable). Compose’s rule: a child that consumes the drag
wins over the parent scrollable.
Sourcepub fn handle_touch_cancel(&mut self, touch: Option<u64>)
pub fn handle_touch_cancel(&mut self, touch: Option<u64>)
Cancel mouse pointer state (focus lost). Touch fingers never feed
the polled mouse position, so only a mouse cancel clears it.
A touch cancel drops just that finger’s path (the viewport
must drop the contact); a mouse cancel (None) keeps the old
full-reset behavior for the single mouse path.
pub fn handle_touch_cancel_at(&mut self, tid: u64, pos: Vec2)
pub fn handle_pointer_cancel(&mut self)
Sourcepub fn clear_hover(&mut self)
pub fn clear_hover(&mut self)
Clear hover state, emitting HoverLeave for the currently hovered region.
Sourcepub fn reconcile_hover_from_mouse_pos(&mut self, new_frame: &Frame)
pub fn reconcile_hover_from_mouse_pos(&mut self, new_frame: &Frame)
Reconcile hover state when the composed frame changes.
Sourcepub fn handle_scroll(&mut self, delta: Vec2) -> bool
pub fn handle_scroll(&mut self, delta: Vec2) -> bool
Process a scroll event. Returns true if consumed.
Sourcepub fn handle_key(&mut self, event: &KeyEvent) -> bool
pub fn handle_key(&mut self, event: &KeyEvent) -> bool
Process a keyboard key event. Returns true if consumed.
Sourcepub fn dispatch_action(&mut self, action: Action) -> bool
pub fn dispatch_action(&mut self, action: Action) -> bool
Dispatch a shortcut action: widget handler first, then built-in textfield editing, then the global shortcut map, then focus navigation. Returns true if the action was consumed.
Sourcepub fn handle_ime(&mut self, event: &ImeEvent)
pub fn handle_ime(&mut self, event: &ImeEvent)
Process an IME event.
Sourcepub fn finish_compositions(&mut self)
pub fn finish_compositions(&mut self)
Finish the active composition in every field without deleting text. Used for focus changes and IME disconnects where the confirmed text must be kept; distinct from cancelling, which discards the preedit.
Sourcepub fn handle_focus_lost(&mut self)
pub fn handle_focus_lost(&mut self)
Handle focus lost (window unfocused, etc.). Physical-key and
mouse-button levels clear too: winit does not deliver key-ups
for keys still down across an alt-tab, so without this the
polled held_keys set sticks until the next press of that key.
Sourcepub fn set_physical_key(&mut self, name: &str, down: bool)
pub fn set_physical_key(&mut self, name: &str, down: bool)
Report one physical key transition (true = down). Platform
runners call this from the raw KeyboardInput event alongside
the focus-routed handle_key_with_text, so held reflects
hardware even when no widget has focus.
Sourcepub fn held_physical_keys(&self) -> Vec<String>
pub fn held_physical_keys(&self) -> Vec<String>
Snapshot of currently held physical keys (debug names).
Sourcepub fn physical_key_held(&self, name: &str) -> bool
pub fn physical_key_held(&self, name: &str) -> bool
True while the named physical key is down (KeyCode::KeyW, …).
True while the mouse button is down.
Sourcepub fn ensure_textfield_state(
&mut self,
key: u64,
) -> Rc<RefCell<TextFieldState>>
pub fn ensure_textfield_state( &mut self, key: u64, ) -> Rc<RefCell<TextFieldState>>
Get or create a text field state by its key.
pub fn ensure_textfield_state_seeded( &mut self, key: u64, seed: &str, ) -> Rc<RefCell<TextFieldState>>
Sourcepub fn tf_key_of(&self, visual_id: u64) -> u64
pub fn tf_key_of(&self, visual_id: u64) -> u64
Look up the persistent state key for a visual hit-region id.
Sourcepub fn is_textfield(&self, id: u64) -> bool
pub fn is_textfield(&self, id: u64) -> bool
True if the given id belongs to a TextField.
Sourcepub fn is_editable_textfield(&self, id: u64) -> bool
pub fn is_editable_textfield(&self, id: u64) -> bool
True if the given id is an enabled, editable text field.
Sourcepub fn is_multiline(&self, id: u64) -> bool
pub fn is_multiline(&self, id: u64) -> bool
True if the given textfield id is multiline.
Sourcepub fn focused_keyboard_hints(
&self,
) -> (ImePurposeHint, bool, KeyboardCapitalization)
pub fn focused_keyboard_hints( &self, ) -> (ImePurposeHint, bool, KeyboardCapitalization)
Keyboard hints of the currently focused text field, or defaults if none.
Returns (purpose, auto_correct, capitalization) for the platform runner.
pub fn focused_ime_action(&self) -> ImeAction
Sourcepub fn insert_text_into_focused(&mut self, text: &str) -> bool
pub fn insert_text_into_focused(&mut self, text: &str) -> bool
Insert arbitrary text into the focused text field (composed keyboard text, clipboard paste, hardware-keyboard fallback, …). Returns true if text was inserted.
Control chars are filtered. Newlines are dropped for single-line fields. Skipped during IME preedit.
Sourcepub fn insert_text(&mut self, text: &str) -> bool
pub fn insert_text(&mut self, text: &str) -> bool
Insert plain text into the focused textfield (winit key_event.text,
Android soft-keyboard text, web paste). Alias for
Self::insert_text_into_focused.
Sourcepub fn paste_into_focused(&mut self, text: &str)
pub fn paste_into_focused(&mut self, text: &str)
Insert text into a focused text field (used for paste). Uses an atomic (non-mergeable) edit so Ctrl+V doesn’t merge with adjacent typing.
Sourcepub fn handle_gamepad(&mut self, event: &GamepadEvent) -> bool
pub fn handle_gamepad(&mut self, event: &GamepadEvent) -> bool
Process a gamepad event: mirror connection/button/axis state into
ReposeRuntime::gamepads. Sticks, shoulders and face extras stay raw
gameplay input for the game to read from ReposeRuntime::gamepads.
Returns true when the event drove UI navigation.
Sourcepub fn request_rumble(
&mut self,
id: GamepadId,
low_freq: f32,
high_freq: f32,
duration_ms: u32,
)
pub fn request_rumble( &mut self, id: GamepadId, low_freq: f32, high_freq: f32, duration_ms: u32, )
Queue a dual-motor rumble for id (SDL-style: low = strong motor,
high = weak motor, 0.0..=1.0, duration_ms). The platform runner
drains the queue each frame into GamepadBackend::set_rumble.
A duration_ms of 0 stops. No-op when the pad is unknown.
Sourcepub fn stop_rumble(&mut self, id: GamepadId)
pub fn stop_rumble(&mut self, id: GamepadId)
Queue a rumble stop for id.
Sourcepub fn take_rumble_requests(&mut self) -> Vec<(u32, f32, f32, u32)>
pub fn take_rumble_requests(&mut self) -> Vec<(u32, f32, f32, u32)>
Drain queued rumble requests (platform runners call this after poll).
Sourcepub fn handle_key_with_text(
&mut self,
event: &KeyEvent,
composed_text: Option<&str>,
) -> bool
pub fn handle_key_with_text( &mut self, event: &KeyEvent, composed_text: Option<&str>, ) -> bool
Process a key event with an optional host-composed text payload
(winit key_event.text, Android soft-keyboard text, …).
When the modifiers are free of Ctrl/Alt/Meta and the payload is Printable text goes to the focused field first. Otherwise falls through to handle_key.
Sourcepub fn handle_scroll_at(
&mut self,
pos: Vec2,
delta: Vec2,
scroll_capture: Option<u64>,
) -> (bool, Option<u64>)
pub fn handle_scroll_at( &mut self, pos: Vec2, delta: Vec2, scroll_capture: Option<u64>, ) -> (bool, Option<u64>)
Process a scroll event at an explicit position, honoring a caller-owned
scroll capture id (touch gestures initialize the capture themselves).
Returns (consumed, updated_capture_id).
Sourcepub fn next_wakeup_deadline(&self) -> Option<Instant>
pub fn next_wakeup_deadline(&self) -> Option<Instant>
Centralized wakeup helper for platform runners (caret, snackbar, timers, etc.).
Debounced entries live on the shared timer queue, so timer covers them.
Sourcepub fn is_wakeup_due(&self, now: Instant) -> bool
pub fn is_wakeup_due(&self, now: Instant) -> bool
Whether a scheduled wakeup is due at now (deadline <= now).
Sourcepub fn is_caret_blink_due(&self, now: Instant) -> bool
pub fn is_caret_blink_due(&self, now: Instant) -> bool
Whether a caret blink edge is due at now (deadline <= now).
Deprecated: use is_wakeup_due.
Sourcepub fn next_frame_deadline(&self, now: Instant, idle_cap: Duration) -> Instant
pub fn next_frame_deadline(&self, now: Instant, idle_cap: Duration) -> Instant
Desktop-style deadline with idle keep-alive fallback.
idle_cap is the maximum time the host should sleep without a
scheduled wakeup (e.g. 1s on desktop to handle tray Deeplinks).
Sourcepub fn tick_overlays(&self)
pub fn tick_overlays(&self)
Tick host-facing overlays (snackbar timeouts) and timers (including debounced entries, which live on the shared timer queue). Call once per redraw.
Sourcepub fn cursor_suggestion(&self) -> Option<CursorIcon>
pub fn cursor_suggestion(&self) -> Option<CursorIcon>
Get the cursor suggestion (set during pointer-move handling).
Sourcepub fn take_cursor_suggestion(&mut self) -> Option<CursorIcon>
pub fn take_cursor_suggestion(&mut self) -> Option<CursorIcon>
Take the cursor suggestion (clears it).