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

Side by Side Diff: sky/engine/platform/PlatformGestureEvent.h

Issue 874823002: Move GestureEvent to NewEventDispatcher (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Build fixes Created 5 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 unified diff | Download patch
« no previous file with comments | « sky/engine/platform/PlatformEvent.h ('k') | sky/engine/platform/scroll/Scrollbar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef SKY_ENGINE_PLATFORM_PLATFORMGESTUREEVENT_H_
27 #define SKY_ENGINE_PLATFORM_PLATFORMGESTUREEVENT_H_
28
29 #include <string.h>
30 #include "sky/engine/platform/PlatformEvent.h"
31 #include "sky/engine/platform/geometry/FloatPoint.h"
32 #include "sky/engine/platform/geometry/IntPoint.h"
33 #include "sky/engine/platform/geometry/IntSize.h"
34 #include "sky/engine/wtf/Assertions.h"
35
36 namespace blink {
37
38 class PlatformGestureEvent : public PlatformEvent {
39 public:
40 PlatformGestureEvent()
41 : PlatformEvent(PlatformEvent::GestureScrollBegin)
42 {
43 memset(&m_data, 0, sizeof(m_data));
44 }
45
46 PlatformGestureEvent(Type type, const IntPoint& position, const IntPoint& gl obalPosition, const IntSize& area, double timestamp, bool shiftKey, bool ctrlKey , bool altKey, bool metaKey, float deltaX, float deltaY, float velocityX, float velocityY)
47 : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp)
48 , m_position(position)
49 , m_globalPosition(globalPosition)
50 , m_area(area)
51 {
52 memset(&m_data, 0, sizeof(m_data));
53 if (type == PlatformEvent::GestureScrollBegin
54 || type == PlatformEvent::GestureScrollEnd
55 || type == PlatformEvent::GestureScrollUpdate
56 || type == PlatformEvent::GestureScrollUpdateWithoutPropagation) {
57 m_data.m_scrollUpdate.m_deltaX = deltaX;
58 m_data.m_scrollUpdate.m_deltaY = deltaY;
59 m_data.m_scrollUpdate.m_velocityX = velocityX;
60 m_data.m_scrollUpdate.m_velocityY = velocityY;
61 }
62 }
63
64 const IntPoint& position() const { return m_position; } // PlatformWindow co ordinates.
65 const IntPoint& globalPosition() const { return m_globalPosition; } // Scree n coordinates.
66
67 const IntSize& area() const { return m_area; }
68
69 float deltaX() const
70 {
71 ASSERT(m_type == PlatformEvent::GestureScrollUpdate
72 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation);
73 return m_data.m_scrollUpdate.m_deltaX;
74 }
75
76 float deltaY() const
77 {
78 ASSERT(m_type == PlatformEvent::GestureScrollUpdate
79 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation);
80 return m_data.m_scrollUpdate.m_deltaY;
81 }
82
83 int tapCount() const
84 {
85 ASSERT(m_type == PlatformEvent::GestureTap);
86 return m_data.m_tap.m_tapCount;
87 }
88
89 float velocityX() const
90 {
91 ASSERT(m_type == PlatformEvent::GestureScrollUpdate
92 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation);
93 return m_data.m_scrollUpdate.m_velocityX;
94 }
95
96 float velocityY() const
97 {
98 ASSERT(m_type == PlatformEvent::GestureScrollUpdate
99 || m_type == PlatformEvent::GestureScrollUpdateWithoutPropagation);
100 return m_data.m_scrollUpdate.m_velocityY;
101 }
102
103 float scale() const
104 {
105 ASSERT(m_type == PlatformEvent::GesturePinchUpdate);
106 return m_data.m_pinchUpdate.m_scale;
107 }
108
109 bool isScrollEvent() const
110 {
111 switch (m_type) {
112 case GestureScrollBegin:
113 case GestureScrollEnd:
114 case GestureScrollUpdate:
115 case GestureScrollUpdateWithoutPropagation:
116 case GestureFlingStart:
117 case GesturePinchBegin:
118 case GesturePinchEnd:
119 case GesturePinchUpdate:
120 return true;
121 case GestureTap:
122 case GestureTapUnconfirmed:
123 case GestureTapDown:
124 case GestureShowPress:
125 case GestureTapDownCancel:
126 case GestureTwoFingerTap:
127 case GestureLongPress:
128 case GestureLongTap:
129 return false;
130 default:
131 ASSERT_NOT_REACHED();
132 return false;
133 }
134 }
135
136 protected:
137 IntPoint m_position;
138 IntPoint m_globalPosition;
139 IntSize m_area;
140
141 union {
142 struct {
143 int m_tapCount;
144 } m_tap;
145
146 struct {
147 float m_deltaX;
148 float m_deltaY;
149 float m_velocityX;
150 float m_velocityY;
151 } m_scrollUpdate;
152
153 struct {
154 float m_scale;
155 } m_pinchUpdate;
156 } m_data;
157 };
158
159 } // namespace blink
160
161 #endif // SKY_ENGINE_PLATFORM_PLATFORMGESTUREEVENT_H_
OLDNEW
« no previous file with comments | « sky/engine/platform/PlatformEvent.h ('k') | sky/engine/platform/scroll/Scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698