pub struct GridLayoutState { /* private fields */ }Expand description
The state of a GridLayout: the items’ areas, the
rules the layout settles under, and any gesture in progress.
The application owns the layout. Create the state with the grid’s rules,
then its areas, and subscribe to GridLayoutEvent::Change to persist
what the user arranges.
let state = cx.new(|cx| {
GridLayoutState::new(cx).cols(12).default_areas([
GridArea::new("revenue").col_span(8).row_span(4),
GridArea::new("orders").col(8).col_span(4).row_span(4),
])
});Implementations§
Source§impl GridLayoutState
impl GridLayoutState
Sourcepub fn cols(self, cols: usize) -> Self
pub fn cols(self, cols: usize) -> Self
The number of equal columns the width is divided into. Defaults to 12.
Sourcepub fn compaction(self, compaction: Option<Axis>) -> Self
pub fn compaction(self, compaction: Option<Axis>) -> Self
The direction items float toward when space opens up, or None to
leave them wherever they are put. Defaults to Some(Axis::Vertical).
Sourcepub fn prevent_collision(self, prevent_collision: bool) -> Self
pub fn prevent_collision(self, prevent_collision: bool) -> Self
Refuse a move or resize that would overlap another item, instead of
pushing that item out of the way. Defaults to false.
Sourcepub fn resizable(self, resizable: bool) -> Self
pub fn resizable(self, resizable: bool) -> Self
Whether items can be resized. Defaults to true.
Sourcepub fn default_areas(self, areas: impl IntoIterator<Item = GridArea>) -> Self
pub fn default_areas(self, areas: impl IntoIterator<Item = GridArea>) -> Self
The areas the grid starts with, settled under the rules set so far: overlaps are pushed apart and, with compaction on, gaps close. Set the rules first.
pub fn column_count(&self) -> usize
pub fn compaction_axis(&self) -> Option<Axis>
pub fn is_collision_prevented(&self) -> bool
pub fn is_draggable(&self) -> bool
pub fn is_resizable(&self) -> bool
Sourcepub fn selected_item(&self) -> Option<&SharedString>
pub fn selected_item(&self) -> Option<&SharedString>
The item keyboard commands act on.
Sourcepub fn active_item(&self) -> Option<&SharedString>
pub fn active_item(&self) -> Option<&SharedString>
The item being dragged or resized, if a gesture is in progress.
Sourcepub fn set_areas(
&mut self,
areas: impl IntoIterator<Item = GridArea>,
cx: &mut Context<'_, Self>,
)
pub fn set_areas( &mut self, areas: impl IntoIterator<Item = GridArea>, cx: &mut Context<'_, Self>, )
Replace the layout, settling it under the grid’s rules. Cancels any
gesture in progress, and does not emit GridLayoutEvent::Change.
pub fn set_cols(&mut self, cols: usize, cx: &mut Context<'_, Self>)
pub fn set_compaction( &mut self, compaction: Option<Axis>, cx: &mut Context<'_, Self>, )
pub fn set_prevent_collision( &mut self, prevent_collision: bool, cx: &mut Context<'_, Self>, )
pub fn set_draggable(&mut self, draggable: bool, cx: &mut Context<'_, Self>)
pub fn set_resizable(&mut self, resizable: bool, cx: &mut Context<'_, Self>)
Sourcepub fn set_selected_item(
&mut self,
id: Option<SharedString>,
cx: &mut Context<'_, Self>,
)
pub fn set_selected_item( &mut self, id: Option<SharedString>, cx: &mut Context<'_, Self>, )
Select the item keyboard commands act on.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for GridLayoutState
impl !UnwindSafe for GridLayoutState
impl Forget for GridLayoutState
impl Freeze for GridLayoutState
impl Send for GridLayoutState
impl Sync for GridLayoutState
impl Unpin for GridLayoutState
impl UnsafeUnpin for GridLayoutState
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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 more