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

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

Issue 9104021: aura: Update GestureRecognizer to be able to process multi-point gestures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/gestures/gesture_point.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_AURA_GESTURES_GESTURE_POINT_H_
6 #define UI_AURA_GESTURES_GESTURE_POINT_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "ui/gfx/point.h"
11
12 namespace aura {
13 class TouchEvent;
14
15 // Gesture state.
16 enum GestureState {
17 GS_NO_GESTURE,
18 GS_PENDING_SYNTHETIC_CLICK,
19 GS_SCROLL,
20 };
21
22 // A GesturePoint represents a single touch-point/finger during a gesture
23 // recognition process.
24 class GesturePoint {
25 public:
26 GesturePoint();
27 virtual ~GesturePoint() {}
28
29 // Resets various states.
30 void Reset();
31
32 // Updates some states when a Tap gesture has been recognized for this point.
33 void UpdateForTap();
34
35 // Updates some states when a Scroll gesture has been recognized for this
36 // point.
37 void UpdateForScroll();
38
39 // Updates states depending on the event and the gesture-state.
40 void UpdateValues(const TouchEvent& event, GestureState state);
41
42 // Responds according to the state of the gesture point (i.e. the point can
43 // represent a click or scroll etc.)
44 bool IsInClickWindow(const TouchEvent& event) const;
45 bool IsInDoubleClickWindow(const TouchEvent& event) const;
46 bool IsInScrollWindow(const TouchEvent& event) const;
47 bool IsInFlickWindow(const TouchEvent& event) const;
48
49 const gfx::Point& first_touch_position() const {
50 return first_touch_position_;
51 }
52
53 double last_touch_time() const { return last_touch_time_; }
54 const gfx::Point& last_touch_position() const { return last_touch_position_; }
55
56 double x_delta() const {
57 return last_touch_position_.x() - first_touch_position_.x();
58 }
59
60 double y_delta() const {
61 return last_touch_position_.y() - first_touch_position_.y();
62 }
63
64 float x_velocity() const { return x_velocity_; }
65 float y_velocity() const { return y_velocity_; }
66
67 private:
68 // Various statistical functions to manipulate gestures.
69 bool IsInClickTimeWindow() const;
70 bool IsInSecondClickTimeWindow() const;
71 bool IsInsideManhattanSquare(const TouchEvent& event) const;
72 bool IsSecondClickInsideManhattanSquare(const TouchEvent& event) const;
73 bool IsOverMinFlickSpeed() const;
74
75 gfx::Point first_touch_position_;
76 double first_touch_time_;
77 gfx::Point last_touch_position_;
78 double last_touch_time_;
79
80 double last_tap_time_;
81 gfx::Point last_tap_position_;
82
83 float x_velocity_;
84 float y_velocity_;
85
86 DISALLOW_COPY_AND_ASSIGN(GesturePoint);
87 };
88
89 } // namespace aura
90
91 #endif // UI_AURA_GESTURES_GESTURE_POINT_H_
OLDNEW
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/gestures/gesture_point.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698