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

Unified Diff: ui/views/controls/animated_icon_view.h

Issue 2892563004: Use animated vector icon for app menu notification animation. (Closed)
Patch Set: one more f Created 3 years, 7 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
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/controls/animated_icon_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/animated_icon_view.h
diff --git a/ui/views/controls/animated_icon_view.h b/ui/views/controls/animated_icon_view.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb493eaccad22df7e03008f276e923aa15b6f1d1
--- /dev/null
+++ b/ui/views/controls/animated_icon_view.h
@@ -0,0 +1,67 @@
+// 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 UI_VIEWS_CONTROLS_ANIMATED_ICON_VIEW_H_
+#define UI_VIEWS_CONTROLS_ANIMATED_ICON_VIEW_H_
+
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "ui/compositor/compositor_animation_observer.h"
+#include "ui/gfx/vector_icon_types.h"
+#include "ui/views/controls/image_view.h"
+
+namespace views {
+
+// This class hosts a vector icon that defines transitions. It can be in the
+// start steady state, the end steady state, or transitioning in between.
+class VIEWS_EXPORT AnimatedIconView : public views::ImageView,
+ public ui::CompositorAnimationObserver {
+ public:
+ enum State {
+ START,
+ END,
+ };
+
+ explicit AnimatedIconView(const gfx::VectorIcon& icon);
+ ~AnimatedIconView() override;
+
+ void set_color(SkColor color) { color_ = color; }
+
+ // Animates to the end or start state.
+ void Animate(State target);
+
+ // Jumps to the end or start state.
+ void SetState(State state);
+
+ // views::ImageView
+ void OnPaint(gfx::Canvas* canvas) override;
+
+ // ui::CompositorAnimationObserver
+ void OnAnimationStep(base::TimeTicks timestamp) override;
+ void OnCompositingShuttingDown(ui::Compositor* compositor) override;
+
+ private:
+ bool IsAnimating() const;
+
+ void UpdateStaticImage();
+
+ const gfx::VectorIcon& icon_;
+ SkColor color_;
+
+ // Tracks the last time Animate() was called.
+ base::TimeTicks start_time_;
+
+ // The amount of time that must elapse until all transitions are done, i.e.
+ // the length of the animation.
+ const base::TimeDelta duration_;
+
+ // The current state, or when transitioning the goal state.
+ State state_ = START;
+
+ DISALLOW_COPY_AND_ASSIGN(AnimatedIconView);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_CONTROLS_ANIMATED_ICON_VIEW_H_
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/controls/animated_icon_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698