dioxus_tui

Struct Size

Source
pub struct Size<T> {
    pub width: T,
    pub height: T,
}
Expand description

The width and height of a Rect

Fields§

§width: T

The x extent of the rectangle

§height: T

The y extent of the rectangle

Implementations§

Source§

impl<T> Size<T>

Source

pub fn get_abs(self, axis: AbsoluteAxis) -> T

Get either the width or height depending on the AbsoluteAxis passed in

Source§

impl<T> Size<T>

Source

pub fn map<R, F>(self, f: F) -> Size<R>
where F: Fn(T) -> R,

Applies the function f to both the width and height

This is used to transform a Size<T> into a Size<R>.

Source

pub fn map_width<F>(self, f: F) -> Size<T>
where F: Fn(T) -> T,

Applies the function f to the width

Source

pub fn map_height<F>(self, f: F) -> Size<T>
where F: Fn(T) -> T,

Applies the function f to the height

Source

pub fn zip_map<Other, Ret, Func>(self, other: Size<Other>, f: Func) -> Size<Ret>
where Func: Fn(T, Other) -> Ret,

Applies the function f to both the width and height of this value and another passed value

Source§

impl Size<f32>

Source

pub const ZERO: Size<f32>

A Size with zero width and height

Source

pub fn f32_max(self, rhs: Size<f32>) -> Size<f32>

Applies f32_max to each component separately

Source§

impl Size<Option<f32>>

Source

pub const NONE: Size<Option<f32>>

A Size with None width and height

Source

pub const fn new(width: f32, height: f32) -> Size<Option<f32>>

A Size<Option<f32>> with Some(width) and Some(height) as parameters

Source

pub fn maybe_apply_aspect_ratio( self, aspect_ratio: Option<f32>, ) -> Size<Option<f32>>

Applies aspect_ratio (if one is supplied) to the Size:

  • If width is Some but height is None, then height is computed from width and aspect_ratio
  • If height is Some but width is None, then width is computed from height and aspect_ratio

If aspect_ratio is None then this function simply returns self.

Source§

impl<T> Size<Option<T>>

Source

pub fn unwrap_or(self, alt: Size<T>) -> Size<T>

Performs Option::unwrap_or on each component separately

Source

pub fn or(self, alt: Size<Option<T>>) -> Size<Option<T>>

Performs Option::or on each component separately

Source

pub fn both_axis_defined(&self) -> bool

Return true if both components are Some, else false.

Source§

impl Size<Dimension>

Source

pub const fn from_points(width: f32, height: f32) -> Size<Dimension>

Generates a Size<Dimension> using Dimension::Points values

Source

pub const fn from_percent(width: f32, height: f32) -> Size<Dimension>

Generates a Size<Dimension> using Dimension::Percent values

Source§

impl Size<AvailableSpace>

Source

pub fn into_options(self) -> Size<Option<f32>>

Convert Size<AvailableSpace> into Size<Option<f32>>

Source

pub fn maybe_set(self, value: Size<Option<f32>>) -> Size<AvailableSpace>

If passed value is Some then return AvailableSpace::Definite containing that value, else return self

Source§

impl<T> Size<T>
where T: TaffyZero,

Source

pub const fn zero() -> Size<T>

Returns a Size where both the width and height values are the zero value of the contained type (e.g. 0.0, Some(0.0), or Dimension::Points(0.0))

Source§

impl<T> Size<T>
where T: TaffyAuto,

Source

pub const fn auto() -> Size<T>

Returns a Size where both the width and height values are the auto value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

Source§

impl<T> Size<T>
where T: TaffyMinContent,

Source

pub const fn min_content() -> Size<T>

Returns a Size where both the width and height values are the min_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

Source§

impl<T> Size<T>
where T: TaffyMaxContent,

Source

pub const fn max_content() -> Size<T>

Returns a Size where both the width and height values are the max_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

Source§

impl<T> Size<T>
where T: TaffyFitContent,

Source

pub fn fit_content(argument: LengthPercentage) -> Size<T>

Returns a Size where both the width and height values are the constant fit_content value of the contained type (e.g. 2.1, Some(2.1), or Dimension::Points(2.1))

Source§

impl<T> Size<T>
where T: FromPoints,

Source

pub fn points<Input>(points_value: Input) -> Size<T>
where Input: Into<f32> + Copy,

Returns a Size where both the width and height values are the constant points value of the contained type (e.g. 2.1, Some(2.1), or Dimension::Points(2.1))

Source§

impl<T> Size<T>
where T: FromPercent,

Source

pub fn percent<Input>(percent_value: Input) -> Size<T>
where Input: Into<f32> + Copy,

Returns a Size where both the width and height values are the constant percent value of the contained type (e.g. 2.1, Some(2.1), or Dimension::Points(2.1))

Trait Implementations§

Source§

impl<U, T> Add<Size<U>> for Size<T>
where T: Add<U>,

Source§

type Output = Size<<T as Add<U>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Size<U>) -> <Size<T> as Add<Size<U>>>::Output

Performs the + operation. Read more
Source§

impl<T> Clone for Size<T>
where T: Clone,

Source§

fn clone(&self) -> Size<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> Debug for Size<T>
where T: Debug,

Source§

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

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

impl<T> Default for Size<T>
where T: Default,

Source§

fn default() -> Size<T>

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

impl<T> FromPercent for Size<T>
where T: FromPercent,

Source§

fn from_percent<Input>(percent: Input) -> Size<T>
where Input: Into<f32> + Copy,

Converts into an Into<f32> into Self
Source§

impl<T> FromPoints for Size<T>
where T: FromPoints,

Source§

fn from_points<Input>(points: Input) -> Size<T>
where Input: Into<f32> + Copy,

Converts into an Into<f32> into Self
Source§

impl<T> PartialEq for Size<T>
where T: PartialEq,

Source§

fn eq(&self, other: &Size<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> TaffyAuto for Size<T>
where T: TaffyAuto,

Source§

const AUTO: Size<T>

The auto value for type implementing TaffyZero
Source§

impl<T> TaffyFitContent for Size<T>
where T: TaffyFitContent,

Source§

fn fit_content(argument: LengthPercentage) -> Size<T>

Converts into a LengthPercentage into Self
Source§

impl<T> TaffyMaxContent for Size<T>
where T: TaffyMaxContent,

Source§

const MAX_CONTENT: Size<T>

The max_content value for type implementing TaffyZero
Source§

impl<T> TaffyMinContent for Size<T>
where T: TaffyMinContent,

Source§

const MIN_CONTENT: Size<T>

The min_content value for type implementing TaffyZero
Source§

impl<T> TaffyZero for Size<T>
where T: TaffyZero,

Source§

const ZERO: Size<T>

The zero value for type implementing TaffyZero
Source§

impl<T> Copy for Size<T>
where T: Copy,

Source§

impl<T> Eq for Size<T>
where T: Eq,

Source§

impl<T> StructuralPartialEq for Size<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Size<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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> To for T
where T: ?Sized,

Source§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
Source§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
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
Source§

impl<T> CloneAny for T
where T: Any + Clone,