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

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: 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 aa013c16d706dde2b4e4e23c8b221e97ad446f2d..8e427a2309f355478c51ca84e7fe06e5d8d160cf 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
@@ -58,6 +58,7 @@
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
#include "ui/gfx/text_elider.h"
#include "ui/native_theme/native_theme.h"
@@ -410,18 +411,25 @@ 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()];
groby-ooo-7-16 2014/05/23 17:33:42 Can you get rid of the image resource, too?
noms (inactive) 2014/05/23 19:32:13 Not yet -- until it lands, it's still being used o
- [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];
+ {
groby-ooo-7-16 2014/05/23 17:33:42 You can kill the scoped state - Cocoa automaticall
noms (inactive) 2014/05/23 19:32:13 Nice! Done. On 2014/05/23 17:33:42, groby wrote:
+ gfx::ScopedNSGraphicsContextSaveGState scopedGState;
+ [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