mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
* Headers/AppKit/NSSplitView.h:
* Source/NSSplitView.m: Add support for splitView:shouldAdjustSizeOfSubview: delegate method. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35002 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
51e255fffe
commit
a900e2f5cb
3 changed files with 58 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
2012-03-26 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Headers/AppKit/NSSplitView.h:
|
||||
* Source/NSSplitView.m: Add support for
|
||||
splitView:shouldAdjustSizeOfSubview: delegate method.
|
||||
|
||||
2012-03-26 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Images: Add NSAddTemplate.tiff
|
||||
|
|
|
@ -148,6 +148,11 @@ forDoubleClickOnDividerAtIndex: (NSInteger)dividerIndex;
|
|||
- (BOOL) splitView: (NSSplitView *)splitView
|
||||
shouldHideDividerAtIndex: (NSInteger)dividerIndex;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
- (BOOL) splitView: (NSSplitView *)splitView
|
||||
shouldAdjustSizeOfSubview: (NSView *)view;
|
||||
#endif
|
||||
@end
|
||||
|
||||
/* Notifications */
|
||||
|
|
|
@ -766,6 +766,17 @@ static NSNotificationCenter *nc = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (BOOL) _shouldAdjustSubviewAtIndex: (NSUInteger)index
|
||||
{
|
||||
if (_delegate != nil
|
||||
&& [_delegate respondsToSelector: @selector(splitView:shouldAdjustSizeOfSubview:)])
|
||||
{
|
||||
return [_delegate splitView: self
|
||||
shouldAdjustSizeOfSubview: [[self subviews] objectAtIndex: index]];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) adjustSubviews
|
||||
{
|
||||
/* Try to load the autosaved view proportions, if any; if there are
|
||||
|
@ -779,13 +790,20 @@ static NSNotificationCenter *nc = nil;
|
|||
NSPoint newPoint;
|
||||
unsigned i;
|
||||
BOOL autoloading = NO;
|
||||
double proportionsTotal = 1.0;
|
||||
double proportions[count];
|
||||
BOOL shouldAdjust[count];
|
||||
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
[nc postNotificationName: NSSplitViewWillResizeSubviewsNotification
|
||||
object: self];
|
||||
object: self];
|
||||
|
||||
for (i = 0; i < (count - 1); i++)
|
||||
{
|
||||
shouldAdjust[i] = [self _shouldAdjustSubviewAtIndex: i];
|
||||
}
|
||||
|
||||
/* Try loading the autosaved view proportions. We store the
|
||||
* proportions between the size of each view and the size of the
|
||||
|
@ -864,6 +882,18 @@ static NSNotificationCenter *nc = nil;
|
|||
}
|
||||
}
|
||||
|
||||
// For any subviews we aren't resizing, subtract their
|
||||
// proportion from the total
|
||||
|
||||
for (i = 0; i < (count - 1); i++)
|
||||
{
|
||||
if (!shouldAdjust[i])
|
||||
{
|
||||
proportionsTotal -= proportions[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_isVertical == NO)
|
||||
{
|
||||
float newTotal = NSHeight(_bounds) - _dividerWidth*(count - 1);
|
||||
|
@ -875,7 +905,14 @@ static NSNotificationCenter *nc = nil;
|
|||
|
||||
if (i < (count - 1))
|
||||
{
|
||||
newHeight = proportions[i] * newTotal;
|
||||
if (shouldAdjust[i])
|
||||
{
|
||||
newHeight = (proportions[i] / proportionsTotal) * newTotal;
|
||||
}
|
||||
else
|
||||
{
|
||||
newHeight = NSHeight([views[i] frame]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -900,7 +937,14 @@ static NSNotificationCenter *nc = nil;
|
|||
|
||||
if (i < (count - 1))
|
||||
{
|
||||
newWidth = proportions[i] * newTotal;
|
||||
if (shouldAdjust[i])
|
||||
{
|
||||
newWidth = (proportions[i] / proportionsTotal) * newTotal;
|
||||
}
|
||||
else
|
||||
{
|
||||
newWidth = NSWidth([views[i] frame]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue