~fginther/libgrip/libgrip-0.3.5-precise

« back to all changes in this revision

Viewing changes to src/gripgesturemanager.h

  • Committer: Stephen M. Webb
  • Date: 2011-03-04 19:15:32 UTC
  • mfrom: (0.1.30 libgrip)
  • mto: (17.1.1 ubuntu)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: stephen.webb@canonical.com-20110304191532-46jnihnpbul5w569
Tags: upstream-0.1.4
ImportĀ upstreamĀ versionĀ 0.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2010 Canonical, Ltd.
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify it
5
 
 * under the terms of either or both of the following licenses:
6
 
 *
7
 
 * 1) the GNU Lesser General Public License version 3, as published by the
8
 
 * Free Software Foundation; and/or
9
 
 * 2) the GNU Lesser General Public License version 2.1, as published by
10
 
 * the Free Software Foundation.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful, but
13
 
 * WITHOUT ANY WARRANTY; without even the implied warranties of
14
 
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
15
 
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
16
 
 * License for more details.
17
 
 *
18
 
 * You should have received a copy of both the GNU Lesser General Public
19
 
 * License version 3 and version 2.1 along with this program.  If not, see
20
 
 * <http://www.gnu.org/licenses/>
21
 
 *
22
 
 * Authors:
23
 
 *    Cody Russell <crussell@canonical.com>
24
 
 */
25
 
 
26
 
#ifndef __GRIP_GESTURE_MANAGER_H__
27
 
#define __GRIP_GESTURE_MANAGER_H__
28
 
 
29
 
#include <gtk/gtk.h>
30
 
 
31
 
G_BEGIN_DECLS
32
 
 
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))
39
 
 
40
 
typedef struct _GripGestureManager        GripGestureManager;
41
 
typedef struct _GripGestureManagerClass   GripGestureManagerClass;
42
 
typedef struct _GripGestureManagerPrivate GripGestureManagerPrivate;
43
 
 
44
 
typedef union  _GripGestureEvent       GripGestureEvent;
45
 
typedef struct _GripEventGestureAny    GripEventGestureAny;
46
 
typedef struct _GripEventGestureDrag   GripEventGestureDrag;
47
 
typedef struct _GripEventGesturePinch  GripEventGesturePinch;
48
 
typedef struct _GripEventGestureRotate GripEventGestureRotate;
49
 
typedef struct _GripEventGestureTap    GripEventGestureTap;
50
 
 
51
 
typedef enum {
52
 
  GRIP_GESTURE_DRAG    = 0,
53
 
  GRIP_GESTURE_PINCH   = 1,
54
 
  GRIP_GESTURE_ROTATE  = 2,
55
 
  GRIP_GESTURE_TAP     = 15
56
 
} GripGestureType;
57
 
 
58
 
typedef enum {
59
 
  GRIP_TIME_START,
60
 
  GRIP_TIME_UPDATE,
61
 
  GRIP_TIME_END
62
 
} GripTimeType;
63
 
 
64
 
struct _GripEventGestureAny
65
 
{
66
 
  GdkEventType  type;
67
 
  GdkWindow    *window;
68
 
};
69
 
 
70
 
struct _GripEventGestureDrag
71
 
{
72
 
  GripGestureType   type;
73
 
  guint             id;
74
 
  GdkWindow        *window;
75
 
  GdkWindow        *root;
76
 
  GdkWindow        *child;
77
 
  guint32           timestamp;
78
 
  gint              fingers;
79
 
  gdouble           focus_x;
80
 
  gdouble           focus_y;
81
 
  gint              delta_x;
82
 
  gint              delta_y;
83
 
  gdouble           velocity_x;
84
 
  gdouble           velocity_y;
85
 
  gdouble           position_x;
86
 
  gdouble           position_y;
87
 
};
88
 
 
89
 
struct _GripEventGesturePinch
90
 
{
91
 
  GripGestureType   type;
92
 
  guint             id;
93
 
  GdkWindow        *window;
94
 
  GdkWindow        *root;
95
 
  GdkWindow        *child;
96
 
  guint32           timestamp;
97
 
  guint             fingers;
98
 
  gdouble           focus_x;
99
 
  gdouble           focus_y;
100
 
  gdouble           radius_delta;
101
 
  gdouble           radial_velocity;
102
 
  gdouble           radius;
103
 
};
104
 
 
105
 
struct _GripEventGestureRotate
106
 
