Struct taffy::compute::grid::types::grid_item::GridItem

source ·
pub(in compute::grid) struct GridItem {
Show 29 fields pub node: NodeId, pub source_order: u16, pub row: Line<OriginZeroLine>, pub column: Line<OriginZeroLine>, pub overflow: Point<Overflow>, pub box_sizing: BoxSizing, pub size: Size<Dimension>, pub min_size: Size<Dimension>, pub max_size: Size<Dimension>, pub aspect_ratio: Option<f32>, pub padding: Rect<LengthPercentage>, pub border: Rect<LengthPercentage>, pub margin: Rect<LengthPercentageAuto>, pub align_self: AlignSelf, pub justify_self: AlignSelf, pub baseline: Option<f32>, pub baseline_shim: f32, pub row_indexes: Line<u16>, pub column_indexes: Line<u16>, pub crosses_flexible_row: bool, pub crosses_flexible_column: bool, pub crosses_intrinsic_row: bool, pub crosses_intrinsic_column: bool, pub available_space_cache: Option<Size<Option<f32>>>, pub min_content_contribution_cache: Size<Option<f32>>, pub minimum_contribution_cache: Size<Option<f32>>, pub max_content_contribution_cache: Size<Option<f32>>, pub y_position: f32, pub height: f32,
}
Expand description

Represents a single grid item

Fields§

§node: NodeId

The id of the node that this item represents

§source_order: u16

The order of the item in the children array

We sort the list of grid items during track sizing. This field allows us to sort back the original order for final positioning

§row: Line<OriginZeroLine>

The item’s definite row-start and row-end, as resolved by the placement algorithm (in origin-zero coordinates)

§column: Line<OriginZeroLine>

The items definite column-start and column-end, as resolved by the placement algorithm (in origin-zero coordinates)

§overflow: Point<Overflow>

The item’s overflow style

§box_sizing: BoxSizing

The item’s box_sizing style

§size: Size<Dimension>

The item’s size style

§min_size: Size<Dimension>

The item’s min_size style

§max_size: Size<Dimension>

The item’s max_size style

§aspect_ratio: Option<f32>

The item’s aspect_ratio style

§padding: Rect<LengthPercentage>

The item’s padding style

§border: Rect<LengthPercentage>

The item’s border style

§margin: Rect<LengthPercentageAuto>

The item’s margin style

§align_self: AlignSelf

The item’s align_self property, or the parent’s align_items property is not set

§justify_self: AlignSelf

The item’s justify_self property, or the parent’s justify_items property is not set

§baseline: Option<f32>

The items first baseline (horizontal)

§baseline_shim: f32

Shim for baseline alignment that acts like an extra top margin TODO: Support last baseline and vertical text baselines

§row_indexes: Line<u16>

The item’s definite row-start and row-end (same as row field, except in a different coordinate system) (as indexes into the Vec stored in a grid’s AbstractAxisTracks)

§column_indexes: Line<u16>

The items definite column-start and column-end (same as column field, except in a different coordinate system) (as indexes into the Vec stored in a grid’s AbstractAxisTracks)

§crosses_flexible_row: bool

Whether the item crosses a flexible row

§crosses_flexible_column: bool

Whether the item crosses a flexible column

§crosses_intrinsic_row: bool

Whether the item crosses a intrinsic row

§crosses_intrinsic_column: bool

Whether the item crosses a intrinsic column

§available_space_cache: Option<Size<Option<f32>>>

Cache for the known_dimensions input to intrinsic sizing computation

§min_content_contribution_cache: Size<Option<f32>>

Cache for the min-content size

§minimum_contribution_cache: Size<Option<f32>>

Cache for the minimum contribution

§max_content_contribution_cache: Size<Option<f32>>

Cache for the max-content size

§y_position: f32

Final y position. Used to compute baseline alignment for the container.

§height: f32

Final height. Used to compute baseline alignment for the container.

Implementations§

source§

impl GridItem

source

pub fn new_with_placement_style_and_order<S: GridItemStyle>( node: NodeId, col_span: Line<OriginZeroLine>, row_span: Line<OriginZeroLine>, style: S, parent_align_items: AlignItems, parent_justify_items: AlignItems, source_order: u16, ) -> Self

Create a new item given a concrete placement in both axes

source

pub fn placement(&self, axis: AbstractAxis) -> Line<OriginZeroLine>

This item’s placement in the specified axis in OriginZero coordinates

source

pub fn placement_indexes(&self, axis: AbstractAxis) -> Line<u16>

This item’s placement in the specified axis as GridTrackVec indices

source

pub fn track_range_excluding_lines(&self, axis: AbstractAxis) -> Range<usize>

