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

Unified Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 298973007: [Mac] Draw the circular avatar programmatically rather than with a frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rachel comments 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
index ddb04bcd659ee7942beaec1cb0ce8eb552063c37..a79c2a2348e0ec4e2aadeb56bff9d84f2e390c9d 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
@@ -411,18 +411,23 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
// Hide the button until the image is hovered over.
[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;
}
+- (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 {
avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex());
}
« 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