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

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: 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 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]}];
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
707
708 if (textSize.width > frameRect.size.width - [hoverImage size].width * 2)
709 [self setToolTip:profileName];
704 } 710 }
705 711
706 [[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole 712 [[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole
707 forAttribute:NSAccessibilityRoleAttribute]; 713 forAttribute:NSAccessibilityRoleAttribute];
708 [[self cell] 714 [[self cell]
709 accessibilitySetOverrideValue:NSAccessibilityRoleDescription( 715 accessibilitySetOverrideValue:NSAccessibilityRoleDescription(
710 NSAccessibilityButtonRole, nil) 716 NSAccessibilityButtonRole, nil)
711 forAttribute:NSAccessibilityRoleDescriptionAttribute]; 717 forAttribute:NSAccessibilityRoleDescriptionAttribute];
712 718
713 [self setBordered:NO]; 719 [self setBordered:NO];
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 1804
1799 [profileButton setDefaultImage:CreateProfileImage( 1805 [profileButton setDefaultImage:CreateProfileImage(
1800 itemIcon, kSmallImageSide).ToNSImage()]; 1806 itemIcon, kSmallImageSide).ToNSImage()];
1801 [profileButton setImagePosition:NSImageLeft]; 1807 [profileButton setImagePosition:NSImageLeft];
1802 [profileButton setAlignment:NSLeftTextAlignment]; 1808 [profileButton setAlignment:NSLeftTextAlignment];
1803 [profileButton setBordered:NO]; 1809 [profileButton setBordered:NO];
1804 [profileButton setTag:itemIndex]; 1810 [profileButton setTag:itemIndex];
1805 [profileButton setTarget:self]; 1811 [profileButton setTarget:self];
1806 [profileButton setAction:@selector(switchToProfile:)]; 1812 [profileButton setAction:@selector(switchToProfile:)];
1807 1813
1814 NSSize textSize = [[profileButton title] sizeWithAttributes:
1815 @{NSFontAttributeName: [profileButton font]}];
1816
1817 CGFloat availableWidth = rect.size.width - kSmallImageSide -
1818 kImageTitleSpacing - kHorizontalSpacing;
1819
1820 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
1821 [profileButton setToolTip:[profileButton title]];
1822
1808 return profileButton.autorelease(); 1823 return profileButton.autorelease();
1809 } 1824 }
1810 1825
1811 - (NSView*)createOptionsViewWithRect:(NSRect)rect 1826 - (NSView*)createOptionsViewWithRect:(NSRect)rect
1812 displayLock:(BOOL)displayLock { 1827 displayLock:(BOOL)displayLock {
1813 NSRect viewRect = NSMakeRect(0, 0, 1828 NSRect viewRect = NSMakeRect(0, 0,
1814 rect.size.width, 1829 rect.size.width,
1815 kBlueButtonHeight + kSmallVerticalSpacing); 1830 kBlueButtonHeight + kSmallVerticalSpacing);
1816 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); 1831 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]);
1817 1832
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 } 2299 }
2285 2300
2286 - (bool)shouldShowGoIncognito { 2301 - (bool)shouldShowGoIncognito {
2287 bool incognitoAvailable = 2302 bool incognitoAvailable =
2288 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2303 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2289 IncognitoModePrefs::DISABLED; 2304 IncognitoModePrefs::DISABLED;
2290 return incognitoAvailable && !browser_->profile()->IsGuestSession(); 2305 return incognitoAvailable && !browser_->profile()->IsGuestSession();
2291 } 2306 }
2292 2307
2293 @end 2308 @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