Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Side by Side Diff: chrome/browser/cocoa/browser_frame_view.mm

Issue 351010: Shifted patterns in tabs and background pattern over so that patterns line up... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/cocoa/browser_window_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/browser_frame_view.h" 5 #import "chrome/browser/cocoa/browser_frame_view.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #import <Carbon/Carbon.h> 8 #import <Carbon/Carbon.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/scoped_nsautorelease_pool.h" 11 #include "base/scoped_nsautorelease_pool.h"
12 #import "chrome/browser/cocoa/chrome_browser_window.h" 12 #import "chrome/browser/cocoa/chrome_browser_window.h"
13 #import "third_party/GTM/AppKit/GTMTheme.h" 13 #import "third_party/GTM/AppKit/GTMTheme.h"
14 14
15 // To line up our background pattern with the patterns in the tabs we need
16 // to move our background patterns in the window frame up by two pixels.
17 // This will make the themes look slightly different than in Windows/Linux
18 // because of the differing heights between window top and tab top, but this
19 // has been approved by UI.
20 static const NSInteger kBrowserFrameViewPatternPhaseOffset = 2;
21
22 @interface NSView (Swizzles) 15 @interface NSView (Swizzles)
23 - (void)drawRectOriginal:(NSRect)rect; 16 - (void)drawRectOriginal:(NSRect)rect;
24 - (BOOL)_mouseInGroup:(NSButton*)widget; 17 - (BOOL)_mouseInGroup:(NSButton*)widget;
25 - (void)updateTrackingAreas; 18 - (void)updateTrackingAreas;
26 @end 19 @end
27 20
28 @implementation BrowserFrameView 21 @implementation BrowserFrameView
29 22
30 + (void)load { 23 + (void)load {
31 // This is where we swizzle drawRect, and add in two methods that we 24 // This is where we swizzle drawRect, and add in two methods that we
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 [[NSBezierPath bezierPathWithRect:rect] addClip]; 104 [[NSBezierPath bezierPathWithRect:rect] addClip];
112 105
113 // Draw our background color if we have one, otherwise fall back on 106 // Draw our background color if we have one, otherwise fall back on
114 // system drawing. 107 // system drawing.
115 GTMTheme* theme = [self gtm_theme]; 108 GTMTheme* theme = [self gtm_theme];
116 GTMThemeState state = [window isMainWindow] ? GTMThemeStateActiveWindow 109 GTMThemeState state = [window isMainWindow] ? GTMThemeStateActiveWindow
117 : GTMThemeStateInactiveWindow; 110 : GTMThemeStateInactiveWindow;
118 NSColor* color = [theme backgroundPatternColorForStyle:GTMThemeStyleWindow 111 NSColor* color = [theme backgroundPatternColorForStyle:GTMThemeStyleWindow
119 state:state]; 112 state:state];
120 if (color) { 113 if (color) {
121 // If we have a theme pattern, draw it here. 114 // If there is a theme pattern, draw it here.
122 NSPoint phase = NSMakePoint(0, (NSHeight(windowRect) + 115
123 kBrowserFrameViewPatternPhaseOffset)); 116 // To line up the background pattern with the patterns in the tabs the
117 // background pattern in the window frame need to be moved up by two
118 // pixels and left by 5.
119 // This will make the themes look slightly different than in Windows/Linux
120 // because of the differing heights between window top and tab top, but this
121 // has been approved by UI.
122 static const NSPoint kBrowserFrameViewPatternPhaseOffset = { -5, 2 };
123 NSPoint phase = kBrowserFrameViewPatternPhaseOffset;
124 phase.y += NSHeight(windowRect);
124 [[NSGraphicsContext currentContext] setPatternPhase:phase]; 125 [[NSGraphicsContext currentContext] setPatternPhase:phase];
125 [color set]; 126 [color set];
126 NSRectFill(rect); 127 NSRectFill(rect);
127 } 128 }
128 129
129 // Check to see if we have an overlay image. 130 // Check to see if we have an overlay image.
130 NSImage* overlayImage = [theme valueForAttribute:@"overlay" 131 NSImage* overlayImage = [theme valueForAttribute:@"overlay"
131 style:GTMThemeStyleWindow 132 style:GTMThemeStyleWindow
132 state:state]; 133 state:state];
133 if (overlayImage) { 134 if (overlayImage) {
(...skipping 27 matching lines...) Expand all
161 - (void)updateTrackingAreas { 162 - (void)updateTrackingAreas {
162 [super updateTrackingAreas]; 163 [super updateTrackingAreas];
163 if ([[self window] isKindOfClass:[ChromeBrowserWindow class]]) { 164 if ([[self window] isKindOfClass:[ChromeBrowserWindow class]]) {
164 ChromeBrowserWindow* window = 165 ChromeBrowserWindow* window =
165 static_cast<ChromeBrowserWindow*>([self window]); 166 static_cast<ChromeBrowserWindow*>([self window]);
166 [window updateTrackingAreas]; 167 [window updateTrackingAreas];
167 } 168 }
168 } 169 }
169 170
170 @end 171 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698