From 7be96df1c903c11711336c5ad1859b347ae4b661 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 10 Aug 2010 11:47:00 +0100 Subject: api: Rename gestures to conform to design docs Use the names drag, pinch and rotate, and remove the combo gesture. Signed-off-by: Henrik Rydberg --- src/Makefile.am | 3 +- src/gestures-combo.c | 70 ----------------------------------------------- src/gestures-drag.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/gestures-pan.c | 74 -------------------------------------------------- src/gestures-pinch.c | 8 +++--- src/gestures-rotate.c | 8 +++--- src/grail-gestures.h | 4 +-- src/grail-recognizer.c | 3 +- src/grail-recognizer.h | 3 +- 9 files changed, 87 insertions(+), 160 deletions(-) delete mode 100644 src/gestures-combo.c create mode 100644 src/gestures-drag.c delete mode 100644 src/gestures-pan.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 7dc3ac2..96ac7ed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,10 +15,9 @@ libgrail_la_SOURCES = \ grail-inserter.h \ grail-gestures.c \ grail-gestures.h \ - gestures-pan.c \ + gestures-drag.c \ gestures-pinch.c \ gestures-rotate.c \ - gestures-combo.c \ gestures-tapping.c \ grail-recognizer.c \ grail-recognizer.h \ diff --git a/src/gestures-combo.c b/src/gestures-combo.c deleted file mode 100644 index 5b6de5b..0000000 --- a/src/gestures-combo.c +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************************** - * - * grail - Gesture Recognition And Instantiation Library - * - * Copyright (C) 2010 Canonical Ltd. - * Copyright (C) 2010 Henrik Rydberg - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - ****************************************************************************/ - -#include "grail-recognizer.h" -#include -#include - -static const int getype[DIM_TOUCH + 1] = { - 0, - 0, - GRAIL_TYPE_COMBO2, - GRAIL_TYPE_COMBO3, - GRAIL_TYPE_COMBO4, - GRAIL_TYPE_COMBO5, -}; - -static const int fm_mask = 0x0f; - -int gru_combo(struct grail *ge, - const struct touch_frame *frame) -{ - struct gesture_recognizer *gru = ge->gru; - struct combo_model *state = &gru->combo; - struct move_model *move = &gru->move; - grail_prop_t prop[DIM_GRAIL_PROP]; - int mask = state->active ? (move->active & fm_mask) : fm_mask; - if (!move->multi) { - if (state->active) { - gru_end(ge, state->gid, move); - state->active = 0; - } - return 0; - } - if (!(move->tickle & mask)) - return 0; - if (!state->active) { - int type = getype[move->ntouch]; - if (!type) - return 0; - state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); - state->active = 1; - } - if (!(move->active & fm_mask)) - return 0; - prop[0] = move->fm[FM_X].action_delta; - prop[1] = move->fm[FM_Y].action_delta; - prop[2] = move->fm[FM_R].action_delta; - prop[3] = move->fm[FM_A].action_delta; - gru_event(ge, state->gid, move, prop, 4); - return 1; -} diff --git a/src/gestures-drag.c b/src/gestures-drag.c new file mode 100644 index 0000000..3f21041 --- /dev/null +++ b/src/gestures-drag.c @@ -0,0 +1,74 @@ +/***************************************************************************** + * + * grail - Gesture Recognition And Instantiation Library + * + * Copyright (C) 2010 Canonical Ltd. + * Copyright (C) 2010 Henrik Rydberg + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + ****************************************************************************/ + +#include "grail-recognizer.h" +#include +#include + +static const int getype[DIM_TOUCH + 1] = { + -1, + GRAIL_TYPE_DRAG1, + GRAIL_TYPE_DRAG2, + GRAIL_TYPE_DRAG3, + GRAIL_TYPE_DRAG4, + GRAIL_TYPE_DRAG5, +}; + +static const int fm_mask = 0x03; + +int gru_drag(struct grail *ge, + const struct touch_frame *frame) +{ + struct gesture_recognizer *gru = ge->gru; + struct combo_model *state = &gru->drag; + struct move_model *move = &gru->move; + grail_prop_t prop[DIM_GRAIL_PROP]; + int mask = state->active ? (move->active & fm_mask) : fm_mask; + if (!move->multi && (!gru->pointer_gesture || !move->single)) { + if (state->active) { + gru_end(ge, state->gid, move); + state->active = 0; + } + return 0; + } + if (!(move->tickle & mask)) + return 0; + if (!state->active) { + int type = getype[move->ntouch]; + if (type < 0) + return 0; + state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); + state->active = 1; + } + if (move->single) { + prop[0] = move->fm[FM_X].raw_delta; + prop[1] = move->fm[FM_Y].raw_delta; + } else { + if (!(move->active & fm_mask)) + return 0; + prop[0] = move->fm[FM_X].action_delta; + prop[1] = move->fm[FM_Y].action_delta; + } + gru_event(ge, state->gid, move, prop, 2); + return 1; +} + diff --git a/src/gestures-pan.c b/src/gestures-pan.c deleted file mode 100644 index c951b78..0000000 --- a/src/gestures-pan.c +++ /dev/null @@ -1,74 +0,0 @@ -/***************************************************************************** - * - * grail - Gesture Recognition And Instantiation Library - * - * Copyright (C) 2010 Canonical Ltd. - * Copyright (C) 2010 Henrik Rydberg - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - ****************************************************************************/ - -#include "grail-recognizer.h" -#include -#include - -static const int getype[DIM_TOUCH + 1] = { - -1, - GRAIL_TYPE_POINTER, - GRAIL_TYPE_PAN, - GRAIL_TYPE_SWIPE, - GRAIL_TYPE_BRUSH, - GRAIL_TYPE_HAND, -}; - -static const int fm_mask = 0x03; - -int gru_pan(struct grail *ge, - const struct touch_frame *frame) -{ - struct gesture_recognizer *gru = ge->gru; - struct combo_model *state = &gru->pan; - struct move_model *move = &gru->move; - grail_prop_t prop[DIM_GRAIL_PROP]; - int mask = state->active ? (move->active & fm_mask) : fm_mask; - if (!move->multi && (!gru->pointer_gesture || !move->single)) { - if (state->active) { - gru_end(ge, state->gid, move); - state->active = 0; - } - return 0; - } - if (!(move->tickle & mask)) - return 0; - if (!state->active) { - int type = getype[move->ntouch]; - if (type < 0) - return 0; - state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); - state->active = 1; - } - if (move->single) { - prop[0] = move->fm[FM_X].raw_delta; - prop[1] = move->fm[FM_Y].raw_delta; - } else { - if (!(move->active & fm_mask)) - return 0; - prop[0] = move->fm[FM_X].action_delta; - prop[1] = move->fm[FM_Y].action_delta; - } - gru_event(ge, state->gid, move, prop, 2); - return 1; -} - diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c index 62f6601..3b94a66 100644 --- a/src/gestures-pinch.c +++ b/src/gestures-pinch.c @@ -27,10 +27,10 @@ static const int getype[DIM_TOUCH + 1] = { 0, 0, - GRAIL_TYPE_PINCH, - GRAIL_TYPE_SCALE, - GRAIL_TYPE_PICK, - GRAIL_TYPE_GRAB, + GRAIL_TYPE_PINCH2, + GRAIL_TYPE_PINCH3, + GRAIL_TYPE_PINCH4, + GRAIL_TYPE_PINCH5, }; static const int fm_mask = 0x04; diff --git a/src/gestures-rotate.c b/src/gestures-rotate.c index fa0db22..ebab6d3 100644 --- a/src/gestures-rotate.c +++ b/src/gestures-rotate.c @@ -27,10 +27,10 @@ static const int getype[DIM_TOUCH + 1] = { 0, 0, - GRAIL_TYPE_ROTATE, - GRAIL_TYPE_TURN, - GRAIL_TYPE_WHIRL, - GRAIL_TYPE_REVOLVE, + GRAIL_TYPE_ROTATE2, + GRAIL_TYPE_ROTATE3, + GRAIL_TYPE_ROTATE4, + GRAIL_TYPE_ROTATE5, }; static const int fm_mask = 0x08; diff --git a/src/grail-gestures.h b/src/grail-gestures.h index 2acbb6d..6846ed0 100644 --- a/src/grail-gestures.h +++ b/src/grail-gestures.h @@ -63,8 +63,8 @@ struct combo_model { int active, gid; }; -int gru_pan(struct grail *ge, - const struct touch_frame *frame); +int gru_drag(struct grail *ge, + const struct touch_frame *frame); int gru_pinch(struct grail *ge, const struct touch_frame *frame); int gru_rotate(struct grail *ge, diff --git a/src/grail-recognizer.c b/src/grail-recognizer.c index bcfbc2c..5f4bee0 100644 --- a/src/grail-recognizer.c +++ b/src/grail-recognizer.c @@ -47,10 +47,9 @@ void gru_recognize(struct grail *ge, const struct touch_frame *frame) if (!ge->gin || !ge->gru) return; gru_motion(ge, frame); - gru_pan(ge, frame); + gru_drag(ge, frame); gru_pinch(ge, frame); gru_rotate(ge, frame); - gru_combo(ge, frame); gru_tapping(ge, frame); ge->gru->frame = *frame; } diff --git a/src/grail-recognizer.h b/src/grail-recognizer.h index 11b44ce..1c36819 100644 --- a/src/grail-recognizer.h +++ b/src/grail-recognizer.h @@ -28,10 +28,9 @@ struct gesture_recognizer { struct touch_frame frame; struct move_model move; - struct combo_model pan; + struct combo_model drag; struct combo_model pinch; struct combo_model rotate; - struct combo_model combo; struct tapping_model tapping; int pointer_gesture; }; -- cgit v1.2.3