Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1038)

Side by Side Diff: ui/views/controls/button/custom_button.cc

Issue 1478303003: Converted all Views to use an InkDropDelegate instead of a InkDropAnimationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved some ripple controlling logic up the Button hierarchy. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 SetState(STATE_DISABLED); 133 SetState(STATE_DISABLED);
134 } 134 }
135 135
136 const char* CustomButton::GetClassName() const { 136 const char* CustomButton::GetClassName() const {
137 return kViewClassName; 137 return kViewClassName;
138 } 138 }
139 139
140 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) { 140 bool CustomButton::OnMousePressed(const ui::MouseEvent& event) {
141 if (state_ == STATE_DISABLED) 141 if (state_ == STATE_DISABLED)
142 return true; 142 return true;
143 if (ShouldEnterPushedState(event) && HitTestPoint(event.location())) 143 if (ShouldEnterPushedState(event) && HitTestPoint(event.location())) {
144 SetState(STATE_PRESSED); 144 SetState(STATE_PRESSED);
145 if (ink_drop_delegate_)
146 ink_drop_delegate_->OnAction(views::InkDropState::ACTION_PENDING);
147 }
145 if (request_focus_on_press_) 148 if (request_focus_on_press_)
146 RequestFocus(); 149 RequestFocus();
147 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { 150 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) {
148 NotifyClick(event); 151 NotifyClick(event);
149 // NOTE: We may be deleted at this point (by the listener's notification 152 // NOTE: We may be deleted at this point (by the listener's notification
150 // handler). 153 // handler).
151 } 154 }
152 return true; 155 return true;
153 } 156 }
154 157
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 const ViewHierarchyChangedDetails& details) { 402 const ViewHierarchyChangedDetails& details) {
400 if (!details.is_add && state_ != STATE_DISABLED) 403 if (!details.is_add && state_ != STATE_DISABLED)
401 SetState(STATE_NORMAL); 404 SetState(STATE_NORMAL);
402 } 405 }
403 406
404 void CustomButton::OnBlur() { 407 void CustomButton::OnBlur() {
405 if (IsHotTracked()) 408 if (IsHotTracked())
406 SetState(STATE_NORMAL); 409 SetState(STATE_NORMAL);
407 } 410 }
408 411
412 void CustomButton::NotifyClick(const ui::Event& event) {
413 Button::NotifyClick(event);
414 if (ink_drop_delegate())
415 ink_drop_delegate()->OnAction(views::InkDropState::QUICK_ACTION);
416 }
417
418 void CustomButton::OnClickCanceled(const ui::Event& event) {
419 Button::OnClickCanceled(event);
420 if (ink_drop_delegate())
421 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
422 }
423
409 bool CustomButton::IsChildWidget() const { 424 bool CustomButton::IsChildWidget() const {
410 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); 425 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget();
411 } 426 }
412 427
413 bool CustomButton::FocusInChildWidget() const { 428 bool CustomButton::FocusInChildWidget() const {
414 return GetWidget() && 429 return GetWidget() &&
415 GetWidget()->GetRootView()->Contains( 430 GetWidget()->GetRootView()->Contains(
416 GetFocusManager()->GetFocusedView()); 431 GetFocusManager()->GetFocusedView());
417 } 432 }
418 433
419 } // namespace views 434 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698