| OLD | NEW |
| 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 #include "ui/views/animation/ink_drop_host_view.h" | 5 #include "ui/views/animation/ink_drop_host_view.h" |
| 6 | 6 |
| 7 #include "ui/gfx/color_palette.h" |
| 7 #include "ui/views/animation/ink_drop_hover.h" | 8 #include "ui/views/animation/ink_drop_hover.h" |
| 8 #include "ui/views/animation/square_ink_drop_animation.h" | 9 #include "ui/views/animation/square_ink_drop_animation.h" |
| 9 | 10 |
| 10 namespace views { | 11 namespace views { |
| 11 | 12 |
| 12 // Default sizes for ink drop effects. | 13 // Default sizes for ink drop effects. |
| 13 const int kInkDropLargeSize = 32; | 14 const int kInkDropLargeSize = 32; |
| 14 const int kInkDropLargeCornerRadius = 4; | 15 const int kInkDropLargeCornerRadius = 4; |
| 15 const int kInkDropSmallSize = 24; | 16 const int kInkDropSmallSize = 24; |
| 16 const int kInkDropSmallCornerRadius = 2; | 17 const int kInkDropSmallCornerRadius = 2; |
| 17 | 18 |
| 18 InkDropHostView::InkDropHostView() {} | 19 InkDropHostView::InkDropHostView() {} |
| 19 | 20 |
| 20 InkDropHostView::~InkDropHostView() {} | 21 InkDropHostView::~InkDropHostView() {} |
| 21 | 22 |
| 22 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 23 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 23 SetPaintToLayer(true); | 24 SetPaintToLayer(true); |
| 24 SetFillsBoundsOpaquely(false); | 25 SetFillsBoundsOpaquely(false); |
| 25 layer()->Add(ink_drop_layer); | 26 layer()->Add(ink_drop_layer); |
| 26 layer()->StackAtBottom(ink_drop_layer); | 27 layer()->StackAtBottom(ink_drop_layer); |
| 27 } | 28 } |
| 28 | 29 |
| 29 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 30 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 30 layer()->Remove(ink_drop_layer); | 31 layer()->Remove(ink_drop_layer); |
| 31 SetFillsBoundsOpaquely(true); | |
| 32 SetPaintToLayer(false); | 32 SetPaintToLayer(false); |
| 33 } | 33 } |
| 34 | 34 |
| 35 scoped_ptr<InkDropAnimation> InkDropHostView::CreateInkDropAnimation() const { | 35 scoped_ptr<InkDropAnimation> InkDropHostView::CreateInkDropAnimation() const { |
| 36 scoped_ptr<InkDropAnimation> animation(new SquareInkDropAnimation( | 36 scoped_ptr<InkDropAnimation> animation(new SquareInkDropAnimation( |
| 37 gfx::Size(kInkDropLargeSize, kInkDropLargeSize), | 37 gfx::Size(kInkDropLargeSize, kInkDropLargeSize), |
| 38 kInkDropLargeCornerRadius, | 38 kInkDropLargeCornerRadius, |
| 39 gfx::Size(kInkDropSmallSize, kInkDropSmallSize), | 39 gfx::Size(kInkDropSmallSize, kInkDropSmallSize), |
| 40 kInkDropSmallCornerRadius)); | 40 kInkDropSmallCornerRadius, GetInkDropCenter(), GetInkDropBaseColor())); |
| 41 animation->SetCenterPoint(GetInkDropCenter()); | |
| 42 return animation; | 41 return animation; |
| 43 } | 42 } |
| 44 | 43 |
| 45 scoped_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { | 44 scoped_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { |
| 46 scoped_ptr<InkDropHover> hover( | 45 scoped_ptr<InkDropHover> hover(new InkDropHover( |
| 47 new InkDropHover(gfx::Size(kInkDropSmallSize, kInkDropSmallSize), | 46 gfx::Size(kInkDropSmallSize, kInkDropSmallSize), |
| 48 kInkDropSmallCornerRadius)); | 47 kInkDropSmallCornerRadius, GetInkDropCenter(), GetInkDropBaseColor())); |
| 49 hover->SetCenterPoint(GetInkDropCenter()); | |
| 50 return hover; | 48 return hover; |
| 51 } | 49 } |
| 52 | 50 |
| 53 gfx::Point InkDropHostView::GetInkDropCenter() const { | 51 gfx::Point InkDropHostView::GetInkDropCenter() const { |
| 54 return GetLocalBounds().CenterPoint(); | 52 return GetLocalBounds().CenterPoint(); |
| 55 } | 53 } |
| 56 | 54 |
| 55 SkColor InkDropHostView::GetInkDropBaseColor() const { |
| 56 NOTREACHED(); |
| 57 return gfx::kPlaceholderColor; |
| 58 } |
| 59 |
| 57 } // namespace views | 60 } // namespace views |
| OLD | NEW |