~ubuntu-branches/ubuntu/precise/libgrip/precise

« back to all changes in this revision

Viewing changes to src/gripgesturemanager.h

  • Committer: Bazaar Package Importer
  • Author(s): Chase Douglas
  • Date: 2011-08-09 16:33:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110809163326-p2ky362j7dbl0d99
Tags: 0.3.0-0ubuntu1
* New upstream release.
  - Add documentation (LP: #744911)
  - Expose device type and attributes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2010 Canonical, Ltd.
 
2
 * Copyright 2010, 2011 Canonical, Ltd.
3
3
 *
4
4
 * This program is free software: you can redistribute it and/or modify it
5
5
 * under the terms of either or both of the following licenses:
27
27
#define GRIP_GESTURE_MANAGER_H
28
28
 
29
29
#include <gtk/gtk.h>
 
30
#include "gripinputdevice.h"
30
31
 
31
32
G_BEGIN_DECLS
32
33
 
33
 
#define GRIP_TYPE_GESTURE_MANAGER         (grip_gesture_manager_get_type ())
34
 
#define GRIP_GESTURE_MANAGER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GRIP_TYPE_GESTURE_MANAGER, GripGestureManager))
35
 
#define GRIP_GESTURE_MANAGER_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerClass))
36
 
#define GRIP_IS_GESTURE_MANAGER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GRIP_TYPE_GESTURE_MANAGER))
37
 
#define GRIP_IS_GESTURE_MANAGER_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c), GRIP_TYPE_GESTURE_MANAGER))
38
 
#define GRIP_GESTURE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerClass))
 
34
/**
 
35
 * SECTION:GripGestureManager
 
36
 *
 
37
 * The Grip gesture managre is a singleton object that connections to the
 
38
 * gesture recognition engine and manages gesture subscriptions for GTK widgets.
 
39
 */
 
40
 
 
41
/**
 
42
 * SECTION:GripGestureEvents
 
43
 *
 
44
 * A series of one or more events are passed to the gesture callback.  Each
 
45
 * event conveys information specific to the type of gesture occurring.
 
46
 */
 
47
 
 
48
/**
 
49
 * GRIP_TYPE_GESTURE_MANAGER:
 
50
 *
 
51
 * Gets the #GType for the #GripGestureManager.
 
52
 */
 
53
#define GRIP_TYPE_GESTURE_MANAGER            (grip_gesture_manager_get_type ())
 
54
 
 
55
/**
 
56
 * GRIP_GESTURE_MANAGER:
 
57
 * @obj: The #GObject to convert.
 
58
 *
 
59
 * Performs a checked conversion of a #GObject to a #GripGestureManager.
 
60
 */
 
61
#define GRIP_GESTURE_MANAGER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRIP_TYPE_GESTURE_MANAGER, GripGestureManager))
 
62
 
 
63
/**
 
64
 * GRIP_GESTURE_MANAGER_CLASS:
 
65
 * @klass: The #GObjectClass to convert.
 
66
 *
 
67
 * Performes a checked conversion of a #GObjectClass to a
 
68
 * #GripGestureManagerClass.
 
69
 */
 
70
#define GRIP_GESTURE_MANAGER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerClass))
 
71
 
 
72
/**
 
73
 * GRIP_IS_GESTURE_MANAGER:
 
74
 * @obj: The #GObject to check.
 
75
 *
 
76
 * Checks to see if #GripGestureManagerClass is in the #GObjectClass heirarchy
 
77
 * of @obj.
 
78
 */
 
79
#define GRIP_IS_GESTURE_MANAGER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRIP_TYPE_GESTURE_MANAGER))
 
80
 
 
81
/**
 
82
 * GRIP_IS_GESTURE_MANAGER_CLASS:
 
83
 * @klass: The #GObjectClass to check.
 
84
 *
 
85
 * Checks to see if a #GripGestureManagerClass object is in the object heirarchy
 
86
 * of @klass.
 
87
 */
 
88
#define GRIP_IS_GESTURE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRIP_TYPE_GESTURE_MANAGER))
 
89
 
 
90
/**
 
91
 * GRIP_GESTURE_MANAGER_GET_CLASS:
 
92
 * @obj: A #GObject.
 
93
 *
 
94
 * Gets the @GripGestureManagerClass object for @obj if that object is a member
 
95
 * of its #GObjectClass heirarchy.
 
96
 */
 
97
#define GRIP_GESTURE_MANAGER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GRIP_TYPE_GESTURE_MANAGER, GripGestureManagerClass))
39
98
 
40
99
typedef struct _GripGestureManager        GripGestureManager;
41
100
typedef struct _GripGestureManagerClass   GripGestureManagerClass;
48
107
typedef struct _GripEventGestureRotate GripEventGestureRotate;
49
108
typedef struct _GripEventGestureTap    GripEventGestureTap;
50
109
 
 
110
/**
 
111
 * GripGestureType:
 
112
 * @GRIP_GESTURE_DRAG: a drag gesture
 
113
 * @GRIP_GESTURE_PINCH: a pinch/expand gesture
 
114
 * @GRIP_GESTURE_ROTATE: a rotate gesture
 
115
 * @GRIP_GESTURE_TAP: a tap gesture
 
116
 *
 
117
 * Indicates the type of gesture for which a gesture event is being received.
 
118
 */
51
119
typedef enum {
52
120
  GRIP_GESTURE_DRAG    = 0,
53
121
  GRIP_GESTURE_PINCH   = 1,
55
123
  GRIP_GESTURE_TAP     = 15
56
124
} GripGestureType;
57
125
 
58
 
typedef enum {
59
 
  GRIP_DEVICE_TOUCHSCREEN = 1,
60
 
  GRIP_DEVICE_TOUCHPAD    = 2,
61
 
  GRIP_DEVICE_INDEPENDENT = 4,
62
 
} GripDeviceType;
63
126
 
64
127
#define GRIP_DEVICE_ALL (GRIP_DEVICE_TOUCHSCREEN | GRIP_DEVICE_TOUCHPAD | GRIP_DEVICE_INDEPENDENT)
65
128
 
 
129
/**
 
130
 * GripTimeType:
 
131
 * @GRIP_TIME_START: a new gesture is starting
 
132
 * @GRIP_TIME_UPDATE: an existing gesture is updating
 
133
 * @GRIP_TIME_END: a gesture is ending
 
134
 *
 
135
 * Indicates the part of the gesture stream ocuuring during the gesture event.
 
136
 */
66
137
typedef enum {
67
138
  GRIP_TIME_START,
68
139
  GRIP_TIME_UPDATE,
69
140
  GRIP_TIME_END
70
141
} GripTimeType;
71
142
 
 
143
/**
 
144
 * GripEventGestureAny:
 
145
 * 
 
146
 * This struct is not used.
 
147
 */
72
148
struct _GripEventGestureAny
73
149
{
74
150
  GdkEventType  type;
75
151
  GdkWindow    *window;
76
152
};
77
153
 
 
154
/**
 
155
 * GripEventGestureDrag:
 
156
 * @type: the #GripGestureType of the gesture
 
157
 * @id: identifies the gesture
 
158
 * @window: the #GdkWindow in which the gesture occurred
 
159
 * @root: the root #GdkWindow
 
160
 * @child: the child #GdkWindow
 
161
 * @timestamp: the time the gesture event occurred
 
162
 * @fingers: the number of touches making up the gesture
 
163
 * @focus_x: the X coordinate of the focus point of the gesture start
 
164
 * @focus_y: the Y coordinate of the focus point of the gesture start
 
165
 * @delta_x: the change in the X coordinate since the last gesture event
 
166
 * @delta_y: the change in the Y coordinate since the last gesture event
 
167
 * @velocity_x: the rate of change of the X coordinate
 
168
 * @velocity_y: the rate of change of the Y coordinate
 
169
 * @position_x: the current X coordinate of the centroid poistion of the touches
 
170
 * @position_y: the current Y coordinate of the centroid poistion of the touches
 
171
 * @input_device: the #GripInputDevice used to make the gesture
 
172
 *
 
173
 * Data associated with a drag event.  A drag is a lateral motion.
 
174
 */
78
175
struct _GripEventGestureDrag
79
176
{
80
177
  GripGestureType   type;
92
189
  gdouble           velocity_y;
93
190
  gdouble           position_x;
94
191
  gdouble           position_y;
 
192
  GripInputDevice  *input_device;
95
193
};
96
194
 
 
195
/**
 
196
 * GripEventGesturePinch:
 
197
 * @type: the #GripGestureType of the gesture
 
198
 * @id: identifies the gesture
 
199
 * @window: the #GdkWindow in which the gesture occurred
 
200
 * @root: the root #GdkWindow
 
201
 * @child: the child #GdkWindow
 
202
 * @timestamp: the time the gesture event occurred
 
203
 * @fingers: the number of touches making up the gesture
 
204
 * @focus_x: the X coordinate of the focus point of the gesture start
 
205
 * @focus_y: the Y coordinate of the focus point of the gesture start
 
206
 * @radius_delta: the change in the radius (in screen coordinates)
 
207
 * @radial_velocity: the rate of change of the radius
 
208
 * @radius: the current radius (in screen coordinates)
 
209
 * @position_x: the current X coordinate of the centroid poistion of the touches
 
210
 * @position_y: the current Y coordinate of the centroid poistion of the touches
 
211
 * @input_device: the #GripInputDevice used to make the gesture
 
212
 *
 
213
 * Data associated with a pinch event.  A pinch is an expand or contract motion.
 
214
 */
97
215
struct _GripEventGesturePinch
98
216
{
99
217
  GripGestureType   type;
110
228
  gdouble           radius;
111
229
  gfloat            position_x;
112
230
  gfloat            position_y;
 
231
  GripInputDevice  *input_device;
113
232
};
114
233
 
 
234
/**
 
235
 * GripEventGestureRotate:
 
236
 * @type: the #GripGestureType of the gesture
 
237
 * @id: identifies the gesture
 
238
 * @window: the #GdkWindow in which the gesture occurred
 
239
 * @root: the root #GdkWindow
 
240
 * @child: the child #GdkWindow
 
241
 * @timestamp: the time the gesture event occurred
 
242
 * @fingers: the number of touches making up the gesture
 
243
 * @focus_x: the X coordinate of the focus point of the gesture start
 
244
 * @focus_y: the Y coordinate of the focus point of the gesture start
 
245
 * @angle_delta: the change in the rotation angle (in radians) 
 
246
 * @angular_velocity: the rate of change in the rotation angle
 
247
 * @angle: the current rotation angle
 
248
 * @position_x: the current X coordinate of the centroid poistion of the touches
 
249
 * @position_y: the current Y coordinate of the centroid poistion of the touches
 
250
 * @input_device: the #GripInputDevice used to make the gesture
 
251
 *
 
252
 * Data associated with a rotate gesture event.
 
253
 */
115
254
struct _GripEventGestureRotate
116
255
{
117
256
  GripGestureType  type;
128
267
  gdouble           angle;
129
268
  gfloat            position_x;
130
269
  gfloat            position_y;
 
270
  GripInputDevice  *input_device;
131
271
};
132
272
 
 
273
/**
 
274
 * GripEventGestureTap:
 
275
 * @type: the #GripGestureType of the gesture
 
276
 * @id: identifies the gesture
 
277
 * @window: the #GdkWindow in which the gesture occurred
 
278
 * @root: the root #GdkWindow
 
279
 * @child: the child #GdkWindow
 
280
 * @timestamp: the time the gesture event occurred
 
281
 * @fingers: the number of touches making up the gesture
 
282
 * @tap_time: the duration of the tap
 
283
 * @focus_x: the X coordinate of the focus point of the gesture start
 
284
 * @focus_y: the Y coordinate of the focus point of the gesture start
 
285
 * @position_x: the current X coordinate of the centroid poistion of the touches
 
286
 * @position_y: the current Y coordinate of the centroid poistion of the touches
 
287
 * @input_device: the #GripInputDevice used to make the gesture
 
288
 *
 
289
 * Data associated with a tap gesture.
 
290
 */
133
291
struct _GripEventGestureTap
134
292
{
135
293
  GripGestureType  type;
139
297
  GdkWindow        *child;
140
298
  guint32           timestamp;
141
299
  guint             fingers;
142
 
 
143
300
  guint32           tap_time;
144
301
  gfloat            focus_x;
145
302
  gfloat            focus_y;
146
303
  gfloat            position_x;
147
304
  gfloat            position_y;
 
305
  GripInputDevice  *input_device;
148
306
};
149
307
 
 
308
/**
 
309
 * GripGestureEvent:
 
310
 * @type: the #GripGestureType, selects the variant record
 
311
 * @any: (not used)
 
312
 * @drag: the event contains a drag gesture record
 
313
 * @pinch: the event contains a pinch gesture record
 
314
 * @rotate: the event contains a rotate gesture record
 
315
 * @tap: the event contains a tap gesture record
 
316
 *
 
317
 * This is a boxed type.
 
318
 */
150
319
union _GripGestureEvent
151
320
{
152
321
  GripGestureType        type;
158
327
};
159
328
 
160
329
/**
161
 
   GripGestureManager
162
 
   @parent: #GObject.
163
 
 
164
 
   A singleton manager into which a window may be registered to receive
165
 
   multitouch gesture events.
 
330
 * GripGestureManager:
 
331
 * @parent_instance: the parent #GObject instance.
 
332
 *
 
333
 * A singleton manager into which a window may be registered to receive
 
334
 * multitouch gesture events.
166
335
 */
167
336
struct _GripGestureManager
168
337
{
 
338
  /*< Public >*/
169
339
  GObject parent_instance;
170
340
 
171
341
  /*< Private >*/
173
343
};
174
344
 
175
345
/**
176
 
   GripGestureManagerClass
177
 
   @parent_class: #GObjectClass
178
 
*/
 
346
 * GripGestureManagerClass:
 
347
 * @parent_class: the base #GObjectClass
 
348
 *
 
349
 * The class object for a #GripGestureManager.
 
350
 */
179
351
struct _GripGestureManagerClass
180
352
{
181
353
  GObjectClass parent_class;
187
359
 * @time: A #GripTimeType
188
360
 * @gesture: (in): A #GripGestureEvent pointer
189
361
 * @user_data: (transfer none): user data
 
362
 *
 
363
 * The gesture callback function is registered by the
 
364
 * grip_gesture_manager_register_window() function and gets called whenever a
 
365
 * new gesture event has been received.  The same function may be registered for
 
366
 * more than one gesture type.
 
367
 *
 
368
 * The <type>GripGestureCallback</type> function is the main customization point
 
369
 * for application response to gestural input.
190
370
 **/
191
371
typedef void (* GripGestureCallback) (GtkWidget         *widget,
192
372
                                      GripTimeType       time,
193
373
                                      GripGestureEvent  *gesture,
194
 
                                      gpointer            user_data);
 
374
                                      gpointer           user_data);
195
375
 
196
376
GType                grip_gesture_manager_get_type        (void) G_GNUC_CONST;
197
377