[−][src]Struct iced_native::widget::pane_grid::PaneGrid
A collection of panes distributed using either vertical or horizontal splits to completely fill the space available.
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]
state: &'a mut State<T>,
view: impl Fn(Pane, &'a mut T, Option<Focus>) -> Element<'a, Message, Renderer>
) -> Self
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]
F: 'a + Fn(DragEvent) -> Message,
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]
F: 'a + Fn(ResizeEvent) -> Message,
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]
F: 'a + Fn(KeyPressEvent) -> Option<Message>,
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]
Renderer: 'static + Renderer,
Message: 'a,
impl<'a, Message, Renderer> Widget<Message, Renderer> for PaneGrid<'a, Message, Renderer> where
Renderer: 'static + Renderer,
[src]
Renderer: 'static + Renderer,
fn width(&self) -> Length
[src]
fn height(&self) -> Length
[src]
fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node
[src]
fn on_event(
&mut self,
event: Event,
layout: Layout,
cursor_position: Point,
messages: &mut Vec<Message>,
renderer: &Renderer,
clipboard: Option<&dyn Clipboard>
)
[src]
&mut self,
event: Event,
layout: Layout,
cursor_position: Point,
messages: &mut Vec<Message>,
renderer: &Renderer,
clipboard: Option<&dyn Clipboard>
)
fn draw(
&self,
renderer: &mut Renderer,
defaults: &Renderer::Defaults,
layout: Layout,
cursor_position: Point
) -> Renderer::Output
[src]
&self,
renderer: &mut Renderer,
defaults: &Renderer::Defaults,
layout: Layout,
cursor_position: Point
) -> Renderer::Output
fn hash_layout(&self, state: &mut Hasher)
[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]
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, 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>,
V: MultiLane<T>,