Chromium Code Reviews| 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 namespace views { | |
| 19 class View; | |
| 20 } // namespace views | |
| 21 | |
| 22 // This class is used for animating and drawing the app menu icon. | |
| 23 class AppMenuAnimation : public gfx::AnimationDelegate { | |
| 24 public: | |
| 25 AppMenuAnimation(views::View* owner, bool should_animation_close); | |
| 26 | |
| 27 ~AppMenuAnimation() override; | |
| 28 | |
| 29 // Paints the app menu icon. | |
| 30 void PaintAppMenu(gfx::Canvas* canvas, const gfx::Rect& bounds); | |
| 31 | |
| 32 // Updates the icon colors. | |
| 33 void SetIconColors(SkColor start_color, SkColor severity_color); | |
| 34 | |
| 35 // Starts the animation if it's not already running. | |
| 36 void StartAnimation(); | |
| 37 | |
| 38 // gfx::AnimationDelegate: | |
| 39 void AnimationEnded(const gfx::Animation* animation) override; | |
| 40 void AnimationProgressed(const gfx::Animation* animation) override; | |
| 41 | |
| 42 private: | |
| 43 // This class is used to represent and paint a dot on the app menu. | |
| 44 class AppMenuDot { | |
| 45 public: | |
| 46 AppMenuDot(base::TimeDelta delay, | |
| 47 float width_open_interval, | |
| 48 float stroke_open_interval); | |
| 49 void Paint(const gfx::PointF& center_pt, | |
| 50 SkColor start_color, | |
| 51 SkColor final_color, | |
| 52 gfx::Canvas* canvas, | |
| 53 const gfx::Rect& bounds, | |
| 54 const gfx::SlideAnimation* animation); | |
| 55 | |
| 56 private: | |
| 57 // The delay before the dot starts animating in ms. | |
| 58 const base::TimeDelta delay_; | |
| 59 | |
| 60 // The percentage of time it takes for each dot to animate to its width | |
| 61 // and stroke in its open state. | |
| 62 const float width_open_interval_; | |
| 63 const float stroke_open_interval_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(AppMenuDot); | |
| 66 }; | |
| 67 | |
| 68 views::View* owner_; // weak. | |
|
danakj
2017/04/12 14:38:39
View* const owner_
danakj
2017/04/12 14:38:39
Comments are complete sentences, starting with a c
spqchan
2017/04/12 19:42:10
Done.
| |
| 69 | |
| 70 // True if the animation should close after it finishes opening. | |
| 71 bool should_animate_closed_; | |
|
danakj
2017/04/12 14:38:39
const
spqchan
2017/04/12 19:42:10
Done.
| |
| 72 | |
| 73 std::unique_ptr<gfx::SlideAnimation> animation_; | |
| 74 | |
| 75 AppMenuDot bottom_dot_; | |
| 76 AppMenuDot middle_dot_; | |
| 77 AppMenuDot top_dot_; | |
| 78 | |
| 79 // The starting color of the dots. The animation is expected to transition | |
| 80 // from this color to |severity_color_|. | |
| 81 SkColor start_color_; | |
| 82 | |
| 83 // The severity color of the dots. This is final color at the end of the | |
| 84 // animation. | |
| 85 SkColor severity_color_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(AppMenuAnimation); | |
| 88 }; | |
| 89 | |
| 90 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ | |
| OLD | NEW |