Struct taffy::compute::grid::types::cell_occupancy::CellOccupancyMatrix

source ·
pub(crate) struct CellOccupancyMatrix {
    inner: Grid<CellOccupancyState>,
    columns: TrackCounts,
    rows: TrackCounts,
}
Expand description

A dynamically sized matrix (2d grid) which tracks the occupancy of each grid cell during auto-placement It also keeps tabs on how many tracks there are and which tracks are implicit and which are explicit.

Fields§

§inner: Grid<CellOccupancyState>

The grid of occupancy states

§columns: TrackCounts

The counts of implicit and explicit columns

§rows: TrackCounts

The counts of implicit and explicit rows

Implementations§

source§

impl CellOccupancyMatrix

source

pub fn with_track_counts(columns: TrackCounts, rows: TrackCounts) -> Self

Create a CellOccupancyMatrix given a set of provisional track counts. The grid can expand as needed to fit more tracks, the provisional track counts represent a best effort attempt to avoid the extra allocations this requires.

source

pub fn is_area_in_range( &self, primary_axis: AbsoluteAxis, primary_range: Range<i16>, secondary_range: Range<i16>, ) -> bool

Determines whether the specified area fits within the tracks currently represented by the matrix

source

fn expand_to_fit_range(&mut self, row_range: Range<i16>, col_range: Range<i16>)

Expands the grid (potentially in all 4 directions) in order to ensure that the specified range fits within the allocated space

source

pub fn mark_area_as( &mut self, primary_axis: AbsoluteAxis, primary_span: Line<OriginZeroLine>, secondary_span: Line<OriginZeroLine>, value: CellOccupancyState, )

Mark an area of the matrix as occupied, expanding the allocated space as necessary to accommodate the passed area.

source

pub fn line_area_is_unoccupied( &self, primary_axis: AbsoluteAxis, primary_span: Line<OriginZeroLine>, secondary_span: Line<OriginZeroLine>, ) -> bool

Determines whether a grid area specified by the bounding grid lines in OriginZero coordinates is entirely unnocupied. Returns true if all grid cells within the grid area are unnocupied, else false.

source

pub fn track_area_is_unoccupied( &self, primary_axis: AbsoluteAxis, primary_range: Range<i16>, secondary_range: Range<i16>, ) -> bool

Determines whether a grid area specified by a range of indexes into this CellOccupancyMatrix is entirely unnocupied. Returns true if all grid cells within the grid area are unnocupied, else false.

source

pub fn row_is_occupied(&self, row_index: usize) -> bool

Determines whether the specified row contains any items

source

pub fn column_is_occupied(&self, column_index: usize) -> bool

Determines whether the specified column contains any items

source

pub fn track_counts(&self, track_type: AbsoluteAxis) -> &TrackCounts

Returns the track counts of this CellOccunpancyMatrix in the relevant axis

source

pub fn last_of_type( &self, track_type: AbsoluteAxis, start_at: OriginZeroLine, kind: CellOccupancyState, ) -> Option<OriginZeroLine>

Given an axis and a track index Search backwards from the end of the track and find the last grid cell matching the specified state (if any) Return the index of that cell or None.

Trait Implementations§

source§

impl Debug for CellOccupancyMatrix

Debug impl that represents the matrix in a compact 2d text format

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.