From 7c24783cab322ed2d33a6b1b2e85e2ec7e9dcd6c Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 24 Sep 2010 16:48:07 -0300 Subject: [PATCH] More corrections to handling of the "user" matrix. Made controls more intuitive. - solidify/overlap.c (rotate): don't reverse y shift either - solidify/overlap.c (scroll_event): reverse rotation (since we've fixed the math of the coordinate transformation) - solidify/overlap.c (scroll_event): reverse rotation if mouse is on the left side - solidify/overlap.c (shift): reversing the direction in the "down" quadrant is systematic but quite confusing, so don't do it --- solidify/overlap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/solidify/overlap.c b/solidify/overlap.c index 95b2a1a..cebf03c 100644 --- a/solidify/overlap.c +++ b/solidify/overlap.c @@ -312,12 +312,21 @@ static void rotate(struct matrix *m, double r) static void do_shift(struct matrix *m, int dx, int dy) { m->b[0] += dx; - m->b[1] -= dy; + m->b[1] += dy; } static void shift(struct matrix *m, int dx, int dy, int dir) { + /* + * Wheeling "up" in each quadrant shifts in the respective direction, + * wheeling "down" in the opposite direction. + * + * No rule without exception: we treat the "down" quadrant like the + * "up" quadrant, because it would be extremely counter-intuitive to + * wheel "up" to move "down". + */ + if (dx > 0 && dy < dx && dy > -dx) do_shift(m, dir, 0); if (dx < 0 && dy < -dx && dy > dx) @@ -325,7 +334,7 @@ static void shift(struct matrix *m, int dx, int dy, int dir) if (dy > 0 && dx < dy && dx > -dy) do_shift(m, 0, dir); if (dy < 0 && dx < -dy && dx > dy) - do_shift(m, 0, -dir); + do_shift(m, 0, dir); /* exception ! */ } @@ -363,14 +372,14 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, if (center) shift(&s->a->m, dx, dy, 1); else - rotate(&s->a->m, -r); + rotate(&s->a->m, dx > 0 ? r : -r); draw_image(darea, s, osd); break; case GDK_SCROLL_DOWN: if (center) shift(&s->a->m, dx, dy, -1); else - rotate(&s->a->m, r); + rotate(&s->a->m, dx > 0 ? -r : r); draw_image(darea, s, osd); break; default: