Chromium Code Reviews| Index: ui/views/controls/button/custom_button.cc |
| diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc |
| index 3ab8303e9f8821d8dd77e1f7ba7308153cd78a60..e63619e6711613c27be17149b296994cde863f57 100644 |
| --- a/ui/views/controls/button/custom_button.cc |
| +++ b/ui/views/controls/button/custom_button.cc |
| @@ -123,6 +123,8 @@ void CustomButton::Layout() { |
| } |
| void CustomButton::OnEnabledChanged() { |
| + // TODO(bruthig): Is there any reason we are not calling |
| + // Button::OnEnabledChanged() here? |
| if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED)) |
| return; |
| @@ -130,6 +132,7 @@ void CustomButton::OnEnabledChanged() { |
| SetState(ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); |
| else |
| SetState(STATE_DISABLED); |
| + UpdateInkDropHoverState(); |
| } |
| const char* CustomButton::GetClassName() const { |
| @@ -193,12 +196,14 @@ void CustomButton::OnMouseCaptureLost() { |
| void CustomButton::OnMouseEntered(const ui::MouseEvent& event) { |
| if (state_ != STATE_DISABLED) |
| SetState(STATE_HOVERED); |
| + UpdateInkDropHoverState(); |
| } |
| void CustomButton::OnMouseExited(const ui::MouseEvent& event) { |
| // Starting a drag results in a MouseExited, we need to ignore it. |
| if (state_ != STATE_DISABLED && !InDrag()) |
| SetState(STATE_NORMAL); |
| + UpdateInkDropHoverState(); |
|
sadrul
2016/01/12 15:55:38
Can ButtonInkDropDelegate take care of updating th
bruthig
2016/01/12 16:27:17
Done.
|
| } |
| void CustomButton::OnMouseMoved(const ui::MouseEvent& event) { |
| @@ -352,6 +357,10 @@ gfx::Point CustomButton::CalculateInkDropCenter() const { |
| return GetLocalBounds().CenterPoint(); |
| } |
| +bool CustomButton::ShouldShowInkDropHover() const { |
| + return enabled() && IsMouseHovered() && !InDrag(); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // CustomButton, protected: |
| @@ -408,6 +417,11 @@ bool CustomButton::ShouldEnterHoveredState() { |
| return check_mouse_position && IsMouseHovered(); |
| } |
| +void CustomButton::UpdateInkDropHoverState() { |
| + if (ink_drop_delegate_) |
| + ink_drop_delegate_->SetHovered(ShouldShowInkDropHover()); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // CustomButton, View overrides (protected): |