| 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_hover.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { | 67 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { |
| 68 std::unique_ptr<InkDropHover> hover( | 68 std::unique_ptr<InkDropHover> hover( |
| 69 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius, | 69 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius, |
| 70 GetInkDropCenter(), GetInkDropBaseColor())); | 70 GetInkDropCenter(), GetInkDropBaseColor())); |
| 71 hover->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_)); | 71 hover->set_explode_size(CalculateLargeInkDropSize(ink_drop_size_)); |
| 72 return hover; | 72 return hover; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void InkDropHostView::VisibilityChanged(View* starting_from, bool is_visible) { |
| 76 View::VisibilityChanged(starting_from, is_visible); |
| 77 if (ink_drop_delegate() && GetWidget() && !is_visible) { |
| 78 ink_drop_delegate()->GetInkDrop()->AnimateToState(InkDropState::HIDDEN); |
| 79 ink_drop_delegate()->GetInkDrop()->SetHovered(false); |
| 80 } |
| 81 } |
| 82 |
| 75 void InkDropHostView::OnFocus() { | 83 void InkDropHostView::OnFocus() { |
| 76 views::View::OnFocus(); | 84 views::View::OnFocus(); |
| 77 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) | 85 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) |
| 78 ink_drop_delegate()->GetInkDrop()->SetFocused(true); | 86 ink_drop_delegate()->GetInkDrop()->SetFocused(true); |
| 79 } | 87 } |
| 80 | 88 |
| 81 void InkDropHostView::OnBlur() { | 89 void InkDropHostView::OnBlur() { |
| 82 views::View::OnBlur(); | 90 views::View::OnBlur(); |
| 83 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) | 91 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) |
| 84 ink_drop_delegate()->GetInkDrop()->SetFocused(false); | 92 ink_drop_delegate()->GetInkDrop()->SetFocused(false); |
| 85 } | 93 } |
| 86 | 94 |
| 87 gfx::Point InkDropHostView::GetInkDropCenter() const { | 95 gfx::Point InkDropHostView::GetInkDropCenter() const { |
| 88 return GetLocalBounds().CenterPoint(); | 96 return GetLocalBounds().CenterPoint(); |
| 89 } | 97 } |
| 90 | 98 |
| 91 SkColor InkDropHostView::GetInkDropBaseColor() const { | 99 SkColor InkDropHostView::GetInkDropBaseColor() const { |
| 92 NOTREACHED(); | 100 NOTREACHED(); |
| 93 return gfx::kPlaceholderColor; | 101 return gfx::kPlaceholderColor; |
| 94 } | 102 } |
| 95 | 103 |
| 96 bool InkDropHostView::ShouldShowInkDropForFocus() const { | 104 bool InkDropHostView::ShouldShowInkDropForFocus() const { |
| 97 return false; | 105 return false; |
| 98 } | 106 } |
| 99 | 107 |
| 100 } // namespace views | 108 } // namespace views |
| OLD | NEW |