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

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

Issue 2720183002: [Views] Update ink drop for omnibox icons (Closed)
Patch Set: Fixed tests and added comments 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "ui/compositor/layer_tree_owner.h" 12 #include "ui/compositor/layer_tree_owner.h"
13 #include "ui/events/event_handler.h" 13 #include "ui/events/event_handler.h"
14 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 #include "ui/views/animation/ink_drop_state.h" 16 #include "ui/views/animation/ink_drop_state.h"
17 #include "ui/views/view.h" 17 #include "ui/views/view.h"
18 #include "ui/views/views_export.h" 18 #include "ui/views/views_export.h"
19 19
20 namespace views { 20 namespace views {
21 21
22 // Pure virtual base class that manages the lifetime and state of an ink drop 22 class InkDropObserver;
23 // ripple as well as visual hover state feedback. 23
24 // Base class that manages the lifetime and state of an ink drop ripple as
25 // well as visual hover state feedback.
24 class VIEWS_EXPORT InkDrop { 26 class VIEWS_EXPORT InkDrop {
25 public: 27 public:
26 virtual ~InkDrop() {} 28 virtual ~InkDrop();
27 29
28 // Called by ink drop hosts when their size is changed. 30 // Called by ink drop hosts when their size is changed.
29 virtual void HostSizeChanged(const gfx::Size& new_size) = 0; 31 virtual void HostSizeChanged(const gfx::Size& new_size) = 0;
30 32
31 // Gets the target state of the ink drop. 33 // Gets the target state of the ink drop.
32 virtual InkDropState GetTargetInkDropState() const = 0; 34 virtual InkDropState GetTargetInkDropState() const = 0;
33 35
34 // Animates from the current InkDropState to |ink_drop_state|. 36 // Animates from the current InkDropState to |ink_drop_state|.
35 virtual void AnimateToState(InkDropState ink_drop_state) = 0; 37 virtual void AnimateToState(InkDropState ink_drop_state) = 0;
36 38
37 // Immediately snaps the InkDropState to ACTIVATED. This more specific 39 // Immediately snaps the InkDropState to ACTIVATED. This more specific
38 // implementation of the non-existent SnapToState(InkDropState) function is 40 // implementation of the non-existent SnapToState(InkDropState) function is
39 // the only one available because it was the only InkDropState that clients 41 // the only one available because it was the only InkDropState that clients
40 // needed to skip animations for. 42 // needed to skip animations for.
41 virtual void SnapToActivated() = 0; 43 virtual void SnapToActivated() = 0;
42 44
43 // Enables or disables the hover state. 45 // Enables or disables the hover state.
44 virtual void SetHovered(bool is_hovered) = 0; 46 virtual void SetHovered(bool is_hovered) = 0;
45 47
46 // Enables or disables the focus state. 48 // Enables or disables the focus state.
47 virtual void SetFocused(bool is_focused) = 0; 49 virtual void SetFocused(bool is_focused) = 0;
48 50
51 // Returns true if the highlight animation is in the process of fading in or
52 // is visible.
53 virtual bool IsHighlightFadingInOrVisible() const = 0;
54
55 // Enables or disables the highlight when the target is hovered.
56 virtual void SetShowHighlightOnHover(bool show_highlight_on_hover) = 0;
57
58 // Enables or disables the highlight when the target is focused.
59 virtual void SetShowHighlightOnFocus(bool show_highlight_on_focus) = 0;
60
61 // Methods to add/remove observers for this object.
62 void AddObserver(InkDropObserver* observer);
63 void RemoveObserver(InkDropObserver* observer);
64
49 protected: 65 protected:
50 InkDrop() {} 66 InkDrop();
67
68 // Notifes all of the observers that the animation has started.
69 void NotifyInkDropAnimationStarted();
51 70
52 private: 71 private:
72 base::ObserverList<InkDropObserver> observers_;
73
53 DISALLOW_COPY_AND_ASSIGN(InkDrop); 74 DISALLOW_COPY_AND_ASSIGN(InkDrop);
54 }; 75 };
55 76
56 // A View which can be used to parent ink drop layers. Typically this is used 77 // A View which can be used to parent ink drop layers. Typically this is used
57 // as a non-ancestor view to labels so that the labels can paint on an opaque 78 // as a non-ancestor view to labels so that the labels can paint on an opaque
58 // canvas. This is used to avoid ugly text renderings when labels with subpixel 79 // canvas. This is used to avoid ugly text renderings when labels with subpixel
59 // rendering enabled are painted onto a non-opaque canvas. 80 // rendering enabled are painted onto a non-opaque canvas.
60 class VIEWS_EXPORT InkDropContainerView : public views::View { 81 class VIEWS_EXPORT InkDropContainerView : public views::View {
61 public: 82 public:
62 InkDropContainerView(); 83 InkDropContainerView();
63 84
64 void AddInkDropLayer(ui::Layer* ink_drop_layer); 85 void AddInkDropLayer(ui::Layer* ink_drop_layer);
65 void RemoveInkDropLayer(ui::Layer* ink_drop_layer); 86 void RemoveInkDropLayer(ui::Layer* ink_drop_layer);
66 87
67 // View: 88 // View:
68 bool CanProcessEventsWithinSubtree() const override; 89 bool CanProcessEventsWithinSubtree() const override;
69 90
70 private: 91 private:
71 DISALLOW_COPY_AND_ASSIGN(InkDropContainerView); 92 DISALLOW_COPY_AND_ASSIGN(InkDropContainerView);
72 }; 93 };
73 94
74 } // namespace views 95 } // namespace views
75 96
76 #endif // UI_VIEWS_ANIMATION_INK_DROP_H_ 97 #endif // UI_VIEWS_ANIMATION_INK_DROP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698