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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_utils.mm

Issue 7734003: Implement basic theming for panel titlebars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/cocoa/browser_window_utils.h" 5 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 9 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" 11 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
12 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" 12 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h"
13 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
13 #include "content/common/native_web_keyboard_event.h" 14 #include "content/common/native_web_keyboard_event.h"
14 15
15 @interface MenuWalker : NSObject 16 @interface MenuWalker : NSObject
16 + (NSMenuItem*)itemForKeyEquivalent:(NSEvent*)key 17 + (NSMenuItem*)itemForKeyEquivalent:(NSEvent*)key
17 menu:(NSMenu*)menu; 18 menu:(NSMenu*)menu;
18 @end 19 @end
19 20
20 @implementation MenuWalker 21 @implementation MenuWalker
21 + (NSMenuItem*)itemForKeyEquivalent:(NSEvent*)key 22 + (NSMenuItem*)itemForKeyEquivalent:(NSEvent*)key
22 menu:(NSMenu*)menu { 23 menu:(NSMenu*)menu {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if ([event_window handleExtraWindowKeyboardShortcut:event]) 115 if ([event_window handleExtraWindowKeyboardShortcut:event])
115 return true; 116 return true;
116 117
117 if ([event_window handleDelayedWindowKeyboardShortcut:event]) 118 if ([event_window handleDelayedWindowKeyboardShortcut:event])
118 return true; 119 return true;
119 } 120 }
120 121
121 return [event_window redispatchKeyEvent:event]; 122 return [event_window redispatchKeyEvent:event];
122 } 123 }
123 124
125 + (NSString*)scheduleReplaceOldTitle:(NSString*)oldTitle
126 withNewTitle:(NSString*)newTitle
127 forWindow:(NSWindow*)window {
128 if (oldTitle)
129 [[NSRunLoop currentRunLoop]
130 cancelPerformSelector:@selector(setTitle:)
131 target:window
132 argument:oldTitle];
133
134 [[NSRunLoop currentRunLoop]
135 performSelector:@selector(setTitle:)
136 target:window
137 argument:newTitle
138 order:0
139 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
140 return [newTitle copy];
Nico 2013/03/04 14:07:02 Doesn't this leak? Who frees this?
141 }
142
143 // Our patterns want to be drawn from the upper left hand corner of the view.
144 // Cocoa wants to do it from the lower left of the window.
145 //
146 // Rephase our pattern to fit this view. Some other views (Tabs, Toolbar etc.)
147 // will phase their patterns relative to this so all the views look right.
148 //
149 // To line up the background pattern with the pattern in the browser window
150 // the background pattern for the tabs needs to be moved left by 5 pixels.
151 const CGFloat kPatternHorizontalOffset = -5;
152 // To match Windows and CrOS, have to offset vertically by 2 pixels.
153 // Without tab strip, offset an extra pixel (determined by experimentation).
154 const CGFloat kPatternVerticalOffset = 2;
155 const CGFloat kPatternVerticalOffsetNoTabStrip = 3;
156
157
158 + (NSPoint)themePatternPhaseFor:(NSView*)windowView
159 withTabStrip:(NSView*)tabStripView {
160 // When we have a tab strip, line up with the top of the tab, otherwise,
161 // line up with the top of the window.
162 if (!tabStripView)
163 return NSMakePoint(kPatternHorizontalOffset,
164 NSHeight([windowView bounds])
165 + kPatternVerticalOffsetNoTabStrip);
166
167 NSRect tabStripViewWindowBounds = [tabStripView bounds];
168 tabStripViewWindowBounds =
169 [tabStripView convertRect:tabStripViewWindowBounds
170 toView:windowView];
171 return NSMakePoint(NSMinX(tabStripViewWindowBounds)
172 + kPatternHorizontalOffset,
173 NSMinY(tabStripViewWindowBounds)
174 + [TabStripController defaultTabHeight]
175 + kPatternVerticalOffset);
176 }
177
124 @end 178 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_utils.h ('k') | chrome/browser/ui/cocoa/chrome_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698