From 2453c7843cb779cc55de526d6d0fd935d445b97f Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Tue, 6 Jan 2009 22:10:18 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 ++ Source/GSWindowDecorationView.m | 132 +++++++++++++++----------------- 2 files changed, 66 insertions(+), 71 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28fb38b58..9cf8a26ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-01-06 Fred Kiefer + + * 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 * Source/GSTheme.m: diff --git a/Source/GSWindowDecorationView.m b/Source/GSWindowDecorationView.m index 2ccd60f9f..28c22fc0b 100644 --- a/Source/GSWindowDecorationView.m +++ b/Source/GSWindowDecorationView.m @@ -202,6 +202,7 @@ NSView *cv = [_window contentView]; NSToolbar *tb = [_window toolbar]; + // Wouldn't it be better to rely on the autoresize mechanism? _autoresizes_subviews = NO; [super setFrame: frameRect]; @@ -293,6 +294,9 @@ NSView *contentView = [window contentView]; NSRect contentViewFrame = [contentView frame]; float newToolbarViewHeight; + NSRect orgWindowFrame; + NSRect windowFrame; + NSRect windowContentFrame; [toolbarView setFrameSize: NSMakeSize(contentViewFrame.size.width, 100)]; // Will recalculate the layout @@ -302,66 +306,59 @@ // Plug the toolbar view [toolbarView setFrame: NSMakeRect( contentViewFrame.origin.x, -#if 1 NSMaxY(contentViewFrame), -#else - NSMaxY(contentViewFrame) - newToolbarViewHeight, -#endif contentViewFrame.size.width, newToolbarViewHeight)]; [self addSubview: toolbarView]; - // Resize the content view - contentViewFrame.size.height -= newToolbarViewHeight; - [contentView setFrame: contentViewFrame]; - -#if 1 - { - NSRect orgWindowFrame; - NSRect windowFrame; - NSRect windowContentFrame; - - orgWindowFrame = [window frame]; - windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame - 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 + orgWindowFrame = [window frame]; + windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame + 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; + + // Set the local frames + contentRect = windowContentFrame; + windowContentFrame = windowFrame; + windowContentFrame.origin = NSZeroPoint; + _autoresizes_subviews = NO; + [super setFrame: windowContentFrame]; + + // then resize the window + [window setFrame: windowFrame display: YES]; } - (void) removeToolbarView: (GSToolbarView *)toolbarView { - NSView *contentView = [window contentView]; - NSRect contentViewFrame = [contentView frame]; float toolbarViewHeight = [toolbarView frame].size.height; + NSRect orgWindowFrame; + NSRect windowFrame; + NSRect windowContentFrame; // Unplug the toolbar view [toolbarView removeFromSuperviewWithoutNeedingDisplay]; - // Resize the content view - contentViewFrame.size.height += toolbarViewHeight; - [contentView setFrame: contentViewFrame]; + orgWindowFrame = [window frame]; + windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame + 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 - { - NSRect orgWindowFrame; - NSRect windowFrame; - NSRect windowContentFrame; - - orgWindowFrame = [window frame]; - windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame - 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 + // Set the local frames + contentRect = windowContentFrame; + windowContentFrame = windowFrame; + windowContentFrame.origin = NSZeroPoint; + _autoresizes_subviews = NO; + [super setFrame: windowContentFrame]; + + // then resize the window and display + [window setFrame: windowFrame display: YES]; } - (void) adjustToolbarView: (GSToolbarView *)toolbarView @@ -373,38 +370,31 @@ if (toolbarViewHeight != newToolbarViewHeight) { - NSView *contentView = [window contentView]; - NSRect contentViewFrame = [contentView frame]; - + NSRect orgWindowFrame; + NSRect windowFrame; + NSRect windowContentFrame; + [toolbarView setFrame: NSMakeRect( toolbarViewFrame.origin.x, toolbarViewFrame.origin.y + (toolbarViewHeight - newToolbarViewHeight), toolbarViewFrame.size.width, newToolbarViewHeight)]; - - // Resize the content view - contentViewFrame.size.height += toolbarViewHeight - newToolbarViewHeight; - [contentView setFrame: contentViewFrame]; - -#if 1 - { - 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 + 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; + // Set the local frames + contentRect = windowContentFrame; + windowContentFrame = windowFrame; + windowContentFrame.origin = NSZeroPoint; + _frame = windowContentFrame; + + // then resize the window and display + [window setFrame: windowFrame display: YES]; } }