From 3efe33d2fb66cce268f57dbe6eec3c77071cb31f Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sun, 23 Oct 2011 12:51:51 +0100 Subject: [PATCH] Split view resize cursors for rightwards collapse. If the right/lower subview is collapsible and the divider is at its uncollapsed maximum position, continue showing the two way resize cursor to indicate additional movement is actually possible. Also show the shrink cursor when the mouse is over the divider to the left/above of a collapsed subview. --- AppKit/CPSplitView.j | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 4b96ef8bb..806d5c8c0 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -560,20 +560,34 @@ var CPSplitViewHorizontalImage = nil, // If we are currently tracking, keep the resize cursor active even outside of hit areas. if (_currentDivider === i || (_currentDivider == CPNotFound && [self cursorAtPoint:point hitDividerAtIndex:i])) { - var frame = [_subviews[i] frame], - size = frame.size[_sizeComponent], - startPosition = frame.origin[_originComponent] + size, + var frameA = [_subviews[i] frame], + sizeA = frameA.size[_sizeComponent], + startPosition = frameA.origin[_originComponent] + sizeA, + frameB = [_subviews[i + 1] frame], + sizeB = frameB.size[_sizeComponent], canShrink = [self _realPositionForPosition:startPosition - 1 ofDividerAtIndex:i] < startPosition, canGrow = [self _realPositionForPosition:startPosition + 1 ofDividerAtIndex:i] > startPosition, cursor = [CPCursor arrowCursor]; - if (size === 0) + if (sizeA === 0) canGrow = YES; // Subview is collapsed. else if (!canShrink && [_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)] && [_delegate splitView:self canCollapseSubview:_subviews[i]]) canShrink = YES; // Subview is collapsible. + if (sizeB === 0) + { + // Right/lower subview is collapsed. + canGrow = NO; + // It's safe to assume it can always be uncollapsed. + canShrink = YES; + } + else if (!canGrow && + [_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)] && + [_delegate splitView:self canCollapseSubview:_subviews[i + 1]]) + canGrow = YES; // Right/lower subview is collapsible. + if (_isVertical && canShrink && canGrow) cursor = [CPCursor resizeLeftRightCursor]; else if (_isVertical && canShrink)