Skip to main content

Host

Struct Host 

Source
pub struct Host {
    pub viewport: Size,
    /* private fields */
}
Expand description

A window hosting several documents.

Fields§

§viewport: Size

The window size.

Implementations§

Source§

impl Host

Source

pub fn new(viewport: Size) -> Self

An empty host for a window of viewport.

Source

pub fn set_glyphs(&mut self, glyphs: Box<dyn Glyphs + Send + Sync>)

Paint text with glyphs from the next layout on: e.g. noonoo-ttf’s OutlineGlyphs, so a GPU window receives glyph outlines. The default, TextRuns, emits DrawText commands.

Source

pub fn add_chrome(&mut self, engine: Engine, rect: Rect) -> usize

Admit the chrome document, placed at rect.

Source

pub fn add_content(&mut self, engine: Engine, rect: Rect) -> usize

Admit a content document, placed at rect.

Source

pub fn add_sub_document( &mut self, parent: usize, host: NodeId, engine: Engine, ) -> usize

Attach engine as a sub-document of the host node host in parent.

The parent sizes the sub-document: its rectangle is the host node’s content box, computed on the next Host::layout. Sub-documents are first-class layers, so routing, hit-testing, and composition apply to them unchanged.

Source

pub fn layers(&self) -> &[Layer]

Every layer, in admission order (later layers paint on top).

Source

pub fn layers_mut(&mut self) -> &mut [Layer]

Every layer, mutably — for a host adjusting rectangles on resize.

Source

pub fn layer(&self, index: usize) -> Option<&Layer>

The layer at index.

Source

pub fn layout(&mut self, shaper: &dyn Shaper)

Compute styles, layout, and paint commands for every layer.

A sub-document’s rectangle is taken from its host node’s content box in the (already laid-out) parent, so the parent sizes it; the sub-document is then laid out and painted with its own styles.

Source

pub fn poll_resources(&mut self) -> bool

Take in each layer’s finished loads (see Engine::poll_resources); true when an image arrived, so the next Host::layout changes what’s drawn.

Source

pub fn route(&self, point: Point) -> Option<usize>

The topmost layer whose rectangle contains point.

Source

pub fn hit(&self, point: Point) -> Option<(usize, NodeId)>

The topmost layer and node under point.

Source

pub fn element_hit(&self, point: Point) -> Option<(usize, NodeId)>

The topmost layer and element under point: a hit on text resolves to the element containing it, which is what :hover, :active, focus and cursor apply to.

Source

pub fn focus(&self) -> Option<(usize, NodeId)>

The layer that last received a pointer event.

Source

pub fn set_focus(&mut self, layer: usize, node: NodeId)

Set focus to a specific layer and node.

Source

pub fn hover(&mut self, point: Point) -> bool

Update the hovered node from a hit test at point.

Returns whether it changed — a caller re-layouts to restyle, which is when :hover takes effect.

Source

pub fn hovered(&self) -> Option<(usize, NodeId)>

The hovered (layer, node), if any.

Source

pub fn press(&mut self, point: Point)

Mark the node under point as pressed (:active).

Source

pub fn release(&mut self)

Release the press (:active ends).

Source

pub fn active(&self) -> Option<(usize, NodeId)>

The pressed (layer, node), if any.

Source

pub fn cursor_at(&self, point: Point) -> Cursor

The computed cursor of the node under point (Auto when nothing is there). Call after a layout, so the styles are fresh.

Source

pub fn dispatch_pointer( &mut self, point: Point, event: &Event, listener: &impl EventListener, ) -> Option<(usize, NodeId)>

Route a pointer event to the layer under point, updating focus.

Returns the (layer, node) the event was delivered to, if any.

Source

pub fn dispatch_key( &mut self, event: &Event, listener: &impl EventListener, ) -> bool

Route a key event to the focused node (or the focused layer’s root).

Source

pub fn wheel(&mut self, point: Point, delta_y: f32) -> Vec<(usize, f32)>

Apply a wheel (scroll) delta at point, chaining outward.

Inside a layer, the innermost scroll container under point scrolls first; what it cannot consume goes to the next container outward, then to the layer’s own viewport, then — for a sub-document — to its parent.

Returns (layer, consumed) pairs along the layer-level chain, innermost first. Per-container consumption is visible through Layer::layout/LayoutTree::scroll_offset.

Source

pub fn a11y(&self) -> A11yTree

The window’s accessibility tree: every layer under one window root.

Bounds are translated by each layer’s position (minus its scroll), and nodes are renumbered so ids are unique across the window. The focused node, if any, is marked and reported as noonoo_a11y::A11yTree::focus.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Host

§

impl !UnwindSafe for Host

§

impl Forget for Host

§

impl Freeze for Host

§

impl Move for Host

§

impl Send for Host
where RawVecInner: Send, BoxRaw<SelectorList>: Send, RawTable<(String, Vec<usize>)>: Send, BoxRaw<dyn Loader + Sync + Send>: Send, Arc<Shared>: Send, RawTable<(String, ())>: Send, RawTable<(RequestId, String)>: Send, RawTable<(String, Image)>: Send, BoxRaw<[CalcTerm]>: Send, Arc<HashMap<String, Vec<Value>>>: Send, RawTable<(NodeId, usize)>: Send, RawTable<(NodeId, NodeId)>: Send, RawTable<(NodeId, EncodedImage)>: Send, RawTable<(NodeId, Vec<BorderSegment>)>: Send, Arc<[u8]>: Send, BoxRaw<dyn Glyphs + Sync + Send>: Send,

§

impl Sync for Host
where RawVecInner: Sync, BoxRaw<SelectorList>: Sync, RawTable<(String, Vec<usize>)>: Sync, BoxRaw<dyn Loader + Sync + Send>: Sync, Arc<Shared>: Sync, RawTable<(String, ())>: Sync, RawTable<(RequestId, String)>: Sync, RawTable<(String, Image)>: Sync, BoxRaw<[CalcTerm]>: Sync, Arc<HashMap<String, Vec<Value>>>: Sync, RawTable<(NodeId, usize)>: Sync, RawTable<(NodeId, NodeId)>: Sync, RawTable<(NodeId, EncodedImage)>: Sync, RawTable<(NodeId, Vec<BorderSegment>)>: Sync, Arc<[u8]>: Sync, BoxRaw<dyn Glyphs + Sync + Send>: Sync,

§

impl Unpin for Host
where *const u8 is !null: Unpin, Box<SelectorList>: Unpin, Box<dyn Loader + Sync + Send>: Unpin, Arc<Shared>: Unpin, Arc<[u8]>: Unpin, Box<[CalcTerm]>: Unpin, Arc<HashMap<String, Vec<Value>>>: Unpin, Box<dyn Glyphs + Sync + Send>: Unpin,

§

impl UnsafeUnpin for Host

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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