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.
5 #include "ui/views/animation/ink_drop_animation_controller_factory.h"
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"
18 // A stub implementation of an InkDropAnimationController that can be used when
19 // material design is not enabled.
20 class InkDropAnimationControllerStub
21 : public InkDropAnimationController
{
23 explicit InkDropAnimationControllerStub(InkDropHost
* ink_drop_host
);
24 ~InkDropAnimationControllerStub() override
;
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
;
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_
;
37 DISALLOW_COPY_AND_ASSIGN(InkDropAnimationControllerStub
);
40 InkDropAnimationControllerStub::InkDropAnimationControllerStub(
41 InkDropHost
* ink_drop_host
) {}
43 InkDropAnimationControllerStub::~InkDropAnimationControllerStub() {}
45 void InkDropAnimationControllerStub::AnimateToState(InkDropState state
) {}
47 void InkDropAnimationControllerStub::SetInkDropSize(const gfx::Size
& size
) {
48 ink_drop_bounds_
.set_size(size
);
51 gfx::Rect
InkDropAnimationControllerStub::GetInkDropBounds() const {
52 return ink_drop_bounds_
;
55 void InkDropAnimationControllerStub::SetInkDropBounds(const gfx::Rect
& bounds
) {
56 ink_drop_bounds_
= bounds
;
61 InkDropAnimationControllerFactory::InkDropAnimationControllerFactory() {}
63 InkDropAnimationControllerFactory::~InkDropAnimationControllerFactory() {}
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
));
73 return scoped_ptr
<InkDropAnimationController
>(
74 new InkDropAnimationControllerStub(ink_drop_host
));
76 #endif // defined(OS_CHROMEOS)
78 return scoped_ptr
<InkDropAnimationController
>(
79 new InkDropAnimationControllerStub(ink_drop_host
));