| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/views/animation/ink_drop_animation_controller_factory.h" |
| 6 |
| 7 #include "ui/base/resource/material_design/material_design_controller.h" |
| 8 #include "ui/gfx/geometry/rect.h" |
| 9 #include "ui/gfx/geometry/size.h" |
| 10 #include "ui/views/animation/ink_drop_animation_controller.h" |
| 11 #include "ui/views/animation/ink_drop_animation_controller_impl.h" |
| 12 #include "ui/views/views_export.h" |
| 13 |
| 14 namespace views { |
| 15 |
| 16 namespace { |
| 17 |
| 18 // A stub implementation of an InkDropAnimationController that can be used when |
| 19 // material design is not enabled. |
| 20 class VIEWS_EXPORT InkDropAnimationControllerStub |
| 21 : public InkDropAnimationController { |
| 22 public: |
| 23 explicit InkDropAnimationControllerStub(InkDropHost* ink_drop_host); |
| 24 ~InkDropAnimationControllerStub() override; |
| 25 |
| 26 // InkDropAnimationController: |
| 27 void AnimateToState(InkDropState state) override; |
| 28 void SetInkDropSize(const gfx::Size& size) override; |
| 29 gfx::Rect GetInkDropBounds() const override; |
| 30 void SetInkDropBounds(const gfx::Rect& bounds) override; |
| 31 |
| 32 private: |
| 33 // The bounds of the ink drop layers. Defined in the coordinate space of the |
| 34 // parent ui::Layer that the ink drop layers were added to. |
| 35 gfx::Rect ink_drop_bounds_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerStub); |
| 38 }; |
| 39 |
| 40 InkDropAnimationControllerStub::InkDropAnimationControllerStub( |
| 41 InkDropHost* ink_drop_host) {} |
| 42 |
| 43 InkDropAnimationControllerStub::~InkDropAnimationControllerStub() {} |
| 44 |
| 45 void InkDropAnimationControllerStub::AnimateToState(InkDropState state) {} |
| 46 |
| 47 void InkDropAnimationControllerStub::SetInkDropSize(const gfx::Size& size) { |
| 48 ink_drop_bounds_.set_size(size); |
| 49 } |
| 50 |
| 51 gfx::Rect InkDropAnimationControllerStub::GetInkDropBounds() const { |
| 52 return ink_drop_bounds_; |
| 53 } |
| 54 |
| 55 void InkDropAnimationControllerStub::SetInkDropBounds(const gfx::Rect& bounds) { |
| 56 ink_drop_bounds_ = bounds; |
| 57 } |
| 58 |
| 59 } // namespace |
| 60 |
| 61 InkDropAnimationControllerFactory::InkDropAnimationControllerFactory() {} |
| 62 |
| 63 InkDropAnimationControllerFactory::~InkDropAnimationControllerFactory() {} |
| 64 |
| 65 scoped_ptr<InkDropAnimationController> |
| 66 InkDropAnimationControllerFactory::CreateInkDropAnimationController( |
| 67 InkDropHost* ink_drop_host) { |
| 68 #if defined(OS_CHROMEOS) |
| 69 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 70 return scoped_ptr<InkDropAnimationController>( |
| 71 new InkDropAnimationControllerImpl(ink_drop_host)); |
| 72 } else { |
| 73 return scoped_ptr<InkDropAnimationController>( |
| 74 new InkDropAnimationControllerStub(ink_drop_host)); |
| 75 } |
| 76 #endif // defined(OS_CHROMEOS) |
| 77 |
| 78 return scoped_ptr<InkDropAnimationController>( |
| 79 new InkDropAnimationControllerStub(ink_drop_host)); |
| 80 } |
| 81 |
| 82 } // namespace views |
| OLD | NEW |