compose_taffy

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 20)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
fn container<P, C>(s: Scope<P>, style: Style, content: C)
where
    P: 'static,
    C: Fn(Scope<Container>) + Clone + 'static,
{
    let scope = s.child::<Container>();
    s.create_node(
        scope,
        content,
        move |_| style.clone(),
        |style, _| LayoutNode::new(style),
        |n, style, _| {
            if n.style != style {
                n.style = style;
            }
        },
    );
}

struct Leaf;
#[track_caller]
fn leaf<P>(s: Scope<P>, style: Style)
where
    P: 'static,
{
    let scope = s.child::<Leaf>();
    s.create_node(
        scope,
        |_| {},
        move |_| style.clone(),
        |style, _| LayoutNode::new(style),
        |n, style, _| {
            if n.style != style {
                n.style = style;
                n.mark_dirty();
            }
        },
    );
}
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 44)
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
fn leaf<P>(s: Scope<P>, style: Style)
where
    P: 'static,
{
    let scope = s.child::<Leaf>();
    s.create_node(
        scope,
        |_| {},
        move |_| style.clone(),
        |style, _| LayoutNode::new(style),
        |n, style, _| {
            if n.style != style {
                n.style = style;
                n.mark_dirty();
            }
        },
    );
}

Trait Implementations§

Source§

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

Source§

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

Returns a copy 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

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 = 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.