| 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 "ui/base/resource/material_design/material_design_controller.h" | 7 #include "ui/base/resource/material_design/material_design_controller.h" |
| 8 #include "ui/gfx/geometry/rect.h" | 8 #include "ui/gfx/geometry/rect.h" |
| 9 #include "ui/gfx/geometry/size.h" | 9 #include "ui/gfx/geometry/size.h" |
| 10 #include "ui/views/animation/ink_drop_animation_controller.h" | 10 #include "ui/views/animation/ink_drop_animation_controller.h" |
| 11 #include "ui/views/animation/ink_drop_animation_controller_impl.h" | 11 #include "ui/views/animation/ink_drop_animation_controller_impl.h" |
| 12 #include "ui/views/views_export.h" | 12 #include "ui/views/views_export.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // A stub implementation of an InkDropAnimationController that can be used when | 18 // A stub implementation of an InkDropAnimationController that can be used when |
| 19 // material design is not enabled. | 19 // material design is not enabled. |
| 20 class InkDropAnimationControllerStub | 20 class InkDropAnimationControllerStub |
| 21 : public InkDropAnimationController { | 21 : public InkDropAnimationController { |
| 22 public: | 22 public: |
| 23 explicit InkDropAnimationControllerStub(); | 23 explicit InkDropAnimationControllerStub(); |
| 24 ~InkDropAnimationControllerStub() override; | 24 ~InkDropAnimationControllerStub() override; |
| 25 | 25 |
| 26 // InkDropAnimationController: | 26 // InkDropAnimationController: |
| 27 InkDropState GetInkDropState() const override; | 27 InkDropState GetInkDropState() const override; |
| 28 void AnimateToState(InkDropState state) override; | 28 void AnimateToState(InkDropState state) override; |
| 29 bool WillAutoAnimateToHidden() const override; |
| 30 void SetHovered(bool is_hovered) override; |
| 31 bool IsHovered() const override; |
| 29 gfx::Size GetInkDropLargeSize() const override; | 32 gfx::Size GetInkDropLargeSize() const override; |
| 30 void SetInkDropSize(const gfx::Size& large_size, | 33 void SetInkDropSize(const gfx::Size& large_size, |
| 31 int large_corner_radius, | 34 int large_corner_radius, |
| 32 const gfx::Size& small_size, | 35 const gfx::Size& small_size, |
| 33 int small_corner_radius) override; | 36 int small_corner_radius) override; |
| 34 void SetInkDropCenter(const gfx::Point& center_point) override; | 37 void SetInkDropCenter(const gfx::Point& center_point) override; |
| 35 | 38 |
| 36 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 |
| 37 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerStub); | 44 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerStub); |
| 38 }; | 45 }; |
| 39 | 46 |
| 40 InkDropAnimationControllerStub::InkDropAnimationControllerStub() {} | 47 InkDropAnimationControllerStub::InkDropAnimationControllerStub() |
| 48 : is_hovered_(false) {} |
| 41 | 49 |
| 42 InkDropAnimationControllerStub::~InkDropAnimationControllerStub() {} | 50 InkDropAnimationControllerStub::~InkDropAnimationControllerStub() {} |
| 43 | 51 |
| 44 InkDropState InkDropAnimationControllerStub::GetInkDropState() const { | 52 InkDropState InkDropAnimationControllerStub::GetInkDropState() const { |
| 45 return InkDropState::HIDDEN; | 53 return InkDropState::HIDDEN; |
| 46 } | 54 } |
| 47 | 55 |
| 48 void InkDropAnimationControllerStub::AnimateToState(InkDropState state) {} | 56 void InkDropAnimationControllerStub::AnimateToState(InkDropState state) { |
| 57 SetHovered(false); |
| 58 } |
| 59 |
| 60 bool InkDropAnimationControllerStub::WillAutoAnimateToHidden() const { |
| 61 return false; |
| 62 } |
| 63 |
| 64 void InkDropAnimationControllerStub::SetHovered(bool is_hovered) { |
| 65 is_hovered_ = is_hovered; |
| 66 } |
| 67 |
| 68 bool InkDropAnimationControllerStub::IsHovered() const { |
| 69 return is_hovered_; |
| 70 } |
| 49 | 71 |
| 50 gfx::Size InkDropAnimationControllerStub::GetInkDropLargeSize() const { | 72 gfx::Size InkDropAnimationControllerStub::GetInkDropLargeSize() const { |
| 51 return gfx::Size(); | 73 return gfx::Size(); |
| 52 } | 74 } |
| 53 | 75 |
| 54 void InkDropAnimationControllerStub::SetInkDropSize(const gfx::Size& large_size, | 76 void InkDropAnimationControllerStub::SetInkDropSize(const gfx::Size& large_size, |
| 55 int large_corner_radius, | 77 int large_corner_radius, |
| 56 const gfx::Size& small_size, | 78 const gfx::Size& small_size, |
| 57 int small_corner_radius) {} | 79 int small_corner_radius) {} |
| 58 | 80 |
| 59 void InkDropAnimationControllerStub::SetInkDropCenter( | 81 void InkDropAnimationControllerStub::SetInkDropCenter( |
| 60 const gfx::Point& center_point) {} | 82 const gfx::Point& center_point) {} |
| 61 | 83 |
| 62 } // namespace | 84 } // namespace |
| 63 | 85 |
| 64 InkDropAnimationControllerFactory::InkDropAnimationControllerFactory() {} | 86 InkDropAnimationControllerFactory::InkDropAnimationControllerFactory() {} |
| 65 | 87 |
| 66 InkDropAnimationControllerFactory::~InkDropAnimationControllerFactory() {} | 88 InkDropAnimationControllerFactory::~InkDropAnimationControllerFactory() {} |
| 67 | 89 |
| 68 scoped_ptr<InkDropAnimationController> | 90 scoped_ptr<InkDropAnimationController> |
| 69 InkDropAnimationControllerFactory::CreateInkDropAnimationController( | 91 InkDropAnimationControllerFactory::CreateInkDropAnimationController( |
| 70 InkDropHost* ink_drop_host) { | 92 InkDropHost* ink_drop_host, |
| 93 InkDropConsumer* ink_drop_consumer) { |
| 71 if (ui::MaterialDesignController::IsModeMaterial()) { | 94 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 72 return scoped_ptr<InkDropAnimationController>( | 95 return scoped_ptr<InkDropAnimationController>( |
| 73 new InkDropAnimationControllerImpl(ink_drop_host)); | 96 new InkDropAnimationControllerImpl(ink_drop_host, ink_drop_consumer)); |
| 74 } | 97 } |
| 75 | 98 |
| 76 return scoped_ptr<InkDropAnimationController>( | 99 return scoped_ptr<InkDropAnimationController>( |
| 77 new InkDropAnimationControllerStub()); | 100 new InkDropAnimationControllerStub()); |
| 78 } | 101 } |
| 79 | 102 |
| 80 } // namespace views | 103 } // namespace views |
| OLD | NEW |