[−][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| { pane_grid::Content::new(match state { PaneState::SomePane => Text::new("This is some pane"), PaneState::AnotherKindOfPane => Text::new("This is another kind of pane"), }) }) .on_drag(Message::PaneDragged) .on_resize(10, Message::PaneResized);
Implementations
impl<'a, Message, Renderer> PaneGrid<'a, Message, Renderer> where
Renderer: Renderer,
[src]
Renderer: Renderer,
pub fn new<T>(
state: &'a mut State<T>,
view: impl Fn(Pane, &'a mut T, Option<Focus>) -> Content<'a, Message, Renderer>
) -> Self
[src]
state: &'a mut State<T>,
view: impl Fn(Pane, &'a mut T, Option<Focus>) -> Content<'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 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.
pub fn on_resize<F>(self, leeway: u16, 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.
The leeway
describes the amount of space around a split that can be
used to grab it.
The grabbable area of a split will have a length of spacing + leeway
,
properly centered. In other words, a length of
(spacing + leeway) / 2.0
on either side of the split line.
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: 'a + Renderer + Renderer,
Message: 'a,
[src]
Renderer: 'a + Renderer + Renderer,
Message: 'a,
impl<'a, Message, Renderer> Widget<Message, Renderer> for PaneGrid<'a, Message, Renderer> where
Renderer: Renderer + Renderer,
[src]
Renderer: Renderer + 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]
fn overlay(
&mut self,
layout: Layout<'_>
) -> Option<Element<'_, Message, Renderer>>
[src]
&mut self,
layout: Layout<'_>
) -> Option<Element<'_, Message, Renderer>>
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> where
<Renderer as Renderer>::Style: Unpin,
<Renderer as Renderer>::Style: Unpin,
impl<'a, Message, Renderer> !UnwindSafe for PaneGrid<'a, Message, Renderer>
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]
D: AdaptFrom<S, Swp, Dwp, T>,
Dwp: WhitePoint,
Swp: WhitePoint,
T: Component + Float,
fn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
[src]
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into(self) -> D
[src]
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, U> ConvertInto<U> for T where
U: ConvertFrom<T>,
[src]
U: ConvertFrom<T>,
fn convert_into(self) -> U
[src]
fn convert_unclamped_into(self) -> U
[src]
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
[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>,