Commit Graph
8 Commits
Author SHA1 Message Date
David Richardson ac8253edfc CPSplitView: Restore saved layout when setting autosave name
Previously, saved layouts were restored only when loading a cib, so
split views created programmatically saved their layout without ever
restoring it.

Setting the autosave name now restores any saved layout
when subviews are already present, matching NSSplitView.
2026-11-24 12:33:17 -06:00
David Richardson cc2766c2f0 CPSplitView: Restore subview management after replacing unarranged subviews
-replaceSubview:with: previously disabled subview management and returned
early when the replaced subview was unarranged, leaving management off.
Subsequent -addSubview: calls did not arrange new subviews, and

-removeFromSuperview did not remove views from arranged subviews.
Subview management is now re-enabled across all return paths.
2026-11-24 11:20:23 -06:00
David Richardson 156335dc85 CPSplitView: Animate divider moves sent through the animator proxy
Previously, the animator proxy forwarded divider moves directly to the
split view, setting frames immediately and forcing applications to
animate subviews themselves.

CPSplitViewAnimator now animates the two adjacent subviews and the
divider within the active CPAnimationContext group. Collapsing
subviews shrink to zero and are hidden while preserving their saved
size; expanding subviews grow from zero. The split view updates to its
final state immediately, and only on-screen frames animate.
2026-11-23 17:20:56 -06:00
David Richardson b792073dcf CPSplitView: Add holding priorities and preserve arrangement on orientation change
Previously, CPSplitView had no holding priorities, so every subview the
delegate permitted to resize absorbed part of each size change, causing
sidebars to grow and shrink with the window. Additionally,
-setVertical: sized subviews from ratios summing to one per subview
kind—overflowing the split view when both kinds were present—and removed
and re-added every subview.

Each arranged subview now carries a holding priority (defaulting to
250) preserved across insertion, removal, orientation changes, and
archiving. -adjustSubviews distributes size changes first to subviews
the delegate allows to resize and then to others, ordered by ascending
priority; equal-priority subviews share changes proportionally to their
ratios, passing any remainder past zero to the next group.
-setVertical: now preserves each subview's share along the split axis
and keeps subviews arranged.
2026-11-23 17:01:48 -06:00
David Richardson 1938847271 CPSplitView: Hide dividers the delegate asks to hide, per AppKit
The split view did not ask the delegate whether to hide a divider, so every
divider took its full thickness and a collapsed sidebar left a divider line at
the edge.

The split view now sends splitView:shouldHideDividerAtIndex:. A
hidden divider has zero thickness, its view is hidden, layout and the divider
limits give it no space, and it has no drag area of its own; the delegate's
additional effective rect and button bar resize controls still apply.

When a
collapse or expansion changes the answer, the two subviews are placed again
with the new thickness.
2026-11-23 16:52:30 -06:00
David Richardson b3fe257767 CPSplitView: Update ratios and dividers when restoring autosaved state
Previously, restoration set only subview frames, leaving ratios from
the prior layout intact so a subsequent -adjustSubviews resized
subviews back to that layout and dividers remained unmoved until the
next layout pass. Restoration now updates the ratios and lays out the
split view so later resizes preserve the restored sizes.
2026-11-23 16:39:22 -06:00
David Richardson 92bf1b23de CPSplitView fix: Restore autosaved state only for the subviews it was saved for
The restore took one saved frame for each arranged subview and did not check
the count. A split view with more subviews than at the save applied
CGRectFromString(undefined) to the extra subviews. The restore now applies
saved state only when the number of saved frames, and of saved collapsed
flags, matches the number of arranged subviews; otherwise the split view
keeps its current layout.
2026-11-23 16:38:08 -06:00
David Richardson fedb45e4cc Tests: Add CPSplitView interaction tests that state NSSplitView behaviour
Add 23 tests for CPSplitView. They cover divider drags and their
delegate constraints, collapse, double-click collapse and restore,
the resize notifications, hit testing, button bar resize controls,
autosave, orientation, arranged subviews and archiving.

The tests use public behaviour only, with one exception: the
autosave tests call -_restoreFromAutosave, because only a cib load
starts a restore. They are written before the refactor and rework
of CPSplitView. Six of them fail on the current code, and each
failure records a defect:

- A collapsed subview is not hidden and does not keep its size
  (four tests).

- The divider drag posts will-resize notifications that have no
  matching did-resize notification.

- setArrangesAllSubviews:YES does not arrange the subviews that
  were added while it was NO.
2026-11-23 12:03:58 -06:00