Skip to main content

EngineControl

Struct EngineControl 

Source
pub struct EngineControl { /* private fields */ }
Expand description

A cheap, cloneable handle for sending input to the engine from any thread.

Implementations§

Source§

impl EngineControl

Source

pub fn dispatch_event( &self, id: NodeId, event: EventKind, payload: EventPayload, )

Delivers an input event (and its data) to a node.

Source

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.

Source

pub fn key_scrolled(&self, id: NodeId, key_move: KeyMove)

Reports that a scroll key moved scroll view id by key_move. Sent after the platform started its own key scroll, for every key move and not End alone: the core takes a list on to its real end from End and lets go of it on the others (Core::key_scrolled).

Source

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.

Source

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.

Source

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 bar of the app’s follows the text (InputConfig::report_scroll), on every change.

Source

pub fn input_composing(&self, id: NodeId, shown: Option<String>)

Reports what input id shows while an input method composes in it (its text with the composition at the caret), None once the composition ends: the core measures the input with it, so it grows as the composition wraps (Core::input_composing).

Source

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.

Source

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.

Source

pub fn animations_finished(&self, finished: Vec<Finished>)

Reports native animations that finished or were interrupted.

Source

pub fn resize(&self, size: Size<Points>)

Resizes the root view.

Source

pub fn set_environment(&self, environment: Environment)

Reports a change of the surface’s environment (safe area, keyboard, appearance…).

Source

pub fn shaders_unavailable(&self)

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.

Source

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).

Source

pub fn set_root_size(&self, id: NodeId, size: Size<Points>, insets: EdgeInsets)

The platform presents root id (a modal, a window of the app’s own) at size, with insets of it covered by system UI. Reported back after its layout (MountSink::root_resized).

Source

pub fn set_overlay_area(&self, area: Option<Bounds<Points>>)

Where the root view’s anchored overlays may be placed, in its coordinates, when the platform shows them beyond it (the web’s overlays: "viewport": the window); None keeps them to the root view (nsh_core::Core::set_overlay_area).

Source

pub fn press_beyond_root(&self, page: Point<Points>)

A press at page (in the root view’s coordinates) beyond the root view, where the platform shows its anchored overlays too (the web page around the player): the overlays watching presses hear onPressOutside (nsh_core::Core::presses_beyond_root).

Source

pub fn press_on_native(&self, id: NodeId, page: Point<Points>)

A press at page (root view coordinates) that view id’s native content took (a web view’s page): the overlays watching presses that it is outside of hear onPressOutside (nsh_core::Core::presses_on_native).

Source

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).

Source

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.

Source

pub fn chunk_loaded(&self, chunk: Chunk)

Hands over the chunk MountSink::load_chunk asked for: the dynamic imports waiting for it continue.

Source

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).

Source

pub fn frame(&self)

A display frame began, after MountSink::request_frame: runs the requestAnimationFrame callbacks and the tasks waiting for it.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn release_states_after(&self, id: NodeId, states: u16, hold: Duration)

Reports the interaction states of view id after a short completed press, holding PRESSED for hold in the core so same-turn tap-to-click gestures still render :active feedback (nsh_core::Core::release_states_after).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for EngineControl

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ParallelSend for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more