summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 20:48:42 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 20:48:42 +0000
commit74f8f030cefd8118cc97e3d77546fb900ad9403e (patch)
tree46d999e0393dd27c95d7e6909209127ff8213aea /views
parent2d78334cabcfac4c528bb7f737fcafa4067ed2e8 (diff)
downloadchromium_src-74f8f030cefd8118cc97e3d77546fb900ad9403e.zip
chromium_src-74f8f030cefd8118cc97e3d77546fb900ad9403e.tar.gz
chromium_src-74f8f030cefd8118cc97e3d77546fb900ad9403e.tar.bz2
Lands http://codereview.chromium.org/3167002 for rjkroege:
Adds a TouchEvent class for views. BUG= TEST=compiled with and without touchui Review URL: http://codereview.chromium.org/3117010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/event.cc25
-rw-r--r--views/event.h60
2 files changed, 85 insertions, 0 deletions
diff --git a/views/event.cc b/views/event.cc
index 2f9834b..ba05875 100644
--- a/views/event.cc
+++ b/views/event.cc
@@ -47,4 +47,29 @@ MouseEvent::MouseEvent(const MouseEvent& model, View* from, View* to)
: LocatedEvent(model, from, to) {
}
+#if defined(TOUCH_UI)
+TouchEvent::TouchEvent(EventType type, int x, int y, int flags, int touch_id)
+ : LocatedEvent(type, gfx::Point(x, y), flags),
+ touch_id_(touch_id) {
+}
+
+
+TouchEvent::TouchEvent(EventType type,
+ View* from,
+ View* to,
+ const gfx::Point& l,
+ int flags,
+ int touch_id)
+ : LocatedEvent(LocatedEvent(type, gfx::Point(l.x(), l.y()), flags),
+ from,
+ to),
+ touch_id_(touch_id) {
+}
+
+TouchEvent::TouchEvent(const TouchEvent& model, View* from, View* to)
+ : LocatedEvent(model, from, to),
+ touch_id_(model.touch_id_) {
+}
+#endif
+
} // namespace views
diff --git a/views/event.h b/views/event.h
index fd16f31..aa1905c 100644
--- a/views/event.h
+++ b/views/event.h
@@ -45,6 +45,13 @@ class Event {
ET_KEY_PRESSED,
ET_KEY_RELEASED,
ET_MOUSEWHEEL,
+#if defined(TOUCH_UI)
+ ET_TOUCH_RELEASED,
+ ET_TOUCH_PRESSED,
+ ET_TOUCH_MOVED,
+ ET_TOUCH_STATIONARY,
+ ET_TOUCH_CANCELLED,
+#endif
ET_DROP_TARGET_EVENT };
// Event flags currently supported. Although this is a "views"
@@ -104,6 +111,16 @@ class Event {
type_ == ET_MOUSEWHEEL;
}
+#if defined(TOUCH_UI)
+ bool IsTouchEvent() const {
+ return type_ == ET_TOUCH_RELEASED ||
+ type_ == ET_TOUCH_PRESSED ||
+ type_ == ET_TOUCH_MOVED ||
+ type_ == ET_TOUCH_STATIONARY ||
+ type_ == ET_TOUCH_CANCELLED;
+ }
+#endif
+
#if defined(OS_WIN)
// Returns the EventFlags in terms of windows flags.
int GetWindowsFlags() const;
@@ -237,6 +254,49 @@ class MouseEvent : public LocatedEvent {
DISALLOW_COPY_AND_ASSIGN(MouseEvent);
};
+#if defined(TOUCH_UI)
+////////////////////////////////////////////////////////////////////////////////
+//
+// TouchEvent class
+//
+// A touch event is generated by touch screen and advanced track
+// pad devices. There is a deliberate direct correspondence between
+// TouchEvent and PlatformTouchPoint.
+//
+////////////////////////////////////////////////////////////////////////////////
+class TouchEvent : public LocatedEvent {
+ public:
+ // Create a new touch event.
+ TouchEvent(EventType type, int x, int y, int flags, int touch_id);
+
+ // Create a new touch event from a type and a point. If from / to views
+ // are provided, the point will be converted from 'from' coordinate system to
+ // 'to' coordinate system.
+ TouchEvent(EventType type,
+ View* from,
+ View* to,
+ const gfx::Point& l,
+ int flags,
+ int touch_id);
+
+ // Create a new TouchEvent which is identical to the provided model.
+ // If from / to views are provided, the model location will be converted
+ // from 'from' coordinate system to 'to' coordinate system.
+ TouchEvent(const TouchEvent& model, View* from, View* to);
+
+ // Return the touch point for this event.
+ bool identity() const {
+ return touch_id_;
+ }
+
+ private:
+ // The identity (typically finger) of the touch.
+ const int touch_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchEvent);
+};
+#endif
+
////////////////////////////////////////////////////////////////////////////////
//
// KeyEvent class