pub enum ViewNode {
Element {
id: String,
style: Style,
axis: Axis,
children: Vec<ViewNode>,
},
Text {
id: String,
text: String,
style: Style,
},
VirtualRows {
id: String,
count: usize,
style: Style,
first: usize,
render: RowRenderer,
},
}Expand description
The retained view description a host builds and the layout engine consumes. Script runtimes produce the same tree from JSON, so the renderer never needs to know which frontend authored a frame.
Variants§
Implementations§
Source§impl ViewNode
impl ViewNode
pub fn element( id: impl Into<String>, style: Style, children: Vec<ViewNode>, ) -> Self
pub fn row_element( id: impl Into<String>, style: Style, children: Vec<ViewNode>, ) -> Self
pub fn column(children: Vec<ViewNode>) -> Self
pub fn row(children: Vec<ViewNode>) -> Self
pub fn text(text: impl Into<String>, style: Style) -> Self
Sourcepub fn text_node(
id: impl Into<String>,
text: impl Into<String>,
style: Style,
) -> Self
pub fn text_node( id: impl Into<String>, text: impl Into<String>, style: Style, ) -> Self
A text node with a stable id, which is what hit testing and focus use.
pub fn empty(style: Style) -> Self
pub fn virtual_rows( count: usize, style: Style, render: impl Fn(usize) -> ViewNode + Send + Sync + 'static, ) -> Self
Sourcepub fn virtual_rows_from(
first: usize,
count: usize,
style: Style,
render: impl Fn(usize) -> ViewNode + Send + Sync + 'static,
) -> Self
pub fn virtual_rows_from( first: usize, count: usize, style: Style, render: impl Fn(usize) -> ViewNode + Send + Sync + 'static, ) -> Self
A virtual list scrolled to a starting row.
Sourcepub fn virtual_rows_named(
id: impl Into<String>,
first: usize,
count: usize,
style: Style,
render: impl Fn(usize) -> ViewNode + Send + Sync + 'static,
) -> Self
pub fn virtual_rows_named( id: impl Into<String>, first: usize, count: usize, style: Style, render: impl Fn(usize) -> ViewNode + Send + Sync + 'static, ) -> Self
A virtual list with an addressable id, so a host can scroll it in place
with ViewNode::scroll_virtual_rows instead of rebuilding the tree.
A virtual list always fills its parent on the main axis: it is a scrollback panel, and the window is derived from the space it is given.
Sourcepub fn scroll_virtual_rows(&mut self, id: &str, first: usize) -> bool
pub fn scroll_virtual_rows(&mut self, id: &str, first: usize) -> bool
Rewrites the window start of a virtual list, so scrolling only rebuilds the rows the user can actually see.
Sourcepub fn for_each(&self, visit: &mut dyn FnMut(&ViewNode))
pub fn for_each(&self, visit: &mut dyn FnMut(&ViewNode))
Visits every node, parents before children, which is the paint order.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Total node count, including every materialized virtual row.