| 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 #ifndef CHROME_BROWSER_UI_COCOA_PROFILES_AVATAR_MENU_BUBBLE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_PROFILES_AVATAR_MENU_BUBBLE_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_PROFILES_AVATAR_MENU_BUBBLE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_PROFILES_AVATAR_MENU_BUBBLE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/mac/objc_property_releaser.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 13 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 13 #import "ui/base/cocoa/tracking_area.h" | 14 #import "ui/base/cocoa/tracking_area.h" |
| 14 | 15 |
| 15 class AvatarMenu; | 16 class AvatarMenu; |
| 16 class Browser; | 17 class Browser; |
| 17 | 18 |
| 18 // This window controller manages the bubble that displays a "menu" of profiles. | 19 // This window controller manages the bubble that displays a "menu" of profiles. |
| 19 // It is brought open by clicking on the avatar icon in the window frame. | 20 // It is brought open by clicking on the avatar icon in the window frame. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 - (IBAction)switchProfile:(id)sender; | 49 - (IBAction)switchProfile:(id)sender; |
| 49 | 50 |
| 50 @end | 51 @end |
| 51 | 52 |
| 52 //////////////////////////////////////////////////////////////////////////////// | 53 //////////////////////////////////////////////////////////////////////////////// |
| 53 | 54 |
| 54 // This view controller manages the menu item XIB. | 55 // This view controller manages the menu item XIB. |
| 55 @interface AvatarMenuItemController : NSViewController<NSAnimationDelegate> { | 56 @interface AvatarMenuItemController : NSViewController<NSAnimationDelegate> { |
| 56 @private | 57 @private |
| 57 // The parent menu controller; owns this. | 58 // The parent menu controller; owns this. |
| 58 __weak AvatarMenuBubbleController* controller_; | 59 AvatarMenuBubbleController* controller_; // weak |
| 59 | 60 |
| 60 // The index of the item in the AvatarMenu. | 61 // The index of the item in the AvatarMenu. |
| 61 size_t menuIndex_; | 62 size_t menuIndex_; |
| 62 | 63 |
| 63 // Tracks whether this item is currently highlighted. | 64 // Tracks whether this item is currently highlighted. |
| 64 BOOL isHighlighted_; | 65 BOOL isHighlighted_; |
| 65 | 66 |
| 66 // The animation showing the edit link, which is run after the user has | 67 // The animation showing the edit link, which is run after the user has |
| 67 // dwelled over the item for a short delay. | 68 // dwelled over the item for a short delay. |
| 68 base::scoped_nsobject<NSAnimation> linkAnimation_; | 69 base::scoped_nsobject<NSAnimation> linkAnimation_; |
| 69 | 70 |
| 70 // Instance variables that back the outlets. | 71 // Instance variables that back the outlets. |
| 71 __weak NSImageView* iconView_; | 72 NSImageView* iconView_; |
| 72 __weak NSImageView* activeView_; | 73 NSImageView* activeView_; |
| 73 __weak NSTextField* nameField_; | 74 NSTextField* nameField_; |
| 74 // These two views sit on top of each other, and only one is visible at a | 75 // These two views sit on top of each other, and only one is visible at a |
| 75 // time. The editButton_ is visible when the mouse is over the item and the | 76 // time. The editButton_ is visible when the mouse is over the item and the |
| 76 // emailField_ is visible otherwise. | 77 // emailField_ is visible otherwise. |
| 77 __weak NSTextField* emailField_; | 78 NSTextField* emailField_; |
| 78 __weak NSButton* editButton_; | 79 NSButton* editButton_; |
| 80 |
| 81 base::mac::ObjCPropertyReleaser propertyReleaser_; |
| 79 } | 82 } |
| 80 @property(readonly, nonatomic) size_t menuIndex; | 83 @property(readonly, nonatomic) size_t menuIndex; |
| 81 @property(assign, nonatomic) BOOL isHighlighted; | 84 @property(assign, nonatomic) BOOL isHighlighted; |
| 82 @property(assign, nonatomic) IBOutlet NSImageView* iconView; | 85 @property(retain, nonatomic) IBOutlet NSImageView* iconView; |
| 83 @property(assign, nonatomic) IBOutlet NSImageView* activeView; | 86 @property(retain, nonatomic) IBOutlet NSImageView* activeView; |
| 84 @property(assign, nonatomic) IBOutlet NSTextField* nameField; | 87 @property(retain, nonatomic) IBOutlet NSTextField* nameField; |
| 85 @property(assign, nonatomic) IBOutlet NSTextField* emailField; | 88 @property(retain, nonatomic) IBOutlet NSTextField* emailField; |
| 86 @property(assign, nonatomic) IBOutlet NSButton* editButton; | 89 @property(retain, nonatomic) IBOutlet NSButton* editButton; |
| 87 | 90 |
| 88 // Designated initializer. | 91 // Designated initializer. |
| 89 - (id)initWithMenuIndex:(size_t)menuIndex | 92 - (id)initWithMenuIndex:(size_t)menuIndex |
| 90 menuController:(AvatarMenuBubbleController*)controller; | 93 menuController:(AvatarMenuBubbleController*)controller; |
| 91 | 94 |
| 92 // Actions that are forwarded to the |controller_|. | 95 // Actions that are forwarded to the |controller_|. |
| 93 - (IBAction)switchToProfile:(id)sender; | 96 - (IBAction)switchToProfile:(id)sender; |
| 94 - (IBAction)editProfile:(id)sender; | 97 - (IBAction)editProfile:(id)sender; |
| 95 | 98 |
| 96 // Highlights the subviews appropriately for a given event type from the switch | 99 // Highlights the subviews appropriately for a given event type from the switch |
| 97 // profile button. | 100 // profile button. |
| 98 - (void)highlightForEventType:(NSEventType)type; | 101 - (void)highlightForEventType:(NSEventType)type; |
| 99 | 102 |
| 100 @end | 103 @end |
| 101 | 104 |
| 102 //////////////////////////////////////////////////////////////////////////////// | 105 //////////////////////////////////////////////////////////////////////////////// |
| 103 | 106 |
| 104 // Simple button cell to get tracking and mouse events forwarded back to the | 107 // Simple button cell to get tracking and mouse events forwarded back to the |
| 105 // view controller for changing highlight style of the item subviews. This is | 108 // view controller for changing highlight style of the item subviews. This is |
| 106 // an invisible button that underlays most of the menu item and is responsible | 109 // an invisible button that underlays most of the menu item and is responsible |
| 107 // for performing the switch profile action. | 110 // for performing the switch profile action. |
| 108 @interface AvatarMenuItemView : NSView { | 111 @interface AvatarMenuItemView : NSView { |
| 109 @private | 112 @private |
| 110 // The controller that manages this. | 113 // The controller that manages this. |
| 111 __weak AvatarMenuItemController* viewController_; | 114 // weak to not form a reference cycle with the controller. |
| 115 __unsafe_unretained AvatarMenuItemController* viewController_; |
| 112 | 116 |
| 113 // Used to highlight the background on hover. | 117 // Used to highlight the background on hover. |
| 114 ui::ScopedCrTrackingArea trackingArea_; | 118 ui::ScopedCrTrackingArea trackingArea_; |
| 115 } | 119 } |
| 116 @property(assign, nonatomic) IBOutlet AvatarMenuItemController* viewController; | 120 @property(assign, nonatomic) IBOutlet AvatarMenuItemController* viewController; |
| 117 @end | 121 @end |
| 118 | 122 |
| 119 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
| 120 | 124 |
| 121 @interface AccessibilityIgnoredImageCell : NSImageCell | 125 @interface AccessibilityIgnoredImageCell : NSImageCell |
| (...skipping 10 matching lines...) Expand all Loading... |
| 132 anchoredAt:(NSPoint)point; | 136 anchoredAt:(NSPoint)point; |
| 133 - (void)performLayout; | 137 - (void)performLayout; |
| 134 - (NSMutableArray*)items; | 138 - (NSMutableArray*)items; |
| 135 @end | 139 @end |
| 136 | 140 |
| 137 @interface AvatarMenuItemController (ExposedForTesting) | 141 @interface AvatarMenuItemController (ExposedForTesting) |
| 138 - (void)willStartAnimation:(NSAnimation*)animation; | 142 - (void)willStartAnimation:(NSAnimation*)animation; |
| 139 @end | 143 @end |
| 140 | 144 |
| 141 #endif // CHROME_BROWSER_UI_COCOA_PROFILES_AVATAR_MENU_BUBBLE_CONTROLLER_H_ | 145 #endif // CHROME_BROWSER_UI_COCOA_PROFILES_AVATAR_MENU_BUBBLE_CONTROLLER_H_ |
| OLD | NEW |