Struct iced::widget::pane_grid::State

source ·
pub struct State<T> {
    pub panes: HashMap<Pane, T, RandomState>,
    pub internal: Internal,
    /* private fields */
}
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: HashMap<Pane, T, RandomState>

The panes of the PaneGrid.

§internal: Internal

The internal state of the PaneGrid.

Implementations§

source§

impl<T> State<T>

source

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

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

Alongside the State, it returns the first Pane identifier.

source

pub fn with_configuration(config: impl Into<Configuration<T>>) -> State<T>

Creates a new State with the given Configuration.

source

pub fn len(&self) -> usize

Returns the total amount of panes in the State.

source

pub fn is_empty(&self) -> bool

Returns true if the amount of panes in the State is 0.

source

pub fn get(&self, pane: &Pane) -> Option<&T>

Returns the internal state of the given Pane, if it exists.

source

pub fn get_mut(&mut self, pane: &Pane) -> Option<&mut T>

Returns the internal state of the given Pane with mutability, if it exists.

source

pub fn iter(&self) -> impl Iterator<Item = (&Pane, &T)>

Returns an iterator over all the panes of the State, alongside its internal state.

source

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.

source

pub fn layout(&self) -> &Node

Returns the layout of the State.

source

pub fn adjacent(&self, pane: &Pane, direction: Direction) -> Option<Pane>

Returns the adjacent Pane of another Pane in the given direction, if there is one.

source

pub fn split(&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.

source

pub fn swap(&mut self, a: &Pane, b: &Pane)

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.

source

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.

source

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.

source

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.

source

pub fn restore(&mut self)

Restore the currently maximized Pane to it’s normal size. All panes will be rendered by the PaneGrid.

source

pub fn maximized(&self) -> Option<Pane>

Returns the maximized Pane of the PaneGrid.

Trait Implementations§

source§

impl<T> Clone for State<T>where T: Clone,

source§

fn clone(&self) -> State<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for State<T>where T: Debug,

source§

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

Formats the value using the given formatter. Read more

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§

source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere T: FloatComponent, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

source§

fn adapt_into_using<M>(self, method: M) -> Dwhere M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> IntoColor<U> for Twhere U: FromColor<T>,

source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
source§

impl<T, U> IntoColorUnclamped<U> for Twhere U: FromColorUnclamped<T>,

source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

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
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> TryIntoColor<U> for Twhere U: TryFromColor<T>,

source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

fn vzip(self) -> V

source§

impl<T> MaybeSend for Twhere T: Send,