mirror of
git://projects.qi-hardware.com/ben-scans.git
synced 2024-11-22 03:51:33 +02:00
The top face can now be shifted.
- solidify/overlap.c (scroll_event): use center of canvas as center, not center of the top face - solidify/overlap.c (do_shift, shift, scroll_event): added translation (shifting)
This commit is contained in:
parent
525e1557ec
commit
d49f349fa0
@ -180,25 +180,51 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void shift(struct matrix *m, int dx, int dy, int dir)
|
||||||
|
{
|
||||||
|
if (dx > 0 && dy < dx && dy > -dx)
|
||||||
|
do_shift(m, dir, 0);
|
||||||
|
if (dx < 0 && dy < -dx && dy > dx)
|
||||||
|
do_shift(m, -dir, 0);
|
||||||
|
if (dy > 0 && dx < dy && dx > -dy)
|
||||||
|
do_shift(m, 0, dir);
|
||||||
|
if (dy < 0 && dx < -dy && dx > dy)
|
||||||
|
do_shift(m, 0, -dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget *da = gtk_bin_get_child(GTK_BIN(widget));
|
GtkWidget *da = gtk_bin_get_child(GTK_BIN(widget));
|
||||||
struct solid *s = data;
|
struct solid *s = data;
|
||||||
struct face *f = s->a;
|
int dx = event->x-sx(s)/2;
|
||||||
int dx = event->x-f->sx/2;
|
int dy = event->y-sy(s)/2;
|
||||||
int dy = event->y-f->sy/2;
|
|
||||||
double r = hypot(dx, dy);
|
double r = hypot(dx, dy);
|
||||||
|
int center = r/hypot(sx(s), sy(s)) < 0.25;
|
||||||
|
|
||||||
if (r < 1)
|
if (r < 1)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
switch (event->direction) {
|
switch (event->direction) {
|
||||||
case GDK_SCROLL_UP:
|
case GDK_SCROLL_UP:
|
||||||
rotate(&f->m, r);
|
if (center)
|
||||||
|
shift(&s->a->m, dx, dy, 1);
|
||||||
|
else
|
||||||
|
rotate(&s->a->m, r);
|
||||||
draw_image(da, s);
|
draw_image(da, s);
|
||||||
break;
|
break;
|
||||||
case GDK_SCROLL_DOWN:
|
case GDK_SCROLL_DOWN:
|
||||||
rotate(&f->m, -r);
|
if (center)
|
||||||
|
shift(&s->a->m, dx, dy, -1);
|
||||||
|
else
|
||||||
|
rotate(&s->a->m, -r);
|
||||||
draw_image(da, s);
|
draw_image(da, s);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user