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

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

Issue 2042073002: Centered flood fill style ink drop ripples on mouse/touch points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed LocatedEvent::AsLocatedIfLocatedEvent() as FromIfValid(). Created 4 years, 6 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
« no previous file with comments | « ui/views/animation/ink_drop.h ('k') | ui/views/animation/ink_drop_host_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_HOST_VIEW_H_ 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_
6 #define UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ 6 #define UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/geometry/point.h"
11 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
12 #include "ui/views/animation/ink_drop.h" 13 #include "ui/views/animation/ink_drop.h"
13 #include "ui/views/animation/ink_drop_host.h" 14 #include "ui/views/animation/ink_drop_host.h"
14 #include "ui/views/view.h" 15 #include "ui/views/view.h"
15 16
16 namespace views { 17 namespace views {
17 18
18 namespace test { 19 namespace test {
19 class InkDropHostViewTestApi; 20 class InkDropHostViewTestApi;
20 } // namespace test 21 } // namespace test
21 22
22 class InkDropRipple; 23 class InkDropRipple;
23 class InkDropHighlight; 24 class InkDropHighlight;
24 25
25 // A view that provides InkDropHost functionality. 26 // A view that provides InkDropHost functionality.
26 class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost { 27 class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost {
27 public: 28 public:
29 InkDropHostView();
30 ~InkDropHostView() override;
31
28 // Overridden from InkDropHost: 32 // Overridden from InkDropHost:
29 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; 33 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
30 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; 34 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
31 std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override; 35 std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override;
32 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override; 36 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override;
33 37
34 void set_ink_drop_size(const gfx::Size& size) { ink_drop_size_ = size; } 38 void set_ink_drop_size(const gfx::Size& size) { ink_drop_size_ = size; }
35 39
36 protected: 40 protected:
37 InkDropHostView(); 41 static const int kInkDropSmallCornerRadius;
38 ~InkDropHostView() override;
39 42
40 static const int kInkDropSmallCornerRadius; 43 // Returns the default InkDropRipple centered on |center_point|.
44 std::unique_ptr<InkDropRipple> CreateDefaultInkDropRipple(
45 const gfx::Point& center_point) const;
46
47 // Returns the default InkDropHighlight centered on |center_point|.
48 std::unique_ptr<InkDropHighlight> CreateDefaultInkDropHighlight(
49 const gfx::Point& center_point) const;
50
51 // Returns the point of the |last_ripple_triggering_event_| if it was a
52 // LocatedEvent, otherwise the center point of the local bounds is returned.
53 gfx::Point GetInkDropCenterBasedOnLastEvent() const;
54
55 // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the
56 // last_ripple_triggering_event().
57 //
58 // *** NOTE ***: |event| has been plumbed through on a best effort basis for
59 // the purposes of centering ink drop ripples on located Events. Thus nullptr
60 // has been used by clients who do not have an Event instance available to
61 // them.
62 void AnimateInkDrop(InkDropState state, const ui::LocatedEvent* event);
41 63
42 // View: 64 // View:
43 void VisibilityChanged(View* starting_from, bool is_visible) override; 65 void VisibilityChanged(View* starting_from, bool is_visible) override;
44 void OnFocus() override; 66 void OnFocus() override;
45 void OnBlur() override; 67 void OnBlur() override;
46 void OnMouseEvent(ui::MouseEvent* event) override; 68 void OnMouseEvent(ui::MouseEvent* event) override;
47 69
48 // Overrideable methods to allow views to provide minor tweaks to the default 70 // Overrideable methods to allow views to provide minor tweaks to the default
49 // ink drop. 71 // ink drop.
50 virtual gfx::Point GetInkDropCenter() const;
51 virtual SkColor GetInkDropBaseColor() const; 72 virtual SkColor GetInkDropBaseColor() const;
52 73
53 // Should return true if the ink drop is also used to depict focus. 74 // Should return true if the ink drop is also used to depict focus.
54 virtual bool ShouldShowInkDropForFocus() const; 75 virtual bool ShouldShowInkDropForFocus() const;
55 76
56 InkDrop* ink_drop() { return ink_drop_.get(); } 77 InkDrop* ink_drop() { return ink_drop_.get(); }
57 78
58 // Toggle to enable/disable an InkDrop on this View. Descendants can override 79 // Toggle to enable/disable an InkDrop on this View. Descendants can override
59 // CreateInkDropHighlight() and CreateInkDropRipple() to change the look/feel 80 // CreateInkDropHighlight() and CreateInkDropRipple() to change the look/feel
60 // of the InkDrop. 81 // of the InkDrop.
61 void SetHasInkDrop(bool has_an_ink_drop); 82 void SetHasInkDrop(bool has_an_ink_drop);
62 83
63 // Animates |ink_drop_| to the desired |ink_drop_state|.
64 //
65 // TODO(bruthig): Enhance to accept a ui::Event parameter so InkDrops can be
66 // centered (see https://crbug.com/597273) and disabled for touch events on
67 // Windows (see https://crbug.com/595315).
68 void AnimateInkDrop(InkDropState ink_drop_state);
69
70 private: 84 private:
71 class InkDropGestureHandler; 85 class InkDropGestureHandler;
86 friend class InkDropGestureHandler;
72 friend class test::InkDropHostViewTestApi; 87 friend class test::InkDropHostViewTestApi;
73 88
89 // The last user Event to trigger an ink drop ripple animation.
90 std::unique_ptr<ui::LocatedEvent> last_ripple_triggering_event_;
91
74 std::unique_ptr<InkDrop> ink_drop_; 92 std::unique_ptr<InkDrop> ink_drop_;
75 93
76 // Intentionally declared after |ink_drop_| so that it doesn't access a 94 // Intentionally declared after |ink_drop_| so that it doesn't access a
77 // destroyed |ink_drop_| during destruction. 95 // destroyed |ink_drop_| during destruction.
78 std::unique_ptr<InkDropGestureHandler> gesture_handler_; 96 std::unique_ptr<InkDropGestureHandler> gesture_handler_;
79 97
80 gfx::Size ink_drop_size_; 98 gfx::Size ink_drop_size_;
81 99
82 // Determines whether the view was already painting to layer before adding ink 100 // Determines whether the view was already painting to layer before adding ink
83 // drop layer. 101 // drop layer.
84 bool old_paint_to_layer_; 102 bool old_paint_to_layer_;
85 103
86 bool destroying_; 104 bool destroying_;
87 105
88 DISALLOW_COPY_AND_ASSIGN(InkDropHostView); 106 DISALLOW_COPY_AND_ASSIGN(InkDropHostView);
89 }; 107 };
90 } // namespace views 108 } // namespace views
91 109
92 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ 110 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop.h ('k') | ui/views/animation/ink_drop_host_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698