Chromium Code Reviews| Index: chrome/browser/ui/toolbar/app_menu_animation.h |
| diff --git a/chrome/browser/ui/views/toolbar/app_menu_animation.h b/chrome/browser/ui/toolbar/app_menu_animation.h |
| similarity index 70% |
| rename from chrome/browser/ui/views/toolbar/app_menu_animation.h |
| rename to chrome/browser/ui/toolbar/app_menu_animation.h |
| index 122b1c976ea03c613e776a636cf85e154d0db9d1..f8097c8f524a0dd0b62b78663db7b7b132a8bbed 100644 |
| --- a/chrome/browser/ui/views/toolbar/app_menu_animation.h |
| +++ b/chrome/browser/ui/toolbar/app_menu_animation.h |
| @@ -2,8 +2,8 @@ |
| // 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_ |
| +#ifndef CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ANIMATION_H_ |
| +#define CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ANIMATION_H_ |
| #include "base/time/time.h" |
| #include "third_party/skia/include/core/SkColor.h" |
| @@ -13,22 +13,38 @@ |
| namespace gfx { |
| class Canvas; |
| class PointF; |
| +class SizeF; |
| } // namespace gfx |
| -class AppMenuButton; |
| +// Delegate class for AppMenuAnimation. The delegate is expected to |
| +// draw the dots and handle animation events. |
| +class AppMenuAnimationDelegate { |
|
msw
2017/05/05 18:47:38
It'd be nice if we could use Skia on Cocoa too and
spqchan
2017/05/05 21:20:53
Thanks for pointing that out! I had no idea that w
|
| + public: |
| + // Paints a dot according to the given parameters. |canvas| is null |
|
msw
2017/05/05 18:47:38
nit: specify the coordinates for |point|? (screen
spqchan
2017/05/05 21:20:53
The function is gone
|
| + // on the Mac platform. |
| + virtual void PaintDot(const gfx::PointF point, |
|
msw
2017/05/05 18:47:38
nit: pass a rect instead of a point and a size?
spqchan
2017/05/05 21:20:53
gone
|
| + SkColor color, |
| + gfx::SizeF size, |
|
msw
2017/05/05 18:47:38
nit: pass a const ref here (and for the point, or
spqchan
2017/05/05 21:20:53
gone
|
| + gfx::Canvas* canvas) = 0; |
| + |
| + // Called when the animation has started/ended. |
| + virtual void AppMenuAnimationStarted() = 0; |
| + virtual void AppMenuAnimationEnded() = 0; |
| + |
| + // Schedules a redraw of the icon. |
| + virtual void InvalidateIcon() = 0; |
| +}; |
| // This class is used for animating and drawing the app menu icon. |
| class AppMenuAnimation : public gfx::AnimationDelegate { |
| public: |
| - AppMenuAnimation(AppMenuButton* owner, SkColor initial_color); |
| + AppMenuAnimation(AppMenuAnimationDelegate* owner, SkColor initial_color); |
| ~AppMenuAnimation() override; |
| // Paints the app menu icon. |
| void PaintAppMenu(gfx::Canvas* canvas, const gfx::Rect& bounds); |
| - void set_target_color(SkColor target_color) { target_color_ = target_color; } |
| - |
| // Starts the animation if it's not already running. |
| void StartAnimation(); |
| @@ -36,6 +52,8 @@ class AppMenuAnimation : public gfx::AnimationDelegate { |
| void AnimationEnded(const gfx::Animation* animation) override; |
| void AnimationProgressed(const gfx::Animation* animation) override; |
| + void set_target_color(SkColor target_color) { target_color_ = target_color; } |
| + |
| private: |
| // This class is used to represent and paint a dot on the app menu. |
| class AppMenuDot { |
| @@ -53,7 +71,8 @@ class AppMenuAnimation : public gfx::AnimationDelegate { |
| SkColor final_color, |
| gfx::Canvas* canvas, |
| const gfx::Rect& bounds, |
| - const gfx::SlideAnimation* animation); |
| + const gfx::SlideAnimation* animation, |
| + AppMenuAnimationDelegate* delegate); |
| private: |
| // The delay before the dot starts animating in ms. |
| @@ -67,7 +86,7 @@ class AppMenuAnimation : public gfx::AnimationDelegate { |
| DISALLOW_COPY_AND_ASSIGN(AppMenuDot); |
| }; |
| - AppMenuButton* const owner_; |
| + AppMenuAnimationDelegate* const delegate_; |
| std::unique_ptr<gfx::SlideAnimation> animation_; |
| @@ -86,4 +105,4 @@ class AppMenuAnimation : public gfx::AnimationDelegate { |
| DISALLOW_COPY_AND_ASSIGN(AppMenuAnimation); |
| }; |
| -#endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_ |
| +#endif // CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ANIMATION_H_ |