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

Side by Side Diff: ui/events/gesture_detection/scale_gesture_detector.cc

Issue 200623003: Adopt "QuickScale" double-tap drag zoom code in the GestureProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yeah... Created 6 years, 8 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 | « ui/events/gesture_detection/scale_gesture_detector.h ('k') | 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 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/events/gesture_detection/scale_gesture_detector.h" 5 #include "ui/events/gesture_detection/scale_gesture_detector.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/float_util.h" 10 #include "base/float_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "ui/events/gesture_detection/motion_event.h" 12 #include "ui/events/gesture_detection/motion_event.h"
13 13
14 using base::TimeDelta; 14 using base::TimeDelta;
15 using base::TimeTicks; 15 using base::TimeTicks;
16 16
17 namespace ui { 17 namespace ui {
18 namespace { 18 namespace {
19 19
20 const int kTouchStabilizeTimeMs = 128; 20 const int kTouchStabilizeTimeMs = 128;
21 21
22 const float kScaleFactor = .5f; 22 const float kScaleFactor = .5f;
23 23
24 } // namespace 24 } // namespace
25 25
26 // Note: These constants were taken directly from the default (unscaled) 26 // Note: These constants were taken directly from the default (unscaled)
27 // versions found in Android's ViewConfiguration. 27 // versions found in Android's ViewConfiguration.
28 ScaleGestureDetector::Config::Config() 28 ScaleGestureDetector::Config::Config()
29 : quick_scale_enabled(false), 29 : quick_scale_enabled(true),
30 min_scaling_touch_major(48), 30 min_scaling_touch_major(48),
31 min_scaling_span(200) {} 31 min_scaling_span(200) {}
32 32
33 ScaleGestureDetector::Config::~Config() {} 33 ScaleGestureDetector::Config::~Config() {}
34 34
35 bool ScaleGestureDetector::SimpleScaleGestureListener::OnScale( 35 bool ScaleGestureDetector::SimpleScaleGestureListener::OnScale(
36 const ScaleGestureDetector&) { 36 const ScaleGestureDetector&) {
37 return false; 37 return false;
38 } 38 }
39 39
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 new GestureDetector(config_.gesture_detector_config, this, this)); 238 new GestureDetector(config_.gesture_detector_config, this, this));
239 } 239 }
240 } 240 }
241 241
242 bool ScaleGestureDetector::IsQuickScaleEnabled() const { 242 bool ScaleGestureDetector::IsQuickScaleEnabled() const {
243 return quick_scale_enabled_; 243 return quick_scale_enabled_;
244 } 244 }
245 245
246 bool ScaleGestureDetector::IsInProgress() const { return in_progress_; } 246 bool ScaleGestureDetector::IsInProgress() const { return in_progress_; }
247 247
248 bool ScaleGestureDetector::InDoubleTapMode() const {
249 return double_tap_mode_ == DOUBLE_TAP_MODE_IN_PROGRESS;
250 }
251
248 float ScaleGestureDetector::GetFocusX() const { return focus_x_; } 252 float ScaleGestureDetector::GetFocusX() const { return focus_x_; }
249 253
250 float ScaleGestureDetector::GetFocusY() const { return focus_y_; } 254 float ScaleGestureDetector::GetFocusY() const { return focus_y_; }
251 255
252 float ScaleGestureDetector::GetCurrentSpan() const { return curr_span_; } 256 float ScaleGestureDetector::GetCurrentSpan() const { return curr_span_; }
253 257
254 float ScaleGestureDetector::GetCurrentSpanX() const { return curr_span_x_; } 258 float ScaleGestureDetector::GetCurrentSpanX() const { return curr_span_x_; }
255 259
256 float ScaleGestureDetector::GetCurrentSpanY() const { return curr_span_y_; } 260 float ScaleGestureDetector::GetCurrentSpanY() const { return curr_span_y_; }
257 261
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 357 }
354 358
355 void ScaleGestureDetector::ClearTouchHistory() { 359 void ScaleGestureDetector::ClearTouchHistory() {
356 touch_upper_ = std::numeric_limits<float>::quiet_NaN(); 360 touch_upper_ = std::numeric_limits<float>::quiet_NaN();
357 touch_lower_ = std::numeric_limits<float>::quiet_NaN(); 361 touch_lower_ = std::numeric_limits<float>::quiet_NaN();
358 touch_history_last_accepted_ = std::numeric_limits<float>::quiet_NaN(); 362 touch_history_last_accepted_ = std::numeric_limits<float>::quiet_NaN();
359 touch_history_direction_ = 0; 363 touch_history_direction_ = 0;
360 touch_history_last_accepted_time_ = base::TimeTicks(); 364 touch_history_last_accepted_time_ = base::TimeTicks();
361 } 365 }
362 366
363 bool ScaleGestureDetector::InDoubleTapMode() const {
364 return double_tap_mode_ == DOUBLE_TAP_MODE_IN_PROGRESS;
365 }
366
367 } // namespace ui 367 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/scale_gesture_detector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698