[][src]Struct iced::widget::pane_grid::State

pub struct State<T> { /* fields omitted */ }

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.

Implementations

impl<T> State<T>[src]

pub fn new(first_pane_state: T) -> (State<T>, Pane)[src]

Creates a new State, initializing the first pane with the provided state.

Alongside the State, it returns the first Pane identifier.

pub fn with_configuration(config: impl Into<Configuration<T>>) -> State<T>[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]

Returns the focused Pane of the State, if there is one.

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]

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

impl<T> Clone for State<T> where
    T: Clone
[src]

impl<T> Debug for State<T> where
    T: Debug
[src]

Auto Trait Implementations

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> where
    T: Unpin

impl<T> UnwindSafe for State<T> where
    T: UnwindSafe

Blanket Implementations

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> ConvertInto<U> for T where
    U: ConvertFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,