LayoutNode

Struct LayoutNode 

Source
pub struct LayoutNode<T>
where T: 'static,
{ pub style: Style, pub unrounded_layout: Layout, pub final_layout: Layout, pub cache: Cache, pub context: Option<T>, }

Fields§

§style: Style§unrounded_layout: Layout§final_layout: Layout§cache: Cache§context: Option<T>

Implementations§

Source§

impl<T> LayoutNode<T>
where T: 'static,

Source

pub fn new(style: Style) -> Self

Examples found in repository?
examples/basic.rs (line 21)
11fn container<P, C>(s: Scope<P>, style: Style, content: C)
12where
13    P: 'static,
14    C: Fn(Scope<Container>) + Clone + 'static,
15{
16    let scope = s.child::<Container>();
17    s.create_node(
18        scope,
19        content,
20        move || style.clone(),
21        |style, _| LayoutNode::new(style),
22        |n, style, _| {
23            if n.style != style {
24                n.style = style;
25                n.mark_dirty();
26            }
27        },
28    );
29}
30
31struct Leaf;
32
33#[track_caller]
34fn leaf<P>(s: Scope<P>, style: Style)
35where
36    P: 'static,
37{
38    let scope = s.child::<Leaf>();
39    s.create_node(
40        scope,
41        |_| {},
42        move || style.clone(),
43        |style, _| LayoutNode::new(style),
44        |n, style, _| {
45            if n.style != style {
46                n.style = style;
47                n.mark_dirty();
48            }
49        },
50    );
51}
More examples
Hide additional examples
examples/basic_any.rs (line 23)
13fn container<P, C>(s: Scope<P>, style: Style, content: C)
14where
15    P: 'static,
16    C: Fn(Scope<Container>) + Clone + 'static,
17{
18    let scope = s.child::<Container>();
19    s.create_node(
20        scope,
21        content,
22        move || style.clone(),
23        |style, _| LayoutNode::new(style),
24        |n, style, _| {
25            if n.style != style {
26                n.style = style;
27                n.mark_dirty();
28            }
29        },
30    );
31}
32
33struct Leaf;
34
35#[track_caller]
36fn leaf<P>(s: Scope<P>, style: Style)
37where
38    P: 'static,
39{
40    let scope = s.child::<Leaf>();
41    s.create_node(
42        scope,
43        |_| {},
44        move || style.clone(),
45        |style, _| LayoutNode::new(style),
46        |n, style, _| {
47            if n.style != style {
48                n.style = style;
49                n.mark_dirty();
50            }
51        },
52    );
53}
Source

pub fn with_context(style: Style, context: T) -> Self

Source

pub fn mark_dirty(&mut self)

Examples found in repository?
examples/basic.rs (line 25)
11fn container<P, C>(s: Scope<P>, style: Style, content: C)
12where
13    P: 'static,
14    C: Fn(Scope<Container>) + Clone + 'static,
15{
16    let scope = s.child::<Container>();
17    s.create_node(
18        scope,
19        content,
20        move || style.clone(),
21        |style, _| LayoutNode::new(style),
22        |n, style, _| {
23            if n.style != style {
24                n.style = style;
25                n.mark_dirty();
26            }
27        },
28    );
29}
30
31struct Leaf;
32
33#[track_caller]
34fn leaf<P>(s: Scope<P>, style: Style)
35where
36    P: 'static,
37{
38    let scope = s.child::<Leaf>();
39    s.create_node(
40        scope,
41        |_| {},
42        move || style.clone(),
43        |style, _| LayoutNode::new(style),
44        |n, style, _| {
45            if n.style != style {
46                n.style = style;
47                n.mark_dirty();
48            }
49        },
50    );
51}
More examples
Hide additional examples
examples/basic_any.rs (line 27)
13fn container<P, C>(s: Scope<P>, style: Style, content: C)
14where
15    P: 'static,
16    C: Fn(Scope<Container>) + Clone + 'static,
17{
18    let scope = s.child::<Container>();
19    s.create_node(
20        scope,
21        content,
22        move || style.clone(),
23        |style, _| LayoutNode::new(style),
24        |n, style, _| {
25            if n.style != style {
26                n.style = style;
27                n.mark_dirty();
28            }
29        },
30    );
31}
32
33struct Leaf;
34
35#[track_caller]
36fn leaf<P>(s: Scope<P>, style: Style)
37where
38    P: 'static,
39{
40    let scope = s.child::<Leaf>();
41    s.create_node(
42        scope,
43        |_| {},
44        move || style.clone(),
45        |style, _| LayoutNode::new(style),
46        |n, style, _| {
47            if n.style != style {
48                n.style = style;
49                n.mark_dirty();
50            }
51        },
52    );
53}

