Skip to main content

GridPlacer

Struct GridPlacer 

Source
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: Frame

Implementations§

Source§

impl<'a> GridPlacer<'a>

Source

pub const fn width(&self) -> usize

The number of columns in this scope.

Source

pub const fn height(&self) -> usize

The number of rows in this scope.

Source

pub const fn full(&self) -> Rect

The rect covering this whole scope.

Source

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.

Source

pub fn place( &mut self, rect: Rect, container: impl Into<ContainerRef>, ) -> PlacementBuilder<'_, 'a>

Starts placing slots for container over rect, first cell at container slot 0.

Configure the covered container slots with start_at or at_indices, the slot behavior with restrict, guard, display or kind, then commit with section, region or result.

Source

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.

Source

pub fn place_slots<S>( &mut self, rect: Rect, slots: impl IntoIterator<Item = S>, ) -> Region
where 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.

Source

pub fn place_boxed_slots( &mut self, rect: Rect, slots: impl IntoIterator<Item = Box<dyn Slot>>, ) -> Region

Adds heterogeneous or already-erased slots over rect in row-major order.

§Panics

If the slot count differs from the rect’s cell count, or on the overlap/bounds conditions of place.

Source

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.

Source

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.

Source

pub fn paint_all(&mut self, stack: impl Into<ItemStack>)

Paints the whole scope.

Source

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.

Source

pub fn carve_rows<R>( &mut self, count: usize, f: impl FnOnce(&mut GridPlacer<'_>) -> R, ) -> R

Carves the next count rows off this scope and runs f against them.

§Panics

If carve_cols was already used here, if fewer than count rows remain, or on the subgrid conditions.

Source

pub fn carve_cols<R>( &mut self, count: usize, f: impl FnOnce(&mut GridPlacer<'_>) -> R, ) -> R

Carves the next count columns off this scope and runs f against them.

§Panics

If carve_rows was already used here, if fewer than count columns remain, or on the subgrid conditions.

Source

pub fn rest<R>(&mut self, f: impl FnOnce(&mut GridPlacer<'_>) -> R) -> R

Carves everything remaining on the current axis and runs f against it.

§Panics

If nothing remains to carve, or on the subgrid conditions.

Source

fn carve<R>( &mut self, axis: Axis, count: usize, f: impl FnOnce(&mut GridPlacer<'_>) -> R, ) -> R

Source

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.

Source

fn in_sealed(&self, x: usize, y: usize) -> bool

Whether the cell (x, y) lies in a closed subgrid of this scope.

Source

fn claim_functional(&mut self, rect: Rect, kind: PlacementKind) -> Region

Claims rect for a placement and mints its region.

Source

fn region_for(&self, abs: Abs) -> Region

Mints the sections covering abs, one per row, with flat-adjacent rows merged.

Source

fn check_coverage(&self)

Panics if any cell of this scope is still Cell::Empty.

Source

fn assert_mapping(container: &ContainerRef, rect: Abs, mapping: &SlotMapping)

Asserts that the mapping fits the placement’s rect and the container.

Trait Implementations§

Source§

impl Debug for GridPlacer<'_>

Source§

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

Formats the value using the given formatter. Read more

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

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more