pub struct WindowRoot { /* private fields */ }Expand description
Lays its content out against the window, because nothing above it will.
A percent-sized tree resolves to nothing until something hands it a definite space, and Telar hands the tree a window rather than laying it out. Without this root the content’s rects stay zero and the window is black forever, which looks exactly like a renderer that never drew.
ScrollPage is the same shape for a window that is one scrolling column.
Implementations§
Source§impl WindowRoot
impl WindowRoot
Sourcepub fn new(content: Box<dyn LayoutItem>) -> Self
pub fn new(content: Box<dyn LayoutItem>) -> Self
Lays content’s own node out against the window, adding nothing to the tree.
content must size itself to fill the window — a percent-sized box is the usual answer. For content
that sizes itself to its children instead, use WindowRoot::wrapping.
Sourcepub fn wrapping(content: Box<dyn LayoutItem>) -> Result<Self, LayoutError>
pub fn wrapping(content: Box<dyn LayoutItem>) -> Result<Self, LayoutError>
Wraps content in a window-filling box and lays that out, for content that does not fill the
window on its own or that has to stretch inside a parent of a fixed size.
pub fn animate_in(self) -> Self
Sourcepub fn animate(self, transition: SurfaceTransition) -> Self
pub fn animate(self, transition: SurfaceTransition) -> Self
Drives the root from a transition the caller owns, so it can also send the surface back out — see
SurfaceTransition::leave.
Trait Implementations§
Source§impl Component for WindowRoot
impl Component for WindowRoot
Source§fn on_event(&mut self, event: &Event) -> EventResult
fn on_event(&mut self, event: &Event) -> EventResult
Lays out first, then passes the resize on, so anything that has to run once the tree has real rects — a scroll viewport that is its own layout root, a first-layout autofocus — sees it in that order.
Handled regardless of what the content answered: the runner requests a redraw only for a handled
event (runner::handler), so reporting the content’s Ignored would relayout and never repaint.