| 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/gfx/color_palette.h" |
| 8 #include "ui/gfx/geometry/size_conversions.h" | 8 #include "ui/gfx/geometry/size_conversions.h" |
| 9 #include "ui/views/animation/ink_drop_hover.h" | 9 #include "ui/views/animation/ink_drop_hover.h" |
| 10 #include "ui/views/animation/square_ink_drop_animation.h" | 10 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 11 | 11 |
| 12 namespace views { | 12 namespace views { |
| 13 | 13 |
| 14 // Default sizes for ink drop effects. | 14 // Default sizes for ink drop effects. |
| 15 const int kInkDropSize = 24; | 15 const int kInkDropSize = 24; |
| 16 const int kInkDropLargeCornerRadius = 4; | 16 const int kInkDropLargeCornerRadius = 4; |
| 17 | 17 |
| 18 // The scale factor to compute the large ink drop size. | 18 // The scale factor to compute the large ink drop size. |
| 19 const float kLargeInkDropScale = 1.333f; | 19 const float kLargeInkDropScale = 1.333f; |
| 20 | 20 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 39 layer()->SetFillsBoundsOpaquely(false); | 39 layer()->SetFillsBoundsOpaquely(false); |
| 40 layer()->Add(ink_drop_layer); | 40 layer()->Add(ink_drop_layer); |
| 41 layer()->StackAtBottom(ink_drop_layer); | 41 layer()->StackAtBottom(ink_drop_layer); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 44 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 45 layer()->Remove(ink_drop_layer); | 45 layer()->Remove(ink_drop_layer); |
| 46 SetPaintToLayer(false); | 46 SetPaintToLayer(false); |
| 47 } | 47 } |
| 48 | 48 |
| 49 std::unique_ptr<InkDropAnimation> InkDropHostView::CreateInkDropAnimation() | 49 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { |
| 50 const { | 50 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( |
| 51 std::unique_ptr<InkDropAnimation> animation(new SquareInkDropAnimation( | |
| 52 CalculateLargeInkDropSize(ink_drop_size_), kInkDropLargeCornerRadius, | 51 CalculateLargeInkDropSize(ink_drop_size_), kInkDropLargeCornerRadius, |
| 53 ink_drop_size_, kInkDropSmallCornerRadius, GetInkDropCenter(), | 52 ink_drop_size_, kInkDropSmallCornerRadius, GetInkDropCenter(), |
| 54 GetInkDropBaseColor())); | 53 GetInkDropBaseColor())); |
| 55 return animation; | 54 return ripple; |
| 56 } | 55 } |
| 57 | 56 |
| 58 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { | 57 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { |
| 59 std::unique_ptr<InkDropHover> hover( | 58 std::unique_ptr<InkDropHover> hover( |
| 60 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius, | 59 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius, |
| 61 GetInkDropCenter(), GetInkDropBaseColor())); | 60 GetInkDropCenter(), GetInkDropBaseColor())); |
| 62 hover->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_)); | 61 hover->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_)); |
| 63 return hover; | 62 return hover; |
| 64 } | 63 } |
| 65 | 64 |
| 66 gfx::Point InkDropHostView::GetInkDropCenter() const { | 65 gfx::Point InkDropHostView::GetInkDropCenter() const { |
| 67 return GetLocalBounds().CenterPoint(); | 66 return GetLocalBounds().CenterPoint(); |
| 68 } | 67 } |
| 69 | 68 |
| 70 SkColor InkDropHostView::GetInkDropBaseColor() const { | 69 SkColor InkDropHostView::GetInkDropBaseColor() const { |
| 71 NOTREACHED(); | 70 NOTREACHED(); |
| 72 return gfx::kPlaceholderColor; | 71 return gfx::kPlaceholderColor; |
| 73 } | 72 } |
| 74 | 73 |
| 75 } // namespace views | 74 } // namespace views |
| OLD | NEW |