pub struct Host {
pub viewport: Size,
/* private fields */
}Expand description
A window hosting several documents.
Fields§
§viewport: SizeThe window size.
Implementations§
Source§impl Host
impl Host
Sourcepub fn set_glyphs(&mut self, glyphs: Box<dyn Glyphs + Send + Sync>)
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.
Sourcepub fn add_chrome(&mut self, engine: Engine, rect: Rect) -> usize
pub fn add_chrome(&mut self, engine: Engine, rect: Rect) -> usize
Admit the chrome document, placed at rect.
Sourcepub fn add_content(&mut self, engine: Engine, rect: Rect) -> usize
pub fn add_content(&mut self, engine: Engine, rect: Rect) -> usize
Admit a content document, placed at rect.
Sourcepub fn add_sub_document(
&mut self,
parent: usize,
host: NodeId,
engine: Engine,
) -> usize
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.
Sourcepub fn layers_mut(&mut self) -> &mut [Layer]
pub fn layers_mut(&mut self) -> &mut [Layer]
Every layer, mutably — for a host adjusting rectangles on resize.
Sourcepub fn layout(&mut self, shaper: &dyn Shaper)
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.
Sourcepub fn poll_resources(&mut self) -> bool
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.
Sourcepub fn route(&self, point: Point) -> Option<usize>
pub fn route(&self, point: Point) -> Option<usize>
The topmost layer whose rectangle contains point.
Sourcepub fn hit(&self, point: Point) -> Option<(usize, NodeId)>
pub fn hit(&self, point: Point) -> Option<(usize, NodeId)>
The topmost layer and node under point.
Sourcepub fn element_hit(&self, point: Point) -> Option<(usize, NodeId)>
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.
Sourcepub fn set_focus(&mut self, layer: usize, node: NodeId)
pub fn set_focus(&mut self, layer: usize, node: NodeId)
Set focus to a specific layer and node.
Sourcepub fn hover(&mut self, point: Point) -> bool
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.
Sourcepub fn cursor_at(&self, point: Point) -> Cursor
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.
Sourcepub fn dispatch_pointer(
&mut self,
point: Point,
event: &Event,
listener: &impl EventListener,
) -> Option<(usize, NodeId)>
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.
Sourcepub fn dispatch_key(
&mut self,
event: &Event,
listener: &impl EventListener,
) -> bool
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).
Sourcepub fn wheel(&mut self, point: Point, delta_y: f32) -> Vec<(usize, f32)>
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.
Sourcepub fn a11y(&self) -> A11yTree
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.