pub struct State<T> {
pub panes: BTreeMap<Pane, T>,
pub internal: Internal,
}
Expand description
The state of a PaneGrid
.
It keeps track of the state of each Pane
and the position of each
Split
.
The State
needs to own any mutable contents a Pane
may need. This is
why this struct is generic over the type T
. Values of this type are
provided to the view function of PaneGrid::new
for displaying each
Pane
.
Fields§
§panes: BTreeMap<Pane, T>
The panes of the PaneGrid
.
internal: Internal
The internal state of the PaneGrid
.
Implementations§
Source§impl<T> State<T>
impl<T> State<T>
Sourcepub fn with_configuration(config: impl Into<Configuration<T>>) -> State<T>
pub fn with_configuration(config: impl Into<Configuration<T>>) -> State<T>
Creates a new State
with the given Configuration
.
Sourcepub fn get(&self, pane: Pane) -> Option<&T>
pub fn get(&self, pane: Pane) -> Option<&T>
Returns the internal state of the given Pane
, if it exists.
Sourcepub fn get_mut(&mut self, pane: Pane) -> Option<&mut T>
pub fn get_mut(&mut self, pane: Pane) -> Option<&mut T>
Returns the internal state of the given Pane
with mutability, if it
exists.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&Pane, &T)>
pub fn iter(&self) -> impl Iterator<Item = (&Pane, &T)>
Returns an iterator over all the panes of the State
, alongside its
internal state.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = (&Pane, &mut T)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&Pane, &mut T)>
Returns a mutable iterator over all the panes of the State
,
alongside its internal state.
Sourcepub fn split_with(&mut self, target: Pane, pane: Pane, region: Region)
pub fn split_with(&mut self, target: Pane, pane: Pane, region: Region)
Split a target Pane
with a given Pane
on a given Region
.
Panes will be swapped by default for Region::Center
.
Sourcepub fn resize(&mut self, split: Split, ratio: f32)
pub fn resize(&mut self, split: Split, ratio: f32)
Resizes two panes by setting the position of the provided Split
.
The ratio is a value in [0, 1], representing the exact position of a
Split
between two panes.
If you want to enable resize interactions in your PaneGrid
, you will
need to call this method when handling a ResizeEvent
.
Sourcepub fn close(&mut self, pane: Pane) -> Option<(T, Pane)>
pub fn close(&mut self, pane: Pane) -> Option<(T, Pane)>
Closes the given Pane
and returns its internal state and its closest
sibling, if it exists.
Sourcepub fn maximize(&mut self, pane: Pane)
pub fn maximize(&mut self, pane: Pane)
Maximize the given Pane
. Only this pane will be rendered by the
PaneGrid
until Self::restore()
is called.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for State<T>
impl<T> RefUnwindSafe for State<T>where
T: RefUnwindSafe,
impl<T> Send for State<T>where
T: Send,
impl<T> Sync for State<T>where
T: Sync,
impl<T> Unpin for State<T>
impl<T> UnwindSafe for State<T>where
T: RefUnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for 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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application
.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