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

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

Issue 2017833003: Fixes ink drop being "stuck" on when losing focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removal of the nits... Created 4 years, 6 months 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/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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } else if (event.key_code() == ui::VKEY_RETURN) { 234 } else if (event.key_code() == ui::VKEY_RETURN) {
235 SetState(STATE_NORMAL); 235 SetState(STATE_NORMAL);
236 NotifyClick(event); 236 NotifyClick(event);
237 } else { 237 } else {
238 return false; 238 return false;
239 } 239 }
240 return true; 240 return true;
241 } 241 }
242 242
243 bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) { 243 bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) {
244 if ((state_ == STATE_DISABLED) || (event.key_code() != ui::VKEY_SPACE)) 244 if ((state_ == STATE_PRESSED) && (event.key_code() == ui::VKEY_SPACE)) {
245 return false; 245 SetState(STATE_NORMAL);
246 246 NotifyClick(event);
247 SetState(STATE_NORMAL); 247 return true;
248 NotifyClick(event); 248 }
249 return true; 249 return false;
250 } 250 }
251 251
252 void CustomButton::OnGestureEvent(ui::GestureEvent* event) { 252 void CustomButton::OnGestureEvent(ui::GestureEvent* event) {
253 if (state_ == STATE_DISABLED) { 253 if (state_ == STATE_DISABLED) {
254 Button::OnGestureEvent(event); 254 Button::OnGestureEvent(event);
255 return; 255 return;
256 } 256 }
257 257
258 if (event->type() == ui::ET_GESTURE_TAP && IsTriggerableEvent(*event)) { 258 if (event->type() == ui::ET_GESTURE_TAP && IsTriggerableEvent(*event)) {
259 // Set the button state to hot and start the animation fully faded in. The 259 // Set the button state to hot and start the animation fully faded in. The
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // CustomButton, View overrides (public): 364 // CustomButton, View overrides (public):
365 365
366 void CustomButton::ViewHierarchyChanged( 366 void CustomButton::ViewHierarchyChanged(
367 const ViewHierarchyChangedDetails& details) { 367 const ViewHierarchyChangedDetails& details) {
368 if (!details.is_add && state_ != STATE_DISABLED) 368 if (!details.is_add && state_ != STATE_DISABLED)
369 SetState(STATE_NORMAL); 369 SetState(STATE_NORMAL);
370 } 370 }
371 371
372 void CustomButton::OnBlur() { 372 void CustomButton::OnBlur() {
373 Button::OnBlur(); 373 Button::OnBlur();
374 if (IsHotTracked()) 374 if (IsHotTracked() || state_ == STATE_PRESSED) {
375 SetState(STATE_NORMAL); 375 SetState(STATE_NORMAL);
376 if (ink_drop_delegate() &&
377 ink_drop_delegate()->GetTargetInkDropState() !=
378 views::InkDropState::HIDDEN)
379 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
bruthig 2016/06/02 15:21:35 Can you add a TODO here along the following lines:
kylix_rd 2016/06/02 15:52:33 Done.
380 }
376 } 381 }
377 382
378 bool CustomButton::ShouldShowInkDropForFocus() const { 383 bool CustomButton::ShouldShowInkDropForFocus() const {
379 return true; 384 return true;
380 } 385 }
381 386
382 //////////////////////////////////////////////////////////////////////////////// 387 ////////////////////////////////////////////////////////////////////////////////
383 // CustomButton, protected: 388 // CustomButton, protected:
384 389
385 CustomButton::CustomButton(ButtonListener* listener) 390 CustomButton::CustomButton(ButtonListener* listener)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 Button::NotifyClick(event); 455 Button::NotifyClick(event);
451 } 456 }
452 457
453 void CustomButton::OnClickCanceled(const ui::Event& event) { 458 void CustomButton::OnClickCanceled(const ui::Event& event) {
454 if (ink_drop_delegate()) 459 if (ink_drop_delegate())
455 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); 460 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
456 Button::OnClickCanceled(event); 461 Button::OnClickCanceled(event);
457 } 462 }
458 463
459 } // namespace views 464 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698