Struct backer::Node

source ·
pub struct Node<State> { /* private fields */ }
Expand description

A layout tree node. Use methods in crate::nodes to create nodes.

Implementations§

source§

impl<U> Node<U>

source

pub fn pad_leading(self, amount: f32) -> Node<U>

Adds padding to the node along the leading edge

source

pub fn pad_x(self, amount: f32) -> Node<U>

Adds horizontal padding to the node (leading & trailing)

source

pub fn pad_trailing(self, amount: f32) -> Node<U>

Adds padding to the node along the trailing edge

source

pub fn pad_top(self, amount: f32) -> Node<U>

Adds padding to the node along the top edge

source

pub fn pad_y(self, amount: f32) -> Node<U>

Adds vertical padding to the node (top & bottom)

source

pub fn pad_bottom(self, amount: f32) -> Node<U>

Adds padding to the node along the bottom edge

source

pub fn pad(self, amount: f32) -> Node<U>

Adds padding to the node on all sides

source

pub fn offset_x(self, amount: f32) -> Node<U>

Offsets the node along the x axis. This is an absolute offset that simply shifts nodes away from their calculated position This won’t impact layout besides child nodes also being offset

source

pub fn offset_y(self, amount: f32) -> Node<U>

Offsets the node along the y axis. This is an absolute offset that simply shifts nodes away from their calculated position This won’t impact layout besides child nodes also being offset

source

pub fn offset(self, offset_x: f32, offset_y: f32) -> Node<U>

Offsets the node along the x & y axis. This is an absolute offset that simply shifts nodes away from their calculated position This won’t impact layout besides child nodes also being offset

source

pub fn width(self, width: f32) -> Self

Specifies an explicit width for a node

source

pub fn height(self, height: f32) -> Self

Specifies an explicit height for a node

source

pub fn height_range<R>(self, range: R) -> Self
where R: RangeBounds<f32>,

Specifies bounds on a node’s height

source

pub fn width_range<R>(self, range: R) -> Self
where R: RangeBounds<f32>,

Specifies bounds on a node’s width

source

pub fn align(self, align: Align) -> Self

Specifies an alignment along the x and/or y axis.

This will only have an effect if the node is constrained along the axis to be smaller than the area that is available, otherwise, there’s no wiggle room.

source

pub fn aspect(self, ratio: f32) -> Self

Constrains the node’s height to ratio of width

source

pub fn dynamic_height(self, f: impl Fn(f32, &mut U) -> f32 + 'static) -> Self

Constrains the node’s height as a function of available width.

Generally you should prefer size constraints, aspect ratio constraints or area readers over dynamic height.

This is primarily for UI elements such as text where node height must depend on available width & scaling is not a simple option.

source

pub fn dynamic_width(self, f: impl Fn(f32, &mut U) -> f32 + 'static) -> Self

Constrains the node’s width as a function of available height.

Generally you should prefer size constraints, aspect ratio constraints or area readers over dynamic height.

This is primarily for UI elements such as text where node width must depend on available height & scaling is not a simple option.

Trait Implementations§

source§

impl<State> Clone for Node<State>

source§

fn clone(&self) -> Self

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<State: Debug> Debug for Node<State>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<State> Freeze for Node<State>

§

impl<State> !RefUnwindSafe for Node<State>

§

impl<State> !Send for Node<State>

§

impl<State> !Sync for Node<State>

§

impl<State> Unpin for Node<State>

§

impl<State> !UnwindSafe for Node<State>

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 T)

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