From 9b020a9c6ff875c5f6511b50480f07beabb9a694 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 11 Aug 2010 17:30:43 +0100 Subject: split out bounding box computation Signed-off-by: Henrik Rydberg --- src/gestures-pinch.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/gestures-pinch.c') 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, const struct move_model *m, const struct touch_frame *frame) { - float x1, y1, x2, y2, x, y; - int i; + struct grail_coord min, max; s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta; s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity; s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value; s->nprop = 3; if (!frame->nactive) return; - x = frame->active[0]->prop[TP_POS_X]; - y = frame->active[0]->prop[TP_POS_Y]; - x1 = x2 = x; - y1 = y2 = y; - for (i = 1; i < frame->nactive; i++) { - x = frame->active[i]->prop[TP_POS_X]; - y = frame->active[i]->prop[TP_POS_Y]; - if (x < x1) - x1 = x; - if (y < y1) - y1 = y; - if (x > x2) - x2 = x; - if (y > y2) - y2 = y; - } - s->prop[GRAIL_PROP_PINCH_X1] = x1; - s->prop[GRAIL_PROP_PINCH_Y1] = y1; - s->prop[GRAIL_PROP_PINCH_X2] = x2; - s->prop[GRAIL_PROP_PINCH_Y2] = y2; + gru_compute_bbox(&min, &max, frame); + s->prop[GRAIL_PROP_PINCH_X1] = min.x; + s->prop[GRAIL_PROP_PINCH_Y1] = min.y; + s->prop[GRAIL_PROP_PINCH_X2] = max.x; + s->prop[GRAIL_PROP_PINCH_Y2] = max.y; s->nprop = 7; } -- cgit v1.2.3