From 733332da8cf1161a7624ce71f2367335f21a0e8a Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 28 Sep 2010 22:03:02 -0300 Subject: [PATCH] The bottom face can now be shifted and rotated as well. - solidify/overlap.h, solidify/overlap.c (edit_top, overlap_edit): select the face to rotate and shift - solidify/overlap.c (scroll_event): select face to manipulate based on edit_top - solidify/solidify.c (a_b, gui_buttons): new button B+A to select the bottom face for editing - solidify/solidify.c clicked): call overlap_edit to select face to edit --- solidify/overlap.c | 19 +++++++++++++++---- solidify/overlap.h | 1 + solidify/solidify.c | 12 ++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/solidify/overlap.c b/solidify/overlap.c index b319d58..5fbe1d0 100644 --- a/solidify/overlap.c +++ b/solidify/overlap.c @@ -28,6 +28,7 @@ static int has_osd; +static int edit_top; static int sx(const struct solid *s) @@ -405,16 +406,20 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, switch (event->direction) { case GDK_SCROLL_UP: if (center) - shift(&s->a->m, dx, dy, dist); + shift(edit_top ? &s->a->m : &s->b->m, + edit_top ? dx : -dx, dy, dist); else - rotate(&s->a->m, dx > 0 ? rot : -rot); + rotate(edit_top ? &s->a->m : &s->b->m, + dx > 0 ? rot : -rot); draw_image(darea, s, osd); break; case GDK_SCROLL_DOWN: if (center) - shift(&s->a->m, dx, dy, -dist); + shift(edit_top ? &s->a->m : &s->b->m, + edit_top ? dx : -dx, dy, -dist); else - rotate(&s->a->m, dx > 0 ? -rot : rot); + rotate(edit_top ? &s->a->m : &s->b->m, + dx > 0 ? -rot : rot); draw_image(darea, s, osd); break; default: @@ -446,6 +451,12 @@ static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event, } +void overlap_edit(int top) +{ + edit_top = top; +} + + void overlap(GtkWidget *canvas, struct solid *s) { GtkWidget *evbox, *darea; diff --git a/solidify/overlap.h b/solidify/overlap.h index f21bd79..c03b8f4 100644 --- a/solidify/overlap.h +++ b/solidify/overlap.h @@ -18,6 +18,7 @@ #include "solid.h" +void overlap_edit(int top); void overlap(GtkWidget *canvas, struct solid *solid); #endif /* !OVERLAP_H */ diff --git a/solidify/solidify.c b/solidify/solidify.c index 3515435..3510ed3 100644 --- a/solidify/solidify.c +++ b/solidify/solidify.c @@ -28,13 +28,16 @@ static struct project *prj; static const struct face *active; /* NULL if overlapping */ -static GtkWidget *canvas; +static GtkWidget *canvas, *a_b; static void clicked(GtkButton *button, gpointer user_data) { struct face *face = user_data; + if (!face) + overlap_edit(button == GTK_BUTTON(a_b)); + if (active == face) return; @@ -66,7 +69,12 @@ static GtkWidget *gui_buttons(void) g_signal_connect(G_OBJECT(but), "clicked", G_CALLBACK(clicked), prj->s.b); - but = gtk_button_new_with_label("A+B"); + a_b = gtk_button_new_with_label("A+B"); + gtk_box_pack_start(GTK_BOX(vbox), a_b, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(a_b), "clicked", + G_CALLBACK(clicked), NULL); + + but = gtk_button_new_with_label("B+A"); gtk_box_pack_start(GTK_BOX(vbox), but, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(but), "clicked", G_CALLBACK(clicked), NULL);