Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Unified Diff: chrome/browser/ui/views/toolbar/app_menu_animation.h

Issue 2789203003: [Views] App Menu Animated Icon (Closed)
Patch Set: Cleaned up Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cdde3df5ec816b4959c6dcc9b336afc2faf4f1b3
--- /dev/null
+++ b/chrome/browser/ui/views/toolbar/app_menu_animation.h
@@ -0,0 +1,79 @@
+// 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 "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:
+ 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.
+
+ // Paints the app menu icon.
+ void PaintAppMenu(gfx::Canvas* canvas, const gfx::Rect& bounds);
+
+ // Updates the icon colors.
+ void UpdateIconColor(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(float delay, float widthOpenInterval, float strokeOpenInterval);
+ void Paint(gfx::PointF center_pt,
+ SkColor start_color,
+ SkColor final_color,
+ gfx::Canvas* canvas,
+ const gfx::Rect& bounds,
+ gfx::SlideAnimation* animation);
+
+ private:
+ // The delay before the dot starts animating in ms.
+ float delay_;
+
+ // % 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.
+ // its open state.
+ float widthOpenInterval_;
+ float strokeOpenInterval_;
+ };
+
+ AppMenuButton* owner_; // weak.
+
+ // 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.
+ bool should_animation_close_;
+
+ 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 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.
+ // animation.
+ SkColor severity_color_;
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_ANIMATION_H_

Powered by Google App Engine
This is Rietveld 408576698