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 "third_party/skia/include/core/SkColor.h" | |
| 9 #include "ui/gfx/animation/animation_delegate.h" | |
| 10 #include "ui/gfx/animation/slide_animation.h" | |
|
sky
2017/04/11 20:52:00
Generally we use unique_ptr and forward declare me
spqchan
2017/04/12 19:42:10
Done.
| |
| 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 AppMenuAnimation(AppMenuButton* owner, bool should_animation_close); | |
|
sky
2017/04/11 20:52:00
I suggest changing AppMenuButton to View* as the o
spqchan
2017/04/12 19:42:10
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); | |
|
sky
2017/04/11 20:52:00
SetIconColors?
spqchan
2017/04/12 19:42:10
Done.
| |
| 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, | |
| 42 float width_open_interval, | |
| 43 float stroke_open_interval); | |
| 44 void Paint(gfx::PointF center_pt, | |
| 45 SkColor start_color, | |
| 46 SkColor final_color, | |
| 47 gfx::Canvas* canvas, | |
| 48 const gfx::Rect& bounds, | |
| 49 gfx::SlideAnimation* animation); | |
| 50 | |
| 51 private: | |
| 52 // The delay before the dot starts animating in ms. | |
| 53 float delay_; | |
|
sky
2017/04/11 20:52:00
const where possible.
spqchan
2017/04/12 19:42:10
Done.
| |
| 54 | |
| 55 // The percentage of time it takes for each dot to animate to its width | |
| 56 // and stroke in its open state. | |
| 57 float width_open_interval_; | |
| 58 float stroke_open_interval_; | |
| 59 }; | |
|
sky
2017/04/11 20:52:00
DISALLOW...
spqchan
2017/04/12 19:42:10
Done.
| |
| 60 | |
| 61 AppMenuButton* owner_; // weak. | |
| 62 | |
| 63 // True if the animation should close after it finishes opening. | |
| 64 bool should_animation_close_; | |
|
sky
2017/04/11 20:52:00
should_animate_closed_?
spqchan
2017/04/12 19:42:10
Done.
| |
| 65 | |
| 66 gfx::SlideAnimation animation_; | |
| 67 | |
| 68 AppMenuDot bottom_dot_; | |
| 69 AppMenuDot middle_dot_; | |
| 70 AppMenuDot top_dot_; | |
| 71 | |
| 72 // The starting color of the dots. The animation is expected to transition | |
| 73 // from this color to |severity_color_|. | |
| 74 SkColor start_color_; | |
| 75 | |
| 76 // The severity color of the dots. This is final color at the end of the | |
| 77 // animation. | |
| 78 SkColor severity_color_; | |
| 79 }; | |
|
sky
2017/04/11 20:52:00
DISALLOW...
spqchan
2017/04/12 19:42:10
Done.
| |
| 80 | |
| 81 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ | |
| OLD | NEW |