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 keep_rendered(&self, nodes: Vec<NodeId>)
pub fn keep_rendered(&self, nodes: Vec<NodeId>)
Keeps the virtual list rows holding nodes rendered wherever they
scroll (Core::set_kept): the ends of a text selection. Replaces
the last call’s; none releases them.
Sourcepub fn set_content_culling(&self, enabled: bool)
pub fn set_content_culling(&self, enabled: bool)
Whether scroll views make the native views of their content as it
comes near their viewport (the default), or all of it
(Core::set_content_culling): a test driver’s, whose steps reach
every view of a page.
Sourcepub fn input_scroll(
&self,
id: NodeId,
offset: Point<Points>,
content: Size<Points>,
viewport: Size<Points>,
)
pub fn input_scroll( &self, id: NodeId, offset: Point<Points>, content: Size<Points>, viewport: Size<Points>, )
Reports how far a multiline input’s text scrolled: its offset, the
size of the text it scrolls and of its viewport. Sent while a
built-in bar takes the place of its indicator
(InputConfig::replaced), on every change.
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…).
The platform has no GPU to draw shader views with
(shader::Renderer::new is None): the app’s
Environment::shaders turns false now and stays so, whatever the
platform reports later. Telling it again does nothing.
Sourcepub fn set_displays(&self, displays: Vec<Display>)
pub fn set_displays(&self, displays: Vec<Display>)
Reports the displays (desktops: on start, in
Engine::start_with’s setup, so the app reads them as it first
renders, then whenever they change).
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 flush(&self, done: impl FnOnce(bool) + Send + 'static)
pub fn flush(&self, done: impl FnOnce(bool) + Send + 'static)
Runs everything sent to the engine before it and everything due on
its clock now (timers, woken tasks, answers that came at once), with
what they queue in turn, without moving the clock. Then done runs,
after the batches of what ran were submitted, with whether the
engine is idle: nothing is left to run and no request waits for
the network. False when work keeps coming (a task that keeps waking
itself) or a request is in flight, whose answer comes later from
elsewhere. A headless driver on a manual clock settles a step with
it, instead of waiting for the batches to stop for a while.
Sourcepub fn set_input_modality(&self, modality: InputModality)
pub fn set_input_modality(&self, modality: InputModality)
The user gave the surface input with modality: a pointer, finger
or pen going down, or a key pressed (not a modifier alone). Called
for every such event, before the platform acts on it, so it reaches
the core ahead of the focus move it causes; only a change crosses
to the engine. The core shows the keyboard focus by it
(focus-visible:; nsh_core::Core::set_input_modality).
Sourcepub fn set_states(&self, id: NodeId, states: u16)
pub fn set_states(&self, id: NodeId, states: u16)
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 remount(&self)
pub fn remount(&self)
The platform’s views get everything again and text is measured again: the unit the platform converts values with changed (Android’s density). Send the new environment and size too.
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.
Sourcepub fn register_font(&self, data: Vec<u8>)
pub fn register_font(&self, data: Vec<u8>)
Registers a font file the embedding app ships (TrueType, OpenType,
WOFF or WOFF2) so every app this engine runs can name its family.
Sent from Engine::start_with’s setup, it is registered before
the first frame; sent later, text measured already is measured again.