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

Side by Side 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: Styling issues Created 5 years, 9 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
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.mm ('k') | no next file » | 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 #import <Carbon/Carbon.h> // kVK_Return. 6 #import <Carbon/Carbon.h> // kVK_Return.
7 7
8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
9 9
10 #include "base/mac/bundle_locations.h" 10 #include "base/mac/bundle_locations.h"
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 [profileNameTextField_ setTarget:self]; 694 [profileNameTextField_ setTarget:self];
695 [profileNameTextField_ setAction:@selector(saveProfileName:)]; 695 [profileNameTextField_ setAction:@selector(saveProfileName:)];
696 696
697 // Hide the textfield until the user clicks on the button. 697 // Hide the textfield until the user clicks on the button.
698 [profileNameTextField_ setHidden:YES]; 698 [profileNameTextField_ setHidden:YES];
699 699
700 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSStringF( 700 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSStringF(
701 IDS_PROFILES_NEW_AVATAR_MENU_EDIT_NAME_ACCESSIBLE_NAME, 701 IDS_PROFILES_NEW_AVATAR_MENU_EDIT_NAME_ACCESSIBLE_NAME,
702 base::SysNSStringToUTF16(profileName)) 702 base::SysNSStringToUTF16(profileName))
703 forAttribute:NSAccessibilityTitleAttribute]; 703 forAttribute:NSAccessibilityTitleAttribute];
704
705 NSSize textSize = [profileName sizeWithAttributes:@{
706 NSFontAttributeName : [profileNameTextField_ font]
707 }];
708
709 if (textSize.width > frameRect.size.width - [hoverImage size].width * 2)
710 [self setToolTip:profileName];
704 } 711 }
705 712
706 [[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole 713 [[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole
707 forAttribute:NSAccessibilityRoleAttribute]; 714 forAttribute:NSAccessibilityRoleAttribute];
708 [[self cell] 715 [[self cell]
709 accessibilitySetOverrideValue:NSAccessibilityRoleDescription( 716 accessibilitySetOverrideValue:NSAccessibilityRoleDescription(
710 NSAccessibilityButtonRole, nil) 717 NSAccessibilityButtonRole, nil)
711 forAttribute:NSAccessibilityRoleDescriptionAttribute]; 718 forAttribute:NSAccessibilityRoleDescriptionAttribute];
712 719
713 [self setBordered:NO]; 720 [self setBordered:NO];
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 1805
1799 [profileButton setDefaultImage:CreateProfileImage( 1806 [profileButton setDefaultImage:CreateProfileImage(
1800 itemIcon, kSmallImageSide).ToNSImage()]; 1807 itemIcon, kSmallImageSide).ToNSImage()];
1801 [profileButton setImagePosition:NSImageLeft]; 1808 [profileButton setImagePosition:NSImageLeft];
1802 [profileButton setAlignment:NSLeftTextAlignment]; 1809 [profileButton setAlignment:NSLeftTextAlignment];
1803 [profileButton setBordered:NO]; 1810 [profileButton setBordered:NO];
1804 [profileButton setTag:itemIndex]; 1811 [profileButton setTag:itemIndex];
1805 [profileButton setTarget:self]; 1812 [profileButton setTarget:self];
1806 [profileButton setAction:@selector(switchToProfile:)]; 1813 [profileButton setAction:@selector(switchToProfile:)];
1807 1814
1815 NSSize textSize = [[profileButton title] sizeWithAttributes:@{
1816 NSFontAttributeName : [profileButton font]
1817 }];
1818
1819 CGFloat availableWidth = rect.size.width - kSmallImageSide -
1820 kImageTitleSpacing - kHorizontalSpacing;
1821
1822 if (std::ceil(textSize.width) > availableWidth)
1823 [profileButton setToolTip:[profileButton title]];
1824
1808 return profileButton.autorelease(); 1825 return profileButton.autorelease();
1809 } 1826 }
1810 1827
1811 - (NSView*)createOptionsViewWithRect:(NSRect)rect 1828 - (NSView*)createOptionsViewWithRect:(NSRect)rect
1812 displayLock:(BOOL)displayLock { 1829 displayLock:(BOOL)displayLock {
1813 NSRect viewRect = NSMakeRect(0, 0, 1830 NSRect viewRect = NSMakeRect(0, 0,
1814 rect.size.width, 1831 rect.size.width,
1815 kBlueButtonHeight + kSmallVerticalSpacing); 1832 kBlueButtonHeight + kSmallVerticalSpacing);
1816 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); 1833 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]);
1817 1834
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 } 2301 }
2285 2302
2286 - (bool)shouldShowGoIncognito { 2303 - (bool)shouldShowGoIncognito {
2287 bool incognitoAvailable = 2304 bool incognitoAvailable =
2288 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2305 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2289 IncognitoModePrefs::DISABLED; 2306 IncognitoModePrefs::DISABLED;
2290 return incognitoAvailable && !browser_->profile()->IsGuestSession(); 2307 return incognitoAvailable && !browser_->profile()->IsGuestSession();
2291 } 2308 }
2292 2309
2293 @end 2310 @end
OLDNEW
« 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