Skip to main content

Clamp

Struct Clamp 

Source
pub struct Clamp {
    pub max_override: (f32, f32),
    pub anchor: (Anchor, Anchor),
    /* private fields */
}
Expand description

Limits a node’s maximum size.

If the node’s minimum size exceeds the maximum, the minimum takes precedence.

Fields§

§max_override: (f32, f32)

The maximum size to maintain.

§anchor: (Anchor, Anchor)

The position to place the shrunken space. The child is then aligned within the new space.

Implementations§

Source§

impl Clamp

Source

pub fn new() -> Self

Creates a new Clamp with no child, a size limit of 0, default anchoring, and (Begin, Begin) alignment.

The default maximum has no effect, as the maximum is immediately overridden by the child’s min size.

Source

pub fn with_child(self, index: NodeIndex) -> Self

bind a child node.

§Panics

If there is already a child node.

Source

pub fn with_align(self, align: (Alignment, Alignment)) -> Self

Set the horizontal and vertical alignment.

Source

pub fn with_anchor(self, anchor: (Anchor, Anchor)) -> Self

Set the horizontal and vertical anchor mode for the shrunken space.

Source

pub fn with_max(self, max: (f32, f32)) -> Self

Set the maximum size.

If the maximum size is smaller than the minimum size, the minimum takes precedence.

Source

pub fn add_child(&mut self, index: NodeIndex)

Bind a child node to the node.

§Panics

If there is already a child node.

Source

pub fn get_child(&self) -> Option<NodeIndex>

Get the tree index of the child.

Trait Implementations§

Source§

impl Default for Clamp

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl UiNode for Clamp

Source§

fn get_align(&self) -> (Alignment, Alignment)

Get the alignment of the node.
Source§

fn get_align_mut(&mut self) -> (&mut Alignment, &mut Alignment)

Get a mutable reference to the alignment of the node.
Source§

fn calculate_min_size(&self, tree: &UiTree) -> (f32, f32)

Calculate the minimum size of the node. Read more
Source§

fn calculate_rects(&self, cache: &NodeCache, tree: &UiTree) -> Vec<Rect>

Recalculate the position and size of child nodes, in the same order and count as get_visible_children. Read more
Source§

fn get_children(&self) -> Vec<NodeIndex>

Get all children of the node, if applicable.
Source§

fn get_visible_children(&self) -> Vec<NodeIndex>

Get all visible children of the node, if applicable. Read more

Auto Trait Implementations§

§

impl Freeze for Clamp

§

impl RefUnwindSafe for Clamp

§

impl Send for Clamp

§

impl Sync for Clamp

§

impl Unpin for Clamp

§

impl UnsafeUnpin for Clamp

§

impl UnwindSafe for Clamp

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