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/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
| 10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 SetState(STATE_DISABLED); | 136 SetState(STATE_DISABLED); |
| 137 } | 137 } |
| 138 | 138 |
| 139 const char* CustomButton::GetClassName() const { | 139 const char* CustomButton::GetClassName() const { |
| 140 return kViewClassName; | 140 return kViewClassName; |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { | 143 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { |
| 144 if (state_ == STATE_DISABLED) | 144 if (state_ == STATE_DISABLED) |
| 145 return true; | 145 return true; |
| 146 if (ShouldEnterPushedState(event) && HitTestPoint(event.location())) | 146 if (ShouldEnterPushedState(event) && HitTestPoint(event.location())) { |
| 147 SetState(STATE_PRESSED); | 147 SetState(STATE_PRESSED); |
| 148 if (ink_drop_delegate_) | |
| 149 ink_drop_delegate_->OnAction(views::InkDropState::ACTION_PENDING); | |
| 150 } | |
| 148 if (request_focus_on_press_) | 151 if (request_focus_on_press_) |
| 149 RequestFocus(); | 152 RequestFocus(); |
| 150 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { | 153 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { |
| 151 NotifyClick(event); | 154 NotifyClick(event); |
| 152 // NOTE: We may be deleted at this point (by the listener's notification | 155 // NOTE: We may be deleted at this point (by the listener's notification |
| 153 // handler). | 156 // handler). |
| 154 } | 157 } |
| 155 return true; | 158 return true; |
| 156 } | 159 } |
| 157 | 160 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 const ViewHierarchyChangedDetails& details) { | 401 const ViewHierarchyChangedDetails& details) { |
| 399 if (!details.is_add && state_ != STATE_DISABLED) | 402 if (!details.is_add && state_ != STATE_DISABLED) |
| 400 SetState(STATE_NORMAL); | 403 SetState(STATE_NORMAL); |
| 401 } | 404 } |
| 402 | 405 |
| 403 void CustomButton::OnBlur() { | 406 void CustomButton::OnBlur() { |
| 404 if (IsHotTracked()) | 407 if (IsHotTracked()) |
| 405 SetState(STATE_NORMAL); | 408 SetState(STATE_NORMAL); |
| 406 } | 409 } |
| 407 | 410 |
| 411 void CustomButton::NotifyClick(const ui::Event& event) { | |
| 412 Button::NotifyClick(event); | |
| 413 if (ink_drop_delegate()) | |
| 414 ink_drop_delegate()->OnAction(views::InkDropState::QUICK_ACTION); | |
|
varkha
2015/12/09 21:23:36
Wouldn't it make sense to start animating before b
bruthig
2015/12/11 22:09:46
Done.
| |
| 415 } | |
| 416 | |
| 417 void CustomButton::OnClickCanceled(const ui::Event& event) { | |
| 418 Button::OnClickCanceled(event); | |
| 419 if (ink_drop_delegate()) | |
| 420 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); | |
| 421 } | |
| 422 | |
| 408 bool CustomButton::IsChildWidget() const { | 423 bool CustomButton::IsChildWidget() const { |
| 409 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); | 424 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); |
| 410 } | 425 } |
| 411 | 426 |
| 412 bool CustomButton::FocusInChildWidget() const { | 427 bool CustomButton::FocusInChildWidget() const { |
| 413 return GetWidget() && | 428 return GetWidget() && |
| 414 GetWidget()->GetRootView()->Contains( | 429 GetWidget()->GetRootView()->Contains( |
| 415 GetFocusManager()->GetFocusedView()); | 430 GetFocusManager()->GetFocusedView()); |
| 416 } | 431 } |
| 417 | 432 |
| 418 } // namespace views | 433 } // namespace views |
| OLD | NEW |