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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu_button.h

Issue 2858313002: Refactored AppMenuAnimation (Closed)
Patch Set: Add comments Created 3 years, 7 months 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
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
13 #include "chrome/browser/ui/toolbar/app_menu_animation.h"
13 #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" 14 #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h"
14 #include "ui/views/controls/button/menu_button.h" 15 #include "ui/views/controls/button/menu_button.h"
15 #include "ui/views/controls/button/menu_button_listener.h" 16 #include "ui/views/controls/button/menu_button_listener.h"
16 #include "ui/views/view.h" 17 #include "ui/views/view.h"
17 18
18 class AppMenu; 19 class AppMenu;
19 class AppMenuModel; 20 class AppMenuModel;
20 21
21 namespace views { 22 namespace views {
22 class LabelButtonBorder; 23 class LabelButtonBorder;
23 class MenuListener; 24 class MenuListener;
24 } 25 }
25 26
26 class AppMenuAnimation;
27 class ToolbarView; 27 class ToolbarView;
28 28
29 class AppMenuButton : public views::MenuButton, public TabStripModelObserver { 29 class AppMenuButton : public views::MenuButton,
30 public TabStripModelObserver,
31 public AppMenuAnimationDelegate {
30 public: 32 public:
31 explicit AppMenuButton(ToolbarView* toolbar_view); 33 explicit AppMenuButton(ToolbarView* toolbar_view);
32 ~AppMenuButton() override; 34 ~AppMenuButton() override;
33 35
34 void SetSeverity(AppMenuIconController::IconType type, 36 void SetSeverity(AppMenuIconController::IconType type,
35 AppMenuIconController::Severity severity, 37 AppMenuIconController::Severity severity,
36 bool animate); 38 bool animate);
37 39
38 // Shows the app menu. |for_drop| indicates whether the menu is opened for a 40 // Shows the app menu. |for_drop| indicates whether the menu is opened for a
39 // drag-and-drop operation. 41 // drag-and-drop operation.
(...skipping 17 matching lines...) Expand all
57 gfx::Size GetPreferredSize() const override; 59 gfx::Size GetPreferredSize() const override;
58 void Layout() override; 60 void Layout() override;
59 void OnPaint(gfx::Canvas* canvas) override; 61 void OnPaint(gfx::Canvas* canvas) override;
60 62
61 // TabStripObserver: 63 // TabStripObserver:
62 void TabInsertedAt(TabStripModel* tab_strip_model, 64 void TabInsertedAt(TabStripModel* tab_strip_model,
63 content::WebContents* contents, 65 content::WebContents* contents,
64 int index, 66 int index,
65 bool foreground) override; 67 bool foreground) override;
66 68
69 // AppMenuAnimationDelegate:
70 void PaintDot(const gfx::PointF point,
71 SkColor color,
72 gfx::SizeF size,
73 gfx::Canvas* canvas) override;
74 void AppMenuAnimationStarted() override;
75 void AppMenuAnimationEnded() override;
76 void InvalidateIcon() override;
77
67 // Updates the presentation according to |severity_| and the theme provider. 78 // Updates the presentation according to |severity_| and the theme provider.
68 // If |should_animate| is true, the icon should animate. 79 // If |should_animate| is true, the icon should animate.
69 void UpdateIcon(bool should_animate); 80 void UpdateIcon(bool should_animate);
70 81
71 // Sets |margin_trailing_| when the browser is maximized and updates layout 82 // Sets |margin_trailing_| when the browser is maximized and updates layout
72 // to make the focus rectangle centered. 83 // to make the focus rectangle centered.
73 void SetTrailingMargin(int margin); 84 void SetTrailingMargin(int margin);
74 85
75 // Animates the icon if possible. The icon will not animate if the severity 86 // Animates the icon if possible. The icon will not animate if the severity
76 // level is none, |animation_| is nullptr or |should_use_new_icon_| is false. 87 // level is none, |animation_| is nullptr or |should_use_new_icon_| is false.
77 void AnimateIconIfPossible(); 88 void AnimateIconIfPossible();
78 89
79 // Methods called by AppMenuAnimation when the animation has started/ended.
80 // The layer is managed inside these methods.
81 void AppMenuAnimationStarted();
82 void AppMenuAnimationEnded();
83
84 // Opens the app menu immediately during a drag-and-drop operation. 90 // Opens the app menu immediately during a drag-and-drop operation.
85 // Used only in testing. 91 // Used only in testing.
86 static bool g_open_app_immediately_for_testing; 92 static bool g_open_app_immediately_for_testing;
87 93
88 private: 94 private:
89 // views::MenuButton: 95 // views::MenuButton:
90 const char* GetClassName() const override; 96 const char* GetClassName() const override;
91 std::unique_ptr<views::LabelButtonBorder> CreateDefaultBorder() 97 std::unique_ptr<views::LabelButtonBorder> CreateDefaultBorder()
92 const override; 98 const override;
93 gfx::Rect GetThemePaintRect() const override; 99 gfx::Rect GetThemePaintRect() const override;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // a maximized state to extend to the full window width. 132 // a maximized state to extend to the full window width.
127 int margin_trailing_; 133 int margin_trailing_;
128 134
129 // Used to spawn weak pointers for delayed tasks to open the overflow menu. 135 // Used to spawn weak pointers for delayed tasks to open the overflow menu.
130 base::WeakPtrFactory<AppMenuButton> weak_factory_; 136 base::WeakPtrFactory<AppMenuButton> weak_factory_;
131 137
132 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); 138 DISALLOW_COPY_AND_ASSIGN(AppMenuButton);
133 }; 139 };
134 140
135 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ 141 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698