diff --git a/TODO b/TODO index 031ee67..9269e33 100644 --- a/TODO +++ b/TODO @@ -19,7 +19,6 @@ Style: Bugs: - default silk width has no business being hard-coded in obj.c -- after moving, arc sometimes wrap the wrong way - undelete only works if not much has changed since the deletion Code cleanup: diff --git a/dump.c b/dump.c index ca8919c..ccb8fc3 100644 --- a/dump.c +++ b/dump.c @@ -355,9 +355,10 @@ int dump(FILE *file) fprintf(file, "/* MACHINE-GENERATED ! */\n\n"); for (frame = frames; frame; frame = frame->next) { - if (!frame->name) + if (!frame->name) { + fprintf(file, "part \"%s\"\n", part_name); dump_frame(file, frame, ""); - else { + } else { fprintf(file, "frame %s {\n", frame->name); dump_frame(file, frame, "\t"); fprintf(file, "}\n\n"); diff --git a/gui_canvas.c b/gui_canvas.c index e19fcec..4da67c2 100644 --- a/gui_canvas.c +++ b/gui_canvas.c @@ -172,6 +172,7 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event, } if (res) { inst_deselect(); + redraw(); dragging = 1; drag_escaped = 0; drag_start = pos; diff --git a/gui_inst.c b/gui_inst.c index d4fa4fd..5a9ee0e 100644 --- a/gui_inst.c +++ b/gui_inst.c @@ -97,7 +97,12 @@ static void draw_arrow(struct draw_ctx *ctx, GdkGC *gc, int fill, struct coord p[3]; struct coord side; - side = normalize(sub_vec(to, from), len); + if (from.x == to.x && from.y == to.y) { + side.x = 0; + side.y = -len; + } else { + side = normalize(sub_vec(to, from), len); + } p[0] = add_vec(to, rotate(side, 180-angle)); p[1] = to; p[2] = add_vec(to, rotate(side, 180+angle)); @@ -267,7 +272,7 @@ unit_type gui_dist_arc(struct inst *self, struct coord pos, unit_type scale) struct coord c = self->base; struct coord p; unit_type r, d_min, d; - double angle, a2; + double angle, a1, a2; r = self->u.arc.width/scale/2; if (r < SELECT_R) @@ -297,10 +302,15 @@ unit_type gui_dist_arc(struct inst *self, struct coord pos, unit_type scale) /* see if we're close to the part that's actually drawn */ angle = theta(c, pos); + a1 = self->u.arc.a1; a2 = self->u.arc.a2; - if (a2 < self->u.arc.a1) - a2 += 180; - return angle >= self->u.arc.a1 && angle <= a2 ? d : -1; + if (angle < 0) + angle += 360; + if (a2 < a1) + a2 += 360; + if (angle < a1) + angle += 360; + return angle >= a1 && angle <= a2 ? d : -1; } diff --git a/gui_util.c b/gui_util.c index 7d34c2b..aa9f249 100644 --- a/gui_util.c +++ b/gui_util.c @@ -103,8 +103,13 @@ void restore_pix_buf(struct pix_buf *buf) void draw_arc(GdkDrawable *da, GdkGC *gc, int fill, int x, int y, int r, double a1, double a2) { - if (a1 == a2) - a2 = a1+360; + /* + * This adjustment handles two distinct cases: + * - if a1 == a2, we make sure we draw a full circle + * - the end angle a2 must always be greater than the start angle a1 + */ + if (a2 <= a1) + a2 += 360; gdk_draw_arc(da, gc, fill, x-r, y-r, 2*r, 2*r, a1*64, (a2-a1)*64); }