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

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

Issue 2789203003: [Views] App Menu Animated Icon (Closed)
Patch Set: Fixes for sky (and rebased) 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..ead589a28d2b98d46327612ceef2211c18a80057
--- /dev/null
+++ b/chrome/browser/ui/views/toolbar/app_menu_animation.h
@@ -0,0 +1,90 @@
+// 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
+
+namespace views {
+class View;
+} // namespace views
+
+// This class is used for animating and drawing the app menu icon.
+class AppMenuAnimation : public gfx::AnimationDelegate {
+ public:
+ AppMenuAnimation(views::View* owner, bool should_animation_close);
+
+ ~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,
+ 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
+ // and stroke in its open state.
+ const float width_open_interval_;
+ const float stroke_open_interval_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppMenuDot);
+ };
+
+ 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.
+
+ // True if the animation should close after it finishes opening.
+ bool should_animate_closed_;
danakj 2017/04/12 14:38:39 const
spqchan 2017/04/12 19:42:10 Done.
+
+ 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_
« no previous file with comments | « chrome/browser/ui/toolbar/app_menu_icon_controller.cc ('k') | chrome/browser/ui/views/toolbar/app_menu_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698