| 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.h" |
| 9 #include "ui/views/animation/ink_drop_hover.h" | 10 #include "ui/views/animation/ink_drop_hover.h" |
| 10 #include "ui/views/animation/square_ink_drop_ripple.h" | 11 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 11 | 12 |
| 12 namespace views { | 13 namespace views { |
| 13 | 14 |
| 14 // Default sizes for ink drop effects. | 15 // Default sizes for ink drop effects. |
| 15 const int kInkDropSize = 24; | 16 const int kInkDropSize = 24; |
| 16 const int kInkDropLargeCornerRadius = 4; | 17 const int kInkDropLargeCornerRadius = 4; |
| 17 | 18 |
| 18 // The scale factor to compute the large ink drop size. | 19 // The scale factor to compute the large ink drop size. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 56 } |
| 56 | 57 |
| 57 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { | 58 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { |
| 58 std::unique_ptr<InkDropHover> hover( | 59 std::unique_ptr<InkDropHover> hover( |
| 59 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius, | 60 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius, |
| 60 GetInkDropCenter(), GetInkDropBaseColor())); | 61 GetInkDropCenter(), GetInkDropBaseColor())); |
| 61 hover->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_)); | 62 hover->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_)); |
| 62 return hover; | 63 return hover; |
| 63 } | 64 } |
| 64 | 65 |
| 66 void InkDropHostView::OnFocus() { |
| 67 views::View::OnFocus(); |
| 68 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) |
| 69 ink_drop_delegate()->GetInkDrop()->SnapToHovered(true); |
| 70 } |
| 71 |
| 72 void InkDropHostView::OnBlur() { |
| 73 views::View::OnBlur(); |
| 74 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) |
| 75 ink_drop_delegate()->GetInkDrop()->SnapToHovered(false); |
| 76 } |
| 77 |
| 65 gfx::Point InkDropHostView::GetInkDropCenter() const { | 78 gfx::Point InkDropHostView::GetInkDropCenter() const { |
| 66 return GetLocalBounds().CenterPoint(); | 79 return GetLocalBounds().CenterPoint(); |
| 67 } | 80 } |
| 68 | 81 |
| 69 SkColor InkDropHostView::GetInkDropBaseColor() const { | 82 SkColor InkDropHostView::GetInkDropBaseColor() const { |
| 70 NOTREACHED(); | 83 NOTREACHED(); |
| 71 return gfx::kPlaceholderColor; | 84 return gfx::kPlaceholderColor; |
| 72 } | 85 } |
| 73 | 86 |
| 87 bool InkDropHostView::ShouldShowInkDropForFocus() const { |
| 88 return false; |
| 89 } |
| 90 |
| 74 } // namespace views | 91 } // namespace views |
| OLD | NEW |