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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm

Issue 2459073003: [Mac] Implement an active state for the avatar button (Closed)
Patch Set: Updated comment Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_button_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/profiles/avatar_button_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_attributes_entry.h" 10 #include "chrome/browser/profiles/profile_attributes_entry.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // The image used in the generic button case as well as the error icon both 96 // The image used in the generic button case as well as the error icon both
97 // need to be shifted down slightly to be centered correctly. 97 // need to be shifted down slightly to be centered correctly.
98 // TODO(noms): When the assets are fixed, remove this latter offset. 98 // TODO(noms): When the assets are fixed, remove this latter offset.
99 if (!hasError_ || switches::IsMaterialDesignUserMenu()) 99 if (!hasError_ || switches::IsMaterialDesignUserMenu())
100 frame = NSOffsetRect(frame, 0, 1); 100 frame = NSOffsetRect(frame, 0, 1);
101 [super drawImage:image withFrame:frame inView:controlView]; 101 [super drawImage:image withFrame:frame inView:controlView];
102 } 102 }
103 103
104 - (void)drawBezelWithFrame:(NSRect)frame 104 - (void)drawBezelWithFrame:(NSRect)frame
105 inView:(NSView*)controlView { 105 inView:(NSView*)controlView {
106 HoverState hoverState = 106 AvatarButton* button = base::mac::ObjCCastStrict<AvatarButton>(controlView);
107 [base::mac::ObjCCastStrict<AvatarButton>(controlView) hoverState]; 107 HoverState hoverState = [button hoverState];
108 108
109 NSColor* backgroundColor = nil; 109 NSColor* backgroundColor = nil;
110 if (hoverState == kHoverStateMouseDown) { 110 if (hoverState == kHoverStateMouseDown || [button isActive]) {
111 backgroundColor = skia::SkColorToSRGBNSColor(kButtonPressedColor); 111 backgroundColor = skia::SkColorToSRGBNSColor(kButtonPressedColor);
112 } else if (hoverState == kHoverStateMouseOver) { 112 } else if (hoverState == kHoverStateMouseOver) {
113 backgroundColor = skia::SkColorToSRGBNSColor(kButtonHoverColor); 113 backgroundColor = skia::SkColorToSRGBNSColor(kButtonHoverColor);
114 } 114 }
115 115
116 if (backgroundColor) { 116 if (backgroundColor) {
117 [backgroundColor set]; 117 [backgroundColor set];
118 NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:frame 118 NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:frame
119 xRadius:2.0f 119 xRadius:2.0f
120 yRadius:2.0f]; 120 yRadius:2.0f];
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()] 287 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]
288 layoutSubviews]; 288 layoutSubviews];
289 } 289 }
290 } 290 }
291 291
292 - (void)setErrorStatus:(BOOL)hasError { 292 - (void)setErrorStatus:(BOOL)hasError {
293 hasError_ = hasError; 293 hasError_ = hasError;
294 [self updateAvatarButtonAndLayoutParent:YES]; 294 [self updateAvatarButtonAndLayoutParent:YES];
295 } 295 }
296 296
297 - (void)showAvatarBubbleAnchoredAt:(NSView*)anchor
298 withMode:(BrowserWindow::AvatarBubbleMode)mode
299 withServiceType:(signin::GAIAServiceType)serviceType
300 fromAccessPoint:(signin_metrics::AccessPoint)accessPoint {
301 AvatarButton* button = base::mac::ObjCCastStrict<AvatarButton>(button_);
302 [button setIsActive:YES];
303 [super showAvatarBubbleAnchoredAt:anchor
304 withMode:mode
305 withServiceType:serviceType
306 fromAccessPoint:accessPoint];
307 }
308
309 - (void)bubbleWillClose:(NSNotification*)notif {
310 AvatarButton* button = base::mac::ObjCCastStrict<AvatarButton>(button_);
311 [button setIsActive:NO];
312 [super bubbleWillClose:notif];
313 }
314
297 @end 315 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_button_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698