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

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: round2 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 216
217 [mask drawAtPoint:NSZeroPoint 217 [mask drawAtPoint:NSZeroPoint
218 fromRect:NSMakeRect(0, 0, width, height) 218 fromRect:NSMakeRect(0, 0, width, height)
219 operation:NSCompositeDestinationIn 219 operation:NSCompositeDestinationIn
220 fraction:1.0]; 220 fraction:1.0];
221 }) autorelease]; 221 }) autorelease];
222 } 222 }
223 223
224 // Paints |overlay| on top of |ground|. 224 // Paints |overlay| on top of |ground|.
225 NSImage* Overlay(NSImage* ground, NSImage* overlay) { 225 NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
226 DCHECK_EQ([ground size].width, [overlay size].width); 226 DCHECK_EQ([ground size].width, [overlay size].width);
227 DCHECK_EQ([ground size].height, [overlay size].height); 227 DCHECK_EQ([ground size].height, [overlay size].height);
228 228
229 return [CreateImageWithSize([ground size], ^(NSSize size) { 229 return [CreateImageWithSize([ground size], ^(NSSize size) {
230 CGFloat width = size.width; 230 CGFloat width = size.width;
231 CGFloat height = size.height; 231 CGFloat height = size.height;
232 [ground drawAtPoint:NSZeroPoint 232 [ground drawAtPoint:NSZeroPoint
233 fromRect:NSMakeRect(0, 0, width, height) 233 fromRect:NSMakeRect(0, 0, width, height)
234 operation:NSCompositeCopy 234 operation:NSCompositeCopy
235 fraction:1.0]; 235 fraction:1.0];
236 [overlay drawAtPoint:NSZeroPoint 236 [overlay drawAtPoint:NSZeroPoint
237 fromRect:NSMakeRect(0, 0, width, height) 237 fromRect:NSMakeRect(0, 0, width, height)
238 operation:NSCompositeSourceOver 238 operation:NSCompositeSourceOver
239 fraction:1.0]; 239 fraction:alpha];
240 }) autorelease]; 240 }) autorelease];
241 } 241 }
242 242
243 } // namespace 243 } // namespace
244 244
245 @interface TabStripController (Private) 245 @interface TabStripController (Private)
246 - (void)addSubviewToPermanentList:(NSView*)aView; 246 - (void)addSubviewToPermanentList:(NSView*)aView;
247 - (void)regenerateSubviewList; 247 - (void)regenerateSubviewList;
248 - (NSInteger)indexForContentsView:(NSView*)view; 248 - (NSInteger)indexForContentsView:(NSView*)view;
249 - (NSImageView*)iconImageViewForContents:(content::WebContents*)contents; 249 - (NSImageView*)iconImageViewForContents:(content::WebContents*)contents;
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 2197
2198 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 2198 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
2199 NSImage* mask = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_MASK).ToNSImage(); 2199 NSImage* mask = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_MASK).ToNSImage();
2200 NSImage* normal = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON).ToNSImage(); 2200 NSImage* normal = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON).ToNSImage();
2201 NSImage* hover = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_H).ToNSImage(); 2201 NSImage* hover = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_H).ToNSImage();
2202 NSImage* pressed = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_P).ToNSImage(); 2202 NSImage* pressed = rb.GetNativeImageNamed(IDR_NEWTAB_BUTTON_P).ToNSImage();
2203 2203
2204 NSImage* foreground = ApplyMask( 2204 NSImage* foreground = ApplyMask(
2205 theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND, true), mask); 2205 theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND, true), mask);
2206 2206
2207 [[newTabButton_ cell] setImage:Overlay(foreground, normal) 2207 [[newTabButton_ cell] setImage:Overlay(foreground, normal, 1.0)
2208 forButtonState:image_button_cell::kDefaultState]; 2208 forButtonState:image_button_cell::kDefaultState];
2209 [[newTabButton_ cell] setImage:Overlay(foreground, hover) 2209 [[newTabButton_ cell] setImage:Overlay(foreground, hover, 1.0)
2210 forButtonState:image_button_cell::kHoverState]; 2210 forButtonState:image_button_cell::kHoverState];
2211 [[newTabButton_ cell] setImage:Overlay(foreground, pressed) 2211 [[newTabButton_ cell] setImage:Overlay(foreground, pressed, 1.0)
2212 forButtonState:image_button_cell::kPressedState]; 2212 forButtonState:image_button_cell::kPressedState];
2213 2213
2214 // IDR_THEME_TAB_BACKGROUND_INACTIVE is only used with the default theme. 2214 // IDR_THEME_TAB_BACKGROUND_INACTIVE is only used with the default theme.
2215 if (theme->UsingDefaultTheme()) { 2215 if (theme->UsingDefaultTheme()) {
2216 const CGFloat alpha = tabs::kImageNoFocusAlpha;
2216 NSImage* background = ApplyMask( 2217 NSImage* background = ApplyMask(
2217 theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND_INACTIVE, true), mask); 2218 theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND_INACTIVE, true), mask);
2218 [[newTabButton_ cell] setImage:Overlay(background, normal) 2219 [[newTabButton_ cell] setImage:Overlay(background, normal, alpha)
2219 forButtonState:image_button_cell::kDefaultStateBackground]; 2220 forButtonState:image_button_cell::kDefaultStateBackground];
2220 [[newTabButton_ cell] setImage:Overlay(background, hover) 2221 [[newTabButton_ cell] setImage:Overlay(background, hover, alpha)
2221 forButtonState:image_button_cell::kHoverStateBackground]; 2222 forButtonState:image_button_cell::kHoverStateBackground];
2222 } else { 2223 } else {
2223 [[newTabButton_ cell] setImage:nil 2224 [[newTabButton_ cell] setImage:nil
2224 forButtonState:image_button_cell::kDefaultStateBackground]; 2225 forButtonState:image_button_cell::kDefaultStateBackground];
2225 [[newTabButton_ cell] setImage:nil 2226 [[newTabButton_ cell] setImage:nil
2226 forButtonState:image_button_cell::kHoverStateBackground]; 2227 forButtonState:image_button_cell::kHoverStateBackground];
2227 } 2228 }
2228 } 2229 }
2229 2230
2230 @end 2231 @end
2231 2232
2232 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { 2233 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) {
2233 // View hierarchy of the contents view: 2234 // View hierarchy of the contents view:
2234 // NSView -- switchView, same for all tabs 2235 // NSView -- switchView, same for all tabs
2235 // +- NSView -- TabContentsController's view 2236 // +- NSView -- TabContentsController's view
2236 // +- TabContentsViewCocoa 2237 // +- TabContentsViewCocoa
2237 // 2238 //
2238 // Changing it? Do not forget to modify 2239 // Changing it? Do not forget to modify
2239 // -[TabStripController swapInTabAtIndex:] too. 2240 // -[TabStripController swapInTabAtIndex:] too.
2240 return [web_contents->GetNativeView() superview]; 2241 return [web_contents->GetNativeView() superview];
2241 } 2242 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/image_button_cell.mm ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698