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

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

Issue 404213003: [WIP] Allow scroll events to permanently change the default gesture handler in RootView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: friend test Created 6 years, 4 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 | Annotate | Revision Log
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/keycodes/keyboard_codes.h" 9 #include "ui/events/keycodes/keyboard_codes.h"
10 #include "ui/gfx/animation/throb_animation.h" 10 #include "ui/gfx/animation/throb_animation.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return true; 221 return true;
222 } 222 }
223 223
224 void CustomButton::OnGestureEvent(ui::GestureEvent* event) { 224 void CustomButton::OnGestureEvent(ui::GestureEvent* event) {
225 if (state_ == STATE_DISABLED) { 225 if (state_ == STATE_DISABLED) {
226 Button::OnGestureEvent(event); 226 Button::OnGestureEvent(event);
227 return; 227 return;
228 } 228 }
229 229
230 if (event->type() == ui::ET_GESTURE_TAP && IsTriggerableEvent(*event)) { 230 if (event->type() == ui::ET_GESTURE_TAP && IsTriggerableEvent(*event)) {
231 // Set the button state to hot and start the animation fully faded in. The 231 // Since no hover state was shown on a tap down, do not show any
232 // GESTURE_END event issued immediately after will set the state to 232 // hover state after a tap.
233 // STATE_NORMAL beginning the fade out animation. See 233 SetState(STATE_NORMAL);
sadrul 2014/07/24 19:12:13 Does this actually cause any visual regression?
tdanderson 2014/07/25 17:16:10 Yes it does. After a tap is complete we no longer
tdresser 2014/07/25 17:24:20 I'm pretty sure we do want to see the hover state
tdanderson 2014/07/25 17:49:20 My point was that the HOVERED state shouldn't appe
tdanderson 2014/07/25 18:53:02 Looks like https://codereview.chromium.org/4163430
234 // http://crbug.com/131184.
235 SetState(STATE_HOVERED);
236 hover_animation_->Reset(1.0);
237 NotifyClick(*event); 234 NotifyClick(*event);
238 event->StopPropagation(); 235 event->StopPropagation();
239 } else if (event->type() == ui::ET_GESTURE_TAP_DOWN && 236 } else if (event->type() == ui::ET_GESTURE_TAP_DOWN &&
240 ShouldEnterPushedState(*event)) { 237 ShouldEnterPushedState(*event)) {
241 SetState(STATE_PRESSED); 238 SetState(STATE_PRESSED);
242 if (request_focus_on_press_) 239 if (request_focus_on_press_)
243 RequestFocus(); 240 RequestFocus();
244 event->StopPropagation(); 241 event->StopPropagation();
245 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL || 242 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL) {
246 event->type() == ui::ET_GESTURE_END) {
247 SetState(STATE_NORMAL); 243 SetState(STATE_NORMAL);
248 } 244 }
249 if (!event->handled()) 245 if (!event->handled())
250 Button::OnGestureEvent(event); 246 Button::OnGestureEvent(event);
251 } 247 }
252 248
253 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { 249 bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) {
254 SetState(STATE_NORMAL); 250 SetState(STATE_NORMAL);
255 /* 251 /*
256 ui::KeyEvent key_event(ui::ET_KEY_RELEASED, accelerator.key_code(), 252 ui::KeyEvent key_event(ui::ET_KEY_RELEASED, accelerator.key_code(),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 if (!details.is_add && state_ != STATE_DISABLED) 346 if (!details.is_add && state_ != STATE_DISABLED)
351 SetState(STATE_NORMAL); 347 SetState(STATE_NORMAL);
352 } 348 }
353 349
354 void CustomButton::OnBlur() { 350 void CustomButton::OnBlur() {
355 if (IsHotTracked()) 351 if (IsHotTracked())
356 SetState(STATE_NORMAL); 352 SetState(STATE_NORMAL);
357 } 353 }
358 354
359 } // namespace views 355 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698