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
impl CellOccupancyMatrix
sourcepub fn with_track_counts(columns: TrackCounts, rows: TrackCounts) -> Self
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.
sourcepub fn is_area_in_range(
&self,
primary_axis: AbsoluteAxis,
primary_range: Range<i16>,
secondary_range: Range<i16>,
) -> bool
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
sourcefn expand_to_fit_range(&mut self, row_range: Range<i16>, col_range: Range<i16>)
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
sourcepub fn mark_area_as(
&mut self,
primary_axis: AbsoluteAxis,
primary_span: Line<OriginZeroLine>,
secondary_span: Line<OriginZeroLine>,
value: CellOccupancyState,
)
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.
sourcepub fn line_area_is_unoccupied(
&self,
primary_axis: AbsoluteAxis,
primary_span: Line<OriginZeroLine>,
secondary_span: Line<OriginZeroLine>,
) -> bool
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.
sourcepub fn track_area_is_unoccupied(
&self,
primary_axis: AbsoluteAxis,
primary_range: Range<i16>,
secondary_range: Range<i16>,
) -> bool
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.
sourcepub fn row_is_occupied(&self, row_index: usize) -> bool
pub fn row_is_occupied(&self, row_index: usize) -> bool
Determines whether the specified row contains any items
sourcepub fn column_is_occupied(&self, column_index: usize) -> bool
pub fn column_is_occupied(&self, column_index: usize) -> bool
Determines whether the specified column contains any items
sourcepub fn track_counts(&self, track_type: AbsoluteAxis) -> &TrackCounts
pub fn track_counts(&self, track_type: AbsoluteAxis) -> &TrackCounts
Returns the track counts of this CellOccunpancyMatrix in the relevant axis
sourcepub fn last_of_type(
&self,
track_type: AbsoluteAxis,
start_at: OriginZeroLine,
kind: CellOccupancyState,
) -> Option<OriginZeroLine>
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.