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

Unified Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 290333012: [Win] Draw the circular avatar programmatically rather than with a frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing virtual keyword Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.cc ('k') | ui/app_list/views/app_list_background.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/profiles/profile_chooser_view.cc
diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
index 5d35fcd96461d9af1500346ad53b616763c9d06d..73993c456709252447190b7a12e133615bf3a352 100644
--- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
@@ -38,6 +38,8 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/path.h"
+#include "ui/gfx/skia_util.h"
#include "ui/gfx/text_elider.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/button/blue_button.h"
@@ -157,13 +159,11 @@ class EditableProfilePhoto : public views::ImageView {
SetImage(image.ToImageSkia());
SetBoundsRect(bounds);
- ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
- views::ImageView* frame_overlay = new views::ImageView();
- frame_overlay->SetImage(rb->GetImageNamed(
- IDR_ICON_PROFILES_AVATAR_PHOTO_FRAME).ToImageSkia());
- frame_overlay->SetVerticalAlignment(views::ImageView::CENTER);
- frame_overlay->SetBoundsRect(bounds);
- AddChildView(frame_overlay);
+ // Calculate the circular mask that will be used to display the photo.
+ gfx::Point center = bounds.CenterPoint();
+ circular_mask_.addCircle(SkIntToScalar(center.x()),
+ SkIntToScalar(center.y()),
+ SkIntToScalar(bounds.width() / 2));
if (!is_editing_allowed)
return;
@@ -179,13 +179,27 @@ class EditableProfilePhoto : public views::ImageView {
change_photo_button_->set_background(
views::Background::CreateSolidBackground(kBackgroundColor));
change_photo_button_->SetImage(views::LabelButton::STATE_NORMAL,
- *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_CAMERA));
+ *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
+ IDR_ICON_PROFILES_EDIT_CAMERA));
change_photo_button_->SetBoundsRect(bounds);
change_photo_button_->SetVisible(false);
AddChildView(change_photo_button_);
}
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
+ // Display the profile picture as a circle.
+ canvas->ClipPath(circular_mask_, true);
+ views::ImageView::OnPaint(canvas);
+ }
+
+ virtual void PaintChildren(gfx::Canvas* canvas,
+ const views::CullSet& cull_set) OVERRIDE {
+ // Display any children (the "change photo" overlay) as a circle.
+ canvas->ClipPath(circular_mask_, true);
+ View::PaintChildren(canvas, cull_set);
+ }
+
views::LabelButton* change_photo_button() { return change_photo_button_; }
private:
@@ -200,6 +214,8 @@ class EditableProfilePhoto : public views::ImageView {
change_photo_button_->SetVisible(false);
}
+ gfx::Path circular_mask_;
+
// Button that is shown when hovering over the image view. Can be NULL if
// the photo isn't allowed to be edited (e.g. for guest profiles).
views::LabelButton* change_photo_button_;
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.cc ('k') | ui/app_list/views/app_list_background.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698