Commit 5b1568f6 authored by noms@chromium.org's avatar noms@chromium.org

[Mac] Draw the circular avatar programmatically rather than with a frame.

Since we had to change it on Win/Linux, I thought it would be good to be 
consistent and draw the frame on Mac as well.

BUG=372721

Review URL: https://codereview.chromium.org/298973007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272719 0039d316-1c4b-4281-b951-d872f2087c98
parent c5b27fec
...@@ -411,18 +411,23 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -411,18 +411,23 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
// Hide the button until the image is hovered over. // Hide the button until the image is hovered over.
[changePhotoButton_ setHidden:YES]; [changePhotoButton_ setHidden:YES];
} }
// Add the frame overlay last, so that both the photo and the button
// look like circles.
base::scoped_nsobject<NSImageView> frameOverlay(
[[NSImageView alloc] initWithFrame:bounds]);
[frameOverlay setImage:ui::ResourceBundle::GetSharedInstance().
GetNativeImageNamed(IDR_ICON_PROFILES_AVATAR_PHOTO_FRAME).AsNSImage()];
[self addSubview:frameOverlay];
} }
return self; return self;
} }
- (void)drawRect:(NSRect)dirtyRect {
NSRect bounds = [self bounds];
// Display the profile picture as a circle.
NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:bounds];
[path addClip];
[self.image drawAtPoint:bounds.origin
fromRect:bounds
operation:NSCompositeSourceOver
fraction:1.0];
}
- (void)editPhoto:(id)sender { - (void)editPhoto:(id)sender {
avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex());
} }
......
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