Chromium Code Reviews| Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| index dfb5158aaf92bb470ea84d90cb0274118ae9d3d5..db4a11fac7c8f19f4770d61146d46356d86cec13 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| @@ -716,9 +716,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| frameOrigin:(NSPoint)frameOrigin |
| action:(SEL)action; |
| -// Creates an email account button with |title| and a remove icon. |
| +// Creates an email account button with |title| and a remove icon. |tag| |
| +// indicates which account the button refers to. |
| - (NSButton*)accountButtonWithRect:(NSRect)rect |
| - title:(const std::string&)title; |
| + title:(const std::string&)title |
| + tag:(int)tag; |
| @end |
| @@ -1338,19 +1340,19 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| // Save the original email address, as the button text could be elided. |
| currentProfileAccounts_[i] = accounts[i]; |
| NSButton* accountButton = [self accountButtonWithRect:rect |
| - title:accounts[i]]; |
| - [accountButton setTag:i]; |
| + title:accounts[i] |
| + tag:i]; |
| [container addSubview:accountButton]; |
| rect.origin.y = NSMaxY([accountButton frame]); |
| } |
| // The primary account should always be listed first. |
| NSButton* accountButton = [self accountButtonWithRect:rect |
| - title:primaryAccount]; |
| + title:primaryAccount |
| + tag:kPrimaryProfileTag]; |
| [container addSubview:accountButton]; |
| [container setFrameSize:NSMakeSize(NSWidth([container frame]), |
| NSMaxY([accountButton frame]))]; |
| - [accountButton setTag:kPrimaryProfileTag]; |
| return container.autorelease(); |
| } |
| @@ -1523,20 +1525,39 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| } |
| - (NSButton*)accountButtonWithRect:(NSRect)rect |
| - title:(const std::string&)title { |
| + title:(const std::string&)title |
| + tag:(int)tag { |
| NSColor* backgroundColor = gfx::SkColorToCalibratedNSColor( |
| profiles::kAvatarBubbleAccountsBackgroundColor); |
| base::scoped_nsobject<BackgroundColorHoverButton> button( |
| [[BackgroundColorHoverButton alloc] initWithFrame:rect |
| imageTitleSpacing:0 |
| backgroundColor:backgroundColor]); |
| - |
| - [button setTitle:ElideEmail(title, rect.size.width)]; |
| + const CGFloat kDeleteButtonWidth = 18; |
|
groby-ooo-7-16
2014/05/02 22:21:57
Why 18? Any chance we can get that number from the
noms (inactive)
2014/05/05 17:21:24
Done.
|
| + CGFloat availableWidth = rect.size.width - |
| + kDeleteButtonWidth - kHorizontalSpacing; |
| + [button setTitle:ElideEmail(title, availableWidth)]; |
| [button setAlignment:NSLeftTextAlignment]; |
| [button setBordered:NO]; |
| - [button setTarget:self]; |
| - [button setAction:@selector(showAccountRemovalView:)]; |
| + // Delete button. |
| + rect.origin = NSMakePoint(availableWidth, 0); |
| + rect.size.width = kDeleteButtonWidth; |
| + base::scoped_nsobject<HoverImageButton> deleteButton( |
| + [[HoverImageButton alloc] initWithFrame:rect]); |
| + [deleteButton setBordered:NO]; |
| + ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| + [deleteButton setDefaultImage:rb->GetNativeImageNamed( |
| + IDR_CLOSE_1).ToNSImage()]; |
| + [deleteButton setHoverImage:rb->GetNativeImageNamed( |
| + IDR_CLOSE_1_H).ToNSImage()]; |
| + [deleteButton setPressedImage:rb->GetNativeImageNamed( |
| + IDR_CLOSE_1_P).ToNSImage()]; |
| + [deleteButton setTarget:self]; |
| + [deleteButton setAction:@selector(showAccountRemovalView:)]; |
| + [deleteButton setTag:tag]; |
| + |
| + [button addSubview:deleteButton]; |
|
groby-ooo-7-16
2014/05/02 22:21:57
A HoverButton in a HoverButton? We must go deeper!
noms (inactive)
2014/05/05 17:21:24
Blerg. :(
Yup, the hovering is fine by magic. The
|
| return button.autorelease(); |
| } |