mirror of
git://projects.qi-hardware.com/ben-scans.git
synced 2024-11-21 21:05:56 +02:00
Like rotations, shifts can now be accelerated by changing the mouse position.
- solidify/overlap.c (do_shift, shift): instead of passing an integer direction, pass a floating-point distance - solidify/overlap.c (scroll_event): weight shifts as well. Closer to the circle means faster. - solidify/style.h (DIST_STEPS): acceleration factor for shifts
This commit is contained in:
parent
9c614db35a
commit
a7105addcb
@ -309,14 +309,14 @@ 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, double dx, double dy)
|
||||
{
|
||||
m->b[0] += dx;
|
||||
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, double dist)
|
||||
{
|
||||
/*
|
||||
* Wheeling "up" in each quadrant shifts in the respective direction,
|
||||
@ -328,13 +328,13 @@ static void shift(struct matrix *m, int dx, int dy, int dir)
|
||||
*/
|
||||
|
||||
if (dx > 0 && dy < dx && dy > -dx)
|
||||
do_shift(m, dir, 0);
|
||||
do_shift(m, dist, 0);
|
||||
if (dx < 0 && dy < -dx && dy > dx)
|
||||
do_shift(m, -dir, 0);
|
||||
do_shift(m, -dist, 0);
|
||||
if (dy > 0 && dx < dy && dx > -dy)
|
||||
do_shift(m, 0, dir);
|
||||
do_shift(m, 0, dist);
|
||||
if (dy < 0 && dx < -dy && dx > dy)
|
||||
do_shift(m, 0, dir); /* exception ! */
|
||||
do_shift(m, 0, dist); /* exception ! */
|
||||
}
|
||||
|
||||
|
||||
@ -362,7 +362,7 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
||||
int dy = event->y-sy(s)/2;
|
||||
double r = hypot(dx, dy);
|
||||
double rc = r_center(s);
|
||||
double rs, rot;
|
||||
double rs, rot, dist;
|
||||
int center = r < rc;
|
||||
int osd = osd_proximity(s, dx, dy);
|
||||
|
||||
@ -386,17 +386,25 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
||||
rot = (r-rc)/(rs-rc);
|
||||
rot = SLOWEST_ROT*rs*exp(-rot*log(SLOWEST_ROT*rs/FASTEST_ROT));
|
||||
|
||||
/*
|
||||
* dist stays at 1 from 0...rc/DIST_STEPS, then linearly goes up to
|
||||
* DIST_STEPS from rc/DIST_STEPS...rc
|
||||
*/
|
||||
dist = r/rc*DIST_STEPS;
|
||||
if (dist < 0)
|
||||
dist = 1;
|
||||
|
||||
switch (event->direction) {
|
||||
case GDK_SCROLL_UP:
|
||||
if (center)
|
||||
shift(&s->a->m, dx, dy, 1);
|
||||
shift(&s->a->m, dx, dy, dist);
|
||||
else
|
||||
rotate(&s->a->m, dx > 0 ? rot : -rot);
|
||||
draw_image(darea, s, osd);
|
||||
break;
|
||||
case GDK_SCROLL_DOWN:
|
||||
if (center)
|
||||
shift(&s->a->m, dx, dy, -1);
|
||||
shift(&s->a->m, dx, dy, -dist);
|
||||
else
|
||||
rotate(&s->a->m, dx > 0 ? -rot : rot);
|
||||
draw_image(darea, s, osd);
|
||||
|
@ -25,6 +25,7 @@ extern GdkGC *gc_osd;
|
||||
#define OVERLAP_CENTER_DIV 5 /* fraction of diagonal */
|
||||
#define SLOWEST_ROT 3 /* thrice the half-diagonal */
|
||||
#define FASTEST_ROT 2 /* one pixel in distance of 2 pixels */
|
||||
#define DIST_STEPS 5 /* fastest shift is 5 px/wheel step */
|
||||
|
||||
|
||||
void init_style(GdkDrawable *da);
|
||||
|
Loading…
Reference in New Issue
Block a user