pub struct GridPlacer<'a> {
state: &'a mut GridState,
frame: Frame,
}Expand description
Places rectangles on a grid scope. Created by MenuBuilder::grid.
All coordinates are local to this scope, which makes grids combineable.
Fields§
§state: &'a mut GridState§frame: FrameImplementations§
Source§impl<'a> GridPlacer<'a>
impl<'a> GridPlacer<'a>
Sourcepub fn size_of(&self, rect: Rect) -> (usize, usize)
pub fn size_of(&self, rect: Rect) -> (usize, usize)
The resolved size of rect as (columns, rows), unbounded ends run to the edges.
§Panics
If the rect does not fit this scope.
Sourcepub fn place(
&mut self,
rect: Rect,
container: impl Into<ContainerRef>,
) -> PlacementBuilder<'_, 'a>
pub fn place( &mut self, rect: Rect, container: impl Into<ContainerRef>, ) -> PlacementBuilder<'_, 'a>
Sourcefn place_section(
&mut self,
rect: Rect,
container: ContainerRef,
mapping: SlotMapping,
kind: SectionKind,
) -> Region
fn place_section( &mut self, rect: Rect, container: ContainerRef, mapping: SlotMapping, kind: SectionKind, ) -> Region
§Panics
If the rect exceeds this scope, overlaps another placement or subgrid, the container is too small, or an explicit index mapping does not match the rect’s cell count.
Sourcepub fn place_slots<S>(
&mut self,
rect: Rect,
slots: impl IntoIterator<Item = S>,
) -> Regionwhere
S: Slot + 'static,
pub fn place_slots<S>(
&mut self,
rect: Rect,
slots: impl IntoIterator<Item = S>,
) -> Regionwhere
S: Slot + 'static,
Adds concrete pre-built slots over rect, consumed in row-major order.
The menu derives its lock set from each slot’s
SlotStorage.
Use place_boxed_slots for a heterogeneous or
already-erased collection.
§Panics
If the slot count differs from the rect’s cell count, or on the overlap/bounds conditions of place.
Sourcepub fn place_boxed_slots(
&mut self,
rect: Rect,
slots: impl IntoIterator<Item = Box<dyn Slot>>,
) -> Region
pub fn place_boxed_slots( &mut self, rect: Rect, slots: impl IntoIterator<Item = Box<dyn Slot>>, ) -> Region
Sourcefn place_result(
&mut self,
at: Rect,
slot: ResultSlot,
container: ContainerRef,
) -> Section
fn place_result( &mut self, at: Rect, slot: ResultSlot, container: ContainerRef, ) -> Section
§Panics
If the rect is not a single cell, or on the overlap/bounds conditions of a placement.
Sourcepub fn paint(&mut self, rect: Rect, stack: impl Into<ItemStack>)
pub fn paint(&mut self, rect: Rect, stack: impl Into<ItemStack>)
Paints decoration over rect. Painted cells become locked display slots of one filler container.
Paint is the bottom layer. Placements and subgrids mask it regardless of call order, and the last paint on a cell wins.
§Panics
If the rect exceeds this scope.
Sourcepub fn subgrid<R>(
&mut self,
rect: Rect,
f: impl FnOnce(&mut GridPlacer<'_>) -> R,
) -> R
pub fn subgrid<R>( &mut self, rect: Rect, f: impl FnOnce(&mut GridPlacer<'_>) -> R, ) -> R
Runs f against the sub-area rect with its own local coordinates.
Self-contained. It must fully cover its own area, parent paint does not reach in, and nothing may be placed over it afterwards.
§Panics
If the rect exceeds this scope or overlaps a placement or subgrid, or if f leaves cells uncovered.
Sourcepub fn carve_rows<R>(
&mut self,
count: usize,
f: impl FnOnce(&mut GridPlacer<'_>) -> R,
) -> R
pub fn carve_rows<R>( &mut self, count: usize, f: impl FnOnce(&mut GridPlacer<'_>) -> R, ) -> R
Sourcepub fn carve_cols<R>(
&mut self,
count: usize,
f: impl FnOnce(&mut GridPlacer<'_>) -> R,
) -> R
pub fn carve_cols<R>( &mut self, count: usize, f: impl FnOnce(&mut GridPlacer<'_>) -> R, ) -> R
Sourcepub fn rest<R>(&mut self, f: impl FnOnce(&mut GridPlacer<'_>) -> R) -> R
pub fn rest<R>(&mut self, f: impl FnOnce(&mut GridPlacer<'_>) -> R) -> R
fn carve<R>( &mut self, axis: Axis, count: usize, f: impl FnOnce(&mut GridPlacer<'_>) -> R, ) -> R
Sourcefn to_abs(&self, rect: Rect) -> Abs
fn to_abs(&self, rect: Rect) -> Abs
Resolves a scope-local rect to absolute coordinates, unbounded ends running to the scope’s edges.
§Panics
If the rect does not fit this scope.
Sourcefn in_sealed(&self, x: usize, y: usize) -> bool
fn in_sealed(&self, x: usize, y: usize) -> bool
Whether the cell (x, y) lies in a closed subgrid of this scope.
Sourcefn claim_functional(&mut self, rect: Rect, kind: PlacementKind) -> Region
fn claim_functional(&mut self, rect: Rect, kind: PlacementKind) -> Region
Claims rect for a placement and mints its region.
Sourcefn region_for(&self, abs: Abs) -> Region
fn region_for(&self, abs: Abs) -> Region
Mints the sections covering abs, one per row, with flat-adjacent rows merged.
Sourcefn check_coverage(&self)
fn check_coverage(&self)
Panics if any cell of this scope is still Cell::Empty.
Sourcefn assert_mapping(container: &ContainerRef, rect: Abs, mapping: &SlotMapping)
fn assert_mapping(container: &ContainerRef, rect: Abs, mapping: &SlotMapping)
Asserts that the mapping fits the placement’s rect and the container.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for GridPlacer<'a>
impl<'a> !UnwindSafe for GridPlacer<'a>
impl<'a> Freeze for GridPlacer<'a>
impl<'a> Send for GridPlacer<'a>
impl<'a> Sync for GridPlacer<'a>
impl<'a> Unpin for GridPlacer<'a>
impl<'a> UnsafeUnpin for GridPlacer<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>