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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 NotifyClick(event); | 156 NotifyClick(event); |
157 // NOTE: We may be deleted at this point (by the listener's notification | 157 // NOTE: We may be deleted at this point (by the listener's notification |
158 // handler). | 158 // handler). |
159 } | 159 } |
160 return true; | 160 return true; |
161 } | 161 } |
162 | 162 |
163 bool CustomButton::OnMouseDragged(const ui::MouseEvent& event) { | 163 bool CustomButton::OnMouseDragged(const ui::MouseEvent& event) { |
164 if (state_ != STATE_DISABLED) { | 164 if (state_ != STATE_DISABLED) { |
165 bool should_enter_pushed = ShouldEnterPushedState(event); | 165 bool should_enter_pushed = ShouldEnterPushedState(event); |
166 bool should_show_pending = | |
bruthig
2016/06/17 17:58:45
nit: const, and should probably be consistent and
mohsen
2016/06/18 06:25:15
Done.
| |
167 should_enter_pushed && notify_action_ == NOTIFY_ON_RELEASE && !InDrag(); | |
166 if (HitTestPoint(event.location())) { | 168 if (HitTestPoint(event.location())) { |
167 SetState(should_enter_pushed ? STATE_PRESSED : STATE_HOVERED); | 169 SetState(should_enter_pushed ? STATE_PRESSED : STATE_HOVERED); |
168 if (!InDrag() && should_enter_pushed && | 170 if (should_show_pending && |
169 ink_drop()->GetTargetInkDropState() == views::InkDropState::HIDDEN) { | 171 ink_drop()->GetTargetInkDropState() == views::InkDropState::HIDDEN) { |
170 AnimateInkDrop(views::InkDropState::ACTION_PENDING); | 172 AnimateInkDrop(views::InkDropState::ACTION_PENDING); |
171 } | 173 } |
172 } else { | 174 } else { |
173 SetState(STATE_NORMAL); | 175 SetState(STATE_NORMAL); |
174 if (!InDrag() && should_enter_pushed && | 176 if (should_show_pending && |
175 ink_drop()->GetTargetInkDropState() == | 177 ink_drop()->GetTargetInkDropState() == |
176 views::InkDropState::ACTION_PENDING) { | 178 views::InkDropState::ACTION_PENDING) { |
177 AnimateInkDrop(views::InkDropState::HIDDEN); | 179 AnimateInkDrop(views::InkDropState::HIDDEN); |
178 } | 180 } |
179 } | 181 } |
180 } | 182 } |
181 return true; | 183 return true; |
182 } | 184 } |
183 | 185 |
184 void CustomButton::OnMouseReleased(const ui::MouseEvent& event) { | 186 void CustomButton::OnMouseReleased(const ui::MouseEvent& event) { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 AnimateInkDrop(InkDropState::ACTION_TRIGGERED); | 466 AnimateInkDrop(InkDropState::ACTION_TRIGGERED); |
465 Button::NotifyClick(event); | 467 Button::NotifyClick(event); |
466 } | 468 } |
467 | 469 |
468 void CustomButton::OnClickCanceled(const ui::Event& event) { | 470 void CustomButton::OnClickCanceled(const ui::Event& event) { |
469 AnimateInkDrop(views::InkDropState::HIDDEN); | 471 AnimateInkDrop(views::InkDropState::HIDDEN); |
470 Button::OnClickCanceled(event); | 472 Button::OnClickCanceled(event); |
471 } | 473 } |
472 | 474 |
473 } // namespace views | 475 } // namespace views |
OLD | NEW |