[−][src]Struct iced_native::widget::pane_grid::State
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.
Methods
impl<T> State<T>[src]
pub fn new(first_pane_state: T) -> (Self, Pane)[src]
Creates a new State, initializing the first pane with the provided
state.
pub fn with_configuration(config: impl Into<Configuration<T>>) -> Self[src]
Creates a new State with the given Configuration.
pub fn len(&self) -> usize[src]
Returns the total amount of panes in the State.
pub fn get(&self, pane: &Pane) -> Option<&T>[src]
Returns the internal state of the given Pane, if it exists.
pub fn get_mut(&mut self, pane: &Pane) -> Option<&mut T>[src]
Returns the internal state of the given Pane with mutability, if it
exists.
pub fn iter(&self) -> impl Iterator<Item = (&Pane, &T)>[src]
Returns an iterator over all the panes of the State, alongside its
internal state.
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&Pane, &mut T)>[src]
Returns a mutable iterator over all the panes of the State,
alongside its internal state.
pub fn layout(&self) -> &Node[src]
Returns the layout of the State.
pub fn focused(&self) -> Option<Pane>[src]
pub fn active(&self) -> Option<Pane>[src]
Returns the active Pane of the State, if there is one.
A Pane is active if it is focused and is not being dragged.
pub fn adjacent(&self, pane: &Pane, direction: Direction) -> Option<Pane>[src]
Returns the adjacent Pane of another Pane in the given
direction, if there is one.
Example
You can combine this with State::active to find the pane that is
adjacent to the current active one, and then swap them. For instance:
if let Some(active) = state.active() { if let Some(adjacent) = state.adjacent(&active, pane_grid::Direction::Right) { state.swap(&active, &adjacent); } }
pub fn focus(&mut self, pane: &Pane)[src]
Focuses the given Pane.
pub fn unfocus(&mut self)[src]
Unfocuses the current focused Pane.
pub fn split(
&mut self,
axis: Axis,
pane: &Pane,
state: T
) -> Option<(Pane, Split)>[src]
&mut self,
axis: Axis,
pane: &Pane,
state: T
) -> Option<(Pane, Split)>
Splits the given Pane into two in the given Axis and
initializing the new Pane with the provided internal state.
pub fn swap(&mut self, a: &Pane, b: &Pane)[src]
Swaps the position of the provided panes in the State.
If you want to swap panes on drag and drop in your PaneGrid, you
will need to call this method when handling a DragEvent.
pub fn resize(&mut self, split: &Split, ratio: f32)[src]
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.
pub fn close(&mut self, pane: &Pane) -> Option<T>[src]
Closes the given Pane and returns its internal state, if it exists.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for State<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for State<T> where
T: Send,
T: Send,
impl<T> Sync for State<T> where
T: Sync,
T: Sync,
impl<T> Unpin for State<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for State<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>, [src]
V: MultiLane<T>,