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

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

Issue 404443008: [Mac] Fix the alignment of the new avatar button and the bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | 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_base_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_info_cache_observer.h" 9 #include "chrome/browser/profiles/profile_info_cache_observer.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/profiles/profile_metrics.h" 12 #include "chrome/browser/profiles/profile_metrics.h"
13 #include "chrome/browser/signin/signin_header_helper.h" 13 #include "chrome/browser/signin/signin_header_helper.h"
14 #include "chrome/browser/profiles/profiles_state.h" 14 #include "chrome/browser/profiles/profiles_state.h"
15 #include "chrome/browser/profiles/profile_window.h" 15 #include "chrome/browser/profiles/profile_window.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_commands.h" 17 #include "chrome/browser/ui/browser_commands.h"
18 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
19 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" 19 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
20 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 20 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
21 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" 21 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
22 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 22 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
23 #include "components/signin/core/browser/signin_error_controller.h" 23 #include "components/signin/core/browser/signin_error_controller.h"
24 #include "components/signin/core/common/profile_management_switches.h" 24 #include "components/signin/core/common/profile_management_switches.h"
25 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
26 26
27 // Space between the avatar icon and the avatar menu bubble. 27 // Space between the avatar icon and the avatar menu bubble.
28 const CGFloat kMenuYOffsetAdjust = 1.0; 28 const CGFloat kMenuYOffsetAdjust = 1.0;
29 // Offset needed to align the edge of the avatar bubble with the edge of the
30 // avatar button.
31 const CGFloat kMenuXOffsetAdjust = 2.0;
29 32
30 @interface AvatarBaseController (Private) 33 @interface AvatarBaseController (Private)
31 // Shows the avatar bubble. 34 // Shows the avatar bubble.
32 - (IBAction)buttonClicked:(id)sender; 35 - (IBAction)buttonClicked:(id)sender;
33 36
34 - (void)bubbleWillClose:(NSNotification*)notif; 37 - (void)bubbleWillClose:(NSNotification*)notif;
35 38
36 // Updates the profile name displayed by the avatar button. If |layoutParent| is 39 // Updates the profile name displayed by the avatar button. If |layoutParent| is
37 // yes, then the BrowserWindowController is notified to relayout the subviews, 40 // yes, then the BrowserWindowController is notified to relayout the subviews,
38 // as the button needs to be repositioned. 41 // as the button needs to be repositioned.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 149
147 NSWindowController* wc = 150 NSWindowController* wc =
148 [browser_->window()->GetNativeWindow() windowController]; 151 [browser_->window()->GetNativeWindow() windowController];
149 if ([wc isKindOfClass:[BrowserWindowController class]]) { 152 if ([wc isKindOfClass:[BrowserWindowController class]]) {
150 [static_cast<BrowserWindowController*>(wc) 153 [static_cast<BrowserWindowController*>(wc)
151 lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; 154 lockBarVisibilityForOwner:self withAnimation:NO delay:NO];
152 } 155 }
153 156
154 // The new avatar bubble does not have an arrow, and it should be anchored 157 // The new avatar bubble does not have an arrow, and it should be anchored
155 // to the edge of the avatar button. 158 // to the edge of the avatar button.
156 int anchorX = switches::IsNewAvatarMenu() ? NSMaxX([anchor bounds]) : 159 int anchorX = switches::IsNewAvatarMenu() ?
157 NSMidX([anchor bounds]); 160 NSMaxX([anchor bounds]) - kMenuXOffsetAdjust :
161 NSMidX([anchor bounds]);
158 NSPoint point = NSMakePoint(anchorX, 162 NSPoint point = NSMakePoint(anchorX,
159 NSMaxY([anchor bounds]) - kMenuYOffsetAdjust); 163 NSMaxY([anchor bounds]) - kMenuYOffsetAdjust);
160 point = [anchor convertPoint:point toView:nil]; 164 point = [anchor convertPoint:point toView:nil];
161 point = [[anchor window] convertBaseToScreen:point]; 165 point = [[anchor window] convertBaseToScreen:point];
162 166
163 // |menuController_| will automatically release itself on close. 167 // |menuController_| will automatically release itself on close.
164 if (switches::IsNewAvatarMenu()) { 168 if (switches::IsNewAvatarMenu()) {
165 profiles::BubbleViewMode viewMode = 169 profiles::BubbleViewMode viewMode =
166 profiles::BubbleViewModeFromAvatarBubbleMode(mode); 170 profiles::BubbleViewModeFromAvatarBubbleMode(mode);
167 menuController_ = 171 menuController_ =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 211 }
208 212
209 - (void)updateErrorStatus:(BOOL)hasError { 213 - (void)updateErrorStatus:(BOOL)hasError {
210 } 214 }
211 215
212 - (BaseBubbleController*)menuController { 216 - (BaseBubbleController*)menuController {
213 return menuController_; 217 return menuController_;
214 } 218 }
215 219
216 @end 220 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698