1
0
mirror of git://projects.qi-hardware.com/ben-scans.git synced 2024-11-22 02:48:06 +02:00

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
This commit is contained in:
Werner Almesberger 2010-09-24 16:48:07 -03:00
parent 898970b3dd
commit 7c24783cab

View File

@ -312,12 +312,21 @@ static void rotate(struct matrix *m, double r)
static void do_shift(struct matrix *m, int dx, int dy) static void do_shift(struct matrix *m, int dx, int dy)
{ {
m->b[0] += dx; m->b[0] += dx;
m->b[1] -= dy; m->b[1] += dy;
} }
static void shift(struct matrix *m, int dx, int dy, int dir) 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) if (dx > 0 && dy < dx && dy > -dx)
do_shift(m, dir, 0); do_shift(m, dir, 0);
if (dx < 0 && dy < -dx && dy > dx) 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) if (dy > 0 && dx < dy && dx > -dy)
do_shift(m, 0, dir); do_shift(m, 0, dir);
if (dy < 0 && dx < -dy && dx > dy) 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) if (center)
shift(&s->a->m, dx, dy, 1); shift(&s->a->m, dx, dy, 1);
else else
rotate(&s->a->m, -r); rotate(&s->a->m, dx > 0 ? r : -r);
draw_image(darea, s, osd); draw_image(darea, s, osd);
break; break;
case GDK_SCROLL_DOWN: case GDK_SCROLL_DOWN:
if (center) if (center)
shift(&s->a->m, dx, dy, -1); shift(&s->a->m, dx, dy, -1);
else else
rotate(&s->a->m, r); rotate(&s->a->m, dx > 0 ? -r : r);
draw_image(darea, s, osd); draw_image(darea, s, osd);
break; break;
default: default: