Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/controls/button/custom_button.h" | 5 #include "ui/views/controls/button/custom_button.h" |
| 6 | 6 |
| 7 #include "ui/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
| 8 #include "ui/base/material_design/material_design_controller.h" | 8 #include "ui/base/material_design/material_design_controller.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 | 123 |
| 124 //////////////////////////////////////////////////////////////////////////////// | 124 //////////////////////////////////////////////////////////////////////////////// |
| 125 // CustomButton, View overrides: | 125 // CustomButton, View overrides: |
| 126 | 126 |
| 127 void CustomButton::OnEnabledChanged() { | 127 void CustomButton::OnEnabledChanged() { |
| 128 // TODO(bruthig): Is there any reason we are not calling | 128 // TODO(bruthig): Is there any reason we are not calling |
| 129 // Button::OnEnabledChanged() here? | 129 // Button::OnEnabledChanged() here? |
| 130 if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED)) | 130 if (enabled() ? (state_ != STATE_DISABLED) : (state_ == STATE_DISABLED)) |
| 131 return; | 131 return; |
| 132 | 132 |
| 133 if (enabled()) | 133 if (enabled()) { |
| 134 SetState(ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); | 134 SetState(ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); |
| 135 else | 135 if (ink_drop_delegate()) |
| 136 ink_drop_delegate()->SetHovered(InDrag() && IsMouseHovered()); | |
|
sky
2016/06/02 03:07:26
Why do you check the InDrag here? I have to admit
Evan Stade
2016/06/02 19:34:07
because I'm copying ShouldShowInkDropHover (minus
bruthig
2016/06/02 19:46:36
Feel free to make this name change, I will deal wi
| |
| 137 } else { | |
| 136 SetState(STATE_DISABLED); | 138 SetState(STATE_DISABLED); |
| 137 | 139 } |
| 138 if (ink_drop_delegate()) | |
| 139 ink_drop_delegate()->SetHovered(ShouldShowInkDropHover()); | |
|
Evan Stade
2016/06/01 22:46:20
this change/fix is tangential
| |
| 140 } | 140 } |
| 141 | 141 |
| 142 const char* CustomButton::GetClassName() const { | 142 const char* CustomButton::GetClassName() const { |
| 143 return kViewClassName; | 143 return kViewClassName; |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { | 146 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { |
| 147 if (state_ == STATE_DISABLED) | 147 if (state_ == STATE_DISABLED) |
| 148 return true; | 148 return true; |
| 149 if (state_ != STATE_PRESSED && ShouldEnterPushedState(event) && | 149 if (state_ != STATE_PRESSED && ShouldEnterPushedState(event) && |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 state->AddStateFlag(ui::AX_STATE_DISABLED); | 333 state->AddStateFlag(ui::AX_STATE_DISABLED); |
| 334 break; | 334 break; |
| 335 case STATE_NORMAL: | 335 case STATE_NORMAL: |
| 336 case STATE_COUNT: | 336 case STATE_COUNT: |
| 337 // No additional accessibility state set for this button state. | 337 // No additional accessibility state set for this button state. |
| 338 break; | 338 break; |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { | 342 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { |
| 343 Button::VisibilityChanged(starting_from, visible); | |
| 343 if (state_ == STATE_DISABLED) | 344 if (state_ == STATE_DISABLED) |
| 344 return; | 345 return; |
| 345 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); | 346 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); |
| 346 } | 347 } |
| 347 | 348 |
| 348 std::unique_ptr<InkDropHover> CustomButton::CreateInkDropHover() const { | 349 std::unique_ptr<InkDropHover> CustomButton::CreateInkDropHover() const { |
| 349 return ShouldShowInkDropHover() ? Button::CreateInkDropHover() : nullptr; | 350 return ShouldShowInkDropHover() ? Button::CreateInkDropHover() : nullptr; |
| 350 } | 351 } |
| 351 | 352 |
| 352 SkColor CustomButton::GetInkDropBaseColor() const { | 353 SkColor CustomButton::GetInkDropBaseColor() const { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 Button::NotifyClick(event); | 451 Button::NotifyClick(event); |
| 451 } | 452 } |
| 452 | 453 |
| 453 void CustomButton::OnClickCanceled(const ui::Event& event) { | 454 void CustomButton::OnClickCanceled(const ui::Event& event) { |
| 454 if (ink_drop_delegate()) | 455 if (ink_drop_delegate()) |
| 455 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); | 456 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); |
| 456 Button::OnClickCanceled(event); | 457 Button::OnClickCanceled(event); |
| 457 } | 458 } |
| 458 | 459 |
| 459 } // namespace views | 460 } // namespace views |
| OLD | NEW |