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>
Vipul Bhasin <vipul.bhasin@gmail.com>
Visa Putkinen <v.putkinen@partner.samsung.com>
Vivek Galatage <vivek.vg@samsung.com>
Wesley Lancel <wesleylancel@gmail.com>
Will Hirsch <chromium@willhirsch.co.uk>
William Xie <william.xie@intel.com>
Xiang Long <xiang.long@intel.com>
......
......@@ -285,6 +285,10 @@ enum {
- (NSString*)UUIDString;
@end
@interface NSControl (MountainLionSDK)
@property BOOL allowsExpansionToolTips;
@end
#endif // MAC_OS_X_VERSION_10_8
......
......@@ -5,6 +5,7 @@
#import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/sdk_forward_declarations.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/avatar_menu.h"
......@@ -159,6 +160,8 @@ const CGFloat kSupervisedUserSpacing = 26.0;
NSRect frame = [nameField frame];
frame.size.width = kMaxItemTextWidth;
[nameField setFrame:frame];
if ([nameField respondsToSelector:@selector(setAllowsExpansionToolTips:)])
[nameField setAllowsExpansionToolTips:YES];
}
*widthAdjust = std::max(*widthAdjust, delta.width);
......
......@@ -701,6 +701,13 @@ 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]
}];
if (textSize.width > frameRect.size.width - [hoverImage size].width * 2)
[self setToolTip:profileName];
}
[[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole
......@@ -1805,6 +1812,16 @@ 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 (std::ceil(textSize.width) > availableWidth)
[profileButton setToolTip:[profileButton title]];
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