pub struct EngineControl { /* private fields */ }Expand description
A cheap, cloneable handle for sending input to the engine from any thread.
Implementations§
Source§impl EngineControl
impl EngineControl
Sourcepub fn dispatch_event(
&self,
id: NodeId,
event: EventKind,
payload: EventPayload,
)
pub fn dispatch_event( &self, id: NodeId, event: EventKind, payload: EventPayload, )
Delivers an input event (and its data) to a node.
Sourcepub fn scroll(&self, id: NodeId, offset: Point<Points>, applied: u32)
pub fn scroll(&self, id: NodeId, offset: Point<Points>, applied: u32)
Reports the content offset of a scroll view or list, and how many
scrolls the core asked for (MountItem::ScrollBy items and
Command::ScrollTo commands for the view) were applied before it.
Cheap to call on every scroll frame: offsets are coalesced per
engine frame.
Sourcepub fn zoom(&self, id: NodeId, scale: f32)
pub fn zoom(&self, id: NodeId, scale: f32)
Reports the zoom scale of a zoomable scroll view (before the offset
the zoom changed); onScroll carries it.
Sourcepub fn set_component_size(&self, id: NodeId, size: Size<Points>)
pub fn set_component_size(&self, id: NodeId, size: Size<Points>)
A registered native component’s own size (points): it is laid out at it where its style leaves a dimension open.
Sourcepub fn animations_finished(&self, finished: Vec<Finished>)
pub fn animations_finished(&self, finished: Vec<Finished>)
Reports native animations that finished or were interrupted.
Sourcepub fn set_environment(&self, environment: Environment)
pub fn set_environment(&self, environment: Environment)
Reports a change of the surface’s environment (safe area, keyboard, appearance…).
Sourcepub fn set_root_size(&self, id: NodeId, size: Size<Points>, insets: EdgeInsets)
pub fn set_root_size(&self, id: NodeId, size: Size<Points>, insets: EdgeInsets)
The platform presents root id (a modal) at size, with insets
of it covered by system UI.
Sourcepub fn set_screen_header(&self, id: NodeId, height: Option<Points>)
pub fn set_screen_header(&self, id: NodeId, height: Option<Points>)
The platform measured where the content of screen id starts below
its header (None: let the core estimate it).
Sourcepub fn hot_update(&self, update: HotUpdate)
pub fn hot_update(&self, update: HotUpdate)
Applies a development update in place. When it cannot be applied,
MountSink::hot_update_failed asks the platform to reload.
Sourcepub fn chunk_loaded(&self, chunk: Chunk)
pub fn chunk_loaded(&self, chunk: Chunk)
Hands over the chunk MountSink::load_chunk asked for: the
dynamic imports waiting for it continue.
Sourcepub fn chunk_failed(&self, id: String, message: String)
pub fn chunk_failed(&self, id: String, message: String)
Chunk id could not be loaded: the dynamic imports waiting for it
fail with message (a later import asks for it again).
Sourcepub fn frame(&self)
pub fn frame(&self)
A display frame began, after MountSink::request_frame: runs the
requestAnimationFrame callbacks and the tasks waiting for it.
Sourcepub fn advance_clock(&self, by: Duration, done: impl FnOnce() + Send + 'static)
pub fn advance_clock(&self, by: Duration, done: impl FnOnce() + Send + 'static)
Moves the engine’s manual clock (EngineConfig::clock) forward
by by: the timers and tasks due meanwhile run in the order they
come due, each at its time, with what they make due in turn, and the
clock’s alarms (a response it holds back) go off on the way. Then
done runs, after the batches of what ran were submitted. With the
system’s clock it only runs done.
Sourcepub fn set_states(&self, id: NodeId, states: u8)
pub fn set_states(&self, id: NodeId, states: u8)
Reports the interaction states of view id that the core asked to
track (nsh_core::MountItem::TrackStates; bits of
nsh_core::tailwind::state). Class styles that depend on them
(active:, hover:, focus:) update without JS.
Sourcepub fn fonts_changed(&self)
pub fn fonts_changed(&self)
Fonts the platform loads asynchronously became usable (on the web,
a FontFace finished loading): text measured with a fallback font
is measured again.
Sourcepub fn set_perf_monitor(&self, monitor: Option<Arc<PerfMonitor>>)
pub fn set_perf_monitor(&self, monitor: Option<Arc<PerfMonitor>>)
Records the engine’s commits into monitor from now on (None:
stops). Measuring costs nothing while no monitor is installed.
Sourcepub fn set_tokens(&self, tokens: Option<Tokens>)
pub fn set_tokens(&self, tokens: Option<Tokens>)
Sets the embedding app’s design tokens (nsh-base’s theme’s),
which the app renders with instead of its own (None: its own
again; Core::set_host_tokens). Sent from
Engine::start_with’s setup, they are in the first frame.