mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 16:40:50 +00:00
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:
parent
33b3166d05
commit
2453c7843c
2 changed files with 66 additions and 71 deletions
|
@ -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:
|
||||||
|
|
|
@ -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;
|
||||||
#if 1
|
windowFrame = [isa frameRectForContentRect: windowContentFrame
|
||||||
{
|
styleMask: [window styleMask]];
|
||||||
NSRect orgWindowFrame;
|
// Keep the top of the window at the same place
|
||||||
NSRect windowFrame;
|
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
|
||||||
NSRect windowContentFrame;
|
|
||||||
|
// Set the local frames
|
||||||
orgWindowFrame = [window frame];
|
contentRect = windowContentFrame;
|
||||||
windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame
|
windowContentFrame = windowFrame;
|
||||||
styleMask: [window styleMask]];
|
windowContentFrame.origin = NSZeroPoint;
|
||||||
windowContentFrame.size.height += newToolbarViewHeight;
|
_autoresizes_subviews = NO;
|
||||||
windowFrame = [isa frameRectForContentRect: windowContentFrame
|
[super setFrame: windowContentFrame];
|
||||||
styleMask: [window styleMask]];
|
|
||||||
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
|
// then resize the window
|
||||||
[window setFrame: windowFrame display: YES];
|
[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];
|
|
||||||
windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame
|
// then resize the window and display
|
||||||
styleMask: [window styleMask]];
|
[window setFrame: windowFrame display: YES];
|
||||||
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,38 +370,31 @@
|
||||||
|
|
||||||
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,
|
||||||
toolbarViewFrame.origin.y + (toolbarViewHeight - newToolbarViewHeight),
|
toolbarViewFrame.origin.y + (toolbarViewHeight - newToolbarViewHeight),
|
||||||
toolbarViewFrame.size.width,
|
toolbarViewFrame.size.width,
|
||||||
newToolbarViewHeight)];
|
newToolbarViewHeight)];
|
||||||
|
|
||||||
// Resize the content view
|
|
||||||
contentViewFrame.size.height += toolbarViewHeight - newToolbarViewHeight;
|
|
||||||
[contentView setFrame: contentViewFrame];
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
{
|
|
||||||
NSRect orgWindowFrame;
|
|
||||||
NSRect windowFrame;
|
|
||||||
NSRect windowContentFrame;
|
|
||||||
|
|
||||||
orgWindowFrame = [window frame];
|
orgWindowFrame = [window frame];
|
||||||
windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame
|
windowContentFrame = [isa contentRectForFrameRect: orgWindowFrame
|
||||||
styleMask: [window styleMask]];
|
styleMask: [window styleMask]];
|
||||||
windowContentFrame.size.height -= toolbarViewHeight - newToolbarViewHeight;
|
windowContentFrame.size.height -= toolbarViewHeight - newToolbarViewHeight;
|
||||||
windowFrame = [isa frameRectForContentRect: windowContentFrame
|
windowFrame = [isa frameRectForContentRect: windowContentFrame
|
||||||
styleMask: [window styleMask]];
|
styleMask: [window styleMask]];
|
||||||
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
|
windowFrame.origin.y += orgWindowFrame.size.height - windowFrame.size.height;
|
||||||
[window setFrame: windowFrame display: YES];
|
// Set the local frames
|
||||||
}
|
contentRect = windowContentFrame;
|
||||||
#else
|
windowContentFrame = windowFrame;
|
||||||
// Redisplay the window
|
windowContentFrame.origin = NSZeroPoint;
|
||||||
[window display];
|
_frame = windowContentFrame;
|
||||||
#endif
|
|
||||||
|
// then resize the window and display
|
||||||
|
[window setFrame: windowFrame display: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue