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

Side by Side Diff: ui/touch_selection/touch_handle.cc

Issue 1424683002: Refactor TouchSelectionDraggableClient APIs Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/touch_selection/touch_handle.h" 5 #include "ui/touch_selection/touch_handle.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 namespace ui { 9 namespace ui {
10 10
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 BeginDrag(); 188 BeginDrag();
189 } break; 189 } break;
190 190
191 case MotionEvent::ACTION_MOVE: { 191 case MotionEvent::ACTION_MOVE: {
192 gfx::PointF touch_move_position(event.GetX(), event.GetY()); 192 gfx::PointF touch_move_position(event.GetX(), event.GetY());
193 is_drag_within_tap_region_ &= 193 is_drag_within_tap_region_ &=
194 client_->IsWithinTapSlop(touch_down_position_ - touch_move_position); 194 client_->IsWithinTapSlop(touch_down_position_ - touch_move_position);
195 195
196 // Note that we signal drag update even if we're inside the tap region, 196 // Note that we signal drag update even if we're inside the tap region,
197 // as there are cases where characters are narrower than the slop length. 197 // as there are cases where characters are narrower than the slop length.
198 client_->OnDragUpdate(*this, touch_move_position + touch_drag_offset_); 198 client_->OnDragEvent(HANDLE_DRAG_UPDATE, *this,
199 touch_move_position + touch_drag_offset_);
199 } break; 200 } break;
200 201
201 case MotionEvent::ACTION_UP: { 202 case MotionEvent::ACTION_UP: {
202 if (is_drag_within_tap_region_ && 203 if (is_drag_within_tap_region_ &&
203 (event.GetEventTime() - touch_down_time_) < 204 (event.GetEventTime() - touch_down_time_) <
204 client_->GetMaxTapDuration()) { 205 client_->GetMaxTapDuration()) {
205 client_->OnHandleTapped(*this); 206 client_->OnHandleTapped(*this);
206 } 207 }
207 208
208 EndDrag(); 209 EndDrag();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 return focus - gfx::Vector2dF(focal_offset_x, focal_offset_y); 331 return focus - gfx::Vector2dF(focal_offset_x, focal_offset_y);
331 } 332 }
332 333
333 void TouchHandle::BeginDrag() { 334 void TouchHandle::BeginDrag() {
334 DCHECK(enabled_); 335 DCHECK(enabled_);
335 if (is_dragging_) 336 if (is_dragging_)
336 return; 337 return;
337 EndFade(); 338 EndFade();
338 is_dragging_ = true; 339 is_dragging_ = true;
339 is_drag_within_tap_region_ = true; 340 is_drag_within_tap_region_ = true;
340 client_->OnDragBegin(*this, focus_bottom()); 341 client_->OnDragEvent(HANDLE_DRAG_BEGIN, *this, focus_bottom());
341 } 342 }
342 343
343 void TouchHandle::EndDrag() { 344 void TouchHandle::EndDrag() {
344 DCHECK(enabled_); 345 DCHECK(enabled_);
345 if (!is_dragging_) 346 if (!is_dragging_)
346 return; 347 return;
347 348
348 is_dragging_ = false; 349 is_dragging_ = false;
349 is_drag_within_tap_region_ = false; 350 is_drag_within_tap_region_ = false;
350 client_->OnDragEnd(*this); 351 client_->OnDragEvent(HANDLE_DRAG_BEGIN, *this, focus_bottom());
351 352
352 if (deferred_orientation_ != TouchHandleOrientation::UNDEFINED) { 353 if (deferred_orientation_ != TouchHandleOrientation::UNDEFINED) {
353 TouchHandleOrientation deferred_orientation = deferred_orientation_; 354 TouchHandleOrientation deferred_orientation = deferred_orientation_;
354 deferred_orientation_ = TouchHandleOrientation::UNDEFINED; 355 deferred_orientation_ = TouchHandleOrientation::UNDEFINED;
355 SetOrientation(deferred_orientation); 356 SetOrientation(deferred_orientation);
356 // Handle layout may be deferred while the handle is dragged. 357 // Handle layout may be deferred while the handle is dragged.
357 SetUpdateLayoutRequired(); 358 SetUpdateLayoutRequired();
358 UpdateHandleLayout(); 359 UpdateHandleLayout();
359 } 360 }
360 361
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 drawable_->SetAlpha(alpha); 400 drawable_->SetAlpha(alpha);
400 } 401 }
401 402
402 void TouchHandle::SetUpdateLayoutRequired() { 403 void TouchHandle::SetUpdateLayoutRequired() {
403 // TODO(AviD): Make the layout call explicit to the caller by adding this in 404 // TODO(AviD): Make the layout call explicit to the caller by adding this in
404 // TouchHandleClient. 405 // TouchHandleClient.
405 is_handle_layout_update_required_ = true; 406 is_handle_layout_update_required_ = true;
406 } 407 }
407 408
408 } // namespace ui 409 } // namespace ui
OLDNEW
« no previous file with comments | « ui/touch_selection/longpress_drag_selector_unittest.cc ('k') | ui/touch_selection/touch_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698