Skip to main content

AlignmentDirectional

Struct AlignmentDirectional 

Source
pub struct AlignmentDirectional {
    pub start: f64,
    pub y: f64,
}
Expand description

An offset that’s expressed as a fraction of a Size, but whose horizontal component is dependent on the writing direction.

This can be used to indicate an offset from the left in TextDirection::Ltr text and an offset from the right in TextDirection::Rtl text without having to be aware of the current text direction.

See also:

  • Alignment, a variant that is defined in physical terms (i.e. whose horizontal component does not depend on the text direction).

Fields§

§start: f64

The distance fraction in the horizontal direction.

A value of -1.0 corresponds to the edge on the “start” side, which is the left side in TextDirection::Ltr contexts and the right side in TextDirection::Rtl contexts. A value of 1.0 corresponds to the opposite edge, the “end” side. Values are not limited to that range; values less than -1.0 represent positions beyond the start edge, and values greater than 1.0 represent positions beyond the end edge.

This value is normalized into an Alignment::x value by the resolve method.

§y: f64

The distance fraction in the vertical direction.

A value of -1.0 corresponds to the topmost edge. A value of 1.0 corresponds to the bottommost edge. Values are not limited to that range; values less than -1.0 represent positions above the top, and values greater than 1.0 represent positions below the bottom.

This value is passed through to Alignment::y unmodified by the resolve method.

Implementations§

Source§

impl AlignmentDirectional

Source

pub const TOP_START: AlignmentDirectional

The top corner on the “start” side.

Source

pub const TOP_CENTER: AlignmentDirectional

The center point along the top edge.

Consider using Alignment::TOP_CENTER instead, as it does not need to be resolved to be used.

Source

pub const TOP_END: AlignmentDirectional

The top corner on the “end” side.

Source

pub const CENTER_START: AlignmentDirectional

The center point along the “start” edge.

Source

pub const CENTER: AlignmentDirectional

The center point, both horizontally and vertically.

Consider using Alignment::CENTER instead, as it does not need to be resolved to be used.

Source

pub const CENTER_END: AlignmentDirectional

The center point along the “end” edge.

Source

pub const BOTTOM_START: AlignmentDirectional

The bottom corner on the “start” side.

Source

pub const BOTTOM_CENTER: AlignmentDirectional

The center point along the bottom edge.

Consider using Alignment::BOTTOM_CENTER instead, as it does not need to be resolved to be used.

Source

pub const BOTTOM_END: AlignmentDirectional

The bottom corner on the “end” side.

Source

pub const fn new(start: f64, y: f64) -> AlignmentDirectional

Creates a directional alignment.

Source

pub fn truncating_div(&self, other: f64) -> AlignmentDirectional

Integer divides the AlignmentDirectional in each dimension by the given factor.

Source

pub fn lerp( a: Option<AlignmentDirectional>, b: Option<AlignmentDirectional>, t: f64, ) -> Option<AlignmentDirectional>

Linearly interpolate between two AlignmentDirectionals.

If either is null, this function interpolates from AlignmentDirectional::CENTER.

Source

pub fn resolve(&self, direction: Option<TextDirection>) -> Alignment

Convert this instance into an Alignment, which uses literal coordinates.

Trait Implementations§

Source§

impl Add for AlignmentDirectional

Source§

type Output = AlignmentDirectional

The resulting type after applying the + operator.
Source§

fn add(self, other: AlignmentDirectional) -> AlignmentDirectional

Performs the + operation. Read more
Source§

impl Clone for AlignmentDirectional

Source§

fn clone(&self) -> AlignmentDirectional

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AlignmentDirectional

Source§

impl Debug for AlignmentDirectional

Source§

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

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

impl Div<f64> for AlignmentDirectional

Source§

type Output = AlignmentDirectional

The resulting type after applying the / operator.
Source§

fn div(self, other: f64) -> AlignmentDirectional

Performs the / operation. Read more
Source§

impl From<AlignmentDirectional> for AlignmentGeometry

Source§

fn from(alignment: AlignmentDirectional) -> AlignmentGeometry

Converts to this type from the input type.
Source§

impl Mul<f64> for AlignmentDirectional

Source§

type Output = AlignmentDirectional

The resulting type after applying the * operator.
Source§

fn mul(self, other: f64) -> AlignmentDirectional

Performs the * operation. Read more
Source§

impl Neg for AlignmentDirectional

Source§

type Output = AlignmentDirectional

The resulting type after applying the - operator.
Source§

fn neg(self) -> AlignmentDirectional

Performs the unary - operation. Read more
Source§

impl PartialEq for AlignmentDirectional

Source§

fn eq(&self, other: &AlignmentDirectional) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Rem<f64> for AlignmentDirectional

Source§

type Output = AlignmentDirectional

The resulting type after applying the % operator.
Source§

fn rem(self, other: f64) -> AlignmentDirectional

Performs the % operation. Read more
Source§

impl StructuralPartialEq for AlignmentDirectional

Source§

impl Sub for AlignmentDirectional

Source§

type Output = AlignmentDirectional

The resulting type after applying the - operator.
Source§

fn sub(self, other: AlignmentDirectional) -> AlignmentDirectional

Performs the - operation. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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