OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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_EVENTS_GESTURES_TOUCH_POINT_STATE_H_ |
| 6 #define UI_EVENTS_GESTURES_TOUCH_POINT_STATE_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_vector.h" |
| 12 #include "ui/events/event.h" |
| 13 |
| 14 namespace ui { |
| 15 class TouchEvent; |
| 16 |
| 17 class EVENTS_EXPORT TouchPointState { |
| 18 public: |
| 19 enum RequiresAck { |
| 20 WAIT_FOR_ACK = 0, |
| 21 NO_ACK |
| 22 }; |
| 23 |
| 24 TouchPointState(int touch_id); |
| 25 TouchPointState(int touch_id, |
| 26 bool has_press, |
| 27 bool has_release, |
| 28 int move_count, |
| 29 int timer_count); |
| 30 virtual ~TouchPointState(); |
| 31 void Update(const TouchEvent& event); |
| 32 void TimerFired(); |
| 33 void Reset(); |
| 34 |
| 35 // The caller is responsible for deleting the new |TouchPointState|. The new |
| 36 // |TouchPointState| will have timer_count_ set correctly, and will only |
| 37 // report events the associated gesture depends upon. See goo.gl/gZc70m for |
| 38 // details. |
| 39 TouchPointState* CopyForGestureType( |
| 40 EventType type, RequiresAck requires_ack) const; |
| 41 |
| 42 bool HasEmptyIntersection(const TouchPointState& tps) const; |
| 43 bool Contains(const TouchPointState& tps) const; |
| 44 |
| 45 int touch_id() const {return touch_id_; } |
| 46 bool has_press() const { return has_press_; } |
| 47 bool has_release() const { return has_release_; } |
| 48 int move_count() const { return move_count_; } |
| 49 int timer_count() const { return timer_count_; } |
| 50 |
| 51 bool operator==(const TouchPointState& tps) const { |
| 52 return touch_id_ == tps.touch_id() && |
| 53 has_press() == tps.has_press() && |
| 54 has_release() == tps.has_release() && |
| 55 move_count() == tps.move_count() && |
| 56 timer_count() == tps.timer_count(); |
| 57 } |
| 58 |
| 59 private: |
| 60 TouchPointState(const TouchPointState& tps); |
| 61 TouchPointState Intersect(const TouchPointState& tps) const; |
| 62 |
| 63 int touch_id_; |
| 64 bool has_press_; |
| 65 bool has_release_; |
| 66 int move_count_; |
| 67 int timer_count_; |
| 68 |
| 69 DISALLOW_ASSIGN(TouchPointState); |
| 70 }; |
| 71 |
| 72 } // namespace ui |
| 73 |
| 74 #endif // UI_EVENTS_GESTURES_TOUCH_POINT_STATE_H_ |
OLD | NEW |