summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/floating_bar_backing_view.mm
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 15:01:23 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 15:01:23 +0000
commit9b0b5b1d9f92505192c1c0a98bbdf3ad70e78842 (patch)
tree56500538767752092c22aa594efe1cad8e647d6c /chrome/browser/cocoa/floating_bar_backing_view.mm
parent89b4fbf77e6e36efa7b10adce0f383ecbd00a034 (diff)
downloadchromium_src-9b0b5b1d9f92505192c1c0a98bbdf3ad70e78842.zip
chromium_src-9b0b5b1d9f92505192c1c0a98bbdf3ad70e78842.tar.gz
chromium_src-9b0b5b1d9f92505192c1c0a98bbdf3ad70e78842.tar.bz2
[Mac] Fixes floating bar pattern drawing.
BUG=31638 TEST=Install the Topography theme. When in fullscreen mode, the background in the tabs should line up with the window background. Review URL: http://codereview.chromium.org/593041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/floating_bar_backing_view.mm')
-rw-r--r--chrome/browser/cocoa/floating_bar_backing_view.mm31
1 files changed, 19 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/floating_bar_backing_view.mm b/chrome/browser/cocoa/floating_bar_backing_view.mm
index b44c244..b4f7054 100644
--- a/chrome/browser/cocoa/floating_bar_backing_view.mm
+++ b/chrome/browser/cocoa/floating_bar_backing_view.mm
@@ -17,30 +17,37 @@
[[NSColor windowBackgroundColor] set];
NSRectFill(rect);
- // Code basically clipped from browser_frame_view.mm, with modifications to
- // not use window rect and not draw rounded corners.
+ // The code here mirrors the code in browser_frame_view.mm, with modifications
+ // to not use window rect and not draw rounded corners.
NSRect bounds = [self bounds];
- // Draw our background color if we have one, otherwise fall back on
- // system drawing.
+ // Draw our background image or theme pattern, if one exists.
GTMTheme* theme = [self gtm_theme];
GTMThemeState state = isMainWindow ? GTMThemeStateActiveWindow
: GTMThemeStateInactiveWindow;
NSColor* color = [theme backgroundPatternColorForStyle:GTMThemeStyleWindow
state:state];
if (color) {
- // If there is a theme pattern, draw it here.
-
- // To line up the background pattern with the patterns in the tabs the
- // background pattern in the window frame need to be moved up by two
- // pixels and left by 5.
+ // The titlebar/tabstrip header on the mac is slightly smaller than on
+ // Windows. To keep the window background lined up with the tab and toolbar
+ // patterns, we have to shift the pattern slightly, rather than simply
+ // drawing it from the top left corner. The offset below was empirically
+ // determined in order to line these patterns up.
+ //
// This will make the themes look slightly different than in Windows/Linux
// because of the differing heights between window top and tab top, but this
// has been approved by UI.
static const NSPoint kBrowserFrameViewPatternPhaseOffset = { -5, 2 };
- NSPoint phase = kBrowserFrameViewPatternPhaseOffset;
- phase.y += NSHeight(bounds);
- phase = [self gtm_themePatternPhase];
+ NSPoint offsetTopLeft = kBrowserFrameViewPatternPhaseOffset;
+ offsetTopLeft.y += NSHeight(bounds);
+
+ // We want the pattern to start at the upper left corner of the floating
+ // bar, but the phase needs to be in the coordinate system of
+ // |windowChromeView|.
+ NSView* windowChromeView = [[[self window] contentView] superview];
+ NSPoint phase = [self convertPoint:offsetTopLeft toView:windowChromeView];
+
+ // Apply the offset.
[[NSGraphicsContext currentContext] setPatternPhase:phase];
[color set];
NSRectFill(rect);