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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 11791030: mac: New asset for the tabstrip border, tweak drawing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweak Created 7 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tabs/tab_strip_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // The amount by which the profile menu button is offset (from tab tabs or new 105 // The amount by which the profile menu button is offset (from tab tabs or new
106 // tab button). 106 // tab button).
107 const CGFloat kProfileMenuButtonOffset = 6.0; 107 const CGFloat kProfileMenuButtonOffset = 6.0;
108 108
109 // The width and height of the icon + glow for projecting mode. 109 // The width and height of the icon + glow for projecting mode.
110 const CGFloat kProjectingIconWidthAndHeight = 32.0; 110 const CGFloat kProjectingIconWidthAndHeight = 32.0;
111 111
112 // Throbbing duration on webrtc "this web page is watching you" favicon overlay. 112 // Throbbing duration on webrtc "this web page is watching you" favicon overlay.
113 const int kRecordingDurationMs = 1000; 113 const int kRecordingDurationMs = 1000;
114 114
115 // When the window doesn't have focus then we want to draw the button with a
116 // slightly lighter color. We do this by just reducing the alpha.
117 const CGFloat kImageNoFocusAlpha = 0.65;
118
115 // Helper class for doing NSAnimationContext calls that takes a bool to disable 119 // Helper class for doing NSAnimationContext calls that takes a bool to disable
116 // all the work. Useful for code that wants to conditionally animate. 120 // all the work. Useful for code that wants to conditionally animate.
117 class ScopedNSAnimationContextGroup { 121 class ScopedNSAnimationContextGroup {
118 public: 122 public:
119 explicit ScopedNSAnimationContextGroup(bool animate) 123 explicit ScopedNSAnimationContextGroup(bool animate)
120 : animate_(animate) { 124 : animate_(animate) {
121 if (animate_) { 125 if (animate_) {
122 [NSAnimationContext beginGrouping]; 126 [NSAnimationContext beginGrouping];
123 } 127 }
124 } 128 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 219 }
216 220
217 [mask drawAtPoint:NSZeroPoint 221 [mask drawAtPoint:NSZeroPoint
218 fromRect:NSMakeRect(0, 0, width, height) 222 fromRect:NSMakeRect(0, 0, width, height)
219 operation:NSCompositeDestinationIn 223 operation:NSCompositeDestinationIn
220 fraction:1.0]; 224 fraction:1.0];
221 }) autorelease]; 225 }) autorelease];
222 } 226 }
223 227
224 // Paints |overlay| on top of |ground|. 228 // Paints |overlay| on top of |ground|.
225 NSImage* Overlay(NSImage* ground, NSImage* overlay) { 229 NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
226 DCHECK_EQ([ground size].width, [overlay size].width); 230 DCHECK_EQ([ground size].width, [overlay size].width);
227 DCHECK_EQ([ground size].height, [overlay size].height); 231 DCHECK_EQ([ground size].height, [overlay size].height);
228 232
229 return [CreateImageWithSize([ground size], ^(NSSize size) { 233 return [CreateImageWithSize([ground size], ^(NSSize size) {
230 CGFloat width = size.width; 234 CGFloat width = size.width;
231 CGFloat height = size.height; 235 CGFloat height = size.height;
232 [ground drawAtPoint:NSZeroPoint 236 [ground drawAtPoint:NSZeroPoint
233 fromRect:NSMakeRect(0, 0, width, height) 237 fromRect:NSMakeRect(0, 0, width, height)
234 operation:NSCompositeCopy 238 operation:NSCompositeCopy
235 fraction:1.0]; 239 fraction:1.0];
236 [overlay drawAtPoint:NSZeroPoint 240 [overlay drawAtPoint:NSZeroPoint
237 fromRect:NSMakeRect(0, 0, width, height) 241 fromRect:NSMakeRect(0, 0, width, height)
238 operation:NSCompositeSourceOver 242 operation:NSCompositeSourceOver
239 fraction:1.0]; 243 fraction:alpha];
240 }) autorelease]; 244 }) autorelease];
241 } 245 }
242 246
243 } // namespace 247 } // namespace
244 248
245 @interface TabStripController (Private) 249 @interface TabStripController (Private)
246 - (void)addSubviewToPermanentList:(NSView*)aView; 250 - (void)addSubviewToPermanentList:(NSView*)aView;
247 - (void)regenerateSubviewList; 251 - (void)regenerateSubviewList;
248 - (NSInteger)indexForContentsView:(NSView*)view; 252 - (NSInteger)indexForContentsView:(NSView*)view;
249 - (NSImageView*)iconImageViewForContents:(content::WebContents*)contents; 253 - (NSImageView*)iconImageViewForContents:(content::WebContents*)contents;
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 2201
2198 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 2202 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
2199 NSImage* mask = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_MASK).ToNSImage(); 2203 NSImage* mask = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_MASK).ToNSImage();
2200 NSImage* normal = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON).ToNSImage(); 2204 NSImage* normal = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON).ToNSImage();
2201 NSImage* hover = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_H).ToNSImage(); 2205 NSImage* hover = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_H).ToNSImage();
2202 NSImage* pressed = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_P).ToNSImage(); 2206 NSImage* pressed = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_P).ToNSImage();
2203 2207
2204 NSImage* foreground = ApplyMask( 2208 NSImage* foreground = ApplyMask(
2205 theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND, true), mask); 2209 theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND, true), mask);
2206 2210
2207 [[newTabButton_ cell] setImage:Overlay(foreground, normal) 2211 [[newTabButton_ cell] setImage:Overlay(foreground, normal, 1.0)
2208 forButtonState:image_button_cell::kDefaultState]; 2212 forButtonState:image_button_cell::kDefaultState];
2209 [[newTabButton_ cell] setImage:Overlay(foreground, hover) 2213 [[newTabButton_ cell] setImage:Overlay(foreground, hover, 1.0)
2210 forButtonState:image_button_cell::kHoverState]; 2214 forButtonState:image_button_cell::kHoverState];
2211 [[newTabButton_ cell] setImage:Overlay(foreground, pressed) 2215 [[newTabButton_ cell] setImage:Overlay(foreground, pressed, 1.0)
2212 forButtonState:image_button_cell::kPressedState]; 2216 forButtonState:image_button_cell::kPressedState];
2213 2217
2214 // IDR_THEME_TAB_BACKGROUND_INACTIVE is only used with the default theme. 2218 // IDR_THEME_TAB_BACKGROUND_INACTIVE is only used with the default theme.
2215 if (theme->UsingDefaultTheme()) { 2219 if (theme->UsingDefaultTheme()) {
2220 const CGFloat alpha = kImageNoFocusAlpha;
2216 NSImage* background = ApplyMask( 2221 NSImage* background = ApplyMask(
2217 theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND_INACTIVE, true), mask); 2222 theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND_INACTIVE, true), mask);
2218 [[newTabButton_ cell] setImage:Overlay(background, normal) 2223 [[newTabButton_ cell] setImage:Overlay(background, normal, alpha)
2219 forButtonState:image_button_cell::kDefaultStateBackground]; 2224 forButtonState:image_button_cell::kDefaultStateBackground];
2220 [[newTabButton_ cell] setImage:Overlay(background, hover) 2225 [[newTabButton_ cell] setImage:Overlay(background, hover, alpha)
2221 forButtonState:image_button_cell::kHoverStateBackground]; 2226 forButtonState:image_button_cell::kHoverStateBackground];
2222 } else { 2227 } else {
2223 [[newTabButton_ cell] setImage:nil 2228 [[newTabButton_ cell] setImage:nil
2224 forButtonState:image_button_cell::kDefaultStateBackground]; 2229 forButtonState:image_button_cell::kDefaultStateBackground];
2225 [[newTabButton_ cell] setImage:nil 2230 [[newTabButton_ cell] setImage:nil
2226 forButtonState:image_button_cell::kHoverStateBackground]; 2231 forButtonState:image_button_cell::kHoverStateBackground];
2227 } 2232 }
2228 } 2233 }
2229 2234
2230 @end 2235 @end
2231 2236
2232 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { 2237 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) {
2233 // View hierarchy of the contents view: 2238 // View hierarchy of the contents view:
2234 // NSView -- switchView, same for all tabs 2239 // NSView -- switchView, same for all tabs
2235 // +- NSView -- TabContentsController's view 2240 // +- NSView -- TabContentsController's view
2236 // +- TabContentsViewCocoa 2241 // +- TabContentsViewCocoa
2237 // 2242 //
2238 // Changing it? Do not forget to modify 2243 // Changing it? Do not forget to modify
2239 // -[TabStripController swapInTabAtIndex:] too. 2244 // -[TabStripController swapInTabAtIndex:] too.
2240 return [web_contents->GetNativeView() superview]; 2245 return [web_contents->GetNativeView() superview];
2241 } 2246 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698