From 074e9f70a0ccd571f23d25f28df054d7867707e4 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Sat, 17 Nov 2012 10:06:08 +0000 Subject: [PATCH] Fixed: incorrect `- CPWindow contentRectForFrameRect:` and `frameRectForContentRect:` for borderless windows with toolbars. The window views driving non standard windows (such as borderless or bridge windows) did not take the toolbar into account when calculating the content rect. Apart from being wrong, this could lead to the content view overlapping the toolbar if the content view was set after the toolbar was prepared. Perhaps the thought was that the base _CPWindowView shouldn't make assumptions about the placement and sizing of a toolbar and leave that up to subclasses, but the _CPWindowView tile method already did. --- AppKit/CPWindow/_CPStandardWindowView.j | 32 ------------------------- AppKit/CPWindow/_CPWindowView.j | 26 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/AppKit/CPWindow/_CPStandardWindowView.j b/AppKit/CPWindow/_CPStandardWindowView.j index 9d8fd7147..3b4b13908 100644 --- a/AppKit/CPWindow/_CPStandardWindowView.j +++ b/AppKit/CPWindow/_CPStandardWindowView.j @@ -152,38 +152,6 @@ var STANDARD_GRADIENT_HEIGHT = 41.0; return _CPStandardWindowViewDividerBackgroundColor; } -- (CGRect)contentRectForFrameRect:(CGRect)aFrameRect -{ - var contentRect = [[self class] contentRectForFrameRect:aFrameRect], - theToolbar = [[self window] toolbar]; - - if ([theToolbar isVisible]) - { - var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]); - - contentRect.origin.y += toolbarHeight; - contentRect.size.height -= toolbarHeight; - } - - return contentRect; -} - -- (CGRect)frameRectForContentRect:(CGRect)aContentRect -{ - var frameRect = [[self class] frameRectForContentRect:aContentRect], - theToolbar = [[self window] toolbar]; - - if ([theToolbar isVisible]) - { - var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]); - - frameRect.origin.y -= toolbarHeight; - frameRect.size.height += toolbarHeight; - } - - return frameRect; -} - - (id)initWithFrame:(CPRect)aFrame styleMask:(unsigned)aStyleMask { self = [super initWithFrame:aFrame styleMask:aStyleMask]; diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index ae02622cf..207a3456e 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -76,12 +76,34 @@ var _CPWindowViewResizeIndicatorImage = nil; - (CGRect)contentRectForFrameRect:(CGRect)aFrameRect { - return [[self class] contentRectForFrameRect:aFrameRect]; + var contentRect = [[self class] contentRectForFrameRect:aFrameRect], + theToolbar = [[self window] toolbar]; + + if ([theToolbar isVisible]) + { + var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]); + + contentRect.origin.y += toolbarHeight; + contentRect.size.height -= toolbarHeight; + } + + return contentRect; } - (CGRect)frameRectForContentRect:(CGRect)aContentRect { - return [[self class] frameRectForContentRect:aContentRect]; + var frameRect = [[self class] frameRectForContentRect:aContentRect], + theToolbar = [[self window] toolbar]; + + if ([theToolbar isVisible]) + { + var toolbarHeight = CGRectGetHeight([[theToolbar _toolbarView] frame]); + + frameRect.origin.y -= toolbarHeight; + frameRect.size.height += toolbarHeight; + } + + return frameRect; } - (id)initWithFrame:(CPRect)aFrame styleMask:(unsigned)aStyleMask