| 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.h" |
| 10 #include "ui/views/animation/ink_drop_hover.h" | 10 #include "ui/views/animation/ink_drop_highlight.h" |
| 11 #include "ui/views/animation/square_ink_drop_ripple.h" | 11 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 | 14 |
| 15 // Default sizes for ink drop effects. | 15 // Default sizes for ink drop effects. |
| 16 const int kInkDropSize = 24; | 16 const int kInkDropSize = 24; |
| 17 const int kInkDropLargeCornerRadius = 4; | 17 const int kInkDropLargeCornerRadius = 4; |
| 18 | 18 |
| 19 // The scale factor to compute the large ink drop size. | 19 // The scale factor to compute the large ink drop size. |
| 20 const float kLargeInkDropScale = 1.333f; | 20 const float kLargeInkDropScale = 1.333f; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { | 59 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { |
| 60 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( | 60 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple( |
| 61 CalculateLargeInkDropSize(ink_drop_size_), kInkDropLargeCornerRadius, | 61 CalculateLargeInkDropSize(ink_drop_size_), kInkDropLargeCornerRadius, |
| 62 ink_drop_size_, kInkDropSmallCornerRadius, GetInkDropCenter(), | 62 ink_drop_size_, kInkDropSmallCornerRadius, GetInkDropCenter(), |
| 63 GetInkDropBaseColor())); | 63 GetInkDropBaseColor())); |
| 64 return ripple; | 64 return ripple; |
| 65 } | 65 } |
| 66 | 66 |
| 67 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { | 67 std::unique_ptr<InkDropHighlight> InkDropHostView::CreateInkDropHighlight() |
| 68 std::unique_ptr<InkDropHover> hover( | 68 const { |
| 69 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius, | 69 std::unique_ptr<InkDropHighlight> highlight( |
| 70 GetInkDropCenter(), GetInkDropBaseColor())); | 70 new InkDropHighlight(ink_drop_size_, kInkDropSmallCornerRadius, |
| 71 hover->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_)); | 71 GetInkDropCenter(), GetInkDropBaseColor())); |
| 72 return hover; | 72 highlight->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_)); |
| 73 return highlight; |
| 73 } | 74 } |
| 74 | 75 |
| 75 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) { | 76 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) { |
| 76 View::VisibilityChanged(starting_from, is_visible); | 77 View::VisibilityChanged(starting_from, is_visible); |
| 77 if (ink_drop_delegate() && GetWidget() && !is_visible) { | 78 if (ink_drop_delegate() && GetWidget() && !is_visible) { |
| 78 ink_drop_delegate()->GetInkDrop()->AnimateToState(InkDropState::HIDDEN); | 79 ink_drop_delegate()->GetInkDrop()->AnimateToState(InkDropState::HIDDEN); |
| 79 ink_drop_delegate()->GetInkDrop()->SetHovered(false); | 80 ink_drop_delegate()->GetInkDrop()->SetHovered(false); |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 | 83 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 99 SkColor InkDropHostView::GetInkDropBaseColor() const { | 100 SkColor InkDropHostView::GetInkDropBaseColor() const { |
| 100 NOTREACHED(); | 101 NOTREACHED(); |
| 101 return gfx::kPlaceholderColor; | 102 return gfx::kPlaceholderColor; |
| 102 } | 103 } |
| 103 | 104 |
| 104 bool InkDropHostView::ShouldShowInkDropForFocus() const { | 105 bool InkDropHostView::ShouldShowInkDropForFocus() const { |
| 105 return false; | 106 return false; |
| 106 } | 107 } |
| 107 | 108 |
| 108 } // namespace views | 109 } // namespace views |
| OLD | NEW |