OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "chrome/browser/ui/toolbar/app_menu_icon_painter.h" | 11 #include "chrome/browser/ui/toolbar/app_menu_icon_painter.h" |
12 #include "ui/views/animation/ink_drop_host.h" | 12 #include "ui/views/animation/ink_drop_host.h" |
13 #include "ui/views/controls/button/menu_button.h" | 13 #include "ui/views/controls/button/menu_button.h" |
14 #include "ui/views/controls/button/menu_button_listener.h" | 14 #include "ui/views/controls/button/menu_button_listener.h" |
15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
16 | 16 |
17 class AppMenu; | 17 class AppMenu; |
18 class AppMenuModel; | 18 class AppMenuModel; |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 class InkDropAnimationController; | 21 class InkDropDelegate; |
22 class LabelButtonBorder; | 22 class LabelButtonBorder; |
23 class MenuListener; | 23 class MenuListener; |
24 } | 24 } |
25 | 25 |
26 class ToolbarView; | 26 class ToolbarView; |
27 | 27 |
28 class AppMenuButton : public views::InkDropHost, | 28 class AppMenuButton : public views::InkDropHost, |
29 public views::MenuButton, | 29 public views::MenuButton, |
30 public AppMenuIconPainter::Delegate { | 30 public AppMenuIconPainter::Delegate { |
31 public: | 31 public: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 // views::MenuButton: | 79 // views::MenuButton: |
80 const char* GetClassName() const override; | 80 const char* GetClassName() const override; |
81 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; | 81 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; |
82 gfx::Rect GetThemePaintRect() const override; | 82 gfx::Rect GetThemePaintRect() const override; |
83 bool GetDropFormats( | 83 bool GetDropFormats( |
84 int* formats, | 84 int* formats, |
85 std::set<ui::Clipboard::FormatType>* format_types) override; | 85 std::set<ui::Clipboard::FormatType>* format_types) override; |
86 bool AreDropTypesRequired() override; | 86 bool AreDropTypesRequired() override; |
87 bool CanDrop(const ui::OSExchangeData& data) override; | 87 bool CanDrop(const ui::OSExchangeData& data) override; |
88 void Layout() override; | |
89 void OnDragEntered(const ui::DropTargetEvent& event) override; | 88 void OnDragEntered(const ui::DropTargetEvent& event) override; |
90 int OnDragUpdated(const ui::DropTargetEvent& event) override; | 89 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
91 void OnDragExited() override; | 90 void OnDragExited() override; |
92 int OnPerformDrop(const ui::DropTargetEvent& event) override; | 91 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
93 void OnPaint(gfx::Canvas* canvas) override; | 92 void OnPaint(gfx::Canvas* canvas) override; |
94 | 93 |
95 // Only used in pre-MD. | 94 // Only used in pre-MD. |
96 scoped_ptr<AppMenuIconPainter> icon_painter_; | 95 scoped_ptr<AppMenuIconPainter> icon_painter_; |
97 | 96 |
98 // Only used in MD. | 97 // Only used in MD. |
99 AppMenuIconPainter::Severity severity_; | 98 AppMenuIconPainter::Severity severity_; |
100 | 99 |
101 // Animation controller for the ink drop ripple effect. | |
102 scoped_ptr<views::InkDropAnimationController> ink_drop_animation_controller_; | |
103 | |
104 // Our owning toolbar view. | 100 // Our owning toolbar view. |
105 ToolbarView* toolbar_view_; | 101 ToolbarView* toolbar_view_; |
106 | 102 |
107 // Whether or not we should allow dragging extension icons onto this button | 103 // Whether or not we should allow dragging extension icons onto this button |
108 // (in order to open the overflow in the app menu). | 104 // (in order to open the overflow in the app menu). |
109 bool allow_extension_dragging_; | 105 bool allow_extension_dragging_; |
110 | 106 |
111 // Listeners to call when the menu opens. | 107 // Listeners to call when the menu opens. |
112 base::ObserverList<views::MenuListener> menu_listeners_; | 108 base::ObserverList<views::MenuListener> menu_listeners_; |
113 | 109 |
114 // App model and menu. | 110 // App model and menu. |
115 // Note that the menu should be destroyed before the model it uses, so the | 111 // Note that the menu should be destroyed before the model it uses, so the |
116 // menu should be listed later. | 112 // menu should be listed later. |
117 scoped_ptr<AppMenuModel> menu_model_; | 113 scoped_ptr<AppMenuModel> menu_model_; |
118 scoped_ptr<AppMenu> menu_; | 114 scoped_ptr<AppMenu> menu_; |
119 | 115 |
120 // Used by ShowMenu() to detect when |this| has been deleted; see comments | 116 // Used by ShowMenu() to detect when |this| has been deleted; see comments |
121 // there. | 117 // there. |
122 bool* destroyed_; | 118 bool* destroyed_; |
123 | 119 |
124 // Any trailing margin to be applied. Used when the browser is in | 120 // Any trailing margin to be applied. Used when the browser is in |
125 // a maximized state to extend to the full window width. | 121 // a maximized state to extend to the full window width. |
126 int margin_trailing_; | 122 int margin_trailing_; |
127 | 123 |
| 124 // Controls the visual feedback for the button state. |
| 125 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; |
| 126 |
128 // Used to spawn weak pointers for delayed tasks to open the overflow menu. | 127 // Used to spawn weak pointers for delayed tasks to open the overflow menu. |
129 base::WeakPtrFactory<AppMenuButton> weak_factory_; | 128 base::WeakPtrFactory<AppMenuButton> weak_factory_; |
130 | 129 |
131 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); | 130 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); |
132 }; | 131 }; |
133 | 132 |
134 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ | 133 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ |
OLD | NEW |