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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 } else { | 190 } else { |
| 191 SetState(STATE_HOVERED); | 191 SetState(STATE_HOVERED); |
| 192 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_RELEASE) { | 192 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_RELEASE) { |
| 193 NotifyClick(event); | 193 NotifyClick(event); |
| 194 // NOTE: We may be deleted at this point (by the listener's notification | 194 // NOTE: We may be deleted at this point (by the listener's notification |
| 195 // handler). | 195 // handler). |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 if (notify_action_ == NOTIFY_ON_RELEASE) | 200 if (state_ == STATE_PRESSED && notify_action_ == NOTIFY_ON_RELEASE) |
|
bruthig
2016/07/26 13:57:16
What's the use case for this? AFAICT this will ne
mohsen
2016/07/26 20:00:58
Sorry! This is totally wrong! The use case is that
| |
| 201 OnClickCanceled(event); | 201 OnClickCanceled(event); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void CustomButton::OnMouseCaptureLost() { | 204 void CustomButton::OnMouseCaptureLost() { |
| 205 // Starting a drag results in a MouseCaptureLost. Reset button state. | 205 // Starting a drag results in a MouseCaptureLost. Reset button state. |
| 206 // TODO(varkha) While in drag only reset the state with Material Design. | 206 // TODO(varkha) While in drag only reset the state with Material Design. |
| 207 // The same logic may applies everywhere so gather any feedback and update. | 207 // The same logic may applies everywhere so gather any feedback and update. |
| 208 bool reset_button_state = | 208 bool reset_button_state = |
| 209 !InDrag() || ui::MaterialDesignController::IsModeMaterial(); | 209 !InDrag() || ui::MaterialDesignController::IsModeMaterial(); |
| 210 if (state_ != STATE_DISABLED && reset_button_state) | 210 if (state_ != STATE_DISABLED && reset_button_state) |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 Button::NotifyClick(event); | 469 Button::NotifyClick(event); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void CustomButton::OnClickCanceled(const ui::Event& event) { | 472 void CustomButton::OnClickCanceled(const ui::Event& event) { |
| 473 AnimateInkDrop(views::InkDropState::HIDDEN, | 473 AnimateInkDrop(views::InkDropState::HIDDEN, |
| 474 ui::LocatedEvent::FromIfValid(&event)); | 474 ui::LocatedEvent::FromIfValid(&event)); |
| 475 Button::OnClickCanceled(event); | 475 Button::OnClickCanceled(event); |
| 476 } | 476 } |
| 477 | 477 |
| 478 } // namespace views | 478 } // namespace views |
| OLD | NEW |