| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { | 157 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { |
| 158 NotifyClick(event); | 158 NotifyClick(event); |
| 159 // NOTE: We may be deleted at this point (by the listener's notification | 159 // NOTE: We may be deleted at this point (by the listener's notification |
| 160 // handler). | 160 // handler). |
| 161 } | 161 } |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool CustomButton::OnMouseDragged(const ui::MouseEvent& event) { | 165 bool CustomButton::OnMouseDragged(const ui::MouseEvent& event) { |
| 166 if (state_ != STATE_DISABLED) { | 166 if (state_ != STATE_DISABLED) { |
| 167 bool should_enter_pushed = ShouldEnterPushedState(event); |
| 167 if (HitTestPoint(event.location())) { | 168 if (HitTestPoint(event.location())) { |
| 168 SetState(ShouldEnterPushedState(event) ? STATE_PRESSED : STATE_HOVERED); | 169 SetState(should_enter_pushed ? STATE_PRESSED : STATE_HOVERED); |
| 169 if (!InDrag() && ink_drop_delegate() && | 170 if (!InDrag() && should_enter_pushed && ink_drop_delegate() && |
| 170 ink_drop_delegate()->GetTargetInkDropState() == | 171 ink_drop_delegate()->GetTargetInkDropState() == |
| 171 views::InkDropState::HIDDEN) | 172 views::InkDropState::HIDDEN) |
| 172 ink_drop_delegate()->OnAction(views::InkDropState::ACTION_PENDING); | 173 ink_drop_delegate()->OnAction(views::InkDropState::ACTION_PENDING); |
| 173 } else { | 174 } else { |
| 174 SetState(STATE_NORMAL); | 175 SetState(STATE_NORMAL); |
| 175 if (!InDrag() && ink_drop_delegate() && | 176 if (!InDrag() && should_enter_pushed && ink_drop_delegate() && |
| 176 ink_drop_delegate()->GetTargetInkDropState() == | 177 ink_drop_delegate()->GetTargetInkDropState() == |
| 177 views::InkDropState::ACTION_PENDING) | 178 views::InkDropState::ACTION_PENDING) |
| 178 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); | 179 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); |
| 179 } | 180 } |
| 180 } | 181 } |
| 181 return true; | 182 return true; |
| 182 } | 183 } |
| 183 | 184 |
| 184 void CustomButton::OnMouseReleased(const ui::MouseEvent& event) { | 185 void CustomButton::OnMouseReleased(const ui::MouseEvent& event) { |
| 185 if (state_ != STATE_DISABLED) { | 186 if (state_ != STATE_DISABLED) { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 Button::NotifyClick(event); | 470 Button::NotifyClick(event); |
| 470 } | 471 } |
| 471 | 472 |
| 472 void CustomButton::OnClickCanceled(const ui::Event& event) { | 473 void CustomButton::OnClickCanceled(const ui::Event& event) { |
| 473 if (ink_drop_delegate()) | 474 if (ink_drop_delegate()) |
| 474 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); | 475 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); |
| 475 Button::OnClickCanceled(event); | 476 Button::OnClickCanceled(event); |
| 476 } | 477 } |
| 477 | 478 |
| 478 } // namespace views | 479 } // namespace views |
| OLD | NEW |