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()); | |
|
bruthig
2016/06/03 14:30:50
Shouldn't this be !InDrag() ?
IMO it would be eas
Evan Stade
2016/06/03 17:55:59
fixed
bruthig
2016/06/03 19:42:36
Yeah.
Evan Stade
2016/06/03 21:53:23
But then IsHovered is different from IsMouseHovere
bruthig
2016/06/03 22:35:25
I'd be more concerned if it were the same as it wo
| |
| 137 } else { | |
| 136 SetState(STATE_DISABLED); | 138 SetState(STATE_DISABLED); |
| 137 | 139 } |
| 138 if (ink_drop_delegate()) | |
| 139 ink_drop_delegate()->SetHovered(ShouldShowInkDropHover()); | |
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 state->AddStateFlag(ui::AX_STATE_DISABLED); | 342 state->AddStateFlag(ui::AX_STATE_DISABLED); |
| 343 break; | 343 break; |
| 344 case STATE_NORMAL: | 344 case STATE_NORMAL: |
| 345 case STATE_COUNT: | 345 case STATE_COUNT: |
| 346 // No additional accessibility state set for this button state. | 346 // No additional accessibility state set for this button state. |
| 347 break; | 347 break; |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | 350 |
| 351 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { | 351 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { |
| 352 Button::VisibilityChanged(starting_from, visible); | |
| 352 if (state_ == STATE_DISABLED) | 353 if (state_ == STATE_DISABLED) |
| 353 return; | 354 return; |
| 354 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); | 355 SetState(visible && ShouldEnterHoveredState() ? STATE_HOVERED : STATE_NORMAL); |
| 355 } | 356 } |
| 356 | 357 |
| 357 std::unique_ptr<InkDropHover> CustomButton::CreateInkDropHover() const { | 358 std::unique_ptr<InkDropHover> CustomButton::CreateInkDropHover() const { |
| 358 return ShouldShowInkDropHover() ? Button::CreateInkDropHover() : nullptr; | 359 return ShouldShowInkDropHover() ? Button::CreateInkDropHover() : nullptr; |
| 359 } | 360 } |
| 360 | 361 |
| 361 SkColor CustomButton::GetInkDropBaseColor() const { | 362 SkColor CustomButton::GetInkDropBaseColor() const { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 Button::NotifyClick(event); | 469 Button::NotifyClick(event); |
| 469 } | 470 } |
| 470 | 471 |
| 471 void CustomButton::OnClickCanceled(const ui::Event& event) { | 472 void CustomButton::OnClickCanceled(const ui::Event& event) { |
| 472 if (ink_drop_delegate()) | 473 if (ink_drop_delegate()) |
| 473 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); | 474 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); |
| 474 Button::OnClickCanceled(event); | 475 Button::OnClickCanceled(event); |
| 475 } | 476 } |
| 476 | 477 |
| 477 } // namespace views | 478 } // namespace views |
| OLD | NEW |