Skip to main content

Module splitter

Module splitter 

Source
Expand description

N-pane split container with draggable, collapsible dividers.

Splitter arranges N ≥ 2 panes along one axis (per Orientation) with N − 1 grabbable handles between them — the Qt QSplitter model. All layout state (per-pane size / min / max / stretch / collapsed) lives in a shared, cloneable SplitterModel; the app holds a clone to read, mutate, persist, and import/export, while the widget renders it and reacts to the model’s version signal.

Strengths carried over from the old two-pane SplitView: anti-jump drag, keyboard resize, Role::Splitter accessibility, per-pane content clipping, RTL-correct horizontal layout. New: N panes, per-pane stretch (container-resize policy), animated collapse with four triggers (programmatic / double-click / drag-past-min snap / keyboard), a Tier-3 [SplitterStyle], and serializable import/export. Intended as the building block for a future DockingLayout.

let model = SplitterModel::from_panes(vec![
    PaneDescriptor::new().size(220.0).min_size(160.0).stretch(0.0).collapsible(true),
    PaneDescriptor::new().stretch(1.0).min_size(320.0),
    PaneDescriptor::new().size(280.0).stretch(0.0).collapsible(true),
], Orientation::Horizontal);

Splitter::new(model.clone())
    .pane(sidebar).pane(editor).pane(inspector)
    .pane_label(0, tr!(sidebar()));

Structs§

PaneDescriptor
Per-pane configuration passed to SplitterModel::from_panes / SplitterModel::insert_pane. Public fields + Default so it can be built with struct-literal ..Default::default() syntax, or via the fluent setters.
PaneSnapshot
Immutable per-pane view handed to the pure distribute sizing function (the internal splitter::distribute engine).
PaneState
Persistable per-pane layout state. Captures the user-controllable values (size + collapsed); structural config (min/max/stretch/ collapsible) is app-declared and not serialized — Qt saveState parity.
Splitter
An N-pane resizable split container driven by a SplitterModel.
SplitterModel
A shared, cloneable handle to a splitter’s layout state. Clone = share-by-handle (cheap Rc bump).
SplitterState
Full serializable snapshot of a SplitterModel’s sizes + collapsed flags. Round-trips through SplitterModel::export_state / import_state and implements Versioned so apps persist it through SettingsFile<SplitterState> + Migrator (TOML).

Constants§

SPLITTER_GUTTER_THICKNESS
Default gutter (handle) thickness in logical px. Resolved into the model at construction; override with SplitterModel::set_gutter_thickness.
SPLITTER_KEYBOARD_STEP
Default keyboard resize step in logical px (per arrow press).
SPLITTER_MIN_PANE_SIZE
Default minimum pane size in logical px.
SPLITTER_SNAP_OFFSET
Default drag-past-min snap-to-collapse threshold in logical px.