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