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 "third_party/skia/include/core/SkColor.h" | |
9 #include "ui/gfx/animation/animation_delegate.h" | |
10 #include "ui/gfx/animation/slide_animation.h" | |
11 | |
12 namespace gfx { | |
13 class Canvas; | |
14 class PointF; | |
15 } // namespace gfx | |
16 | |
17 class AppMenuButton; | |
18 | |
19 // This class is used for animating and drawing the app menu icon. | |
20 class AppMenuAnimation : public gfx::AnimationDelegate { | |
21 public: | |
22 explicit AppMenuAnimation(AppMenuButton* owner, bool should_animation_close); | |
msw
2017/04/11 17:34:13
nit: no explicit for two args
spqchan
2017/04/12 19:42:09
Done.
| |
23 | |
24 // Paints the app menu icon. | |
25 void PaintAppMenu(gfx::Canvas* canvas, const gfx::Rect& bounds); | |
26 | |
27 // Updates the icon colors. | |
28 void UpdateIconColor(SkColor start_color, SkColor severity_color); | |
29 | |
30 // Starts the animation if it's not already running. | |
31 void StartAnimation(); | |
32 | |
33 // gfx::AnimationDelegate: | |
34 void AnimationEnded(const gfx::Animation* animation) override; | |
35 void AnimationProgressed(const gfx::Animation* animation) override; | |
36 | |
37 private: | |
38 // This class is used to represent and paint a dot on the app menu. | |
39 class AppMenuDot { | |
40 public: | |
41 AppMenuDot(float delay, float widthOpenInterval, float strokeOpenInterval); | |
42 void Paint(gfx::PointF center_pt, | |
43 SkColor start_color, | |
44 SkColor final_color, | |
45 gfx::Canvas* canvas, | |
46 const gfx::Rect& bounds, | |
47 gfx::SlideAnimation* animation); | |
48 | |
49 private: | |
50 // The delay before the dot starts animating in ms. | |
51 float delay_; | |
52 | |
53 // % of time it takes for each dot to animate to its width and stroke in | |
msw
2017/04/11 17:34:13
nit: "The percent of the slide animation's time ta
spqchan
2017/04/12 19:42:10
Done.
| |
54 // its open state. | |
55 float widthOpenInterval_; | |
56 float strokeOpenInterval_; | |
57 }; | |
58 | |
59 AppMenuButton* owner_; // weak. | |
60 | |
61 // True if the animation close after it finished opening. | |
msw
2017/04/11 17:34:13
nit: "should close" and "finishes"
spqchan
2017/04/12 19:42:09
Done.
| |
62 bool should_animation_close_; | |
63 | |
64 gfx::SlideAnimation animation_; | |
65 | |
66 AppMenuDot bottom_dot_; | |
67 AppMenuDot middle_dot_; | |
68 AppMenuDot top_dot_; | |
69 | |
70 // The starting color of the dots. The animation is expected to transition | |
71 // from this color to |severity_color_|. | |
72 SkColor start_color_; | |
73 | |
74 // The severity color of the dots. This is expected color at the end of the | |
msw
2017/04/11 17:34:13
nit: "This is the final color at the..."
spqchan
2017/04/12 19:42:09
Done.
| |
75 // animation. | |
76 SkColor severity_color_; | |
77 }; | |
78 | |
79 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ | |
OLD | NEW |