Struct taffy::geometry::Line

source ·
pub struct Line<T> {
    pub start: T,
    pub end: T,
}
Expand description

An abstract “line”. Represents any type that has a start and an end

Fields§

§start: T

The start position of a line

§end: T

The end position of a line

Implementations§

source§

impl<T> Line<T>

source

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

Applies the function f to both the width and height

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

source§

impl<T: Add + Copy> Line<T>

source

pub fn sum(&self) -> <T as Add>::Output

Adds the start and end values together and returns the result

source§

impl<T: GridCoordinate> Line<GenericGridPlacement<T>>

source

pub fn is_definite(&self) -> bool

Whether the track position is definite in this axis (or the item will need auto placement) The track position is definite if least one of the start and end positions is a track index

source

pub fn indefinite_span(&self) -> u16

Resolves the span for an indefinite placement (a placement that does not consist of two Tracks). Panics if called on a definite placement

source§

impl Line<GridPlacement>

source

pub fn into_origin_zero( &self, explicit_track_count: u16 ) -> Line<GenericGridPlacement<OriginZeroLine>>

Apply a mapping function if the GridPlacement is a Track. Otherwise return self unmodified.

source§

impl Line<GenericGridPlacement<OriginZeroLine>>

source

pub fn resolve_definite_grid_lines(&self) -> Line<OriginZeroLine>

If at least one of the of the start and end positions is a track index then the other end can be resolved into a track index purely based on the information contained with the placement specification

source

pub fn resolve_absolutely_positioned_grid_tracks( &self ) -> Line<Option<OriginZeroLine>>

For absolutely positioned items:

  • Tracks resolve to definite tracks
  • For Spans:
    • If the other position is a Track, they resolve to a definite track relative to the other track
    • Else resolve to None
  • Auto resolves to None

When finally positioning the item, a value of None means that the item’s grid area is bounded by the grid container’s border box on that side.

source

pub fn resolve_indefinite_grid_tracks( &self, start: OriginZeroLine ) -> Line<OriginZeroLine>

If neither of the start and end positions is a track index then the other end can be resolved into a track index if a definite start position is supplied externally

source§

impl<T: TaffyZero> Line<T>

source

pub const fn zero() -> Self

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

source§

impl<T: TaffyAuto> Line<T>

source

pub const fn auto() -> Self

Returns a Line where both the start and end values are the auto value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

source§

impl<T: TaffyMinContent> Line<T>

source

pub const fn min_content() -> Self

Returns a Line where both the start and end values are the min_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

source§

impl<T: TaffyMaxContent> Line<T>

source

pub const fn max_content() -> Self

Returns a Line where both the start and end values are the max_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)

source§

impl<T: TaffyFitContent> Line<T>

source

pub fn fit_content(argument: LengthPercentage) -> Self

Returns a Line where both the start and end 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: FromPoints> Line<T>

source

pub fn points<Input: Into<f32> + Copy>(points_value: Input) -> Self

Returns a Line where both the start and end 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: FromPercent> Line<T>

source

pub fn percent<Input: Into<f32> + Copy>(percent_value: Input) -> Self

Returns a Line where both the start and end 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<T: Clone> Clone for Line<T>

source§

fn clone(&self) -> Line<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> Debug for Line<T>

source§

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

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

impl Default for Line<GridPlacement>

Represents the start and end points of a GridItem within a given axis

source§

fn default() -> Self

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

impl<T: FromPercent> FromPercent for Line<T>

source§

fn from_percent<Input: Into<f32> + Copy>(percent: Input) -> Self

Converts into an Into<f32> into Self
source§

impl<T: FromPoints> FromPoints for Line<T>

source§

fn from_points<Input: Into<f32> + Copy>(points: Input) -> Self

Converts into an Into<f32> into Self
source§

impl<T: PartialEq> PartialEq for Line<T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: TaffyAuto> TaffyAuto for Line<T>

source§

const AUTO: Line<T> = _

The auto value for type implementing TaffyZero
source§

impl<T: TaffyFitContent> TaffyFitContent for Line<T>

source§

fn fit_content(argument: LengthPercentage) -> Self

Converts into a LengthPercentage into Self
source§

impl TaffyGridLine for Line<GridPlacement>

source§

fn from_line_index(index: i16) -> Self

Converts an i16 into Self
source§

impl TaffyGridSpan for Line<GridPlacement>

source§

fn from_span(span: u16) -> Self

Converts an iu6 into Self
source§

impl<T: TaffyMaxContent> TaffyMaxContent for Line<T>

source§

const MAX_CONTENT: Line<T> = _

The max_content value for type implementing TaffyZero
source§

impl<T: TaffyMinContent> TaffyMinContent for Line<T>

source§

const MIN_CONTENT: Line<T> = _

The min_content value for type implementing TaffyZero
source§

impl<T: TaffyZero> TaffyZero for Line<T>

source§

const ZERO: Line<T> = _

The zero value for type implementing TaffyZero
source§

impl<T: Copy> Copy for Line<T>

source§

impl<T: Eq> Eq for Line<T>

source§

impl<T> StructuralEq for Line<T>

source§

impl<T> StructuralPartialEq for Line<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Line<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> 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> ToOwned for T
where T: Clone,

§

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

§

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

§

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.