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

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: Removed code intended for another bug fix. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
bruthig 2016/05/31 14:20:40 This opens up the following edge case: 1. Press a
bruthig 2016/05/31 14:23:42 At the very least I do believe this change is an i
375 SetState(STATE_NORMAL); 375 SetState(STATE_NORMAL);
376 if (ink_drop_delegate())
377 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
378 }
376 } 379 }
377 380
378 bool CustomButton::ShouldShowInkDropForFocus() const { 381 bool CustomButton::ShouldShowInkDropForFocus() const {
379 return true; 382 return true;
380 } 383 }
381 384
382 //////////////////////////////////////////////////////////////////////////////// 385 ////////////////////////////////////////////////////////////////////////////////
383 // CustomButton, protected: 386 // CustomButton, protected:
384 387
385 CustomButton::CustomButton(ButtonListener* listener) 388 CustomButton::CustomButton(ButtonListener* listener)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 Button::NotifyClick(event); 453 Button::NotifyClick(event);
451 } 454 }
452 455
453 void CustomButton::OnClickCanceled(const ui::Event& event) { 456 void CustomButton::OnClickCanceled(const ui::Event& event) {
454 if (ink_drop_delegate()) 457 if (ink_drop_delegate())
455 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN); 458 ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
456 Button::OnClickCanceled(event); 459 Button::OnClickCanceled(event);
457 } 460 }
458 461
459 } // namespace views 462 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698