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

Side by Side Diff: ui/views/controls/animated_icon_view.h

Issue 2892563004: Use animated vector icon for app menu notification animation. (Closed)
Patch Set: git add 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_CONTROLS_ANIMATED_ICON_VIEW_H_
6 #define UI_VIEWS_CONTROLS_ANIMATED_ICON_VIEW_H_
7
8 #include "base/macros.h"
9 #include "base/time/time.h"
10 #include "ui/compositor/compositor_animation_observer.h"
11 #include "ui/gfx/vector_icon_types.h"
12 #include "ui/views/controls/image_view.h"
13
14 namespace views {
15
16 // This class hosts a vector icon that defines transitions. It can be in the
17 // start steady state, the end steady state, or transitioning in between.
18 class AnimatedIconView : public views::ImageView,
19 public ui::CompositorAnimationObserver {
20 public:
21 enum State {
22 START,
23 END,
sadrul 2017/05/23 18:01:14 Does it not need a TRANSITION state?
Evan Stade 2017/05/23 23:38:42 no, this enum just describes the static state. Whe
24 };
25
26 explicit AnimatedIconView(const gfx::VectorIcon& icon);
27 ~AnimatedIconView() override;
28
29 void set_color(SkColor color) { color_ = color; }
30
31 // Animates to the end or start state.
32 void Animate(State target);
33
34 // Jumps to the end or start state.
35 void SetState(State state);
36
37 // views::ImageView
38 void OnPaint(gfx::Canvas* canvas) override;
39
40 // ui::CompositorAnimationObserver
41 void OnAnimationStep(base::TimeTicks timestamp) override;
42 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
43
44 private:
45 bool IsAnimating();
46
47 void UpdateStaticImage();
48
49 const gfx::VectorIcon& icon_;
50 SkColor color_;
sadrul 2017/05/23 18:01:14 It's curious that we don't have this for ImageView
Evan Stade 2017/05/23 23:38:42 ImageView doesn't know about VectorIcon, it only d
51
52 // Tracks the last time Animate() was called.
53 base::TimeTicks start_time_;
54
55 // The amount of time that must elapse until all transitions are done, i.e.
56 // the length of the animation.
57 const base::TimeDelta duration_;
58
59 // The current state, or when transitioning the goal state.
60 State state_ = START;
61
62 DISALLOW_COPY_AND_ASSIGN(AnimatedIconView);
63 };
64
65 } // namespace views
66
67 #endif // UI_VIEWS_CONTROLS_ANIMATED_ICON_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698