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

Unified Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 943453003: Add tooltips to profile name when truncated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix code style issues Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2c8a22324cf495473a723774790156fe4271c5b1..f7a600fd529a90cc3a507a2533eda00aa08a8d66 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
@@ -701,6 +701,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
IDS_PROFILES_NEW_AVATAR_MENU_EDIT_NAME_ACCESSIBLE_NAME,
base::SysNSStringToUTF16(profileName))
forAttribute:NSAccessibilityTitleAttribute];
+
+ NSSize textSize = [profileName sizeWithAttributes:
+ @{NSFontAttributeName: [profileNameTextField_ font]}];
Avi (use Gerrit) 2015/02/27 23:14:07 Bad code style for the literal. http://google-sty
wesleylancel 2015/02/27 23:20:40 @AvI: needs to be 2 spaces instead of 4 then I gue
Avi (use Gerrit) 2015/02/27 23:22:51 No. The literal is formatted incorrectly. The lite
+
+ if (textSize.width > frameRect.size.width - [hoverImage size].width * 2)
+ [self setToolTip:profileName];
}
[[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole
@@ -1805,6 +1811,15 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[profileButton setTarget:self];
[profileButton setAction:@selector(switchToProfile:)];
+ NSSize textSize = [[profileButton title] sizeWithAttributes:
+ @{NSFontAttributeName: [profileButton font]}];
+
+ CGFloat availableWidth = rect.size.width - kSmallImageSide -
+ kImageTitleSpacing - kHorizontalSpacing;
+
+ if (lroundf(textSize.width) > availableWidth)
groby-ooo-7-16 2015/02/24 00:37:06 Please use std::ceil instead.
wesleylancel 2015/02/24 08:39:31 I actually need rounding and not ceiling here othe
groby-ooo-7-16 2015/02/27 23:02:24 Maybe I misunderstand, but isn't ceil(width) stric
wesleylancel 2015/02/27 23:20:40 Oh! I'm sorry. I totally thought I was doing somet
+ [profileButton setToolTip:[profileButton title]];
+
return profileButton.autorelease();
}
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698