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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2242873002: [MD User Menu] New profile badge icons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 void OnPaint(gfx::Canvas* canvas) override { 399 void OnPaint(gfx::Canvas* canvas) override {
400 canvas->Save(); 400 canvas->Save();
401 // Display the profile picture as a circle. 401 // Display the profile picture as a circle.
402 canvas->ClipPath(circular_mask_, true); 402 canvas->ClipPath(circular_mask_, true);
403 views::LabelButton::OnPaint(canvas); 403 views::LabelButton::OnPaint(canvas);
404 canvas->Restore(); 404 canvas->Restore();
405 } 405 }
406 406
407 void PaintChildren(const ui::PaintContext& context) override { 407 void PaintChildren(const ui::PaintContext& context) override {
408 // Display any children (the "change photo" overlay) as a circle.
409 { 408 {
409 // Display any children (the "change photo" overlay) as a circle.
410 ui::ClipRecorder clip_recorder(context); 410 ui::ClipRecorder clip_recorder(context);
411 clip_recorder.ClipPathWithAntiAliasing(circular_mask_); 411 clip_recorder.ClipPathWithAntiAliasing(circular_mask_);
412 View::PaintChildren(context); 412 View::PaintChildren(context);
413 } 413 }
414 414
415 ui::PaintRecorder paint_recorder( 415 ui::PaintRecorder paint_recorder(
416 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize())); 416 context, gfx::Size(GetProfileBadgeSize(), GetProfileBadgeSize()));
417 gfx::Canvas* canvas = paint_recorder.canvas(); 417 gfx::Canvas* canvas = paint_recorder.canvas();
418 if (profile_->IsSupervised()) { 418 if (profile_->IsSupervised()) {
419 gfx::VectorIconId icon_id;
420 size_t icon_size;
421 // TODO(janeliulwq): Replace the following two profile badge icons when
422 // new versions of them are ready, which be inverted as silhouettes. Also,
423 // remove the code below for painting the background for the badges as
424 // they won't be necessary.
425 if (profile_->IsChild()) {
426 icon_id = gfx::VectorIconId::ACCOUNT_CHILD_INVERT;
427 icon_size = switches::IsMaterialDesignUserMenu() ? 21 : 26;
428 } else {
429 icon_id = gfx::VectorIconId::SUPERVISOR_ACCOUNT;
430 icon_size = switches::IsMaterialDesignUserMenu() ? 16 : 20;
431 }
432 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize()); 419 gfx::Rect bounds(0, 0, GetProfileBadgeSize(), GetProfileBadgeSize());
433
434 int badge_offset = 420 int badge_offset =
435 icon_image_side() + badge_spacing() - GetProfileBadgeSize(); 421 icon_image_side() + badge_spacing() - GetProfileBadgeSize();
436 gfx::Vector2d badge_offset_vector = gfx::Vector2d( 422 gfx::Vector2d badge_offset_vector = gfx::Vector2d(
437 badge_offset, 423 badge_offset,
438 badge_offset + (switches::IsMaterialDesignUserMenu() 424 badge_offset + (switches::IsMaterialDesignUserMenu()
439 ? views::kRelatedControlSmallVerticalSpacing 425 ? views::kRelatedControlSmallVerticalSpacing
440 : 0)); 426 : 0));
441 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; 427 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector;
442 428
429 // Paint the circular background.
443 SkPaint paint; 430 SkPaint paint;
444 paint.setAntiAlias(true); 431 paint.setAntiAlias(true);
445 paint.setColor(GetNativeTheme()->GetSystemColor( 432 paint.setColor(GetNativeTheme()->GetSystemColor(
446 ui::NativeTheme::kColorId_BubbleBackground)); 433 ui::NativeTheme::kColorId_BubbleBackground));
447 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint); 434 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, paint);
448 435
449 if (!switches::IsMaterialDesignUserMenu()) { 436 gfx::VectorIconId icon_id;
437 size_t icon_size;
438 SkColor icon_color;
439 if (switches::IsMaterialDesignUserMenu()) {
440 icon_id = profile_->IsChild()
441 ? gfx::VectorIconId::ACCOUNT_CHILD_CIRCLE
442 : gfx::VectorIconId::SUPERVISOR_ACCOUNT_CIRCLE;
443 icon_size = 22;
444 icon_color = gfx::kChromeIconGrey;
445 } else {
446 // Paint the light blue circle.
450 paint.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); 447 paint.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc));
451 canvas->DrawCircle( 448 canvas->DrawCircle(
452 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, 449 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding,
453 paint); 450 paint);
451
452 icon_id = profile_->IsChild()
453 ? gfx::VectorIconId::ACCOUNT_CHILD
454 : gfx::VectorIconId::SUPERVISOR_ACCOUNT;
455 icon_size = profile_->IsChild() ? 26 : 20;
456 icon_color = SkColorSetRGB(0, 0x66, 0xff);
454 } 457 }
455 458
459 // Paint the badge icon.
456 int offset = (GetProfileBadgeSize() - icon_size) / 2; 460 int offset = (GetProfileBadgeSize() - icon_size) / 2;
457 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); 461 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset));
458 const SkColor badge_color = switches::IsMaterialDesignUserMenu() 462 gfx::PaintVectorIcon(canvas, icon_id, icon_size, icon_color);
459 ? gfx::kChromeIconGrey
460 : SkColorSetRGB(0, 0x66, 0xff);
461 gfx::PaintVectorIcon(canvas, icon_id, icon_size, badge_color);
462 } 463 }
463 } 464 }
464 465
465 static int icon_image_side() { 466 static int icon_image_side() {
466 return switches::IsMaterialDesignUserMenu() ? kMdImageSide 467 return switches::IsMaterialDesignUserMenu() ? kMdImageSide
467 : kLargeImageSide; 468 : kLargeImageSide;
468 } 469 }
469 470
470 static int badge_spacing() { 471 static int badge_spacing() {
471 // The space between the right/bottom edge of the profile badge and the 472 // The space between the right/bottom edge of the profile badge and the
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2295 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2295 IncognitoModePrefs::DISABLED; 2296 IncognitoModePrefs::DISABLED;
2296 return incognito_available && !browser_->profile()->IsGuestSession(); 2297 return incognito_available && !browser_->profile()->IsGuestSession();
2297 } 2298 }
2298 2299
2299 void ProfileChooserView::PostActionPerformed( 2300 void ProfileChooserView::PostActionPerformed(
2300 ProfileMetrics::ProfileDesktopMenu action_performed) { 2301 ProfileMetrics::ProfileDesktopMenu action_performed) {
2301 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2302 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
2302 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2303 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
2303 } 2304 }
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/vector_icons/account_child.icon » ('j') | ui/gfx/vector_icons/account_child_circle.icon » ('J')

Powered by Google App Engine
This is Rietveld 408576698