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

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

Issue 2041033002: Moved ButtonInkDropDelegate logic into InkDropHostView and deleted InkDropDelegates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/size.h" 11 #include "ui/gfx/geometry/size.h"
12 #include "ui/views/animation/ink_drop_delegate.h" 12 #include "ui/views/animation/ink_drop.h"
13 #include "ui/views/animation/ink_drop_host.h" 13 #include "ui/views/animation/ink_drop_host.h"
14 #include "ui/views/view.h" 14 #include "ui/views/view.h"
15 15
16 namespace views { 16 namespace views {
17 17
18 namespace test {
19 class InkDropHostViewTestApi;
20 } // namespace test
21
18 class InkDropRipple; 22 class InkDropRipple;
19 class InkDropHighlight; 23 class InkDropHighlight;
20 24
21 // A view that provides InkDropHost functionality. 25 // A view that provides InkDropHost functionality.
22 class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost { 26 class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost {
23 public: 27 public:
24 // Overridden from views::InkDropHost: 28 // Overridden from views::InkDropHost:
25 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; 29 void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
26 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; 30 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
27 std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override; 31 std::unique_ptr<InkDropRipple> CreateInkDropRipple() const override;
28 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override; 32 std::unique_ptr<InkDropHighlight> CreateInkDropHighlight() const override;
29 33
30 void set_ink_drop_size(const gfx::Size& size) { ink_drop_size_ = size; } 34 void set_ink_drop_size(const gfx::Size& size) { ink_drop_size_ = size; }
31 35
32 InkDropDelegate* ink_drop_delegate() { return ink_drop_delegate_.get(); }
33
34 protected: 36 protected:
35 InkDropHostView(); 37 InkDropHostView();
36 ~InkDropHostView() override; 38 ~InkDropHostView() override;
37 39
38 static const int kInkDropSmallCornerRadius; 40 static const int kInkDropSmallCornerRadius;
39 41
40 // View 42 // View:
41 void OnFocus() override; 43 void OnFocus() override;
42 void OnBlur() override; 44 void OnBlur() override;
45 void OnMouseEvent(ui::MouseEvent* event) override;
43 46
44 // Overrideable methods to allow views to provide minor tweaks to the default 47 // Overrideable methods to allow views to provide minor tweaks to the default
45 // ink drop. 48 // ink drop.
46 virtual gfx::Point GetInkDropCenter() const; 49 virtual gfx::Point GetInkDropCenter() const;
47 virtual SkColor GetInkDropBaseColor() const; 50 virtual SkColor GetInkDropBaseColor() const;
48 51
49 // Should return true if the ink drop is also used to depict focus. 52 // Should return true if the ink drop is also used to depict focus.
50 virtual bool ShouldShowInkDropForFocus() const; 53 virtual bool ShouldShowInkDropForFocus() const;
51 54
52 void set_ink_drop_delegate(std::unique_ptr<InkDropDelegate> delegate) { 55 InkDrop* ink_drop() { return ink_drop_.get(); }
53 ink_drop_delegate_ = std::move(delegate); 56
54 } 57 // Toggle to enable/disable an InkDrop on this View. Descendants can override
58 // CreateInkDropHighlight() and CreateInkDropRipple() to change the look/feel
59 // of the InkDrop.
60 void SetHasInkDrop(bool has_an_ink_drop);
61
62 // Animates |ink_drop_| to the desired |ink_drop_state|.
63 //
64 // TODO(bruthig): Enhance to accept a ui::Event parameter so InkDrops can be
65 // centered (see https://crbug.com/597273) and disabled for touch events on
66 // Windows (see https://crbug.com/595315).
67 void AnimateInkDrop(InkDropState ink_drop_state);
55 68
56 private: 69 private:
57 std::unique_ptr<InkDropDelegate> ink_drop_delegate_; 70 class InkDropGestureHandler;
71 friend class test::InkDropHostViewTestApi;
72
73 std::unique_ptr<InkDrop> ink_drop_;
74
75 // Intentionally declared after |ink_drop_| so that it doesn't access a
76 // destroyed |ink_drop_| during destruction.
77 std::unique_ptr<InkDropGestureHandler> gesture_handler_;
78
58 gfx::Size ink_drop_size_; 79 gfx::Size ink_drop_size_;
80
59 bool destroying_; 81 bool destroying_;
60 82
61 DISALLOW_COPY_AND_ASSIGN(InkDropHostView); 83 DISALLOW_COPY_AND_ASSIGN(InkDropHostView);
62 }; 84 };
63 } // namespace views 85 } // namespace views
64 86
65 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ 87 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698