| 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 54%
|
| copy from ui/aura/gestures/gesture_recognizer_aura.h
|
| copy to ui/aura/gestures/gesture_sequence.h
|
| index 59fcf25a1d5e847b09fc5a236ab0dd0245f86cc1..05bba2d656e0d015babaf58cdff30883ec00515b 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,92 +85,64 @@ 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; }
|
| + void set_state(const GestureState state ) { state_ = state; }
|
|
|
| // 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);
|
| -};
|
| + // Maximum points in a single gesture.
|
| + static const int kMaxGesturePoints = 12;
|
|
|
| -class AURA_EXPORT GestureRecognizerAura : public GestureRecognizer {
|
| - public:
|
| - GestureRecognizerAura();
|
| - virtual ~GestureRecognizerAura();
|
| + GesturePoint points_[kMaxGesturePoints];
|
| + int point_count_;
|
|
|
| - 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_
|
|
|