Commit bc337a09 authored by anthonyvd's avatar anthonyvd Committed by Commit bot

[User Menu] Flipped the profile badge to be on the LHS for RTL layouts

Discussed with bettes@ to decide that the profile badge on RTL layouts
should be on the LHS instead.
Also fixed the position of the circular mask for profile icon on RTL
layouts (see first bug) - the circular mask needs to be bumped to the
right on RTL layouts so that it's right-aligned.

See comparative screenshots:
https://drive.google.com/drive/folders/0B7Fvv7JszRyGN1FKakw4RXE2Vkk?usp=sharing

BUG=640907
BUG=615893

Review-Url: https://codereview.chromium.org/2285413002
Cr-Commit-Position: refs/heads/master@{#415338}
parent 6f208d56
......@@ -372,12 +372,6 @@ class EditableProfilePhoto : public views::LabelButton {
SetSize(GetPreferredSize());
}
// Calculate the circular mask that will be used to display the photo.
circular_mask_.addCircle(
SkIntToScalar(icon_image_side() / 2),
SkIntToScalar(icon_image_side() / 2) + badge_spacing(),
SkIntToScalar(icon_image_side() / 2));
if (switches::IsMaterialDesignUserMenu() || !is_editing_allowed) {
SetEnabled(false);
return;
......@@ -400,19 +394,17 @@ class EditableProfilePhoto : public views::LabelButton {
AddChildView(photo_overlay_);
}
void OnPaint(gfx::Canvas* canvas) override {
canvas->Save();
// Display the profile picture as a circle.
canvas->ClipPath(circular_mask_, true);
views::LabelButton::OnPaint(canvas);
canvas->Restore();
}
void PaintChildren(const ui::PaintContext& context) override {
{
// Display any children (the "change photo" overlay) as a circle.
ui::ClipRecorder clip_recorder(context);
clip_recorder.ClipPathWithAntiAliasing(circular_mask_);
gfx::Rect clip_bounds = image()->GetMirroredBounds();
gfx::Path clip_mask;
clip_mask.addCircle(
clip_bounds.x() + clip_bounds.width() / 2,
clip_bounds.y() + clip_bounds.height() / 2,
clip_bounds.width() / 2);
clip_recorder.ClipPathWithAntiAliasing(clip_mask);
View::PaintChildren(context);
}
......@@ -424,10 +416,11 @@ class EditableProfilePhoto : public views::LabelButton {
int badge_offset =
icon_image_side() + badge_spacing() - GetProfileBadgeSize();
gfx::Vector2d badge_offset_vector = gfx::Vector2d(
badge_offset,
GetMirroredXWithWidthInView(badge_offset, GetProfileBadgeSize()),
badge_offset + (switches::IsMaterialDesignUserMenu()
? views::kRelatedControlSmallVerticalSpacing
: 0));
gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector;
// Paint the circular background.
......@@ -503,7 +496,6 @@ class EditableProfilePhoto : public views::LabelButton {
}
bool interactive_;
gfx::Path circular_mask_;
// Image that is shown when hovering over the image button. Can be NULL if
// the photo isn't allowed to be edited (e.g. for guest profiles).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment