Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: views/controls/menu/menu_controller.h

Issue 328012: Makes it so that when a folder is open on the bookmark bar and the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/button/menu_button.cc ('k') | views/controls/menu/menu_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ 5 #ifndef VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_
6 #define VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ 6 #define VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include <list> 10 #include <list>
11 #include <set> 11 #include <set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.h"
16 #include "base/timer.h" 16 #include "base/timer.h"
17 #include "views/controls/menu/menu_delegate.h" 17 #include "views/controls/menu/menu_delegate.h"
18 #include "views/controls/menu/menu_item_view.h" 18 #include "views/controls/menu/menu_item_view.h"
19 19
20 class OSExchangeData; 20 class OSExchangeData;
21 21
22 namespace views { 22 namespace views {
23 23
24 class DropTargetEvent; 24 class DropTargetEvent;
25 class MenuButton;
25 class MenuHostRootView; 26 class MenuHostRootView;
26 class MouseEvent; 27 class MouseEvent;
27 class SubmenuView; 28 class SubmenuView;
28 class View; 29 class View;
29 30
30 // MenuController ------------------------------------------------------------- 31 // MenuController -------------------------------------------------------------
31 32
32 // MenuController is used internally by the various menu classes to manage 33 // MenuController is used internally by the various menu classes to manage
33 // showing, selecting and drag/drop for menus. All relevant events are 34 // showing, selecting and drag/drop for menus. All relevant events are
34 // forwarded to the MenuController from SubmenuView and MenuHost. 35 // forwarded to the MenuController from SubmenuView and MenuHost.
35 class MenuController : public MessageLoopForUI::Dispatcher { 36 class MenuController : public MessageLoopForUI::Dispatcher {
36 public: 37 public:
37 friend class MenuHostRootView; 38 friend class MenuHostRootView;
38 friend class MenuItemView; 39 friend class MenuItemView;
39 40
40 // If a menu is currently active, this returns the controller for it. 41 // If a menu is currently active, this returns the controller for it.
41 static MenuController* GetActiveInstance(); 42 static MenuController* GetActiveInstance();
42 43
43 // Runs the menu at the specified location. If the menu was configured to 44 // Runs the menu at the specified location. If the menu was configured to
44 // block, the selected item is returned. If the menu does not block this 45 // block, the selected item is returned. If the menu does not block this
45 // returns NULL immediately. 46 // returns NULL immediately.
46 MenuItemView* Run(gfx::NativeWindow parent, 47 MenuItemView* Run(gfx::NativeWindow parent,
48 MenuButton* button,
47 MenuItemView* root, 49 MenuItemView* root,
48 const gfx::Rect& bounds, 50 const gfx::Rect& bounds,
49 MenuItemView::AnchorPosition position, 51 MenuItemView::AnchorPosition position,
50 int* mouse_event_flags); 52 int* mouse_event_flags);
51 53
52 // Whether or not Run blocks. 54 // Whether or not Run blocks.
53 bool IsBlockingRun() const { return blocking_run_; } 55 bool IsBlockingRun() const { return blocking_run_; }
54 56
55 // Sets the selection to menu_item, a value of NULL unselects everything. 57 // Sets the selection to menu_item, a value of NULL unselects everything.
56 // If open_submenu is true and menu_item has a submenu, the submenu is shown. 58 // If open_submenu is true and menu_item has a submenu, the submenu is shown.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 bool OnKeyDown(int key_code, const MSG& msg); 177 bool OnKeyDown(int key_code, const MSG& msg);
176 #else 178 #else
177 bool OnKeyDown(int key_code); 179 bool OnKeyDown(int key_code);
178 #endif 180 #endif
179 181
180 // Creates a MenuController. If blocking is true, Run blocks the caller 182 // Creates a MenuController. If blocking is true, Run blocks the caller
181 explicit MenuController(bool blocking); 183 explicit MenuController(bool blocking);
182 184
183 ~MenuController(); 185 ~MenuController();
184 186
187 void UpdateInitialLocation(const gfx::Rect& bounds,
188 MenuItemView::AnchorPosition position);
189
185 // Invoked when the user accepts the selected item. This is only used 190 // Invoked when the user accepts the selected item. This is only used
186 // when blocking. This schedules the loop to quit. 191 // when blocking. This schedules the loop to quit.
187 void Accept(MenuItemView* item, int mouse_event_flags); 192 void Accept(MenuItemView* item, int mouse_event_flags);
188 193
194 bool ShowSiblingMenu(SubmenuView* source, const MouseEvent& e);
195
189 // Closes all menus, including any menus of nested invocations of Run. 196 // Closes all menus, including any menus of nested invocations of Run.
190 void CloseAllNestedMenus(); 197 void CloseAllNestedMenus();
191 198
192 // Gets the enabled menu item at the specified location. 199 // Gets the enabled menu item at the specified location.
193 // If over_any_menu is non-null it is set to indicate whether the location 200 // If over_any_menu is non-null it is set to indicate whether the location
194 // is over any menu. It is possible for this to return NULL, but 201 // is over any menu. It is possible for this to return NULL, but
195 // over_any_menu to be true. For example, the user clicked on a separator. 202 // over_any_menu to be true. For example, the user clicked on a separator.
196 MenuItemView* GetMenuItemAt(View* menu, int x, int y); 203 MenuItemView* GetMenuItemAt(View* menu, int x, int y);
197 204
198 // If there is an empty menu item at the specified location, it is returned. 205 // If there is an empty menu item at the specified location, it is returned.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // opening or closing submenus. This gives a slight delayed effect to 330 // opening or closing submenus. This gives a slight delayed effect to
324 // submenus as the user moves the mouse around. This is done so that as the 331 // submenus as the user moves the mouse around. This is done so that as the
325 // user moves the mouse all submenus don't immediately pop. 332 // user moves the mouse all submenus don't immediately pop.
326 State pending_state_; 333 State pending_state_;
327 State state_; 334 State state_;
328 335
329 // If the user accepted the selection, this is the result. 336 // If the user accepted the selection, this is the result.
330 MenuItemView* result_; 337 MenuItemView* result_;
331 338
332 // The mouse event flags when the user clicked on a menu. Is 0 if the 339 // The mouse event flags when the user clicked on a menu. Is 0 if the
333 // user did not use the mousee to select the menu. 340 // user did not use the mouse to select the menu.
334 int result_mouse_event_flags_; 341 int result_mouse_event_flags_;
335 342
336 // If not empty, it means we're nested. When Run is invoked from within 343 // If not empty, it means we're nested. When Run is invoked from within
337 // Run, the current state (state_) is pushed onto menu_stack_. This allows 344 // Run, the current state (state_) is pushed onto menu_stack_. This allows
338 // MenuController to restore the state when the nested run returns. 345 // MenuController to restore the state when the nested run returns.
339 std::list<State> menu_stack_; 346 std::list<State> menu_stack_;
340 347
341 // As the mouse moves around submenus are not opened immediately. Instead 348 // As the mouse moves around submenus are not opened immediately. Instead
342 // they open after this timer fires. 349 // they open after this timer fires.
343 base::OneShotTimer<MenuController> show_timer_; 350 base::OneShotTimer<MenuController> show_timer_;
(...skipping 25 matching lines...) Expand all
369 int drop_y_; 376 int drop_y_;
370 int last_drop_operation_; 377 int last_drop_operation_;
371 378
372 // If true, we're in the middle of invoking ShowAt on a submenu. 379 // If true, we're in the middle of invoking ShowAt on a submenu.
373 bool showing_submenu_; 380 bool showing_submenu_;
374 381
375 // Task for scrolling the menu. If non-null indicates a scroll is currently 382 // Task for scrolling the menu. If non-null indicates a scroll is currently
376 // underway. 383 // underway.
377 scoped_ptr<MenuScrollTask> scroll_task_; 384 scoped_ptr<MenuScrollTask> scroll_task_;
378 385
386 MenuButton* menu_button_;
387
379 DISALLOW_COPY_AND_ASSIGN(MenuController); 388 DISALLOW_COPY_AND_ASSIGN(MenuController);
380 }; 389 };
381 390
382 } // namespace views 391 } // namespace views
383 392
384 #endif // VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_ 393 #endif // VIEWS_CONTROLS_MENU_MENU_CONTROLLER_H_
OLDNEW
« no previous file with comments | « views/controls/button/menu_button.cc ('k') | views/controls/menu/menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698