| 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. |
| 26 scoped_ptr<ui::MenuModel> model_; |
| 27 |
| 28 // Array of the below view controllers. |
| 29 scoped_nsobject<NSMutableArray> items_; |
| 30 } |
| 31 |
| 32 // Designated initializer. |point| must be in screen coordinates. |
| 33 - (id)initWithModel:(scoped_ptr<ui::MenuModel>)model |
| 34 parentWindow:(NSWindow*)parent |
| 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 IBOutlet __weak NSImageView* iconView_; |
| 60 IBOutlet __weak NSTextField* nameField_; |
| 61 } |
| 62 @property(readonly, nonatomic) size_t modelIndex; |
| 63 @property(assign, nonatomic) BOOL isHighlighted; |
| 64 @property(assign, nonatomic) NSTextField* nameField; |
| 65 |
| 66 // Designated initializer. |
| 67 - (id)initWithModelIndex:(size_t)modelIndex |
| 68 menuController:(ActionBoxMenuBubbleController*)controller; |
| 69 |
| 70 // Highlights the subviews appropriately for a given event type. |
| 71 - (void)highlightForEventType:(NSEventType)type; |
| 72 |
| 73 // Execute the action of a given menu item. |
| 74 - (IBAction)itemSelected:(id)sender; |
| 75 |
| 76 @end |
| 77 |
| 78 //////////////////////////////////////////////////////////////////////////////// |
| 79 |
| 80 // Simple button cell to get tracking and mouse events forwarded back to the |
| 81 // view controller for changing highlight style of the item subviews. This is |
| 82 // an invisible button that underlays most of the menu item and is responsible |
| 83 // for performing the attached action. |
| 84 @interface ActionBoxMenuItemView : NSView { |
| 85 @private |
| 86 // The controller that manages this. |
| 87 IBOutlet __weak ActionBoxMenuItemController* viewController_; |
| 88 |
| 89 // Used to highlight the background on hover. |
| 90 ScopedCrTrackingArea trackingArea_; |
| 91 } |
| 92 |
| 93 @property(assign, nonatomic) ActionBoxMenuItemController* viewController; |
| 94 |
| 95 @end |
| 96 |
| 97 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ACTION_BOX_MENU_BUBBLE_CONTROLLE
R_H_ |
| OLD | NEW |