From 887421c9faa459aa09d97c8c2a7aa42f6de807f0 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Mon, 25 Feb 2013 17:50:12 -0500 Subject: [PATCH] Fixed: window content view overlapped window frame Previously, the content view of almost all window types could overlap the frame of the window. This is a follow on to b28429f which insets the content view from the frame for all relevant window types. Refs #1798 --- AppKit/CPWindow/CPWindow.j | 2 +- AppKit/CPWindow/_CPDocModalWindowView.j | 15 +++++++++++++-- AppKit/CPWindow/_CPHUDWindowView.j | 16 ++++++++++++++++ AppKit/CPWindow/_CPTitleableWindowView.j | 2 +- AppKit/CPWindow/_CPToolTipWindowView.j | 2 +- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 05c2848f6..c1f8a677e 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -394,7 +394,7 @@ CPTexturedBackgroundWindowMask return _CPDocModalWindowView; else if (aStyleMask & _CPModalWindowMask) - return _CPModalWindowView + return _CPModalWindowView; return _CPStandardWindowView; } diff --git a/AppKit/CPWindow/_CPDocModalWindowView.j b/AppKit/CPWindow/_CPDocModalWindowView.j index ed8b64b42..5a420b986 100644 --- a/AppKit/CPWindow/_CPDocModalWindowView.j +++ b/AppKit/CPWindow/_CPDocModalWindowView.j @@ -42,6 +42,17 @@ }; } ++ (CGRect)contentRectForFrameRect:(CGRect)aFrameRect +{ + /* + This window view class draws a frame. + So we have to inset the content rect to be inside the frame. + */ + var contentRect = [super contentRectForFrameRect:aFrameRect]; + + return _CGRectInset(contentRect, 1.0, 1.0); +} + - (id)initWithFrame:(CGRect)aFrame styleMask:(unsigned)aStyleMask { self = [super initWithFrame:aFrame styleMask:aStyleMask]; @@ -67,12 +78,12 @@ - (CGRect)contentRectForFrameRect:(CGRect)aFrameRect { - return aFrameRect; + return [[self class] contentRectForFrameRect:aFrameRect]; } - (CGRect)frameRectForContentRect:(CGRect)aContentRect { - return aContentRect; + return [[self class] frameRectForContentRect:aContentRect]; } - (void)_enableSheet:(BOOL)enable diff --git a/AppKit/CPWindow/_CPHUDWindowView.j b/AppKit/CPWindow/_CPHUDWindowView.j index 28a0246dd..865b6c4d0 100644 --- a/AppKit/CPWindow/_CPHUDWindowView.j +++ b/AppKit/CPWindow/_CPHUDWindowView.j @@ -36,6 +36,22 @@ return @"hud-window-view"; } ++ (CGRect)contentRectForFrameRect:(CGRect)aFrameRect +{ + /* + This window view class draws a frame. + So we have to inset the content rect to be inside the frame. + The top coordinate has already been adjusted by _CPTitleableWindowView. + */ + var contentRect = [super contentRectForFrameRect:aFrameRect]; + + contentRect.origin.x += 1; + contentRect.size.width -= 2; + contentRect.size.height -= 1; + + return contentRect; +} + - (CGRect)contentRectForFrameRect:(CGRect)aFrameRect { var contentRect = [[self class] contentRectForFrameRect:aFrameRect]; diff --git a/AppKit/CPWindow/_CPTitleableWindowView.j b/AppKit/CPWindow/_CPTitleableWindowView.j index f363a29bc..34e597eab 100644 --- a/AppKit/CPWindow/_CPTitleableWindowView.j +++ b/AppKit/CPWindow/_CPTitleableWindowView.j @@ -36,7 +36,7 @@ + (CGRect)contentRectForFrameRect:(CGRect)aFrameRect { - var contentRect = CGRectMakeCopy(aFrameRect), + var contentRect = [super contentRectForFrameRect:aFrameRect], titleBarHeight = [self titleBarHeight]; contentRect.origin.y += titleBarHeight; diff --git a/AppKit/CPWindow/_CPToolTipWindowView.j b/AppKit/CPWindow/_CPToolTipWindowView.j index c11e425b2..423725fb7 100644 --- a/AppKit/CPWindow/_CPToolTipWindowView.j +++ b/AppKit/CPWindow/_CPToolTipWindowView.j @@ -54,7 +54,7 @@ */ + (CGRect)contentRectForFrameRect:(CGRect)aFrameRect { - var contentRect = CGRectMakeCopy(aFrameRect); + var contentRect = [super contentRectForFrameRect:aFrameRect]; contentRect.origin.x += 3; contentRect.origin.y += 3;