Chromium Code Reviews| 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) | |
|
sky
2016/06/02 03:07:26
Why do you care if there is a widget here?
Evan Stade
2016/06/02 19:34:07
Without this check it crashes in GetInkDropBaseCol
| |
| 78 ink_drop_delegate()->GetInkDrop()->SetHovered(false); | |
|
Evan Stade
2016/06/01 22:46:20
analogous to CustomButton::VisibilityChanged
bruthig
2016/06/02 19:02:59
Is OnBlur() and more importantly SetFocused(false)
Evan Stade
2016/06/02 19:34:07
I didn't investigate with extreme thoroughness but
bruthig
2016/06/02 19:46:36
Awesome, might be worth a test by a good Samaritan
| |
| 79 } | |
| 80 | |
| 75 void InkDropHostView::OnFocus() { | 81 void InkDropHostView::OnFocus() { |
| 76 views::View::OnFocus(); | 82 views::View::OnFocus(); |
| 77 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) | 83 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) |
| 78 ink_drop_delegate()->GetInkDrop()->SetFocused(true); | 84 ink_drop_delegate()->GetInkDrop()->SetFocused(true); |
| 79 } | 85 } |
| 80 | 86 |
| 81 void InkDropHostView::OnBlur() { | 87 void InkDropHostView::OnBlur() { |
| 82 views::View::OnBlur(); | 88 views::View::OnBlur(); |
| 83 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) | 89 if (ink_drop_delegate() && ShouldShowInkDropForFocus()) |
| 84 ink_drop_delegate()->GetInkDrop()->SetFocused(false); | 90 ink_drop_delegate()->GetInkDrop()->SetFocused(false); |
| 85 } | 91 } |
| 86 | 92 |
| 87 gfx::Point InkDropHostView::GetInkDropCenter() const { | 93 gfx::Point InkDropHostView::GetInkDropCenter() const { |
| 88 return GetLocalBounds().CenterPoint(); | 94 return GetLocalBounds().CenterPoint(); |
| 89 } | 95 } |
| 90 | 96 |
| 91 SkColor InkDropHostView::GetInkDropBaseColor() const { | 97 SkColor InkDropHostView::GetInkDropBaseColor() const { |
| 92 NOTREACHED(); | 98 NOTREACHED(); |
| 93 return gfx::kPlaceholderColor; | 99 return gfx::kPlaceholderColor; |
| 94 } | 100 } |
| 95 | 101 |
| 96 bool InkDropHostView::ShouldShowInkDropForFocus() const { | 102 bool InkDropHostView::ShouldShowInkDropForFocus() const { |
| 97 return false; | 103 return false; |
| 98 } | 104 } |
| 99 | 105 |
| 100 } // namespace views | 106 } // namespace views |
| OLD | NEW |