[][src]Struct iced_native::widget::pane_grid::PaneGrid

pub struct PaneGrid<'a, Message, Renderer> { /* fields omitted */ }

A collection of panes distributed using either vertical or horizontal splits to completely fill the space available.

Pane grid - Iced

This distribution of space is common in tiling window managers (like awesome, i3, or even tmux).

A PaneGrid supports:

  • Vertical and horizontal splits
  • Tracking of the last active pane
  • Mouse-based resizing
  • Drag and drop to reorganize panes
  • Hotkey support
  • Configurable modifier keys
  • State API to perform actions programmatically (split, swap, resize, etc.)

Example

enum PaneState {
    SomePane,
    AnotherKindOfPane,
}

enum Message {
    PaneDragged(pane_grid::DragEvent),
    PaneResized(pane_grid::ResizeEvent),
}

let (mut state, _) = pane_grid::State::new(PaneState::SomePane);

let pane_grid =
    PaneGrid::new(&mut state, |pane, state, focus| {
        match state {
            PaneState::SomePane => Text::new("This is some pane"),
            PaneState::AnotherKindOfPane => Text::new("This is another kind of pane"),
        }.into()
    })
    .on_drag(Message::PaneDragged)
    .on_resize(Message::PaneResized);

Methods

impl<'a, Message, Renderer> PaneGrid<'a, Message, Renderer>[src]

pub fn new<T>(
    state: &'a mut State<T>,
    view: impl Fn(Pane, &'a mut T, Option<Focus>) -> Element<'a, Message, Renderer>
) -> Self
[src]

Creates a PaneGrid with the given State and view function.

The view function will be called to display each Pane present in the State.

pub fn width(self, width: Length) -> Self[src]

Sets the width of the PaneGrid.

pub fn height(self, height: Length) -> Self[src]

Sets the height of the PaneGrid.

pub fn spacing(self, units: u16) -> Self[src]

Sets the spacing between the panes of the PaneGrid.

pub fn modifier_keys(self, modifier_keys: ModifiersState) -> Self[src]

Sets the modifier keys of the PaneGrid.

The modifier keys will need to be pressed to trigger dragging, resizing, and key events.

The default modifier key is Ctrl.

pub fn on_drag<F>(self, f: F) -> Self where
    F: 'a + Fn(DragEvent) -> Message, 
[src]

Enables the drag and drop interactions of the PaneGrid, which will use the provided function to produce messages.

Panes can be dragged using Modifier keys + Left click.

pub fn on_resize<F>(self, f: F) -> Self where
    F: 'a + Fn(ResizeEvent) -> Message, 
[src]

Enables the resize interactions of the PaneGrid, which will use the provided function to produce messages.

Panes can be resized using Modifier keys + Right click.

pub fn on_key_press<F>(self, f: F) -> Self where
    F: 'a + Fn(KeyPressEvent) -> Option<Message>, 
[src]

Captures hotkey interactions with the PaneGrid, using the provided function to produce messages.

The function will be called when:

  • a Pane is focused
  • a key is pressed
  • all the modifier keys are pressed

If the function returns None, the key press event will be discarded without producing any message.

This method is particularly useful to implement hotkey interactions. For instance, you can use it to enable splitting, swapping, or resizing panes by pressing combinations of keys.

Trait Implementations

impl<'a, Message, Renderer> From<PaneGrid<'a, Message, Renderer>> for Element<'a, Message, Renderer> where
    Renderer: 'static + Renderer,
    Message: 'a, 
[src]

impl<'a, Message, Renderer> Widget<Message, Renderer> for PaneGrid<'a, Message, Renderer> where
    Renderer: 'static + Renderer
[src]

Auto Trait Implementations

impl<'a, Message, Renderer> !RefUnwindSafe for PaneGrid<'a, Message, Renderer>

impl<'a, Message, Renderer> !Send for PaneGrid<'a, Message, Renderer>

impl<'a, Message, Renderer> !Sync for PaneGrid<'a, Message, Renderer>

impl<'a, Message, Renderer> Unpin for PaneGrid<'a, Message, Renderer>

impl<'a, Message, Renderer> !UnwindSafe for PaneGrid<'a, Message, Renderer>

Blanket Implementations

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> From<T> for T[src]

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

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>,