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
This commit is contained in:
Riccardo Mottola 2010-01-04 01:43:05 +00:00
parent a7410c2e6d
commit 47422f87d4
2 changed files with 33 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2010-01-04 Riccardo Mottola <rmottola@users.sf.net>
* 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 <german@xelalug.org> 2010-01-03 German Arias <german@xelalug.org>
* Source/NSPrintPanel.m, * Source/NSPrintPanel.m,

View file

@ -353,16 +353,22 @@
- (void) addToolbarView: (GSToolbarView*)toolbarView - (void) addToolbarView: (GSToolbarView*)toolbarView
{ {
float newToolbarViewHeight; float newToolbarViewHeight;
float contentYOrigin;
[toolbarView setFrameSize: NSMakeSize(contentRect.size.width, 100)]; [toolbarView setFrameSize: NSMakeSize(contentRect.size.width, 100)];
// Will recalculate the layout // Will recalculate the layout
[toolbarView _reload]; [toolbarView _reload];
newToolbarViewHeight = [toolbarView _heightFromLayout]; 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 // Plug the toolbar view
[toolbarView setFrame: NSMakeRect( [toolbarView setFrame: NSMakeRect(
contentRect.origin.x, contentRect.origin.x,
NSMaxY(contentRect), contentYOrigin,
contentRect.size.width, contentRect.size.width,
newToolbarViewHeight)]; newToolbarViewHeight)];
[self addSubview: toolbarView]; [self addSubview: toolbarView];
@ -437,6 +443,26 @@
[self changeWindowHeight: -menubarHeight]; [self changeWindowHeight: -menubarHeight];
return AUTORELEASE(v); 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; return nil;
} }