r5401 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Fri Aug 7 18:19:24 CEST 2009


Author: werner
Date: 2009-08-07 18:19:23 +0200 (Fri, 07 Aug 2009)
New Revision: 5401

Modified:
   trunk/eda/fped/TODO
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_style.h
   trunk/eda/fped/gui_tools.c
   trunk/eda/fped/gui_tools.h
   trunk/eda/fped/gui_util.c
   trunk/eda/fped/gui_util.h
   trunk/eda/fped/inst.c
Log:
- zoom out now doesn't stop before there is a significant border around the 
  drawing
- zoom to frame was broken because it didn't track the recent change in
  location of active flag
- we can now pan and zoom while dragging 
- gui_canvas.c:button_release_event didn't consider the button, making 
  centering also end dragging



Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO	2009-08-07 13:37:51 UTC (rev 5400)
+++ trunk/eda/fped/TODO	2009-08-07 16:19:23 UTC (rev 5401)
@@ -24,7 +24,6 @@
 Bugs:
 - default silk width has no business being hard-coded in obj.c
 - undelete only works if not much has changed since the deletion
-- re-center while dragging confuses the save-under mechanism
 
 Code cleanup:
 - merge edit_unique with edit_name

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c	2009-08-07 13:37:51 UTC (rev 5400)
+++ trunk/eda/fped/gui_canvas.c	2009-08-07 16:19:23 UTC (rev 5401)
@@ -104,6 +104,7 @@
 	gdk_draw_rectangle(ctx.widget->window, gc_bg, TRUE, 0, 0, aw, ah);
 
 	inst_draw(&ctx);
+	tool_redraw(&ctx);
 }
 
 
@@ -198,7 +199,10 @@
 {
 	struct coord pos = canvas_to_coord(&ctx, event->x, event->y);
 
-	if (dragging) {
+	switch (event->button) {
+	case 1:
+		if (!dragging)
+			break;
 		dragging = 0;
 		if (hypot(pos.x-drag_start.x, pos.y-drag_start.y)/ctx.scale < 
 		    DRAG_MIN_R)
@@ -207,6 +211,7 @@
 			if (tool_end_drag(&ctx, pos))
 				change_world();
 		}
+		break;
 	}
 	return TRUE;
 }
@@ -234,9 +239,10 @@
 	bbox = inst_get_bbox();
 	bbox.min = translate(&ctx, bbox.min);
 	bbox.max = translate(&ctx, bbox.max);
-	if (bbox.min.x >= 0 && bbox.max.y >= 0 &&
-	    bbox.max.x < ctx.widget->allocation.width &&
-	    bbox.min.y < ctx.widget->allocation.height)
+	if (bbox.min.x >= ZOOM_STOP_BORDER &&
+	    bbox.max.y >= ZOOM_STOP_BORDER &&
+	    bbox.max.x < ctx.widget->allocation.width-ZOOM_STOP_BORDER &&
+	    bbox.min.y < ctx.widget->allocation.height-ZOOM_STOP_BORDER)
 		return;
 	ctx.scale *= 2;
 	ctx.center.x = 2*ctx.center.x-pos.x;

Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h	2009-08-07 13:37:51 UTC (rev 5400)
+++ trunk/eda/fped/gui_style.h	2009-08-07 16:19:23 UTC (rev 5401)
@@ -24,6 +24,9 @@
 
 #define	CANVAS_CLEARANCE	10
 
+#define	ZOOM_STOP_BORDER	50	/* stop zoom if we have at least a 50
+					   pixel border */
+
 #define	VEC_ARROW_LEN		10
 #define	VEC_ARROW_ANGLE		20
 #define	VEC_EYE_R		5

Modified: trunk/eda/fped/gui_tools.c
===================================================================
--- trunk/eda/fped/gui_tools.c	2009-08-07 13:37:51 UTC (rev 5400)
+++ trunk/eda/fped/gui_tools.c	2009-08-07 16:19:23 UTC (rev 5401)
@@ -59,7 +59,6 @@
 static struct inst *hover_inst = NULL;
 static GtkWidget *frame_image, *frame_image_locked, *frame_image_ready;
 
-
 static struct drag_state {
 	struct inst *inst; /* non-NULL if dragging an existing object */
 	struct inst *new; /* non-NULL if dragging a new object */
@@ -72,6 +71,7 @@
 };
 
 static struct pix_buf *pix_buf;
