OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ | |
7 | |
8 #include "base/time/time.h" | |
9 #include "third_party/skia/include/core/SkColor.h" | |
10 #include "ui/gfx/animation/animation_delegate.h" | |
11 #include "ui/gfx/animation/slide_animation.h" | |
12 | |
13 namespace gfx { | |
14 class Canvas; | |
15 class PointF; | |
16 } // namespace gfx | |
17 | |
18 class AppMenuButton; | |
19 | |
20 // This class is used for animating and drawing the app menu icon. | |
21 class AppMenuAnimation : public gfx::AnimationDelegate { | |
22 public: | |
23 AppMenuAnimation(AppMenuButton* owner, bool should_animate_closed); | |
24 | |
25 ~AppMenuAnimation() override; | |
26 | |
27 // Paints the app menu icon. | |
28 void PaintAppMenu(gfx::Canvas* canvas, const gfx::Rect& bounds); | |
29 | |
30 // Updates the icon colors. | |
31 void SetIconColors(SkColor start_color, SkColor severity_color); | |
32 | |
33 // Starts the animation if it's not already running. | |
34 void StartAnimation(); | |
35 | |
36 // gfx::AnimationDelegate: | |
37 void AnimationEnded(const gfx::Animation* animation) override; | |
38 void AnimationProgressed(const gfx::Animation* animation) override; | |
39 | |
40 private: | |
41 // This class is used to represent and paint a dot on the app menu. | |
42 class AppMenuDot { | |
43 public: | |
44 // The class constructor. The params |delay|, |width_open_interval|, and | |
msw
2017/04/13 23:05:24
This doesn't explain the semantics of the argument
spqchan
2017/04/13 23:48:21
Done.
| |
45 // |stroke_open_interval| are used to populate the variables |delay|, | |
46 // |width_open_interval|, and |stroke_open_interval| respectively. | |
47 AppMenuDot(base::TimeDelta delay, | |
48 float width_open_interval, | |
49 float stroke_open_interval); | |
50 | |
51 // Paints the dot on the given |canvas| according to the progress of | |
52 // |animation|. The size of the dot is calculated to fit in |bounds|. | |
53 // |center_point| is the dot's position on the canvas. The dot's color is | |
54 // a transition from |start_color| to |final_color|. | |
55 void Paint(const gfx::PointF& center_point, | |
56 SkColor start_color, | |
57 SkColor final_color, | |
58 gfx::Canvas* canvas, | |
59 const gfx::Rect& bounds, | |
60 const gfx::SlideAnimation* animation); | |
61 | |
62 private: | |
63 // The delay before the dot starts animating in ms. | |
64 const base::TimeDelta delay_; | |
65 | |
66 // The percentage of the overall animation duration it takes to animate the | |
67 // width and stroke to their open state. | |
68 const float width_open_interval_; | |
69 const float stroke_open_interval_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(AppMenuDot); | |
72 }; | |
73 | |
74 AppMenuButton* const owner_; | |
75 | |
76 // True if the animation should close after it finishes opening. | |
77 const bool should_animate_closed_; | |
78 | |
79 std::unique_ptr<gfx::SlideAnimation> animation_; | |
80 | |
81 AppMenuDot bottom_dot_; | |
82 AppMenuDot middle_dot_; | |
83 AppMenuDot top_dot_; | |
84 | |
85 // The starting color of the dots. The animation is expected to transition | |
86 // from this color to |severity_color_|. | |
87 SkColor start_color_; | |
88 | |
89 // The severity color of the dots. This is final color at the end of the | |
90 // animation. | |
91 SkColor severity_color_; | |
92 | |
93 DISALLOW_COPY_AND_ASSIGN(AppMenuAnimation); | |
94 }; | |
95 | |
96 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ | |
OLD | NEW |