iced-cube

Layout

Split pane

Two views, a start and an end, with one handle between them and a ratio that says how the space is shared.

use iced_cube::layout::split_pane::{Axis, Event, Extent, State, split_pane};
API reference
Editor and preview: A text editor beside its live preview. Below 480 pixels the two stack.Editor and preview: A text editor beside its live preview. Below 480 pixels the two stack.
Static preview
Editor and preview. A text editor beside its live preview. Below 480 pixels the two stack.

Usage

A split pane is a resizable panel group with exactly two panels, so it is a thin wrapper rather than a widget of its own. The state wraps the group’s state and adds the ratio, and the view is the same widget. Dragging, keyboard resizing, collapsing and stacking on small screens all behave exactly as they do for resizable panels, and the events, keymap and actions are the same types.

Use a split pane when there are two views and the ratio is all you need to keep. For three or more panels, or for a sidebar with a pixel width beside a flexible page, use a resizable panel.

Examples

Vertical

A query above its results, each with a minimum height.

Vertical: A query above its results, each with a minimum height.Vertical: A query above its results, each with a minimum height.
Static preview

API

ItemDescription
State::new(ratio)A split with the start view taking the given share, from 0.0 to 1.0. Out of range values are clamped. State::default() is an even split.
.min(start, end) / .max(start, end)The smallest and largest each view may get, as Extent::Fraction or Extent::Pixels.
.collapsible(start, end)Lets either view snap shut when dragged below its threshold.
State::with_panels(start, end)Builds the split from two resizable panel settings, for anything the shortcuts above do not cover.
.with_ratio(ratio) / state.set_ratio(ratio)Restores a saved ratio, fitted to the limits.
state.ratio()The start view's share, ready to save.
state.update(Event)Applies the events the view sends. Returns Output::Resized, Collapsed or Expanded.
state.is_start_collapsed() / state.is_end_collapsed()Whether either view is collapsed.
split_pane(&state, start, end)Shows the two views with a handle between them. The handle does nothing until .on_event is set.
.axis(Axis) / .stack_below(width)Side by side by default, or stacked with Axis::Vertical. stack_below stacks a horizontal split on narrow screens.
.grip(bool)Shows a grip on the handle. On by default.
.id(id) / .keymap(Keymap<Action>)The handle's id for focusing it, and the shortcuts it resolves while focused.

Keyboard

Default shortcuts. Every one can be changed or removed with a keymap; see Keyboard shortcuts.

KeysAction
ArrowLeft or ArrowUpDecrease Moves the focused handle one step towards the start.
ArrowRight or ArrowDownIncrease Moves the focused handle one step towards the end.
Shift+ArrowLeft or Shift+ArrowUpDecreaseMore Moves the focused handle a large step towards the start.
Shift+ArrowRight or Shift+ArrowDownIncreaseMore Moves the focused handle a large step towards the end.
HomeMin Shrinks the panel before the handle to its minimum.
EndMax Grows the panel before the handle to its maximum.
EnterToggle Collapses or expands the collapsible panel next to the handle.
EscapeRelease Takes the focus away from the handle.
Esc