Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ACTION_BOX_MENU_BUBBLE_CONTROLLER_H _ | |
| 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ACTION_BOX_MENU_BUBBLE_CONTROLLER_H _ | |
| 7 | |
| 8 #import <Cocoa/Cocoa.h> | |
| 9 | |
| 10 #include "base/memory/scoped_nsobject.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | |
| 13 #import "chrome/browser/ui/cocoa/tracking_area.h" | |
| 14 | |
| 15 class Browser; | |
| 16 @class HoverImageButton; | |
| 17 | |
| 18 namespace ui { | |
| 19 class MenuModel; | |
| 20 } | |
| 21 | |
| 22 // This window controller manages the action box popup menu. | |
| 23 @interface ActionBoxMenuBubbleController : BaseBubbleController { | |
| 24 @private | |
| 25 // The model that contains the data from the backend. (weak) | |
| 26 scoped_ptr<ui::MenuModel> model_; | |
|
Scott Hess - ex-Googler
2012/10/12 23:02:47
Doesn't look weak to me.
beaudoin
2012/10/13 00:20:55
Leftover from old implementation. Good catch!
Don
| |
| 27 | |
| 28 // Array of the below view controllers. | |
| 29 scoped_nsobject<NSMutableArray> items_; | |
| 30 } | |
| 31 | |
| 32 // Designated initializer. | |
| 33 - (id)initWithBrowser:(Browser*)parentBrowser | |
| 34 usingModel:(scoped_ptr<ui::MenuModel>)model | |
| 35 anchoredAt:(NSPoint)point; | |
| 36 | |
| 37 // Accesses the model. | |
| 38 - (ui::MenuModel*)model; | |
| 39 | |
| 40 // Executes the action of a given menu item. | |
| 41 - (IBAction)itemSelected:(id)sender; | |
| 42 | |
| 43 @end | |
| 44 | |
| 45 //////////////////////////////////////////////////////////////////////////////// | |
| 46 | |
| 47 // This view controller manages the menu item XIB. | |
| 48 @interface ActionBoxMenuItemController : NSViewController { | |
| 49 @private | |
| 50 // The parent menu controller owns this. | |
| 51 __weak ActionBoxMenuBubbleController* controller_; | |
| 52 | |
| 53 size_t modelIndex_; | |
| 54 | |
| 55 // Tracks whether this item is currently highlighted. | |
| 56 BOOL isHighlighted_; | |
| 57 | |
| 58 // Instance variables that back the outlets. | |
| 59 __weak NSImageView* iconView_; | |
| 60 __weak NSTextField* nameField_; | |
| 61 } | |
| 62 @property(readonly, nonatomic) size_t modelIndex; | |
| 63 @property(assign, nonatomic) BOOL isHighlighted; | |
| 64 @property(assign, nonatomic) IBOutlet NSImageView* iconView; | |
| 65 @property(assign, nonatomic) IBOutlet NSTextField* nameField; | |
|
Scott Hess - ex-Googler
2012/10/12 23:02:47
IBOutlet is an empty macro which says "Hey, Interf
beaudoin
2012/10/13 00:20:55
Still use nameField outside, so I left it. Took ou
| |
| 66 @property(readonly, nonatomic) ActionBoxMenuBubbleController* controller; | |
| 67 | |
| 68 // Designated initializer. | |
| 69 - (id)initWithModelIndex:(size_t)modelIndex | |
| 70 menuController:(ActionBoxMenuBubbleController*)controller; | |
| 71 | |
| 72 // Highlights the subviews appropriately for a given event type. | |
| 73 - (void)highlightForEventType:(NSEventType)type; | |
| 74 | |
| 75 // Execute the action of a given menu item. | |
| 76 - (IBAction)itemSelected:(id)sender; | |
| 77 | |
| 78 @end | |
| 79 | |
| 80 //////////////////////////////////////////////////////////////////////////////// | |
| 81 | |
| 82 // Simple button cell to get tracking and mouse events forwarded back to the | |
| 83 // view controller for changing highlight style of the item subviews. This is | |
| 84 // an invisible button that underlays most of the menu item and is responsible | |
| 85 // for performing the attached action. | |
| 86 @interface ActionBoxMenuItemView : NSView { | |
| 87 @private | |
| 88 // The controller that manages this. | |
| 89 __weak ActionBoxMenuItemController* viewController_; | |
| 90 | |
| 91 // Used to highlight the background on hover. | |
| 92 ScopedCrTrackingArea trackingArea_; | |
| 93 } | |
| 94 | |
| 95 @property(assign, nonatomic) | |
| 96 IBOutlet ActionBoxMenuItemController* viewController; | |
|
Scott Hess - ex-Googler
2012/10/12 23:02:47
This seems like it could be one line?
beaudoin
2012/10/13 00:20:55
By moving the IBOutlet it now fits!
Done.
| |
| 97 | |
| 98 @end | |
| 99 | |
| 100 | |
| 101 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ACTION_BOX_MENU_BUBBLE_CONTROLLE R_H_ | |
| OLD | NEW |