mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-15 15:11:28 +00:00
Add support for split view shouldAdjustSizeOfSubview: delegate method.
This commit is contained in:
@@ -785,12 +785,16 @@ var CPSplitViewHorizontalImage = nil,
|
||||
nonSizableSpace = 0,
|
||||
lastSizableIndex = -1,
|
||||
totalSizablePanes = 0,
|
||||
isVertical = [self isVertical];
|
||||
isVertical = [self isVertical],
|
||||
isSizableMap = {},
|
||||
delegateRespondsToShouldAdjust = [_delegate respondsToSelector:@selector(splitView:shouldAdjustSizeOfSubview:)];
|
||||
|
||||
for (index = 0; index < count; ++index)
|
||||
{
|
||||
var view = _subviews[index],
|
||||
isSizable = isVertical ? [view autoresizingMask] & CPViewWidthSizable : [view autoresizingMask] & CPViewHeightSizable;
|
||||
isSizable = !delegateRespondsToShouldAdjust || [_delegate splitView:self shouldAdjustSizeOfSubview:view];
|
||||
|
||||
isSizableMap[index] = isSizable;
|
||||
|
||||
if (isSizable)
|
||||
{
|
||||
@@ -812,7 +816,7 @@ var CPSplitViewHorizontalImage = nil,
|
||||
{
|
||||
var view = _subviews[index],
|
||||
viewFrame = CGRectMakeCopy(bounds),
|
||||
isSizable = isVertical ? [view autoresizingMask] & CPViewWidthSizable : [view autoresizingMask] & CPViewHeightSizable;
|
||||
isSizable = isSizableMap[index];
|
||||
|
||||
if (index + 1 === count)
|
||||
viewFrame.size[_sizeComponent] = bounds.size[_sizeComponent] - viewFrame.origin[_originComponent];
|
||||
@@ -832,7 +836,6 @@ var CPSplitViewHorizontalImage = nil,
|
||||
bounds.origin[_originComponent] += viewFrame.size[_sizeComponent] + dividerThickness;
|
||||
|
||||
[view setFrame:viewFrame];
|
||||
|
||||
}
|
||||
|
||||
SPLIT_VIEW_MAYBE_POST_DID_RESIZE();
|
||||
|
||||
@@ -42,6 +42,28 @@
|
||||
[self assert:(120 - dividerThickness) equals:[viewB frameSize].height];
|
||||
}
|
||||
|
||||
- (void)testSplitView_shouldAdjustSizeOfSubview_
|
||||
{
|
||||
var dividerThickness = [splitView dividerThickness],
|
||||
delegate = [CPSplitViewDontResizeTopView new];
|
||||
|
||||
[splitView setDelegate:delegate];
|
||||
[splitView setFrame:CGRectMake(0, 0, 200, 200)];
|
||||
|
||||
// All the extra height should have gone to the bottom view.
|
||||
[self assert:50 equals:[viewA frameSize].height];
|
||||
[self assert:(150 - dividerThickness) equals:[viewB frameSize].height];
|
||||
|
||||
var viewC = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
|
||||
[splitView addSubview:viewC];
|
||||
[splitView setPosition:66 ofDividerAtIndex:0];
|
||||
[splitView setPosition:(132 + dividerThickness) ofDividerAtIndex:1];
|
||||
|
||||
[self assert:66 equals:[viewA frameSize].height];
|
||||
[self assert:66 equals:[viewB frameSize].height];
|
||||
[self assert:66 equals:[viewC frameSize].height];
|
||||
}
|
||||
|
||||
- (void)testAutosave
|
||||
{
|
||||
// Verify that the split view does not attempt to auto save without an auto save name.
|
||||
@@ -55,6 +77,17 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPSplitViewDontResizeTopView : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL)splitView:(CPSplitView)splitView shouldAdjustSizeOfSubview:(CPView)subview
|
||||
{
|
||||
var subviews = [splitView subviews];
|
||||
return (subview !== [subviews firstObject]);
|
||||
}
|
||||
|
||||
@end
|
||||
/*!
|
||||
This store always fails.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user