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

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

Issue 1883033002: [Mac] Update tab audio icon to Material Design and tweak close box color. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/alert_indicator_button_cocoa.h" 5 #import "chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 [super setAction:@selector(handleClick:)]; 65 [super setAction:@selector(handleClick:)];
66 } 66 }
67 return self; 67 return self;
68 } 68 }
69 69
70 - (void)removeFromSuperview { 70 - (void)removeFromSuperview {
71 fadeAnimation_.reset(); 71 fadeAnimation_.reset();
72 [super removeFromSuperview]; 72 [super removeFromSuperview];
73 } 73 }
74 74
75 - (void)updateIconForState:(TabAlertState)aState {
76 if (aState != TabAlertState::NONE) {
77 TabView* const tabView = base::mac::ObjCCast<TabView>([self superview]);
78 SkColor iconColor = [tabView closeButtonColor];
79 NSImage* tabIndicatorImage =
80 chrome::GetTabAlertIndicatorImage(aState, iconColor).ToNSImage();
81 [self setImage:tabIndicatorImage];
82 affordanceImage_.reset([tabIndicatorImage retain]);
Avi (use Gerrit) 2016/04/14 02:35:08 You can do affordanceImage_.reset(tabIndicatorIma
83 }
84 }
85
75 - (void)transitionToAlertState:(TabAlertState)nextState { 86 - (void)transitionToAlertState:(TabAlertState)nextState {
76 if (nextState == alertState_) 87 if (nextState == alertState_)
77 return; 88 return;
78 89
79 if (nextState != TabAlertState::NONE) { 90 [self updateIconForState:nextState];
80 [self
81 setImage:chrome::GetTabAlertIndicatorImage(nextState, 0).ToNSImage()];
82 affordanceImage_.reset(
83 [chrome::GetTabAlertIndicatorAffordanceImage(nextState, 0)
84 .ToNSImage() retain]);
85 }
86 91
87 if ((alertState_ == TabAlertState::AUDIO_PLAYING && 92 if ((alertState_ == TabAlertState::AUDIO_PLAYING &&
88 nextState == TabAlertState::AUDIO_MUTING) || 93 nextState == TabAlertState::AUDIO_MUTING) ||
89 (alertState_ == TabAlertState::AUDIO_MUTING && 94 (alertState_ == TabAlertState::AUDIO_MUTING &&
90 nextState == TabAlertState::AUDIO_PLAYING) || 95 nextState == TabAlertState::AUDIO_PLAYING) ||
91 (alertState_ == TabAlertState::AUDIO_MUTING && 96 (alertState_ == TabAlertState::AUDIO_MUTING &&
92 nextState == TabAlertState::NONE)) { 97 nextState == TabAlertState::NONE)) {
93 // Instant user feedback: No fade animation. 98 // Instant user feedback: No fade animation.
94 showingAlertState_ = nextState; 99 showingAlertState_ = nextState;
95 fadeAnimation_.reset(); 100 fadeAnimation_.reset();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 TabView* const tabView = base::mac::ObjCCast<TabView>([self superview]); 235 TabView* const tabView = base::mac::ObjCCast<TabView>([self superview]);
231 if (enable && tabView && ([tabView state] != NSOnState)) { 236 if (enable && tabView && ([tabView state] != NSOnState)) {
232 const int requiredWidth = 237 const int requiredWidth =
233 NSWidth([self frame]) * kMinMouseSelectableAreaPercent / 100; 238 NSWidth([self frame]) * kMinMouseSelectableAreaPercent / 100;
234 enable = ([tabView widthOfLargestSelectableRegion] >= requiredWidth); 239 enable = ([tabView widthOfLargestSelectableRegion] >= requiredWidth);
235 } 240 }
236 241
237 [self setEnabled:enable]; 242 [self setEnabled:enable];
238 } 243 }
239 244
245 // ThemedWindowDrawing protocol support.
246
247 - (void)windowDidChangeTheme {
248 // Force the alert icon to update because the icon color may change based
249 // on the current theme.
250 [self updateIconForState:alertState_];
251 }
252
253 - (void)windowDidChangeActive {
254 }
255
240 @end 256 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/alert_indicator_button_cocoa.h ('k') | chrome/browser/ui/cocoa/tabs/tab_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698