Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar/app_menu_animation.h |
| diff --git a/chrome/browser/ui/views/toolbar/app_menu_animation.h b/chrome/browser/ui/views/toolbar/app_menu_animation.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ae6f69fcc8a3facedce86bd68c99ef35d950d7c4 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/toolbar/app_menu_animation.h |
| @@ -0,0 +1,88 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ |
| +#define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ |
| + |
| +#include "base/time/time.h" |
| +#include "third_party/skia/include/core/SkColor.h" |
| +#include "ui/gfx/animation/animation_delegate.h" |
| +#include "ui/gfx/animation/slide_animation.h" |
| + |
| +namespace gfx { |
| +class Canvas; |
| +class PointF; |
| +} // namespace gfx |
| + |
| +class AppMenuButton; |
| + |
| +// This class is used for animating and drawing the app menu icon. |
| +class AppMenuAnimation : public gfx::AnimationDelegate { |
| + public: |
| + AppMenuAnimation(AppMenuButton* owner, bool should_animation_close); |
|
msw
2017/04/13 17:23:12
nit: should_animate_closed to match cc.
spqchan
2017/04/13 22:52:42
Done.
|
| + |
| + ~AppMenuAnimation() override; |
| + |
| + // Paints the app menu icon. |
| + void PaintAppMenu(gfx::Canvas* canvas, const gfx::Rect& bounds); |
| + |
| + // Updates the icon colors. |
| + void SetIconColors(SkColor start_color, SkColor severity_color); |
| + |
| + // Starts the animation if it's not already running. |
| + void StartAnimation(); |
| + |
| + // gfx::AnimationDelegate: |
| + void AnimationEnded(const gfx::Animation* animation) override; |
| + void AnimationProgressed(const gfx::Animation* animation) override; |
| + |
| + private: |
| + // This class is used to represent and paint a dot on the app menu. |
| + class AppMenuDot { |
| + public: |
| + AppMenuDot(base::TimeDelta delay, |
|
msw
2017/04/13 17:23:12
nit: document these arguments
spqchan
2017/04/13 22:52:42
Done.
|
| + float width_open_interval, |
| + float stroke_open_interval); |
| + void Paint(const gfx::PointF& center_pt, |
| + SkColor start_color, |
| + SkColor final_color, |
| + gfx::Canvas* canvas, |
| + const gfx::Rect& bounds, |
| + const gfx::SlideAnimation* animation); |
| + |
| + private: |
| + // The delay before the dot starts animating in ms. |
| + const base::TimeDelta delay_; |
| + |
| + // The percentage of time it takes for each dot to animate to its width |
|
msw
2017/04/13 17:23:12
nit: "The percentage of the overall animation dura
spqchan
2017/04/13 22:52:42
Done.
|
| + // and stroke in its open state. |
| + const float width_open_interval_; |
| + const float stroke_open_interval_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppMenuDot); |
| + }; |
| + |
| + AppMenuButton* const owner_; // Weak. |
|
msw
2017/04/13 17:23:12
nit: I agree, this comment isn't necessary.
spqchan
2017/04/13 22:52:42
Done.
|
| + |
| + // True if the animation should close after it finishes opening. |
| + const bool should_animate_closed_; |
| + |
| + std::unique_ptr<gfx::SlideAnimation> animation_; |
| + |
| + AppMenuDot bottom_dot_; |
| + AppMenuDot middle_dot_; |
| + AppMenuDot top_dot_; |
| + |
| + // The starting color of the dots. The animation is expected to transition |
| + // from this color to |severity_color_|. |
| + SkColor start_color_; |
| + |
| + // The severity color of the dots. This is final color at the end of the |
| + // animation. |
| + SkColor severity_color_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppMenuAnimation); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ |