From d3f4e205af894f71864b278e73a6316a03b73266 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sun, 23 Oct 2011 00:01:53 +0100 Subject: [PATCH] Support split view collapse rightwards. When a divider is dragged to the right past half of the minimum width of a collapsible subview, or the divider is double clicked and the delegate returns YES for shouldCollapseSubview:forDoubleClickOnDividerAtIndex:, the subview is collapsed. This is the mirror operation of collapsing towards the left. --- AppKit/CPSplitView.j | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 5c1bdc99c..98172bc7b 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -635,12 +635,19 @@ var CPSplitViewHorizontalImage = nil, } var viewA = _subviews[dividerIndex], + viewB = _subviews[dividerIndex + 1], realPosition = MAX(MIN(position, actualMax), actualMin); - if (position < proposedMin + (actualMin - proposedMin) / 2) + // Is this position past the halfway point to collapse? + if (position < proposedMin + (actualMin - proposedMin) / 2) if ([_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)]) if ([_delegate splitView:self canCollapseSubview:viewA]) realPosition = proposedMin; + // We can also collapse to the right. + if (position > proposedMax - (proposedMax - actualMax) / 2) + if ([_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)]) + if ([_delegate splitView:self canCollapseSubview:viewB]) + realPosition = proposedMax; return realPosition; }