Chromium Code Reviews| Index: ui/events/gesture_detection/motion_event_ui.h |
| diff --git a/ui/events/gesture_detection/motion_event_ui.h b/ui/events/gesture_detection/motion_event_ui.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e7fa336674e8548055f8aae6bdd19ef2adae927d |
| --- /dev/null |
| +++ b/ui/events/gesture_detection/motion_event_ui.h |
| @@ -0,0 +1,98 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ |
| +#define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ |
| + |
| +#include "ui/events/gesture_detection/motion_event.h" |
| + |
| +#include <map> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/time/time.h" |
| +#include "ui/events/event.h" |
| +#include "ui/events/events_export.h" |
| +#include "ui/events/gestures/gesture_sequence.h" |
| +namespace ui { |
|
jdduke (slow)
2014/05/02 17:56:43
Nit: Line before namespace
tdresser
2014/05/05 15:42:35
Done.
|
| + |
| +// Implementation of MotionEvent which takes a stream of ui::Events. |
|
jdduke (slow)
2014/05/02 17:56:43
ui::TouchEvents
tdresser
2014/05/05 15:42:35
Done.
|
| +class EVENTS_EXPORT MotionEventUI : public MotionEvent { |
|
jdduke (slow)
2014/05/02 17:56:43
Would MotionEventAura be more appropriate?
tdresser
2014/05/05 15:42:35
Done.
|
| + public: |
| + MotionEventUI(); |
| + virtual ~MotionEventUI(); |
| + |
| + void OnTouch(const TouchEvent& touch); |
| + |
| + virtual int GetId() const OVERRIDE; |
|
jdduke (slow)
2014/05/02 17:56:43
// MotionEvent implementation.
tdresser
2014/05/05 15:42:35
Done.
|
| + virtual Action GetAction() const OVERRIDE; |
| + virtual int GetActionIndex() const OVERRIDE; |
| + virtual size_t GetPointerCount() const OVERRIDE; |
| + virtual int GetPointerId(size_t pointer_index) const OVERRIDE; |
| + virtual float GetX(size_t pointer_index) const OVERRIDE; |
| + virtual float GetY(size_t pointer_index) const OVERRIDE; |
| + virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE; |
| + virtual float GetPressure(size_t pointer_index) const OVERRIDE; |
| + virtual base::TimeTicks GetEventTime() const OVERRIDE; |
| + |
| + virtual size_t GetHistorySize() const OVERRIDE; |
| + virtual base::TimeTicks GetHistoricalEventTime(size_t historical_index) const |
| + OVERRIDE; |
| + virtual float GetHistoricalTouchMajor(size_t pointer_index, |
| + size_t historical_index) const OVERRIDE; |
| + virtual float GetHistoricalX(size_t pointer_index, |
| + size_t historical_index) const OVERRIDE; |
| + virtual float GetHistoricalY(size_t pointer_index, |
| + size_t historical_index) const OVERRIDE; |
| + |
| + virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE; |
| + virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE; |
| + |
| + // We can't cleanup removed touch points immediately upon receipt of a |
| + // TouchCancel or TouchRelease, as the MotionEvent needs to be able to report |
| + // information about those touch events. Once the MotionEvent has been |
| + // processed, call CleanupRemovedTouchPoints to do the required book-keeping. |
| + void CleanupRemovedTouchPoints(const TouchEvent& touch); |
| + |
| + int GetSourceDeviceId(size_t pointer_index) const; |
| + |
| + private: |
| + struct PointData { |
| + float x; |
|
jdduke (slow)
2014/05/02 17:56:43
Let's give this a default constructor that zero's
tdresser
2014/05/05 15:42:35
Done.
|
| + float y; |
| + int touch_id; |
| + float pressure; |
| + int source_device_id; |
| + float major_radius; |
| + }; |
| + |
| + MotionEventUI( |
| + size_t pointer_count, |
| + const base::TimeDelta& last_touch_time, |
| + Action cached_action, |
| + int cached_action_index, |
| + const PointData (&active_touches)[GestureSequence::kMaxGesturePoints], |
| + const std::map<int, int>& id_to_index); |
| + |
| + void UpdatePointData(const TouchEvent& touch, |
| + MotionEventUI::PointData* point_data); |
| + void AddTouch(const TouchEvent& touch); |
| + void UpdateTouch(const TouchEvent& touch); |
| + void SetCachedAction(const TouchEvent& touch); |
| + |
| + size_t pointer_count_; |
| + base::TimeDelta last_touch_time_; |
| + Action cached_action_; |
| + // The index of the touch responsible for last ACTION_POINTER_DOWN or |
| + // ACTION_POINTER_UP. -1 if no such action has occurred. |
| + int cached_action_index_; |
| + |
| + // We want constant time indexing by pointer_index, and fast indexing by id. |
| + // TODO(tdresser): figure out which constant to use here. |
| + PointData active_touches_[GestureSequence::kMaxGesturePoints]; |
| + std::map<int, int> id_to_index_; |
|
jdduke (slow)
2014/05/02 17:56:43
Would a base::SmallMap be more appropriate here? D
tdresser
2014/05/05 15:42:35
I switched to iterating through |active_touches_|.
|
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ |