OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_ANIMATION_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ |
7 | 7 |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
10 #include "ui/gfx/animation/animation_delegate.h" | 10 #include "ui/gfx/animation/animation_delegate.h" |
11 #include "ui/gfx/animation/slide_animation.h" | 11 #include "ui/gfx/animation/slide_animation.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 class Canvas; | 14 class Canvas; |
15 class PointF; | 15 class PointF; |
16 } // namespace gfx | 16 } // namespace gfx |
17 | 17 |
18 class AppMenuButton; | 18 class AppMenuButton; |
19 | 19 |
20 // This class is used for animating and drawing the app menu icon. | 20 // This class is used for animating and drawing the app menu icon. |
21 class AppMenuAnimation : public gfx::AnimationDelegate { | 21 class AppMenuAnimation : public gfx::AnimationDelegate { |
22 public: | 22 public: |
23 AppMenuAnimation(AppMenuButton* owner, bool should_animate_closed); | 23 AppMenuAnimation(AppMenuButton* owner, SkColor initial_color); |
24 | 24 |
25 ~AppMenuAnimation() override; | 25 ~AppMenuAnimation() override; |
26 | 26 |
27 // Paints the app menu icon. | 27 // Paints the app menu icon. |
28 void PaintAppMenu(gfx::Canvas* canvas, const gfx::Rect& bounds); | 28 void PaintAppMenu(gfx::Canvas* canvas, const gfx::Rect& bounds); |
29 | 29 |
30 // Updates the icon colors. | 30 void set_severity_color(SkColor severity_color) { |
msw
2017/04/29 00:55:05
nit: maybe rename this and the member to |target_c
spqchan
2017/04/29 02:34:42
Done.
| |
31 void SetIconColors(SkColor start_color, SkColor severity_color); | 31 severity_color_ = severity_color; |
32 } | |
32 | 33 |
33 // Starts the animation if it's not already running. | 34 // Starts the animation if it's not already running. |
34 void StartAnimation(); | 35 void StartAnimation(); |
35 | 36 |
36 // gfx::AnimationDelegate: | 37 // gfx::AnimationDelegate: |
37 void AnimationEnded(const gfx::Animation* animation) override; | 38 void AnimationEnded(const gfx::Animation* animation) override; |
38 void AnimationProgressed(const gfx::Animation* animation) override; | 39 void AnimationProgressed(const gfx::Animation* animation) override; |
39 | 40 |
40 private: | 41 private: |
41 // This class is used to represent and paint a dot on the app menu. | 42 // This class is used to represent and paint a dot on the app menu. |
(...skipping 21 matching lines...) Expand all Loading... | |
63 // The percentage of the overall animation duration it takes to animate the | 64 // The percentage of the overall animation duration it takes to animate the |
64 // width and stroke to their open state. | 65 // width and stroke to their open state. |
65 const float width_open_interval_; | 66 const float width_open_interval_; |
66 const float stroke_open_interval_; | 67 const float stroke_open_interval_; |
67 | 68 |
68 DISALLOW_COPY_AND_ASSIGN(AppMenuDot); | 69 DISALLOW_COPY_AND_ASSIGN(AppMenuDot); |
69 }; | 70 }; |
70 | 71 |
71 AppMenuButton* const owner_; | 72 AppMenuButton* const owner_; |
72 | 73 |
73 // True if the animation should close after it finishes opening. | |
74 const bool should_animate_closed_; | |
75 | |
76 std::unique_ptr<gfx::SlideAnimation> animation_; | 74 std::unique_ptr<gfx::SlideAnimation> animation_; |
77 | 75 |
78 AppMenuDot bottom_dot_; | 76 AppMenuDot bottom_dot_; |
79 AppMenuDot middle_dot_; | 77 AppMenuDot middle_dot_; |
80 AppMenuDot top_dot_; | 78 AppMenuDot top_dot_; |
81 | 79 |
82 // The starting color of the dots. The animation is expected to transition | 80 // The starting color of the dots. The animation is expected to transition |
83 // from this color to |severity_color_|. | 81 // from this color to |severity_color_|. |
84 SkColor start_color_; | 82 SkColor start_color_; |
85 | 83 |
86 // The severity color of the dots. This is final color at the end of the | 84 // The severity color of the dots. This is final color at the end of the |
87 // animation. | 85 // animation. |
88 SkColor severity_color_; | 86 SkColor severity_color_; |
89 | 87 |
90 DISALLOW_COPY_AND_ASSIGN(AppMenuAnimation); | 88 DISALLOW_COPY_AND_ASSIGN(AppMenuAnimation); |
91 }; | 89 }; |
92 | 90 |
93 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ | 91 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ |
OLD | NEW |