Linked-divider preset snapping + animated transitions for the stack

Rework 3-pane divider behavior and animate every layout change:

- All transitions now ease over ~100ms via a LayoutAnim between two full stack
  configs (resize, slide, collapse, fullscreen) instead of jumping; edge
  transitions continue from the drag's progress.
- 3-pane dividers are linked along a single path parameter through the three
  presets ([.5,.25,.25] / even / [.25,.25,.5]) so both dividers move together
  and reach their snaps simultaneously. Over-grow past the extreme preset is
  anchored to the path endpoint so the non-dragged divider stays continuous.
- Growing a pane past ~66% collapses the window to 2 panes (dropping the
  opposite-end pane); the surviving divider snaps to the nearest 2-pane preset
  (1/4, 1/2, 3/4) based on the drop position. Dragging to the slide extreme
  still slides the window.
- 2-pane snaps to 1/4, 1/2, 3/4.
This commit is contained in:
Skyler Lehmkuhl
2026-06-30 02:07:31 -04:00
parent 01fe14f197
commit b25e639a1c
2 changed files with 282 additions and 114 deletions
@@ -118,12 +118,18 @@ pub struct StackDrag {
pub offset: f32,
}
/// A short ease of the visible pane weights toward their snapped values after a divider release.
/// A short ease between two stack layouts (resize snap, membership change, or fullscreen toggle).
/// Both endpoints are full configs so the same animation covers panes resizing AND panes
/// entering/leaving the window.
#[derive(Debug, Clone, Copy)]
pub struct SnapAnim {
pub from: [f32; 3],
pub to: [f32; 3],
/// egui time (seconds) when the animation started.
pub struct LayoutAnim {
pub from_top: usize,
pub from_count: usize,
pub from_w: [f32; 3],
pub to_top: usize,
pub to_count: usize,
pub to_w: [f32; 3],
/// egui time (seconds) when the animation started (may be back-dated to continue a drag).
pub start: f64,
}
@@ -140,8 +146,8 @@ pub struct MobileState {
pub show_instruments: bool,
/// Active handle drag (transient).
pub drag: Option<StackDrag>,
/// In-flight snap ease after a divider release (transient).
pub snap_anim: Option<SnapAnim>,
/// In-flight layout ease (transient).
pub anim: Option<LayoutAnim>,
}
impl Default for MobileState {
@@ -153,7 +159,7 @@ impl Default for MobileState {
weights: [1.0, 1.0, 1.0],
show_instruments: false,
drag: None,
snap_anim: None,
anim: None,
}
}
}