Date:2010-09-24 06:11:57 (9 years 2 months ago)
Author:Werner Almesberger
Commit:d49f349fa03bb37058608178ba482bcf55ad1dd1
Message: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)
Files: solidify/overlap.c (1 diff)

Change Details

solidify/overlap.c
180180}
181181
182182
183static void do_shift(struct matrix *m, int dx, int dy)
184{
185    m->b[0] -= dx;
186    m->b[1] += dy;
187}
188
189
190static void shift(struct matrix *m, int dx, int dy, int dir)
191{
192    if (dx > 0 && dy < dx && dy > -dx)
193        do_shift(m, dir, 0);
194    if (dx < 0 && dy < -dx && dy > dx)
195        do_shift(m, -dir, 0);
196    if (dy > 0 && dx < dy && dx > -dy)
197        do_shift(m, 0, dir);
198    if (dy < 0 && dx < -dy && dx > dy)
199        do_shift(m, 0, -dir);
200}
201
202
183203static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
184204    gpointer data)
185205{
186206    GtkWidget *da = gtk_bin_get_child(GTK_BIN(widget));
187207    struct solid *s = data;
188    struct face *f = s->a;
189    int dx = event->x-f->sx/2;
190    int dy = event->y-f->sy/2;
208    int dx = event->x-sx(s)/2;
209    int dy = event->y-sy(s)/2;
191210    double r = hypot(dx, dy);
211    int center = r/hypot(sx(s), sy(s)) < 0.25;
192212
193213    if (r < 1)
194214        return TRUE;
195215    switch (event->direction) {
196216    case GDK_SCROLL_UP:
197        rotate(&f->m, r);
217        if (center)
218            shift(&s->a->m, dx, dy, 1);
219        else
220            rotate(&s->a->m, r);
198221        draw_image(da, s);
199222        break;
200223    case GDK_SCROLL_DOWN:
201        rotate(&f->m, -r);
224        if (center)
225            shift(&s->a->m, dx, dy, -1);
226        else
227            rotate(&s->a->m, -r);
202228        draw_image(da, s);
203229        break;
204230    default:

Archive Download the corresponding diff file

Branches:
master



interactive