No longer resize the content view, when a toolbar is added or removed.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27541 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2009-01-06 22:10:18 +00:00
parent 33b3166d05
commit 2453c7843c
2 changed files with 66 additions and 71 deletions

View file

@ -1,3 +1,8 @@
2009-01-06 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSWindowDecorationView.m: No longer adjust the size of
the content view, when a toolbar is added, removed or resized.
2009-01-06 Richard Frith-Macdonald <rfm@gnu.org> 2009-01-06 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTheme.m: * Source/GSTheme.m:

View file

@ -202,6 +202,7 @@
NSView *cv = [_window contentView]; NSView *cv = [_window contentView];
NSToolbar *tb = [_window toolbar]; NSToolbar *tb = [_window toolbar];
// Wouldn't it be better to rely on the autoresize mechanism?
_autoresizes_subviews = NO; _autoresizes_subviews = NO;
[super setFrame: frameRect]; [super setFrame: frameRect];
@ -293,6 +294,9 @@
NSView *contentView = [window contentView]; NSView *contentView = [window contentView];
NSRect contentViewFrame = [contentView frame]; NSRect contentViewFrame = [contentView frame];
float newToolbarViewHeight; float newToolbarViewHeight;
NSRect orgWindowFrame;
NSRect windowFrame;
NSRect windowContentFrame;
[toolbarView setFrameSize: NSMakeSize(contentViewFrame.size.width, 100)]; [toolbarView setFrameSize: NSMakeSize(contentViewFrame.size.width, 100)];
// Will recalculate the layout // Will recalculate the layout
@ -302,66 +306,59 @@
// Plug the toolbar view // Plug the toolbar view
[toolbarView setFrame: NSMakeRect( [toolbarView setFrame: NSMakeRect(
contentViewFrame.origin.x, contentViewFrame.origin.x,
#if 1
NSMaxY(contentViewFrame), NSMaxY(contentViewFrame),
#else
NSMaxY(contentViewFrame) - newToolbarViewHeight,
#endif
contentViewFrame.size.width, contentViewFrame.size.width,
newToolbarViewHeight)]; newToolbarViewHeight)];
[self addSubview: toolbarView]; [self addSubview: toolbarView];
// Resize the content view orgWindowFrame = [window frame];
contentViewFrame.size.height -= newToolbarViewHeight; windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame
[contentView setFrame: contentViewFrame]; styleMask: [window styleMask]];
windowContentFrame.size.height += newToolbarViewHeight;
windowFrame = [isa frameRectForContentRect: windowContentFrame
styleMask: [window styleMask]];
// Keep the top of the window at the same place
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
#if 1 // Set the local frames
{ contentRect = windowContentFrame;
NSRect orgWindowFrame; windowContentFrame = windowFrame;
NSRect windowFrame; windowContentFrame.origin = NSZeroPoint;
NSRect windowContentFrame; _autoresizes_subviews = NO;
[super setFrame: windowContentFrame];
orgWindowFrame = [window frame]; // then resize the window
windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame [window setFrame: windowFrame display: YES];
styleMask: [window styleMask]];
windowContentFrame.size.height += newToolbarViewHeight;
windowFrame = [isa frameRectForContentRect: windowContentFrame
styleMask: [window styleMask]];
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
[window setFrame: windowFrame display: YES];
}
#endif
} }
- (void) removeToolbarView: (GSToolbarView *)toolbarView - (void) removeToolbarView: (GSToolbarView *)toolbarView
{ {
NSView *contentView = [window contentView];
NSRect contentViewFrame = [contentView frame];
float toolbarViewHeight = [toolbarView frame].size.height; float toolbarViewHeight = [toolbarView frame].size.height;
NSRect orgWindowFrame;
NSRect windowFrame;
NSRect windowContentFrame;
// Unplug the toolbar view // Unplug the toolbar view
[toolbarView removeFromSuperviewWithoutNeedingDisplay]; [toolbarView removeFromSuperviewWithoutNeedingDisplay];
// Resize the content view orgWindowFrame = [window frame];
contentViewFrame.size.height += toolbarViewHeight; windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame
[contentView setFrame: contentViewFrame]; styleMask: [window styleMask]];
windowContentFrame.size.height -= toolbarViewHeight;
windowFrame = [isa frameRectForContentRect: windowContentFrame
styleMask: [window styleMask]];
// Keep the top of the window at the same place
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
#if 1 // Set the local frames
{ contentRect = windowContentFrame;
NSRect orgWindowFrame; windowContentFrame = windowFrame;
NSRect windowFrame; windowContentFrame.origin = NSZeroPoint;
NSRect windowContentFrame; _autoresizes_subviews = NO;
[super setFrame: windowContentFrame];
orgWindowFrame = [window frame]; // then resize the window and display
windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame [window setFrame: windowFrame display: YES];
styleMask: [window styleMask]];
windowContentFrame.size.height -= toolbarViewHeight;
windowFrame = [isa frameRectForContentRect: windowContentFrame
styleMask: [window styleMask]];
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
[window setFrame: windowFrame display: YES];
}
#endif
} }
- (void) adjustToolbarView: (GSToolbarView *)toolbarView - (void) adjustToolbarView: (GSToolbarView *)toolbarView
@ -373,8 +370,9 @@
if (toolbarViewHeight != newToolbarViewHeight) if (toolbarViewHeight != newToolbarViewHeight)
{ {
NSView *contentView = [window contentView]; NSRect orgWindowFrame;
NSRect contentViewFrame = [contentView frame]; NSRect windowFrame;
NSRect windowContentFrame;
[toolbarView setFrame: NSMakeRect( [toolbarView setFrame: NSMakeRect(
toolbarViewFrame.origin.x, toolbarViewFrame.origin.x,
@ -382,29 +380,21 @@
toolbarViewFrame.size.width, toolbarViewFrame.size.width,
newToolbarViewHeight)]; newToolbarViewHeight)];
// Resize the content view orgWindowFrame = [window frame];
contentViewFrame.size.height += toolbarViewHeight - newToolbarViewHeight; windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame
[contentView setFrame: contentViewFrame]; styleMask: [window styleMask]];
windowContentFrame.size.height -= toolbarViewHeight - newToolbarViewHeight;
windowFrame = [isa frameRectForContentRect: windowContentFrame
styleMask: [window styleMask]];
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
// Set the local frames
contentRect = windowContentFrame;
windowContentFrame = windowFrame;
windowContentFrame.origin = NSZeroPoint;
_frame = windowContentFrame;
#if 1 // then resize the window and display
{ [window setFrame: windowFrame display: YES];
NSRect orgWindowFrame;
NSRect windowFrame;
NSRect windowContentFrame;
orgWindowFrame = [window frame];
windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame
styleMask: [window styleMask]];
windowContentFrame.size.height -= toolbarViewHeight - newToolbarViewHeight;
windowFrame = [isa frameRectForContentRect: windowContentFrame
styleMask: [window styleMask]];
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
[window setFrame: windowFrame display: YES];
}
#else
// Redisplay the window
[window display];
#endif
} }
} }