| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
| 8 | 8 |
| 9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 [self addTrackingArea:trackingArea_.get()]; | 404 [self addTrackingArea:trackingArea_.get()]; |
| 405 | 405 |
| 406 NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide); | 406 NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide); |
| 407 if (editingAllowed) { | 407 if (editingAllowed) { |
| 408 changePhotoButton_.reset([self changePhotoButtonWithRect:bounds]); | 408 changePhotoButton_.reset([self changePhotoButtonWithRect:bounds]); |
| 409 [self addSubview:changePhotoButton_]; | 409 [self addSubview:changePhotoButton_]; |
| 410 | 410 |
| 411 // Hide the button until the image is hovered over. | 411 // Hide the button until the image is hovered over. |
| 412 [changePhotoButton_ setHidden:YES]; | 412 [changePhotoButton_ setHidden:YES]; |
| 413 } | 413 } |
| 414 | |
| 415 // Add the frame overlay last, so that both the photo and the button | |
| 416 // look like circles. | |
| 417 base::scoped_nsobject<NSImageView> frameOverlay( | |
| 418 [[NSImageView alloc] initWithFrame:bounds]); | |
| 419 [frameOverlay setImage:ui::ResourceBundle::GetSharedInstance(). | |
| 420 GetNativeImageNamed(IDR_ICON_PROFILES_AVATAR_PHOTO_FRAME).AsNSImage()]; | |
| 421 [self addSubview:frameOverlay]; | |
| 422 } | 414 } |
| 423 return self; | 415 return self; |
| 424 } | 416 } |
| 425 | 417 |
| 418 - (void)drawRect:(NSRect)dirtyRect { |
| 419 NSRect bounds = [self bounds]; |
| 420 |
| 421 // Display the profile picture as a circle. |
| 422 NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:bounds]; |
| 423 [path addClip]; |
| 424 [self.image drawAtPoint:bounds.origin |
| 425 fromRect:bounds |
| 426 operation:NSCompositeSourceOver |
| 427 fraction:1.0]; |
| 428 |
| 429 } |
| 430 |
| 426 - (void)editPhoto:(id)sender { | 431 - (void)editPhoto:(id)sender { |
| 427 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); | 432 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); |
| 428 } | 433 } |
| 429 | 434 |
| 430 - (void)mouseEntered:(NSEvent*)event { | 435 - (void)mouseEntered:(NSEvent*)event { |
| 431 [changePhotoButton_ setHidden:NO]; | 436 [changePhotoButton_ setHidden:NO]; |
| 432 } | 437 } |
| 433 | 438 |
| 434 - (void)mouseExited:(NSEvent*)event { | 439 - (void)mouseExited:(NSEvent*)event { |
| 435 [changePhotoButton_ setHidden:YES]; | 440 [changePhotoButton_ setHidden:YES]; |
| (...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 IDR_CLOSE_1_P).ToNSImage()]; | 1695 IDR_CLOSE_1_P).ToNSImage()]; |
| 1691 [deleteButton setTarget:self]; | 1696 [deleteButton setTarget:self]; |
| 1692 [deleteButton setAction:@selector(showAccountRemovalView:)]; | 1697 [deleteButton setAction:@selector(showAccountRemovalView:)]; |
| 1693 [deleteButton setTag:tag]; | 1698 [deleteButton setTag:tag]; |
| 1694 | 1699 |
| 1695 [button addSubview:deleteButton]; | 1700 [button addSubview:deleteButton]; |
| 1696 return button.autorelease(); | 1701 return button.autorelease(); |
| 1697 } | 1702 } |
| 1698 | 1703 |
| 1699 @end | 1704 @end |
| OLD | NEW |