Returns a range which can be used as an index into the GridTrackVec in the specified axis which will produce a sub-slice of covering all the tracks and lines that this item spans excluding the lines that bound it.

source

pub fn span(&self, axis: AbstractAxis) -> u16

Returns the number of tracks that this item spans in the specified axis

source

pub fn crosses_flexible_track(&self, axis: AbstractAxis) -> bool

Returns the pre-computed value indicating whether the grid item crosses a flexible track in the specified axis

source

pub fn crosses_intrinsic_track(&self, axis: AbstractAxis) -> bool

Returns the pre-computed value indicating whether the grid item crosses an intrinsic track in the specified axis

source

pub fn spanned_track_limit( &mut self, axis: AbstractAxis, axis_tracks: &[GridTrack], axis_parent_size: Option<f32>, ) -> Option<f32>

For an item spanning multiple tracks, the upper limit used to calculate its limited min-/max-content contribution is the sum of the fixed max track sizing functions of any tracks it spans, and is applied if it only spans such tracks.

source

pub fn spanned_fixed_track_limit( &mut self, axis: AbstractAxis, axis_tracks: &[GridTrack], axis_parent_size: Option<f32>, ) -> Option<f32>

Similar to the spanned_track_limit, but excludes FitContent arguments from the limit. Used to clamp the automatic minimum contributions of an item

source

fn known_dimensions( &self, inner_node_size: Size<Option<f32>>, grid_area_size: Size<Option<f32>>, ) -> Size<Option<f32>>

Compute the known_dimensions to be passed to the child sizing functions The key thing that is being done here is applying stretch alignment, which is necessary to allow percentage sizes further down the tree to resolve properly in some cases

source

pub fn available_space( &self, axis: AbstractAxis, other_axis_tracks: &[GridTrack], other_axis_available_space: Option<f32>, get_track_size_estimate: impl Fn(&GridTrack, Option<f32>) -> Option<f32>, ) -> Size<Option<f32>>

Compute the available_space to be passed to the child sizing functions These are estimates based on either the max track sizing function or the provisional base size in the opposite axis to the one currently being sized. https://www.w3.org/TR/css-grid-1/#algo-overview

source

pub fn available_space_cached( &mut self, axis: AbstractAxis, other_axis_tracks: &[GridTrack], other_axis_available_space: Option<f32>, get_track_size_estimate: impl Fn(&GridTrack, Option<f32>) -> Option<f32>, ) -> Size<Option<f32>>

Retrieve the available_space from the cache or compute them using the passed parameters

source

pub fn margins_axis_sums_with_baseline_shims( &self, inner_node_width: Option<f32>, ) -> Size<f32>

Compute the item’s resolved margins for size contributions. Horizontal percentage margins always resolve to zero if the container size is indefinite as otherwise this would introduce a cyclic dependency.

source

pub fn min_content_contribution( &self, axis: AbstractAxis, tree: &mut impl LayoutPartialTree, available_space: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32

Compute the item’s min content contribution from the provided parameters

source

pub fn min_content_contribution_cached( &mut self, axis: AbstractAxis, tree: &mut impl LayoutPartialTree, available_space: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32

Retrieve the item’s min content contribution from the cache or compute it using the provided parameters

source

pub fn max_content_contribution( &self, axis: AbstractAxis, tree: &mut impl LayoutPartialTree, available_space: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32

Compute the item’s max content contribution from the provided parameters

source

pub fn max_content_contribution_cached( &mut self, axis: AbstractAxis, tree: &mut impl LayoutPartialTree, available_space: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32

Retrieve the item’s max content contribution from the cache or compute it using the provided parameters

source

pub fn minimum_contribution( &mut self, tree: &mut impl LayoutPartialTree, axis: AbstractAxis, axis_tracks: &[GridTrack], known_dimensions: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32

The minimum contribution of an item is the smallest outer size it can have. Specifically:

  • If the item’s computed preferred size behaves as auto or depends on the size of its containing block in the relevant axis: Its minimum contribution is the outer size that would result from assuming the item’s used minimum size as its preferred size;
  • Else the item’s minimum contribution is its min-content contribution.

Because the minimum contribution often depends on the size of the item’s content, it is considered a type of intrinsic size contribution. See: https://www.w3.org/TR/css-grid-1/#min-size-auto

source

pub fn minimum_contribution_cached( &mut self, tree: &mut impl LayoutPartialTree, axis: AbstractAxis, axis_tracks: &[GridTrack], known_dimensions: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32

Retrieve the item’s minimum contribution from the cache or compute it using the provided parameters

Trait Implementations§

source§

impl Debug for GridItem

source§

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

Formats the value using the given formatter. 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.