Skip to main content

ViewNode

Enum ViewNode 

Source
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§

§

Element

Fields

§style: Style
§axis: Axis
§children: Vec<ViewNode>
§

Text

Fields

§text: String
§style: Style
§

VirtualRows

Fields

§count: usize
§style: Style
§first: usize

First visible source row, driven by host scroll state.

Implementations§

Source§

impl ViewNode

Source

pub fn element( id: impl Into<String>, style: Style, children: Vec<ViewNode>, ) -> Self

Source

pub fn row_element( id: impl Into<String>, style: Style, children: Vec<ViewNode>, ) -> Self

Source

pub fn column(children: Vec<ViewNode>) -> Self

Source

pub fn row(children: Vec<ViewNode>) -> Self

Source

pub fn text(text: impl Into<String>, style: Style) -> Self

Source

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.

Source

pub fn empty(style: Style) -> Self

Source

pub fn virtual_rows( count: usize, style: Style, render: impl Fn(usize) -> ViewNode + Send + Sync + 'static, ) -> Self

Source

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.

Source

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.

Source

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.

Source

pub fn for_each(&self, visit: &mut dyn FnMut(&ViewNode))

Visits every node, parents before children, which is the paint order.

Source

pub fn node_count(&self) -> usize

Total node count, including every materialized virtual row.

Trait Implementations§

Source§

impl Clone for ViewNode

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