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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm

Issue 2347283003: [Material][Mac] Adjust User Account Button (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | 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 "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_attributes_entry.h" 10 #include "chrome/browser/profiles/profile_attributes_entry.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const CGFloat kMaterialButtonExtraPadding = 6 - kDefaultPadding; 67 const CGFloat kMaterialButtonExtraPadding = 6 - kDefaultPadding;
68 68
69 return ui::MaterialDesignController::IsModeMaterial() 69 return ui::MaterialDesignController::IsModeMaterial()
70 ? kMaterialButtonExtraPadding 70 ? kMaterialButtonExtraPadding
71 : kButtonExtraPadding; 71 : kButtonExtraPadding;
72 } 72 }
73 73
74 // Extra padding for the MD signed out avatar button. 74 // Extra padding for the MD signed out avatar button.
75 const CGFloat kMaterialSignedOutWidthPadding = 2; 75 const CGFloat kMaterialSignedOutWidthPadding = 2;
76 76
77 // Kern value for the MD avatar button title.
78 const CGFloat kMaterialTitleKern = 0.25;
79
77 } // namespace 80 } // namespace
78 81
79 // Button cell with a custom border given by a set of nine-patch image grids. 82 // Button cell with a custom border given by a set of nine-patch image grids.
80 @interface CustomThemeButtonCell : NSButtonCell { 83 @interface CustomThemeButtonCell : NSButtonCell {
81 @private 84 @private
82 BOOL isThemedWindow_; 85 BOOL isThemedWindow_;
83 BOOL hasError_; 86 BOOL hasError_;
84 } 87 }
85 - (void)setIsThemedWindow:(BOOL)isThemedWindow; 88 - (void)setIsThemedWindow:(BOOL)isThemedWindow;
86 - (void)setHasError:(BOOL)hasError withTitle:(NSString*)title; 89 - (void)setHasError:(BOOL)hasError withTitle:(NSString*)title;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (browser_->profile()->IsGuestSession() && 270 if (browser_->profile()->IsGuestSession() &&
268 !ui::MaterialDesignController::IsModeMaterial()) { 271 !ui::MaterialDesignController::IsModeMaterial()) {
269 foregroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.9]; 272 foregroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.9];
270 [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.4]]; 273 [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.4]];
271 } else if (!isThemedWindow_) { 274 } else if (!isThemedWindow_) {
272 foregroundColor = [NSColor blackColor]; 275 foregroundColor = [NSColor blackColor];
273 [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.7]]; 276 [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.7]];
274 } else { 277 } else {
275 foregroundColor = [NSColor blackColor]; 278 foregroundColor = [NSColor blackColor];
276 [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.4]]; 279 [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.4]];
277 } 280 }
Avi (use Gerrit) 2016/09/20 00:35:43 This shadow code from lines 262–280 are only used
spqchan 2016/09/20 20:16:28 Done.
278 281
279 ProfileAttributesStorage& storage = 282 ProfileAttributesStorage& storage =
280 g_browser_process->profile_manager()->GetProfileAttributesStorage(); 283 g_browser_process->profile_manager()->GetProfileAttributesStorage();
281 // If there is a single local profile, then use the generic avatar button 284 // If there is a single local profile, then use the generic avatar button
282 // instead of the profile name. Never use the generic button if the active 285 // instead of the profile name. Never use the generic button if the active
283 // profile is Guest. 286 // profile is Guest.
284 bool useGenericButton = 287 bool useGenericButton =
285 !browser_->profile()->IsGuestSession() && 288 !browser_->profile()->IsGuestSession() &&
286 storage.GetNumberOfProfiles() == 1 && 289 storage.GetNumberOfProfiles() == 1 &&
287 !storage.GetAllProfilesAttributes().front()->IsAuthenticated(); 290 !storage.GetAllProfilesAttributes().front()->IsAuthenticated();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 [button setDefaultImage:nil]; 336 [button setDefaultImage:nil];
334 [button setHoverImage:nil]; 337 [button setHoverImage:nil];
335 [button setPressedImage:nil]; 338 [button setPressedImage:nil];
336 [button setImagePosition:NSNoImage]; 339 [button setImagePosition:NSNoImage];
337 } 340 }
338 341
339 base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( 342 base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
340 [[NSMutableParagraphStyle alloc] init]); 343 [[NSMutableParagraphStyle alloc] init]);
341 [paragraphStyle setAlignment:NSLeftTextAlignment]; 344 [paragraphStyle setAlignment:NSLeftTextAlignment];
342 345
343 base::scoped_nsobject<NSAttributedString> attributedTitle( 346 if (ui::MaterialDesignController::IsModeMaterial()) {
344 [[NSAttributedString alloc] 347 base::scoped_nsobject<NSAttributedString> attributedTitle(
345 initWithString:buttonTitle 348 [[NSAttributedString alloc]
346 attributes:@{ NSShadowAttributeName : shadow.get(), 349 initWithString:buttonTitle
347 NSForegroundColorAttributeName : foregroundColor, 350 attributes:@{
348 NSParagraphStyleAttributeName : paragraphStyle }]); 351 NSForegroundColorAttributeName : foregroundColor,
349 [button_ setAttributedTitle:attributedTitle]; 352 NSParagraphStyleAttributeName : paragraphStyle,
353 NSKernAttributeName :
354 [NSNumber numberWithFloat:kMaterialTitleKern]
355 }]);
356 [button_ setAttributedTitle:attributedTitle];
357 } else {
358 base::scoped_nsobject<NSAttributedString> attributedTitle(
359 [[NSAttributedString alloc]
360 initWithString:buttonTitle
361 attributes:@{
362 NSShadowAttributeName : shadow.get(),
363 NSForegroundColorAttributeName : foregroundColor,
364 NSParagraphStyleAttributeName : paragraphStyle
365 }]);
366 [button_ setAttributedTitle:attributedTitle];
367 }
350 [button_ sizeToFit]; 368 [button_ sizeToFit];
351 369
352 if (layoutParent) { 370 if (layoutParent) {
353 // Because the width of the button might have changed, the parent browser 371 // Because the width of the button might have changed, the parent browser
354 // frame needs to recalculate the button bounds and redraw it. 372 // frame needs to recalculate the button bounds and redraw it.
355 [[BrowserWindowController 373 [[BrowserWindowController
356 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()] 374 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]
357 layoutSubviews]; 375 layoutSubviews];
358 } 376 }
359 } 377 }
360 378
361 - (void)setErrorStatus:(BOOL)hasError { 379 - (void)setErrorStatus:(BOOL)hasError {
362 hasError_ = hasError; 380 hasError_ = hasError;
363 [self updateAvatarButtonAndLayoutParent:YES]; 381 [self updateAvatarButtonAndLayoutParent:YES];
364 } 382 }
365 383
366 @end 384 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698