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

Side by Side Diff: ui/aura/gestures/gesture_point.cc

Issue 9452024: Gestures are now possible using touch events with any ids (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Allow consecutive touch presses with the same touch-id. Created 8 years, 9 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/aura/gestures/gesture_point.h" 5 #include "ui/aura/gestures/gesture_point.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "ui/aura/event.h" 10 #include "ui/aura/event.h"
11 #include "ui/aura/gestures/gesture_configuration.h" 11 #include "ui/aura/gestures/gesture_configuration.h"
12 #include "ui/base/events.h" 12 #include "ui/base/events.h"
13 13
14 namespace { 14 namespace {
15 15
16 const int kMinRailBreakVelocity = 200; 16 const int kMinRailBreakVelocity = 200;
17 const int kMinScrollDeltaSquared = 5 * 5; 17 const int kMinScrollDeltaSquared = 5 * 5;
18 const int kRailBreakProportion = 15; 18 const int kRailBreakProportion = 15;
19 const int kRailStartProportion = 2; 19 const int kRailStartProportion = 2;
20 const int kBufferedPoints = 10; 20 const int kBufferedPoints = 10;
21 21
22 } // namespace 22 } // namespace
23 23
24 namespace aura { 24 namespace aura {
25 25
26 GesturePoint::GesturePoint() 26 GesturePoint::GesturePoint()
27 : first_touch_time_(0.0), 27 : first_touch_time_(0.0),
28 last_touch_time_(0.0), 28 last_touch_time_(0.0),
29 last_tap_time_(0.0), 29 last_tap_time_(0.0),
30 velocity_calculator_(kBufferedPoints) { 30 velocity_calculator_(kBufferedPoints),
31 point_id_(-1) {
31 } 32 }
32 33
33 GesturePoint::~GesturePoint() {} 34 GesturePoint::~GesturePoint() {}
34 35
35 void GesturePoint::Reset() { 36 void GesturePoint::Reset() {
36 first_touch_time_ = last_touch_time_ = 0.0; 37 first_touch_time_ = last_touch_time_ = 0.0;
37 velocity_calculator_.ClearHistory(); 38 velocity_calculator_.ClearHistory();
39 point_id_ = -1;
38 } 40 }
39 41
40 void GesturePoint::UpdateValues(const TouchEvent& event) { 42 void GesturePoint::UpdateValues(const TouchEvent& event) {
41 const int64 event_timestamp_microseconds = 43 const int64 event_timestamp_microseconds =
42 event.time_stamp().InMicroseconds(); 44 event.time_stamp().InMicroseconds();
43 if (event.type() == ui::ET_TOUCH_MOVED) { 45 if (event.type() == ui::ET_TOUCH_MOVED) {
44 velocity_calculator_.PointSeen(event.x(), 46 velocity_calculator_.PointSeen(event.x(),
45 event.y(), 47 event.y(),
46 event_timestamp_microseconds); 48 event_timestamp_microseconds);
47 } 49 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return manhattanDistance < 164 return manhattanDistance <
163 GestureConfiguration::max_touch_move_in_pixels_for_click(); 165 GestureConfiguration::max_touch_move_in_pixels_for_click();
164 } 166 }
165 167
166 bool GesturePoint::IsOverMinFlickSpeed() { 168 bool GesturePoint::IsOverMinFlickSpeed() {
167 return velocity_calculator_.VelocitySquared() > 169 return velocity_calculator_.VelocitySquared() >
168 GestureConfiguration::min_flick_speed_squared(); 170 GestureConfiguration::min_flick_speed_squared();
169 } 171 }
170 172
171 } // namespace aura 173 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698