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

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

Issue 265073003: [Win, Mac] UI fixes for the delete account button in the new avatar bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm » ('j') | 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 imageResourceId:(int)imageResourceId 709 imageResourceId:(int)imageResourceId
710 alternateImageResourceId:(int)alternateImageResourceId 710 alternateImageResourceId:(int)alternateImageResourceId
711 action:(SEL)action; 711 action:(SEL)action;
712 712
713 // Creates a generic link button with |title| and an |action| positioned at 713 // Creates a generic link button with |title| and an |action| positioned at
714 // |frameOrigin|. 714 // |frameOrigin|.
715 - (NSButton*)linkButtonWithTitle:(NSString*)title 715 - (NSButton*)linkButtonWithTitle:(NSString*)title
716 frameOrigin:(NSPoint)frameOrigin 716 frameOrigin:(NSPoint)frameOrigin
717 action:(SEL)action; 717 action:(SEL)action;
718 718
719 // Creates an email account button with |title| and a remove icon. 719 // Creates an email account button with |title| and a remove icon. |tag|
720 // indicates which account the button refers to.
720 - (NSButton*)accountButtonWithRect:(NSRect)rect 721 - (NSButton*)accountButtonWithRect:(NSRect)rect
721 title:(const std::string&)title; 722 title:(const std::string&)title
723 tag:(int)tag;
722 724
723 @end 725 @end
724 726
725 @implementation ProfileChooserController 727 @implementation ProfileChooserController
726 - (BubbleViewMode) viewMode { 728 - (BubbleViewMode) viewMode {
727 return viewMode_; 729 return viewMode_;
728 } 730 }
729 731
730 - (IBAction)switchToProfile:(id)sender { 732 - (IBAction)switchToProfile:(id)sender {
731 // Check the event flags to see if a new window should be created. 733 // Check the event flags to see if a new window should be created.
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); 1333 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername();
1332 DCHECK(!primaryAccount.empty()); 1334 DCHECK(!primaryAccount.empty());
1333 std::vector<std::string>accounts = 1335 std::vector<std::string>accounts =
1334 profiles::GetSecondaryAccountsForProfile(profile, primaryAccount); 1336 profiles::GetSecondaryAccountsForProfile(profile, primaryAccount);
1335 1337
1336 rect.origin.y = 0; 1338 rect.origin.y = 0;
1337 for (size_t i = 0; i < accounts.size(); ++i) { 1339 for (size_t i = 0; i < accounts.size(); ++i) {
1338 // Save the original email address, as the button text could be elided. 1340 // Save the original email address, as the button text could be elided.
1339 currentProfileAccounts_[i] = accounts[i]; 1341 currentProfileAccounts_[i] = accounts[i];
1340 NSButton* accountButton = [self accountButtonWithRect:rect 1342 NSButton* accountButton = [self accountButtonWithRect:rect
1341 title:accounts[i]]; 1343 title:accounts[i]
1342 [accountButton setTag:i]; 1344 tag:i];
1343 [container addSubview:accountButton]; 1345 [container addSubview:accountButton];
1344 rect.origin.y = NSMaxY([accountButton frame]); 1346 rect.origin.y = NSMaxY([accountButton frame]);
1345 } 1347 }
1346 1348
1347 // The primary account should always be listed first. 1349 // The primary account should always be listed first.
1348 NSButton* accountButton = [self accountButtonWithRect:rect 1350 NSButton* accountButton = [self accountButtonWithRect:rect
1349 title:primaryAccount]; 1351 title:primaryAccount
1352 tag:kPrimaryProfileTag];
1350 [container addSubview:accountButton]; 1353 [container addSubview:accountButton];
1351 [container setFrameSize:NSMakeSize(NSWidth([container frame]), 1354 [container setFrameSize:NSMakeSize(NSWidth([container frame]),
1352 NSMaxY([accountButton frame]))]; 1355 NSMaxY([accountButton frame]))];
1353 [accountButton setTag:kPrimaryProfileTag];
1354 return container.autorelease(); 1356 return container.autorelease();
1355 } 1357 }
1356 1358
1357 - (NSView*)buildGaiaEmbeddedView { 1359 - (NSView*)buildGaiaEmbeddedView {
1358 base::scoped_nsobject<NSView> container( 1360 base::scoped_nsobject<NSView> container(
1359 [[NSView alloc] initWithFrame:NSZeroRect]); 1361 [[NSView alloc] initWithFrame:NSZeroRect]);
1360 CGFloat yOffset = 0; 1362 CGFloat yOffset = 0;
1361 1363
1362 bool addSecondaryAccount = viewMode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT; 1364 bool addSecondaryAccount = viewMode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT;
1363 signin::Source source = addSecondaryAccount ? 1365 signin::Source source = addSecondaryAccount ?
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 [link setFont:[NSFont labelFontOfSize:kTextFontSize]]; 1518 [link setFont:[NSFont labelFontOfSize:kTextFontSize]];
1517 [link setTarget:self]; 1519 [link setTarget:self];
1518 [link setAction:action]; 1520 [link setAction:action];
1519 [link setFrameOrigin:frameOrigin]; 1521 [link setFrameOrigin:frameOrigin];
1520 [link sizeToFit]; 1522 [link sizeToFit];
1521 1523
1522 return link.autorelease(); 1524 return link.autorelease();
1523 } 1525 }
1524 1526
1525 - (NSButton*)accountButtonWithRect:(NSRect)rect 1527 - (NSButton*)accountButtonWithRect:(NSRect)rect
1526 title:(const std::string&)title { 1528 title:(const std::string&)title
1529 tag:(int)tag {
1527 NSColor* backgroundColor = gfx::SkColorToCalibratedNSColor( 1530 NSColor* backgroundColor = gfx::SkColorToCalibratedNSColor(
1528 profiles::kAvatarBubbleAccountsBackgroundColor); 1531 profiles::kAvatarBubbleAccountsBackgroundColor);
1529 base::scoped_nsobject<BackgroundColorHoverButton> button( 1532 base::scoped_nsobject<BackgroundColorHoverButton> button(
1530 [[BackgroundColorHoverButton alloc] initWithFrame:rect 1533 [[BackgroundColorHoverButton alloc] initWithFrame:rect
1531 imageTitleSpacing:0 1534 imageTitleSpacing:0
1532 backgroundColor:backgroundColor]); 1535 backgroundColor:backgroundColor]);
1533 1536 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.
1534 [button setTitle:ElideEmail(title, rect.size.width)]; 1537 CGFloat availableWidth = rect.size.width -
1538 kDeleteButtonWidth - kHorizontalSpacing;
1539 [button setTitle:ElideEmail(title, availableWidth)];
1535 [button setAlignment:NSLeftTextAlignment]; 1540 [button setAlignment:NSLeftTextAlignment];
1536 [button setBordered:NO]; 1541 [button setBordered:NO];
1537 [button setTarget:self];
1538 [button setAction:@selector(showAccountRemovalView:)];
1539 1542
1543 // Delete button.
1544 rect.origin = NSMakePoint(availableWidth, 0);
1545 rect.size.width = kDeleteButtonWidth;
1546 base::scoped_nsobject<HoverImageButton> deleteButton(
1547 [[HoverImageButton alloc] initWithFrame:rect]);
1548 [deleteButton setBordered:NO];
1549 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1550 [deleteButton setDefaultImage:rb->GetNativeImageNamed(
1551 IDR_CLOSE_1).ToNSImage()];
1552 [deleteButton setHoverImage:rb->GetNativeImageNamed(
1553 IDR_CLOSE_1_H).ToNSImage()];
1554 [deleteButton setPressedImage:rb->GetNativeImageNamed(
1555 IDR_CLOSE_1_P).ToNSImage()];
1556 [deleteButton setTarget:self];
1557 [deleteButton setAction:@selector(showAccountRemovalView:)];
1558 [deleteButton setTag:tag];
1559
1560 [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
1540 return button.autorelease(); 1561 return button.autorelease();
1541 } 1562 }
1542 1563
1543 @end 1564 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698