diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-08-11 17:30:43 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-08-11 17:59:29 +0100 |
| commit | 9b020a9c6ff875c5f6511b50480f07beabb9a694 (patch) | |
| tree | c36896613eb0161805e72c8c3f909415f5271858 | |
| parent | 6f3c666291dfd1442146883eeaee02570351604d (diff) | |
split out bounding box computation
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
| -rw-r--r-- | src/gestures-pinch.c | 28 | ||||
| -rw-r--r-- | src/grail-gestures.c | 24 | ||||
| -rw-r--r-- | src/grail-gestures.h | 2 |
3 files changed, 32 insertions, 22 deletions
diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c index 91e6504..d05b06f 100644 --- a/src/gestures-pinch.c +++ b/src/gestures-pinch.c | |||
| @@ -39,34 +39,18 @@ static void set_props(struct combo_model *s, | |||
| 39 | const struct move_model *m, | 39 | const struct move_model *m, |
| 40 | const struct touch_frame *frame) | 40 | const struct touch_frame *frame) |
| 41 | { | 41 | { |
| 42 | float x1, y1, x2, y2, x, y; | 42 | struct grail_coord min, max; |
| 43 | int i; | ||
| 44 | s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta; | 43 | s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta; |
| 45 | s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity; | 44 | s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity; |
| 46 | s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value; | 45 | s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value; |
| 47 | s->nprop = 3; | 46 | s->nprop = 3; |
| 48 | if (!frame->nactive) | 47 | if (!frame->nactive) |
| 49 | return; | 48 | return; |
| 50 | x = frame->active[0]->prop[TP_POS_X]; | 49 | gru_compute_bbox(&min, &max, frame); |
| 51 | y = frame->active[0]->prop[TP_POS_Y]; | 50 | s->prop[GRAIL_PROP_PINCH_X1] = min.x; |
| 52 | x1 = x2 = x; | 51 | s->prop[GRAIL_PROP_PINCH_Y1] = min.y; |
| 53 | y1 = y2 = y; | 52 | s->prop[GRAIL_PROP_PINCH_X2] = max.x; |
| 54 | for (i = 1; i < frame->nactive; i++) { | 53 | s->prop[GRAIL_PROP_PINCH_Y2] = max.y; |
| 55 | x = frame->active[i]->prop[TP_POS_X]; | ||
| 56 | y = frame->active[i]->prop[TP_POS_Y]; | ||
| 57 | if (x < x1) | ||
| 58 | x1 = x; | ||
| 59 | if (y < y1) | ||
| 60 | y1 = y; | ||
| 61 | if (x > x2) | ||
| 62 | x2 = x; | ||
| 63 | if (y > y2) | ||
| 64 | y2 = y; | ||
| 65 | } | ||
| 66 | s->prop[GRAIL_PROP_PINCH_X1] = x1; | ||
| 67 | s->prop[GRAIL_PROP_PINCH_Y1] = y1; | ||
| 68 | s->prop[GRAIL_PROP_PINCH_X2] = x2; | ||
| 69 | s->prop[GRAIL_PROP_PINCH_Y2] = y2; | ||
| 70 | s->nprop = 7; | 54 | s->nprop = 7; |
| 71 | } | 55 | } |
| 72 | 56 | ||
diff --git a/src/grail-gestures.c b/src/grail-gestures.c index f1e2093..33d848c 100644 --- a/src/grail-gestures.c +++ b/src/grail-gestures.c | |||
| @@ -218,3 +218,27 @@ void gru_end(struct grail *ge, int gid, const struct move_model *m, | |||
| 218 | prop, nprop); | 218 | prop, nprop); |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | void gru_compute_bbox(struct grail_coord *min, struct grail_coord *max, | ||
| 222 | const struct touch_frame *frame) | ||
| 223 | { | ||
| 224 | float x, y; | ||
| 225 | int i; | ||
| 226 | if (frame->nactive < 1) | ||
| 227 | return; | ||
| 228 | x = frame->active[0]->prop[TP_POS_X]; | ||
| 229 | y = frame->active[0]->prop[TP_POS_Y]; | ||
| 230 | min->x = max->x = x; | ||
| 231 | min->y = max->y = y; | ||
| 232 | for (i = 1; i < frame->nactive; i++) { | ||
| 233 | x = frame->active[i]->prop[TP_POS_X]; | ||
| 234 | y = frame->active[i]->prop[TP_POS_Y]; | ||
| 235 | if (x < min->x) | ||
| 236 | min->x = x; | ||
| 237 | if (y < min->y) | ||
| 238 | min->y = y; | ||
| 239 | if (x > max->x) | ||
| 240 | max->x = x; | ||
| 241 | if (y > max->y) | ||
| 242 | max->y = y; | ||
| 243 | } | ||
| 244 | } | ||
diff --git a/src/grail-gestures.h b/src/grail-gestures.h index e716757..edd641b 100644 --- a/src/grail-gestures.h +++ b/src/grail-gestures.h | |||
| @@ -68,6 +68,8 @@ void gru_event(struct grail *ge, int gid, | |||
| 68 | void gru_end(struct grail *ge, int gid, | 68 | void gru_end(struct grail *ge, int gid, |
| 69 | const struct move_model *move, | 69 | const struct move_model *move, |
| 70 | const grail_prop_t *prop, int nprop); | 70 | const grail_prop_t *prop, int nprop); |
| 71 | void gru_compute_bbox(struct grail_coord *min, struct grail_coord *max, | ||
| 72 | const struct touch_frame *frame); | ||
| 71 | 73 | ||
| 72 | struct combo_model { | 74 | struct combo_model { |
| 73 | int active, gid; | 75 | int active, gid; |
