From cf31b511986339b1f74159bd5098e83bef16582e Mon Sep 17 00:00:00 2001 From: rmottola Date: Mon, 4 Jan 2010 01:43:05 +0000 Subject: [PATCH] When adding a toolbar take in account the possibly existing in-window menu. WHen removing the in-window menu take care of shifting the toolbar view up git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29202 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/GSWindowDecorationView.m | 28 +++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 278768775..b7b38c551 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-04 Riccardo Mottola + + * Source/GSWindowDecorationView.m: When adding a toolbar take in account + the possibly existing in-window menu. + When removing the in-window menu take care of shifitng the toolbar view up. + 2010-01-03 German Arias * Source/NSPrintPanel.m, diff --git a/Source/GSWindowDecorationView.m b/Source/GSWindowDecorationView.m index f41916594..40f7f6b97 100644 --- a/Source/GSWindowDecorationView.m +++ b/Source/GSWindowDecorationView.m @@ -353,16 +353,22 @@ - (void) addToolbarView: (GSToolbarView*)toolbarView { float newToolbarViewHeight; + float contentYOrigin; [toolbarView setFrameSize: NSMakeSize(contentRect.size.width, 100)]; // Will recalculate the layout [toolbarView _reload]; newToolbarViewHeight = [toolbarView _heightFromLayout]; + + // take in account of the menubar when calculating the origin + contentYOrigin = NSMaxY(contentRect); + if ([_window menu] != nil) + contentYOrigin -= [NSMenuView menuBarHeight]; // Plug the toolbar view [toolbarView setFrame: NSMakeRect( contentRect.origin.x, - NSMaxY(contentRect), + contentYOrigin, contentRect.size.width, newToolbarViewHeight)]; [self addSubview: toolbarView]; @@ -437,6 +443,26 @@ [self changeWindowHeight: -menubarHeight]; return AUTORELEASE(v); } + else if ([v isKindOfClass: [GSToolbarView class]] == YES) + { + GSToolbarView *tv = (GSToolbarView *)v; + NSRect toolViewRect; + + if ([[_window toolbar] isVisible]) + { + /* recalculate the origin of the toolbar view */ + toolViewRect = [tv frame]; + toolViewRect = NSMakeRect( + toolViewRect.origin.x, + toolViewRect.origin.y + [NSMenuView menuBarHeight], + toolViewRect.size.width, + toolViewRect.size.height); + + /* move the toolbar view up of the menubar height */ + [tv setFrame: toolViewRect]; + [tv setNeedsDisplay:YES]; + } + } } return nil; }