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 2b8dbf2e385f24fcc263f5e6a2abb4d259376a46..4384ac1aefd56bf2c4c9e57e90a60640b0d4150d 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| @@ -571,14 +571,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| [[CustomCircleImageCell alloc] init]); |
| [self setCell:cell.get()]; |
| - const int imageSide = |
| - switches::IsMaterialDesignUserMenu() ? kMdImageSide : kLargeImageSide; |
| - [self setDefaultImage:CreateProfileImage(profileIcon, imageSide, |
| - profiles::SHAPE_CIRCLE)]; |
| + [self setDefaultImage:CreateProfileImage(profileIcon, kLargeImageSide, |
| + profiles::SHAPE_SQUARE)]; |
| [self setImagePosition:NSImageOnly]; |
| if (editingAllowed) { |
| - NSRect bounds = NSMakeRect(0, 0, imageSide, imageSide); |
| + NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide); |
| [self setTarget:self]; |
| [self setAction:@selector(editPhoto:)]; |
| changePhotoImage_.reset([[TransparentBackgroundImageView alloc] |
| @@ -838,6 +836,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| initWithLeftMarginSpacing:kHorizontalSpacing |
| imageTitleSpacing:imageTitleSpacing]); |
| [cell setLineBreakMode:NSLineBreakByTruncatingTail]; |
| + if (switches::IsMaterialDesignUserMenu()) |
| + [cell setHighlightsBy:NSNoCellMask]; |
| [self setCell:cell.get()]; |
| } |
| return self; |
| @@ -867,7 +867,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| } |
| - (BOOL)canBecomeKeyView { |
| - return YES; |
| + return [self isEnabled] ? YES : NO; |
| } |
| @end |
| @@ -1912,20 +1912,38 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| // Profile card button that contains the profile icon, name, and username. |
| NSRect rect = NSMakeRect(0, yOffset, GetFixedMenuWidth(), |
| kMdImageSide + kVerticalSpacing); |
| - NSButton* profileCard = [self hoverButtonWithRect:rect |
| - text:[[NSString alloc] init] |
| - action:@selector(editProfile:)]; |
| + NSButton* profileCard = |
| + [self hoverButtonWithRect:rect |
| + text:[[NSString alloc] init] |
| + image:CreateProfileImage(item.icon, kMdImageSide, |
| + profiles::SHAPE_CIRCLE) |
| + action:@selector(editProfile:)]; |
| + [[profileCard cell] setImageDimsWhenDisabled:NO]; |
| [container addSubview:profileCard]; |
| if (isGuestSession_) |
| [profileCard setEnabled:NO]; |
| - // Profile icon, left-aligned. |
| - base::scoped_nsobject<NSImageView> iconView([[NSImageView alloc] |
| - initWithFrame:NSMakeRect(xOffset, cardYOffset, kMdImageSide, |
| - kMdImageSide)]); |
| - [iconView setImage:CreateProfileImage(item.icon, kMdImageSide, |
| - profiles::SHAPE_CIRCLE)]; |
| - [profileCard addSubview:iconView]; |
| + // Profile badge for supervised account. |
| + if (browser_->profile()->IsSupervised()) { |
| + base::scoped_nsobject<NSImageView> supervisedIcon( |
| + [[NSImageView alloc] initWithFrame:NSZeroRect]); |
| + // TODO(janeliulwq): Replace the following two profile badge icons with |
| + // smaller versions of them (24 x 24) to adapt to smaller profile icons. |
| + int imageId = browser_->profile()->IsChild() |
| + ? IDR_ICON_PROFILES_MENU_CHILD |
| + : IDR_ICON_PROFILES_MENU_LEGACY_SUPERVISED; |
| + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| + [supervisedIcon setImage:rb.GetNativeImageNamed(imageId).ToNSImage()]; |
| + |
| + NSSize size = [[supervisedIcon image] size]; |
| + [supervisedIcon setFrameSize:size]; |
| + const int badgeSpacing = 4; |
| + [supervisedIcon setFrameOrigin:NSMakePoint(xOffset + kMdImageSide - |
| + size.width + badgeSpacing, |
| + cardYOffset + kMdImageSide - |
| + size.height + badgeSpacing)]; |
| + [profileCard addSubview:supervisedIcon]; |
| + } |
| // Profile name, left-aligned to the right of profile icon. |
| xOffset += kMdImageSide + kHorizontalSpacing; |
| @@ -1936,12 +1954,13 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| NSZeroPoint, nil); |
| [[profileName cell] setLineBreakMode:NSLineBreakByTruncatingTail]; |
| [profileName setFont:[NSFont labelFontOfSize:fontSize]]; |
| + [profileName sizeToFit]; |
|
groby-ooo-7-16
2016/08/10 20:01:51
FWIW: You seem to use sizeToFit only to derive fon
Jane
2016/08/10 22:42:58
Yes, I'm only using sizeToFit to adapt to the new
groby-ooo-7-16
2016/08/11 05:33:19
It _should_ work fine, but since it doesn't, just
|
| + const int profileNameYOffset = |
| + cardYOffset + |
| + std::floor((kMdImageSide - [profileName frame].size.height) / 2); |
| [profileName |
| - setFrame:NSMakeRect( |
| - xOffset, |
| - cardYOffset + |
| - (kMdImageSide - [profileName frame].size.height) / 2, |
| - availableTextWidth, [profileName frame].size.height)]; |
| + setFrame:NSMakeRect(xOffset, profileNameYOffset, availableTextWidth, |
| + [profileName frame].size.height)]; |
|
groby-ooo-7-16
2016/08/10 20:01:51
Tiny nit: NSHeight([profileName frame]) here and p
Jane
2016/08/10 22:42:58
Done.
|
| [profileCard addSubview:profileName]; |
| // Username, left-aligned to the right of profile icon and below the profile |
| @@ -1958,29 +1977,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| [profileCard addSubview:username]; |
| } |
| - // Profile badge for supervised account. |
| - if (browser_->profile()->IsSupervised()) { |
| - base::scoped_nsobject<NSImageView> supervisedIcon( |
| - [[NSImageView alloc] initWithFrame:NSZeroRect]); |
| - // TODO(janeliulwq): Replace the following two profile badge icons with |
| - // smaller versions of them (24 x 24) to adapt to smaller profile icons. |
| - int imageId = browser_->profile()->IsChild() |
| - ? IDR_ICON_PROFILES_MENU_CHILD |
| - : IDR_ICON_PROFILES_MENU_LEGACY_SUPERVISED; |
| - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| - [supervisedIcon setImage:rb.GetNativeImageNamed(imageId).ToNSImage()]; |
| - |
| - NSSize size = [[supervisedIcon image] size]; |
| - [supervisedIcon setFrameSize:size]; |
| - NSRect profileIconFrame = [iconView frame]; |
| - const int badgeSpacing = 4; |
| - [supervisedIcon setFrameOrigin:NSMakePoint(NSMaxX(profileIconFrame) - |
| - size.width + badgeSpacing, |
| - NSMaxY(profileIconFrame) - |
| - size.height + badgeSpacing)]; |
| - [profileCard addSubview:supervisedIcon]; |
| - } |
| - |
| yOffset = NSMaxY([profileCard frame]); |
| [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)]; |
| return container.autorelease(); |