Skip to main content

AspectRatio

Struct AspectRatio 

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

Expands the horizontal or vertical dimensions of a child to maintain an aspect ratio.

An anchor must be specified to determine where the child should be placed after the aspect ratio is applied.

Once the child is added, it cannot be removed.

Fields§

§anchor: (Anchor, Anchor)

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

Implementations§

Source§

impl AspectRatio

Source

pub fn new() -> Self

Creates a new AspectRatio with no child, default anchoring, a 1:1 ratio, and (Begin, Begin) alignment.

Source

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

Create a child node and bind it to the 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.

Source

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

Set the horizontal:vertical ratio to be maintained.

§Panics

If ratio <= 0.0.

Source

pub fn get_ratio(&self) -> f32

Returns the current ratio.

Source

pub fn set_ratio(&mut self, ratio: f32)

Set the horizontal:vertical ratio to be maintained.

§Panics

If ratio <= 0.0.

Source

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

Bind a child 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 AspectRatio

Source§

fn default() -> Self

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

impl UiNode for AspectRatio

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§

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.