Commit 30f4cc56 authored by wesleylancel's avatar wesleylancel Committed by Commit bot

Add tooltips to profile name when truncated

This adds tooltips to profile names in both the old and new profile
switcher when they are truncated on OSX.
This lines up with behaviour on Windows.

Also added myself to the AUTHORS file seeing this is my first contribution.

BUG=459572

Review URL: https://codereview.chromium.org/943453003

Cr-Commit-Position: refs/heads/master@{#318769}
parent a656e72c
...@@ -502,6 +502,7 @@ Vinay Anantharaman <vinaya@adobe.com> ...@@ -502,6 +502,7 @@ Vinay Anantharaman <vinaya@adobe.com>
Vipul Bhasin <vipul.bhasin@gmail.com> Vipul Bhasin <vipul.bhasin@gmail.com>
Visa Putkinen <v.putkinen@partner.samsung.com> Visa Putkinen <v.putkinen@partner.samsung.com>
Vivek Galatage <vivek.vg@samsung.com> Vivek Galatage <vivek.vg@samsung.com>
Wesley Lancel <wesleylancel@gmail.com>
Will Hirsch <chromium@willhirsch.co.uk> Will Hirsch <chromium@willhirsch.co.uk>
William Xie <william.xie@intel.com> William Xie <william.xie@intel.com>
Xiang Long <xiang.long@intel.com> Xiang Long <xiang.long@intel.com>
......
...@@ -285,6 +285,10 @@ enum { ...@@ -285,6 +285,10 @@ enum {
- (NSString*)UUIDString; - (NSString*)UUIDString;
@end @end
@interface NSControl (MountainLionSDK)
@property BOOL allowsExpansionToolTips;
@end
#endif // MAC_OS_X_VERSION_10_8 #endif // MAC_OS_X_VERSION_10_8
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
#include "base/mac/bundle_locations.h" #include "base/mac/bundle_locations.h"
#include "base/mac/sdk_forward_declarations.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/avatar_menu.h" #include "chrome/browser/profiles/avatar_menu.h"
...@@ -159,6 +160,8 @@ const CGFloat kSupervisedUserSpacing = 26.0; ...@@ -159,6 +160,8 @@ const CGFloat kSupervisedUserSpacing = 26.0;
NSRect frame = [nameField frame]; NSRect frame = [nameField frame];
frame.size.width = kMaxItemTextWidth; frame.size.width = kMaxItemTextWidth;
[nameField setFrame:frame]; [nameField setFrame:frame];
if ([nameField respondsToSelector:@selector(setAllowsExpansionToolTips:)])
[nameField setAllowsExpansionToolTips:YES];
} }
*widthAdjust = std::max(*widthAdjust, delta.width); *widthAdjust = std::max(*widthAdjust, delta.width);
......
...@@ -701,6 +701,13 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -701,6 +701,13 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
IDS_PROFILES_NEW_AVATAR_MENU_EDIT_NAME_ACCESSIBLE_NAME, IDS_PROFILES_NEW_AVATAR_MENU_EDIT_NAME_ACCESSIBLE_NAME,
base::SysNSStringToUTF16(profileName)) base::SysNSStringToUTF16(profileName))
forAttribute:NSAccessibilityTitleAttribute]; forAttribute:NSAccessibilityTitleAttribute];
NSSize textSize = [profileName sizeWithAttributes:@{
NSFontAttributeName : [profileNameTextField_ font]
}];
if (textSize.width > frameRect.size.width - [hoverImage size].width * 2)
[self setToolTip:profileName];
} }
[[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole [[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole
...@@ -1805,6 +1812,16 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1805,6 +1812,16 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[profileButton setTarget:self]; [profileButton setTarget:self];
[profileButton setAction:@selector(switchToProfile:)]; [profileButton setAction:@selector(switchToProfile:)];
NSSize textSize = [[profileButton title] sizeWithAttributes:@{
NSFontAttributeName : [profileButton font]
}];
CGFloat availableWidth = rect.size.width - kSmallImageSide -
kImageTitleSpacing - kHorizontalSpacing;
if (std::ceil(textSize.width) > availableWidth)
[profileButton setToolTip:[profileButton title]];
return profileButton.autorelease(); return profileButton.autorelease();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment