OLD | NEW |
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 #include "ui/views/animation/ink_drop_animation_controller_factory.h" | 5 #include "ui/views/animation/ink_drop_animation_controller_factory.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "ui/base/resource/material_design/material_design_controller.h" | 8 #include "ui/base/resource/material_design/material_design_controller.h" |
9 #include "ui/gfx/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
11 #include "ui/views/animation/ink_drop_animation_controller.h" | 11 #include "ui/views/animation/ink_drop_animation_controller.h" |
12 #include "ui/views/animation/ink_drop_animation_controller_impl.h" | 12 #include "ui/views/animation/ink_drop_animation_controller_impl.h" |
13 #include "ui/views/views_export.h" | 13 #include "ui/views/views_export.h" |
14 | 14 |
15 namespace views { | 15 namespace views { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // A stub implementation of an InkDropAnimationController that can be used when | 19 // A stub implementation of an InkDropAnimationController that can be used when |
20 // material design is not enabled. | 20 // material design is not enabled. |
21 class InkDropAnimationControllerStub | 21 class InkDropAnimationControllerStub |
22 : public InkDropAnimationController { | 22 : public InkDropAnimationController { |
23 public: | 23 public: |
24 explicit InkDropAnimationControllerStub(); | 24 explicit InkDropAnimationControllerStub(); |
25 ~InkDropAnimationControllerStub() override; | 25 ~InkDropAnimationControllerStub() override; |
26 | 26 |
27 // InkDropAnimationController: | 27 // InkDropAnimationController: |
28 InkDropState GetInkDropState() const override; | 28 InkDropState GetInkDropState() const override; |
29 void AnimateToState(InkDropState state) override; | 29 void AnimateToState(InkDropState state) override; |
| 30 void SetHovered(bool is_hovered) override; |
| 31 bool IsHovered() const override; |
30 gfx::Size GetInkDropLargeSize() const override; | 32 gfx::Size GetInkDropLargeSize() const override; |
31 void SetInkDropSize(const gfx::Size& large_size, | 33 void SetInkDropSize(const gfx::Size& large_size, |
32 int large_corner_radius, | 34 int large_corner_radius, |
33 const gfx::Size& small_size, | 35 const gfx::Size& small_size, |
34 int small_corner_radius) override; | 36 int small_corner_radius) override; |
35 void SetInkDropCenter(const gfx::Point& center_point) override; | 37 void SetInkDropCenter(const gfx::Point& center_point) override; |
36 | 38 |
37 private: | 39 private: |
| 40 // Tracks whether the ink drop is hovered or not. This is used to ensure that |
| 41 // this behaves like all other InkDropAnimationController implementations. |
| 42 bool is_hovered_; |
| 43 |
38 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerStub); | 44 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerStub); |
39 }; | 45 }; |
40 | 46 |
41 InkDropAnimationControllerStub::InkDropAnimationControllerStub() {} | 47 InkDropAnimationControllerStub::InkDropAnimationControllerStub() |
| 48 : is_hovered_(false) {} |
42 | 49 |
43 InkDropAnimationControllerStub::~InkDropAnimationControllerStub() {} | 50 InkDropAnimationControllerStub::~InkDropAnimationControllerStub() {} |
44 | 51 |
45 InkDropState InkDropAnimationControllerStub::GetInkDropState() const { | 52 InkDropState InkDropAnimationControllerStub::GetInkDropState() const { |
46 return InkDropState::HIDDEN; | 53 return InkDropState::HIDDEN; |
47 } | 54 } |
48 | 55 |
49 void InkDropAnimationControllerStub::AnimateToState(InkDropState state) {} | 56 void InkDropAnimationControllerStub::AnimateToState(InkDropState state) { |
| 57 SetHovered(false); |
| 58 } |
| 59 |
| 60 void InkDropAnimationControllerStub::SetHovered(bool is_hovered) { |
| 61 is_hovered_ = is_hovered; |
| 62 } |
| 63 |
| 64 bool InkDropAnimationControllerStub::IsHovered() const { |
| 65 return is_hovered_; |
| 66 } |
50 | 67 |
51 gfx::Size InkDropAnimationControllerStub::GetInkDropLargeSize() const { | 68 gfx::Size InkDropAnimationControllerStub::GetInkDropLargeSize() const { |
52 return gfx::Size(); | 69 return gfx::Size(); |
53 } | 70 } |
54 | 71 |
55 void InkDropAnimationControllerStub::SetInkDropSize(const gfx::Size& large_size, | 72 void InkDropAnimationControllerStub::SetInkDropSize(const gfx::Size& large_size, |
56 int large_corner_radius, | 73 int large_corner_radius, |
57 const gfx::Size& small_size, | 74 const gfx::Size& small_size, |
58 int small_corner_radius) {} | 75 int small_corner_radius) {} |
59 | 76 |
(...skipping 12 matching lines...) Expand all Loading... |
72 if (ui::MaterialDesignController::IsModeMaterial()) { | 89 if (ui::MaterialDesignController::IsModeMaterial()) { |
73 return scoped_ptr<InkDropAnimationController>( | 90 return scoped_ptr<InkDropAnimationController>( |
74 new InkDropAnimationControllerImpl(ink_drop_host)); | 91 new InkDropAnimationControllerImpl(ink_drop_host)); |
75 } | 92 } |
76 | 93 |
77 return scoped_ptr<InkDropAnimationController>( | 94 return scoped_ptr<InkDropAnimationController>( |
78 new InkDropAnimationControllerStub()); | 95 new InkDropAnimationControllerStub()); |
79 } | 96 } |
80 | 97 |
81 } // namespace views | 98 } // namespace views |
OLD | NEW |