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" | |
13 #include "ui/views/controls/button/menu_button.h" | 12 #include "ui/views/controls/button/menu_button.h" |
14 #include "ui/views/controls/button/menu_button_listener.h" | 13 #include "ui/views/controls/button/menu_button_listener.h" |
15 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
16 | 15 |
17 class AppMenu; | 16 class AppMenu; |
18 class AppMenuModel; | 17 class AppMenuModel; |
19 | 18 |
20 namespace views { | 19 namespace views { |
21 class InkDropDelegate; | 20 class InkDropDelegate; |
22 class LabelButtonBorder; | 21 class LabelButtonBorder; |
23 class MenuListener; | 22 class MenuListener; |
24 } | 23 } |
25 | 24 |
26 class ToolbarView; | 25 class ToolbarView; |
27 | 26 |
28 class AppMenuButton : public views::InkDropHost, | 27 class AppMenuButton : public views::MenuButton, |
29 public views::MenuButton, | |
30 public AppMenuIconPainter::Delegate { | 28 public AppMenuIconPainter::Delegate { |
31 public: | 29 public: |
32 explicit AppMenuButton(ToolbarView* toolbar_view); | 30 explicit AppMenuButton(ToolbarView* toolbar_view); |
33 ~AppMenuButton() override; | 31 ~AppMenuButton() override; |
34 | 32 |
35 void SetSeverity(AppMenuIconPainter::Severity severity, bool animate); | 33 void SetSeverity(AppMenuIconPainter::Severity severity, bool animate); |
36 | 34 |
37 // Shows the app menu. |for_drop| indicates whether the menu is opened for a | 35 // Shows the app menu. |for_drop| indicates whether the menu is opened for a |
38 // drag-and-drop operation. | 36 // drag-and-drop operation. |
39 void ShowMenu(bool for_drop); | 37 void ShowMenu(bool for_drop); |
(...skipping 24 matching lines...) Expand all Loading... |
64 | 62 |
65 // Sets |margin_trailing_| when the browser is maximized and updates layout | 63 // Sets |margin_trailing_| when the browser is maximized and updates layout |
66 // to make the focus rectangle centered. | 64 // to make the focus rectangle centered. |
67 void SetTrailingMargin(int margin); | 65 void SetTrailingMargin(int margin); |
68 | 66 |
69 // Opens the app menu immediately during a drag-and-drop operation. | 67 // Opens the app menu immediately during a drag-and-drop operation. |
70 // Used only in testing. | 68 // Used only in testing. |
71 static bool g_open_app_immediately_for_testing; | 69 static bool g_open_app_immediately_for_testing; |
72 | 70 |
73 private: | 71 private: |
74 // views::InkDropHost: | 72 // views::MenuButton: |
75 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; | 73 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; |
76 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; | 74 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; |
77 gfx::Point CalculateInkDropCenter() const override; | 75 gfx::Point CalculateInkDropCenter() const override; |
78 | 76 |
79 // views::MenuButton: | 77 // views::MenuButton: |
80 const char* GetClassName() const override; | 78 const char* GetClassName() const override; |
81 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; | 79 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; |
82 gfx::Rect GetThemePaintRect() const override; | 80 gfx::Rect GetThemePaintRect() const override; |
83 bool GetDropFormats( | 81 bool GetDropFormats( |
84 int* formats, | 82 int* formats, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Controls the visual feedback for the button state. | 122 // Controls the visual feedback for the button state. |
125 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; | 123 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; |
126 | 124 |
127 // Used to spawn weak pointers for delayed tasks to open the overflow menu. | 125 // Used to spawn weak pointers for delayed tasks to open the overflow menu. |
128 base::WeakPtrFactory<AppMenuButton> weak_factory_; | 126 base::WeakPtrFactory<AppMenuButton> weak_factory_; |
129 | 127 |
130 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); | 128 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); |
131 }; | 129 }; |
132 | 130 |
133 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ | 131 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ |
OLD | NEW |