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

Side by Side Diff: ui/views/animation/ink_drop_animation.h

Issue 1724963002: Color the ink drop ripple and hover effects based on theming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky review Created 4 years, 10 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/observer_list.h"
10 #include "ui/gfx/geometry/point.h" 9 #include "ui/gfx/geometry/point.h"
11 #include "ui/views/animation/ink_drop_animation_observer.h" 10 #include "ui/views/animation/ink_drop_animation_observer.h"
12 #include "ui/views/animation/ink_drop_state.h" 11 #include "ui/views/animation/ink_drop_state.h"
13 #include "ui/views/views_export.h" 12 #include "ui/views/views_export.h"
14 13
15 namespace ui { 14 namespace ui {
16 class Layer; 15 class Layer;
17 } // namespace ui 16 } // namespace ui
18 17
19 namespace views { 18 namespace views {
20 19
21 // Simple base class for animations that provide visual feedback for View state. 20 // Simple base class for animations that provide visual feedback for View state.
22 // Manages the attached InkDropAnimationObservers. 21 // Manages the attached InkDropAnimationObservers.
23 // 22 //
24 // TODO(bruthig): Document the ink drop ripple on chromium.org and add a link to 23 // TODO(bruthig): Document the ink drop ripple on chromium.org and add a link to
25 // the doc here. 24 // the doc here.
26 class VIEWS_EXPORT InkDropAnimation { 25 class VIEWS_EXPORT InkDropAnimation {
27 public: 26 public:
28 // The opacity of the ink drop when it is not visible. 27 // The opacity of the ink drop when it is not visible.
29 static const float kHiddenOpacity; 28 static const float kHiddenOpacity;
30 29
31 // The opacity of the ink drop when it is visible. 30 // The opacity of the ink drop when it is visible.
32 static const float kVisibleOpacity; 31 static const float kVisibleOpacity;
33 32
34 InkDropAnimation(); 33 InkDropAnimation();
35 virtual ~InkDropAnimation(); 34 virtual ~InkDropAnimation();
36 35
37 void AddObserver(InkDropAnimationObserver* observer); 36 void set_observer(InkDropAnimationObserver* observer) {
38 void RemoveObserver(InkDropAnimationObserver* observer); 37 observer_ = observer;
38 }
39 39
40 // Gets the target InkDropState, i.e. the last |ink_drop_state| passed to 40 // Gets the target InkDropState, i.e. the last |ink_drop_state| passed to
41 // AnimateToState() or set by HideImmediately(). 41 // AnimateToState() or set by HideImmediately().
42 virtual InkDropState GetTargetInkDropState() const = 0; 42 virtual InkDropState GetTargetInkDropState() const = 0;
43 43
44 // Animates from the current InkDropState to the new |ink_drop_state|. 44 // Animates from the current InkDropState to the new |ink_drop_state|.
45 // 45 //
46 // NOTE: GetTargetInkDropState() should return the new |ink_drop_state| value 46 // NOTE: GetTargetInkDropState() should return the new |ink_drop_state| value
47 // to any observers being notified as a result of the call. 47 // to any observers being notified as a result of the call.
48 virtual void AnimateToState(InkDropState ink_drop_state) = 0; 48 virtual void AnimateToState(InkDropState ink_drop_state) = 0;
49 49
50 // The root Layer that can be added in to a Layer tree. 50 // The root Layer that can be added in to a Layer tree.
51 virtual ui::Layer* GetRootLayer() = 0; 51 virtual ui::Layer* GetRootLayer() = 0;
52 52
53 // Returns true when the ripple is visible. This is different from checking if 53 // Returns true when the ripple is visible. This is different from checking if
54 // the ink_drop_state() == HIDDEN because the ripple may be visible while it 54 // the ink_drop_state() == HIDDEN because the ripple may be visible while it
55 // animates to the target HIDDEN state. 55 // animates to the target HIDDEN state.
56 virtual bool IsVisible() const = 0; 56 virtual bool IsVisible() const = 0;
57 57
58 // Sets the |center_point| of the ink drop layer relative to its parent Layer.
59 virtual void SetCenterPoint(const gfx::Point& center_point) = 0;
60
61 // Immediately aborts all in-progress animations and hides the ink drop. 58 // Immediately aborts all in-progress animations and hides the ink drop.
62 // 59 //
63 // NOTE: This will NOT raise InkDropAnimation(Started|Ended) events for the 60 // NOTE: This will NOT raise InkDropAnimation(Started|Ended) events for the
64 // state transition to HIDDEN! 61 // state transition to HIDDEN!
65 virtual void HideImmediately() = 0; 62 virtual void HideImmediately() = 0;
66 63
67 protected: 64 protected:
68 // Notify the |observers_| that an animation has started. 65 // Notify the |observers_| that an animation has started.
69 void NotifyAnimationStarted(InkDropState ink_drop_state); 66 void NotifyAnimationStarted(InkDropState ink_drop_state);
70 67
71 // Notify the |observers_| that an animation has ended. 68 // Notify the |observers_| that an animation has ended.
72 void NotifyAnimationEnded( 69 void NotifyAnimationEnded(
73 InkDropState ink_drop_state, 70 InkDropState ink_drop_state,
74 InkDropAnimationObserver::InkDropAnimationEndedReason reason); 71 InkDropAnimationObserver::InkDropAnimationEndedReason reason);
75 72
76 private: 73 private:
77 // List of observers to notify when animations have started and finished. 74 InkDropAnimationObserver* observer_;
78 base::ObserverList<InkDropAnimationObserver> observers_;
79 75
80 DISALLOW_COPY_AND_ASSIGN(InkDropAnimation); 76 DISALLOW_COPY_AND_ASSIGN(InkDropAnimation);
81 }; 77 };
82 78
83 } // namespace views 79 } // namespace views
84 80
85 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_ 81 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.cc ('k') | ui/views/animation/ink_drop_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698