{
107
 
  GripGestureType  type;
108
 
  guint             id;
109
 
  GdkWindow        *window;
110
 
  GdkWindow        *root;
111
 
  GdkWindow        *child;
112
 
  guint32           timestamp;
113
 
  guint             fingers;
114
 
  gdouble           focus_x;
115
 
  gdouble           focus_y;
116
 
  gdouble           angle_delta;
117
 
  gdouble           angular_velocity;
118
 
  gdouble           angle;
119
 
};
120
 
 
121
 
struct _GripEventGestureTap
122
 
{
123
 
  GripGestureType  type;
124
 
  guint             id;
125
 
  GdkWindow        *window;
126
 
  GdkWindow        *root;
127
 
  GdkWindow        *child;
128
 
  guint32           timestamp;
129
 
  guint             fingers;
130
 
 
131
 
  guint32           tap_time;
132
 
  gfloat            focus_x;
133
 
  gfloat            focus_y;
134
 
  gfloat            position_x;
135
 
  gfloat            position_y;
136
 
};
137
 
 
138
 
union _GripGestureEvent
139
 
{
140
 
  GripGestureType        type;
141
 
  GripEventGestureAny    any;
142
 
  GripEventGestureDrag   drag;
143
 
  GripEventGesturePinch  pinch;
144
 
  GripEventGestureRotate rotate;
145
 
  GripEventGestureTap    tap;
146
 
};
147
 
 
148
 
/**
149
 
   GripGestureManager
150
 
   @parent: #GObject.
151
 
 
152
 
   A singleton manager into which a window may be registered to receive
153
 
   multitouch gesture events.
154
 
 */
155
 
struct _GripGestureManager
156
 
{
157
 
  GObject parent_instance;
158
 
 
159
 
  /*< Private >*/
160
 
  GripGestureManagerPrivate *priv;
161
 
};
162
 
 
163
 
/**
164
 
   GripGestureManagerClass
165
 
   @parent_class: #GObjectClass
166
 
*/
167
 
struct _GripGestureManagerClass
168
 
{
169
 
  GObjectClass parent_class;
170
 
};
171
 
 
172
 
/**
173
 
 * GripGestureCallback:
174
 
 * @widget: (in): A #GtkWidget pointer
175
 
 * @time: A #GripTimeType
176
 
 * @gesture: (in): A #GripGestureEvent pointer
177
 
 * @user_data: (transfer none): user data
178
 
 **/
179
 
typedef void (* GripGestureCallback) (GtkWidget         *widget,
180
 
                                      GripTimeType       time,
181
 
                                      GripGestureEvent  *gesture,
182
 
                                      gpointer            user_data);
183
 
 
184
 
GType                grip_gesture_manager_get_type        (void) G_GNUC_CONST;
185
 
 
186
 
/**
187
 
 * grip_gesture_manager_get:
188
 
 *
189
 
 * Retrieves a #GripGestureManager pointer.
190
 
 *
191
 
 * Return value: (transfer none): A #GripGestureManager
192
 
 **/
193
 
GripGestureManager *grip_gesture_manager_get              (void);
194
 
 
195
 
/**
196
 
 * grip_gesture_manager_register_window:
197
 
 * @manager: self
198
 
 * @widget: A #GtkWidget on which to register the gesture
199
 
 * @gesture_type: Gesture type
200
 
 * @touch_points: Number of touch points
201
 
 * @callback: Callback
202
 
 * @user_data: (transfer none): User data
203
 
 * @destroy: (transfer none) (scope async): Destroy
204
 
 */
205
 
void                 grip_gesture_manager_register_window (GripGestureManager *manager,
206
 
                                                           GtkWidget          *widget,
207
 
                                                           GripGestureType     gesture_type,
208
 
                                                           gint                touch_points,
209
 
                                                           GripGestureCallback callback,
210
 
                                                           gpointer            user_data,
211
 
                                                           GDestroyNotify      destroy);
212
 
 
213
 
GType             grip_gesture_event_get_type (void) G_GNUC_CONST;
214
 
GripGestureEvent *grip_gesture_event_new      (GripGestureType   gesture_type);
215
 
void              grip_gesture_event_free     (GripGestureEvent *event);
216
 
GripGestureEvent *grip_gesture_event_copy     (const GripGestureEvent *event);
217
 
 
218
 
 
219
 
G_END_DECLS
220
 
 
221
 
#endif /* __GRIP_GESTURE_MANAGER_H__ */