Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller.h |
| diff --git a/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller.h b/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e3b9adefed339b00a6a5a6b215c4b3e1450a846c |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller.h |
| @@ -0,0 +1,101 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ACTION_BOX_MENU_BUBBLE_CONTROLLER_H_ |
| +#define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ACTION_BOX_MENU_BUBBLE_CONTROLLER_H_ |
| + |
| +#import <Cocoa/Cocoa.h> |
| + |
| +#include "base/memory/scoped_nsobject.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| +#import "chrome/browser/ui/cocoa/tracking_area.h" |
| + |
| +class Browser; |
| +@class HoverImageButton; |
| + |
| +namespace ui { |
| +class MenuModel; |
| +} |
| + |
| +// This window controller manages the action box popup menu. |
| +@interface ActionBoxMenuBubbleController : BaseBubbleController { |
| + @private |
| + // The model that contains the data from the backend. (weak) |
| + 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
|
| + |
| + // Array of the below view controllers. |
| + scoped_nsobject<NSMutableArray> items_; |
| +} |
| + |
| +// Designated initializer. |
| +- (id)initWithBrowser:(Browser*)parentBrowser |
| + usingModel:(scoped_ptr<ui::MenuModel>)model |
| + anchoredAt:(NSPoint)point; |
| + |
| +// Accesses the model. |
| +- (ui::MenuModel*)model; |
| + |
| +// Executes the action of a given menu item. |
| +- (IBAction)itemSelected:(id)sender; |
| + |
| +@end |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| + |
| +// This view controller manages the menu item XIB. |
| +@interface ActionBoxMenuItemController : NSViewController { |
| + @private |
| + // The parent menu controller owns this. |
| + __weak ActionBoxMenuBubbleController* controller_; |
| + |
| + size_t modelIndex_; |
| + |
| + // Tracks whether this item is currently highlighted. |
| + BOOL isHighlighted_; |
| + |
| + // Instance variables that back the outlets. |
| + __weak NSImageView* iconView_; |
| + __weak NSTextField* nameField_; |
| +} |
| +@property(readonly, nonatomic) size_t modelIndex; |
| +@property(assign, nonatomic) BOOL isHighlighted; |
| +@property(assign, nonatomic) IBOutlet NSImageView* iconView; |
| +@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
|
| +@property(readonly, nonatomic) ActionBoxMenuBubbleController* controller; |
| + |
| +// Designated initializer. |
| +- (id)initWithModelIndex:(size_t)modelIndex |
| + menuController:(ActionBoxMenuBubbleController*)controller; |
| + |
| +// Highlights the subviews appropriately for a given event type. |
| +- (void)highlightForEventType:(NSEventType)type; |
| + |
| +// Execute the action of a given menu item. |
| +- (IBAction)itemSelected:(id)sender; |
| + |
| +@end |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| + |
| +// Simple button cell to get tracking and mouse events forwarded back to the |
| +// view controller for changing highlight style of the item subviews. This is |
| +// an invisible button that underlays most of the menu item and is responsible |
| +// for performing the attached action. |
| +@interface ActionBoxMenuItemView : NSView { |
| + @private |
| + // The controller that manages this. |
| + __weak ActionBoxMenuItemController* viewController_; |
| + |
| + // Used to highlight the background on hover. |
| + ScopedCrTrackingArea trackingArea_; |
| +} |
| + |
| +@property(assign, nonatomic) |
| + 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.
|
| + |
| +@end |
| + |
| + |
| +#endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_ACTION_BOX_MENU_BUBBLE_CONTROLLER_H_ |