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

Unified Diff: ui/aura/gestures/gesture_sequence.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, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/gestures/gesture_sequence.h
diff --git a/ui/aura/gestures/gesture_recognizer_aura.h b/ui/aura/gestures/gesture_sequence.h
similarity index 55%
copy from ui/aura/gestures/gesture_recognizer_aura.h
copy to ui/aura/gestures/gesture_sequence.h
index 59fcf25a1d5e847b09fc5a236ab0dd0245f86cc1..19bcfe42e7e4df9f08cb04a4d4673f9253891649 100644
--- a/ui/aura/gestures/gesture_recognizer_aura.h
+++ b/ui/aura/gestures/gesture_sequence.h
@@ -2,35 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_AURA_GESTURES_GESTURE_RECOGNIZER_AURA_H_
-#define UI_AURA_GESTURES_GESTURE_RECOGNIZER_AURA_H_
+#ifndef UI_AURA_GESTURES_GESTURE_SEQUENCE_H_
+#define UI_AURA_GESTURES_GESTURE_SEQUENCE_H_
#pragma once
-#include <map>
-#include <queue>
-#include <vector>
-
-#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
-#include "ui/aura/aura_export.h"
+#include "ui/aura/gestures/gesture_point.h"
#include "ui/aura/gestures/gesture_recognizer.h"
#include "ui/base/events.h"
-#include "ui/gfx/point.h"
namespace aura {
class TouchEvent;
class GestureEvent;
// A GestureSequence recognizes gestures from touch sequences.
-class AURA_EXPORT GestureSequence {
+class GestureSequence {
public:
- // Gesture state.
- enum GestureState {
- GS_NO_GESTURE,
- GS_PENDING_SYNTHETIC_CLICK,
- GS_SCROLL,
- };
-
// ui::EventType is mapped to TouchState so it can fit into 3 bits of
// Signature.
enum TouchState {
@@ -99,23 +85,21 @@ class AURA_EXPORT GestureSequence {
void Reset();
- // Various statistical functions to manipulate gestures.
- bool IsInClickTimeWindow();
- bool IsInSecondClickTimeWindow();
- bool IsInsideManhattanSquare(const TouchEvent& event);
- bool IsSecondClickInsideManhattanSquare(const TouchEvent& event);
- bool IsOverMinFlickSpeed();
+ GesturePoint& GesturePointForEvent(const TouchEvent& event);
// Functions to be called to add GestureEvents, after succesful recognition.
- void AppendTapDownGestureEvent(const TouchEvent& event, Gestures* gestures);
- void AppendClickGestureEvent(const TouchEvent& event, Gestures* gestures);
- void AppendDoubleClickGestureEvent(const TouchEvent& event,
+
+ // Tap gestures.
+ void AppendTapDownGestureEvent(const GesturePoint& point, Gestures* gestures);
+ void AppendClickGestureEvent(const GesturePoint& point, Gestures* gestures);
+ void AppendDoubleClickGestureEvent(const GesturePoint& point,
Gestures* gestures);
- void AppendScrollGestureBegin(const TouchEvent& event, Gestures* gestures);
- void AppendScrollGestureEnd(const TouchEvent& event,
+ // Scroll gestures.
+ void AppendScrollGestureBegin(const GesturePoint& point, Gestures* gestures);
+ void AppendScrollGestureEnd(const GesturePoint& point,
Gestures* gestures,
float x_velocity, float y_velocity);
- void AppendScrollGestureUpdate(const TouchEvent& event, Gestures* gestures);
+ void AppendScrollGestureUpdate(const GesturePoint& point, Gestures* gestures);
void UpdateValues(const TouchEvent& event);
void SetState(const GestureState state ) { state_ = state; }
@@ -123,68 +107,39 @@ class AURA_EXPORT GestureSequence {
// Various GestureTransitionFunctions for a signature.
// There is, 1:many mapping from GestureTransitionFunction to Signature
// But a Signature have only one GestureTransitionFunction.
- bool Click(const TouchEvent& event, Gestures* gestures);
- bool InClickOrScroll(const TouchEvent& event, Gestures* gestures);
- bool InScroll(const TouchEvent& event, Gestures* gestures);
- bool NoGesture(const TouchEvent& event, Gestures* gestures);
- bool TouchDown(const TouchEvent& event, Gestures* gestures);
- bool ScrollEnd(const TouchEvent& event, Gestures* gestures);
-
- // Location of first touch event in a touch sequence.
- gfx::Point first_touch_position_;
-
- // Time of first touch event in a touch sequence.
- double first_touch_time_;
+ bool Click(const TouchEvent& event,
+ const GesturePoint& point,
+ Gestures* gestures);
+ bool InClickOrScroll(const TouchEvent& event,
+ const GesturePoint& point,
+ Gestures* gestures);
+ bool InScroll(const TouchEvent& event,
+ const GesturePoint& point,
+ Gestures* gestures);
+ bool NoGesture(const TouchEvent& event,
+ const GesturePoint& point,
+ Gestures* gestures);
+ bool TouchDown(const TouchEvent& event,
+ const GesturePoint& point,
+ Gestures* gestures);
+ bool ScrollEnd(const TouchEvent& event,
+ const GesturePoint& point,
+ Gestures* gestures);
// Current state of gesture recognizer.
GestureState state_;
- // Time of current touch event in a touch sequence.
- double last_touch_time_;
-
- // Time of click gesture.
- double last_click_time_;
-
// Location of click gesture.
gfx::Point last_click_position_;
- // Location of current touch event in a touch sequence.
- gfx::Point last_touch_position_;
-
- // Velocity in x and y direction.
- float x_velocity_;
- float y_velocity_;
-
// ui::EventFlags.
int flags_;
- DISALLOW_COPY_AND_ASSIGN(GestureSequence);
-};
-
-class AURA_EXPORT GestureRecognizerAura : public GestureRecognizer {
- public:
- GestureRecognizerAura();
- virtual ~GestureRecognizerAura();
+ GesturePoint point_;
- private:
- // Overridden from GestureRecognizer
- virtual Gestures* ProcessTouchEventForGesture(
- const TouchEvent& event,
- ui::TouchStatus status) OVERRIDE;
- virtual void QueueTouchEventForGesture(Window* window,
- const TouchEvent& event) OVERRIDE;
- virtual Gestures* AdvanceTouchQueue(Window* window, bool processed) OVERRIDE;
- virtual void FlushTouchQueue(Window* window) OVERRIDE;
-
- scoped_ptr<GestureSequence> default_sequence_;
-
- typedef std::queue<TouchEvent*> TouchEventQueue;
- std::map<Window*, TouchEventQueue*> event_queue_;
- std::map<Window*, GestureSequence*> window_sequence_;
-
- DISALLOW_COPY_AND_ASSIGN(GestureRecognizerAura);
+ DISALLOW_COPY_AND_ASSIGN(GestureSequence);
};
} // namespace aura
-#endif // UI_AURA_GESTURES_GESTURE_RECOGNIZER_AURA_H_
+#endif // UI_AURA_GESTURES_GESTURE_SEQUENCE_H_

Powered by Google App Engine
This is Rietveld 408576698