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

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
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_H_
6 #define UI_AURA_GESTURES_GESTURE_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 // Various statistical functions to manipulate gestures.
43 bool IsInClickTimeWindow() const;
44 bool IsInSecondClickTimeWindow() const;
45 bool IsInsideManhattanSquare(const TouchEvent& event) const;
46 bool IsSecondClickInsideManhattanSquare(const TouchEvent& event) const;
47 bool IsOverMinFlickSpeed() 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 gfx::Point first_touch_position_;
69 double first_touch_time_;
70 gfx::Point last_touch_position_;
71 double last_touch_time_;
72
73 double last_click_time_;
74 gfx::Point last_click_position_;
75
76 float x_velocity_;
77 float y_velocity_;
78
79 DISALLOW_COPY_AND_ASSIGN(GesturePoint);
80 };
81
82 } // namespace aura
83
84 #endif // UI_AURA_GESTURES_GESTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698