Trait Implementations§

Source§

impl<T> Clone for LayoutNode<T>
where T: 'static + Clone,

Source§

fn clone(&self) -> LayoutNode<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> ComposeNode for LayoutNode<T>
where T: 'static,

Source§

impl<T> Debug for LayoutNode<T>
where T: 'static + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> TaffyNode for LayoutNode<T>
where T: 'static,

Source§

type NodeContext = T

Source§

type CoreContainerStyle = Style

The style type representing the core container styles that all containers should have Used when laying out the root node of a tree
Source§

type BlockContainerStyle<'a> = &'a Style where Self: 'a

The style type representing the CSS Block container’s styles
Source§

type BlockItemStyle<'a> = &'a Style where Self: 'a

The style type representing each CSS Block item’s styles
Source§

type FlexboxContainerStyle<'a> = &'a Style where Self: 'a

The style type representing the Flexbox container’s styles
Source§

type FlexboxItemStyle<'a> = &'a Style where Self: 'a

The style type representing each Flexbox item’s styles
Source§

type GridContainerStyle<'a> = &'a Style where Self: 'a

The style type representing the CSS Grid container’s styles
Source§

type GridItemStyle<'a> = &'a Style where Self: 'a

The style type representing each CSS Grid item’s styles
Source§

fn get_node_context(&self) -> Option<&Self::NodeContext>

Source§

fn get_node_context_mut(&mut self) -> Option<&mut Self::NodeContext>

Source§

fn get_node_context_mut_with_core_style( &mut self, ) -> (Option<&mut Self::NodeContext>, &Self::CoreContainerStyle)

Source§

fn get_display(&self) -> Display

Source§

fn get_final_layout(&self) -> &Layout

Source§

fn set_final_layout(&mut self, layout: &Layout)

Source§

fn get_unrounded_layout(&self) -> &Layout

Source§

fn set_unrounded_layout(&mut self, layout: &Layout)

Source§

fn cache_get( &self, known_dimensions: Size<Option<f32>>, available_space: Size<AvailableSpace>, run_mode: RunMode, ) -> Option<LayoutOutput>

Source§

fn cache_store( &mut self, known_dimensions: Size<Option<f32>>, available_space: Size<AvailableSpace>, run_mode: RunMode, layout_output: LayoutOutput, )

Source§

fn cache_clear(&mut self)

Source§

fn get_core_container_style(&self) -> &Self::CoreContainerStyle

Source§

fn get_block_container_style(&self) -> Self::BlockContainerStyle<'_>

Source§

fn get_block_item_style(&self) -> Self::BlockItemStyle<'_>

Source§

fn get_flexbox_container_style(&self) -> Self::FlexboxContainerStyle<'_>

Source§

fn get_flexbox_item_style(&self) -> Self::FlexboxItemStyle<'_>

Source§

fn get_grid_container_style(&self) -> Self::GridContainerStyle<'_>

Source§

fn get_grid_item_style(&self) -> Self::GridItemStyle<'_>

Auto Trait Implementations§

§

impl<T> Freeze for LayoutNode<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LayoutNode<T>
where T: RefUnwindSafe,

§

impl<T> Send for LayoutNode<T>
where T: Send,

§

impl<T> Sync for LayoutNode<T>
where T: Sync,

§

impl<T> Unpin for LayoutNode<T>
where T: Unpin,

§

impl<T> UnwindSafe for LayoutNode<T>
where T: UnwindSafe,

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more