+static struct coord last_canvas_pos;
 
 
 static struct vec *new_vec(struct inst *base)
@@ -706,6 +706,7 @@
 
 	assert(!drag.new);
 	assert(!drag.anchors_n);
+	last_canvas_pos = translate(ctx, pos);
 	curr = inst_find_point(ctx, pos);
 	if (!curr)
 		return 0;
@@ -736,6 +737,7 @@
 {
 	if (pix_buf)
 		restore_pix_buf(pix_buf);
+	last_canvas_pos = translate(ctx, to);
 	tool_hover(ctx, to);
 	pix_buf = drag.new ? active_ops->drag_new(ctx, drag.new, to) :
 	    inst_draw_move(drag.inst, ctx, to, drag.anchor_i);
@@ -746,8 +748,10 @@
 {
 	tool_dehover(ctx);
 	tool_reset();
-	if (pix_buf)
+	if (pix_buf) {
 		restore_pix_buf(pix_buf);
+		pix_buf = NULL;
+	}
 	drag.new = NULL;
 	active_ops = NULL;
 	drag.anchors_n = 0;
@@ -776,6 +780,18 @@
 }
 
 
+void tool_redraw(struct draw_ctx *ctx)
+{
+	if (!drag.new && !drag.anchors_n)
+		return;
+	if (pix_buf)
+		free_pix_buf(pix_buf);
+	pix_buf = NULL;
+	tool_drag(ctx, canvas_to_coord(ctx,
+	    last_canvas_pos.x, last_canvas_pos.y));
+}
+
+
 /* ----- tool bar creation ------------------------------------------------- */
 
 

Modified: trunk/eda/fped/gui_tools.h
===================================================================
--- trunk/eda/fped/gui_tools.h	2009-08-07 13:37:51 UTC (rev 5400)
+++ trunk/eda/fped/gui_tools.h	2009-08-07 16:19:23 UTC (rev 5401)
@@ -42,6 +42,7 @@
 void tool_drag(struct draw_ctx *ctx, struct coord to);
 void tool_cancel_drag(struct draw_ctx *ctx);
 int tool_end_drag(struct draw_ctx *ctx, struct coord to);
+void tool_redraw(struct draw_ctx *ctx);
 
 /*
  * Cache the frame and track it.

Modified: trunk/eda/fped/gui_util.c
===================================================================
--- trunk/eda/fped/gui_util.c	2009-08-07 13:37:51 UTC (rev 5400)
+++ trunk/eda/fped/gui_util.c	2009-08-07 16:19:23 UTC (rev 5401)
@@ -51,6 +51,13 @@
 /* ----- backing store ----------------------------------------------------- */
 
 
+void free_pix_buf(struct pix_buf *buf)
+{
+	g_object_unref(G_OBJECT(buf->buf));
+	free(buf);
+}
+
+
 struct pix_buf *save_pix_buf(GdkDrawable *da, int xa, int ya, int xb, int yb,
     int border)
 {
@@ -92,8 +99,7 @@
 {
 	gdk_draw_pixbuf(buf->da, NULL, buf->buf, 0, 0, buf->x, buf->y, -1, -1,
 	    GDK_RGB_DITHER_NORMAL, 0, 0);
-	g_object_unref(G_OBJECT(buf->buf));
-	free(buf);
+	free_pix_buf(buf);
 }
 
 

Modified: trunk/eda/fped/gui_util.h
===================================================================
--- trunk/eda/fped/gui_util.h	2009-08-07 13:37:51 UTC (rev 5400)
+++ trunk/eda/fped/gui_util.h	2009-08-07 16:19:23 UTC (rev 5401)
@@ -28,6 +28,7 @@
 
 void set_width(GdkGC *gc, int width);
 
+void free_pix_buf(struct pix_buf *buf);
 struct pix_buf *save_pix_buf(GdkDrawable *da, int xa, int ya, int xb, int yb,
     int border);
 void restore_pix_buf(struct pix_buf *buf);

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c	2009-08-07 13:37:51 UTC (rev 5400)
+++ trunk/eda/fped/inst.c	2009-08-07 16:19:23 UTC (rev 5401)
@@ -763,7 +763,7 @@
 	curr_frame = curr_frame->outer;
 	if (curr_frame)
 		propagate_bbox(inst);
-	if (inst->active && frame == active_frame)
+	if (inst->u.frame.active && frame == active_frame)
 		active_frame_bbox = inst->bbox;
 }
 




More information about the commitlog mailing list