summaryrefslogtreecommitdiff
path: root/src/gestures-rotate.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@bitmath.org>2010-08-03 15:01:50 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-08-05 22:48:38 +0200
commitd07c43f9f19dc0ee38aaf44947cfc396f437490e (patch)
tree2f9af561594a1de5553ba85b69b50bee421d5507 /src/gestures-rotate.c
parent342a43e7b2ceec1dd200bffa24b052fec33f5bdc (diff)
Introduce zoom, rotate and combo gestures
Introduce grail_mask bit functions, and add new gestures as separate functions, referring to the same move model. Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Diffstat (limited to 'src/gestures-rotate.c')
-rw-r--r--src/gestures-rotate.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/gestures-rotate.c b/src/gestures-rotate.c
new file mode 100644
index 0000000..6097347
--- /dev/null
+++ b/src/gestures-rotate.c
@@ -0,0 +1,71 @@
1/*****************************************************************************
2 *
3 * grail - Gesture Recognition And Instantiation Library
4 *
5 * Copyright (C) 2010 Canonical Ltd.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Henrik Rydberg <rydberg@bitmath.org>
22 *
23 ****************************************************************************/
24
25#include "grail-recognizer.h"
26#include <math.h>
27#include <stdio.h>
28
29void gru_reset_rotate(struct grail *ge,
30 const struct touch_frame *frame)
31{
32 struct gesture_inserter *gin = ge->gin;
33 struct gesture_recognizer *gru = ge->gru;
34 struct rotate_model *state = &gru->rotate;
35 struct move_model *move = &gru->move;
36 gin_gesture_discard_type(gin, GRAIL_TYPE_ROTATE);
37 state->a = move->a;
38 state->active = 0;
39 state->rotating = 0;
40}
41
42int gru_rotate(struct grail *ge,
43 const struct touch_frame *frame)
44{
45 struct gesture_inserter *gin = ge->gin;
46 struct gesture_recognizer *gru = ge->gru;
47 struct rotate_model *state = &gru->rotate;
48 struct move_model *move = &gru->move;
49 grail_prop_t prop[DIM_GRAIL_PROP];
50 float da;
51 int i;
52 da = move->a - state->a;
53 if (fabs(da) < 1)
54 return 0;
55 if (!state->active) {
56 i = gin_gesture_begin(ge,
57 GRAIL_TYPE_ROTATE, 1,
58 frame->touches, sizeof(frame->touches));
59 state->geslot = i;
60 state->active = 1;
61 }
62 if (!state->rotating && fabs(da) < move->abar)
63 return 0;
64 state->rotating = 1;
65 prop[0] = da;
66 gin_gesture_event(gin, state->geslot,
67 move->x, move->y, move->ntouch,
68 prop, 1);
69 state->a = move->a;
70 return 1;
71}