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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index dfb04d24ee697530b224a93a6f8a18e1aa4cee66..12b6ecc5ab3897e65ef26381de36f502817f9efc 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -112,6 +112,10 @@ const CGFloat kProjectingIconWidthAndHeight = 32.0;
// Throbbing duration on webrtc "this web page is watching you" favicon overlay.
const int kRecordingDurationMs = 1000;
+// When the window doesn't have focus then we want to draw the button with a
+// slightly lighter color. We do this by just reducing the alpha.
+const CGFloat kImageNoFocusAlpha = 0.65;
+
// Helper class for doing NSAnimationContext calls that takes a bool to disable
// all the work. Useful for code that wants to conditionally animate.
class ScopedNSAnimationContextGroup {
@@ -222,7 +226,7 @@ NSImage* ApplyMask(NSImage* image, NSImage* mask) {
}
// Paints |overlay| on top of |ground|.
-NSImage* Overlay(NSImage* ground, NSImage* overlay) {
+NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
DCHECK_EQ([ground size].width, [overlay size].width);
DCHECK_EQ([ground size].height, [overlay size].height);
@@ -236,7 +240,7 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay) {
[overlay drawAtPoint:NSZeroPoint
fromRect:NSMakeRect(0, 0, width, height)
operation:NSCompositeSourceOver
- fraction:1.0];
+ fraction:alpha];
}) autorelease];
}
@@ -2204,20 +2208,21 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay) {
NSImage* foreground = ApplyMask(
theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND, true), mask);
- [[newTabButton_ cell] setImage:Overlay(foreground, normal)
+ [[newTabButton_ cell] setImage:Overlay(foreground, normal, 1.0)
forButtonState:image_button_cell::kDefaultState];
- [[newTabButton_ cell] setImage:Overlay(foreground, hover)
+ [[newTabButton_ cell] setImage:Overlay(foreground, hover, 1.0)
forButtonState:image_button_cell::kHoverState];
- [[newTabButton_ cell] setImage:Overlay(foreground, pressed)
+ [[newTabButton_ cell] setImage:Overlay(foreground, pressed, 1.0)
forButtonState:image_button_cell::kPressedState];
// IDR_THEME_TAB_BACKGROUND_INACTIVE is only used with the default theme.
if (theme->UsingDefaultTheme()) {
+ const CGFloat alpha = kImageNoFocusAlpha;
NSImage* background = ApplyMask(
theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND_INACTIVE, true), mask);
- [[newTabButton_ cell] setImage:Overlay(background, normal)
+ [[newTabButton_ cell] setImage:Overlay(background, normal, alpha)
forButtonState:image_button_cell::kDefaultStateBackground];
- [[newTabButton_ cell] setImage:Overlay(background, hover)
+ [[newTabButton_ cell] setImage:Overlay(background, hover, alpha)
forButtonState:image_button_cell::kHoverStateBackground];
} else {
[[newTabButton_ cell] setImage:nil

Powered by Google App Engine
This is Rietveld 408576698