r5462 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Sun Aug 16 14:04:01 CEST 2009


Author: werner
Date: 2009-08-16 14:04:01 +0200 (Sun, 16 Aug 2009)
New Revision: 5462

Modified:
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_canvas.h
   trunk/eda/fped/gui_frame.c
   trunk/eda/fped/gui_meas.c
   trunk/eda/fped/inst.c
Log:
- adjust measurement bbox for projection (still not perfect, but better)
- we can now scroll-wheel through table rows
- added menu branch "View" with zoom and var/code display controls
- commented out is_min_of_next until its fate is decided, so that we don't get 
  a warning



Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c	2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui.c	2009-08-16 12:04:01 UTC (rev 5462)
@@ -39,18 +39,37 @@
 static GtkWidget *stuff_image[2], *meas_image[2];
 
 
+/* ----- view callbacks ---------------------------------------------------- */
+
+
+static void swap_var_code(void)
+{
+	extern int show_vars;
+
+	show_vars = !show_vars;
+	change_world();
+}
+
+
 /* ----- menu bar ---------------------------------------------------------- */
 
 
 static GtkItemFactoryEntry menu_entries[] = {
 	{ "/File",		NULL,	NULL,	 	0, "<Branch>" },
 	{ "/File/Save",		NULL,	save_fpd,	0, "<Item>" },
-        { "/File/sep0",		NULL,	NULL,		0, "<Separator>" },
+        { "/File/sep1",		NULL,	NULL,		0, "<Separator>" },
         { "/File/Write KiCad",	NULL,	write_kicad,	0, "<Item>" },
         { "/File/Write Postscript",
 				NULL,	write_ps,	0, "<Item>" },
         { "/File/sep2",		NULL,	NULL,		0, "<Separator>" },
         { "/File/Quit",		NULL,	gtk_main_quit,	0, "<Item>" },
+	{ "/View",		NULL,	NULL,		0, "<Branch>" },
+	{ "/View/Zoom in",	NULL,	zoom_in_center,	0, "<Item>" },
+	{ "/View/Zoom out",	NULL,	zoom_out_center,0, "<Item>" },
+	{ "/View/Zoom all",	NULL,	zoom_to_extents,0, "<Item>" },
+	{ "/View/Zoom frame",	NULL,	zoom_to_frame,	0, "<Item>" },
+	{ "/View/sep1",		NULL,	NULL,		0, "<Separator>" },
+	{ "/View/Swap var&code",NULL,	swap_var_code,	0, "<Item>" },
 };
 
 

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c	2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui_canvas.c	2009-08-16 12:04:01 UTC (rev 5462)
@@ -279,6 +279,38 @@
 }
 
 
+void zoom_in_center(void)
+{
+	zoom_in(draw_ctx.center);
+}
+
+
+void zoom_out_center(void)
+{
+	zoom_out(draw_ctx.center);
+}
+
+
+void zoom_to_frame(void)
+{
+	tool_dehover();
+	center(&active_frame_bbox);
+	auto_scale(&active_frame_bbox);
+	redraw();
+	tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
+}
+
+
+void zoom_to_extents(void)
+{
+	tool_dehover();
+	center(NULL);
+	auto_scale(NULL);
+	redraw();
+	tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
+}
+
+
 static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
     gpointer data)
 {
@@ -321,18 +353,10 @@
 		zoom_out(pos);
 		break;
 	case '*':
-		tool_dehover();
-		center(NULL);
-		auto_scale(NULL);
-		redraw();
-		tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
+		zoom_to_extents();
 		break;
 	case '#':
-		tool_dehover();
-		center(&active_frame_bbox);
-		auto_scale(&active_frame_bbox);
-		redraw();
-		tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
+		zoom_to_frame();
 		break;
 	case '.':
 		tool_dehover();

Modified: trunk/eda/fped/gui_canvas.h
===================================================================
--- trunk/eda/fped/gui_canvas.h	2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui_canvas.h	2009-08-16 12:04:01 UTC (rev 5462)
@@ -29,6 +29,11 @@
 
 void redraw(void);
 
+void zoom_in_center(void);
+void zoom_out_center(void);
+void zoom_to_frame(void);
+void zoom_to_extents(void);
+
 GtkWidget *make_canvas(void);
 void init_canvas(void);
 

Modified: trunk/eda/fped/gui_frame.c
===================================================================
--- trunk/eda/fped/gui_frame.c	2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui_frame.c	2009-08-16 12:04:01 UTC (rev 5462)
@@ -743,6 +743,34 @@
 }
 
 
+static gboolean table_scroll_event(GtkWidget *widget, GdkEventScroll *event,
+    gpointer data)
+{
+	struct table *table = data;
+	struct row *row, *last;
+
+	switch (event->direction) {
+	case GDK_SCROLL_UP:
+		last = NULL;
+		for (row = table->rows;
+		    row && (!last || row != table->active_row); row = row->next)
+			last = row;
+		table->active_row = last;
+		change_world();
+		break;
+	case GDK_SCROLL_DOWN:
+		table->active_row = table->active_row->next;
+		if (!table->active_row)
+			table->active_row = table->rows;
+		change_world();
+		break;
+	default:
+		/* ignore */;
+	}
+	return TRUE;
+}
+
+
 static void build_table(GtkWidget *vbox, struct frame *frame,
     struct table *table)
 {
@@ -786,6 +814,9 @@
 		g_signal_connect(G_OBJECT(box_of_label(field)),
 		    "button_press_event",
 		    G_CALLBACK(table_var_select_event), var);
+		g_signal_connect(G_OBJECT(box_of_label(field)),
+		    "scroll_event",
+		    G_CALLBACK(table_scroll_event), table);
 		var->widget = field;
 		n_vars++;
 	}
@@ -805,6 +836,9 @@
 			g_signal_connect(G_OBJECT(box_of_label(field)),
 			    "button_press_event",
 			    G_CALLBACK(table_value_select_event), value);
+			g_signal_connect(G_OBJECT(box_of_label(field)),
+			    "scroll_event",
+			    G_CALLBACK(table_scroll_event), table);
 			value->widget = field;
 			n_vars++;
 		}

Modified: trunk/eda/fped/gui_meas.c
===================================================================
--- trunk/eda/fped/gui_meas.c	2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui_meas.c	2009-08-16 12:04:01 UTC (rev 5462)
@@ -102,6 +102,7 @@
 }
 
 
+#if 0
 static int is_min_of_next(lt_op_type lt,
     const struct inst *inst, const struct inst *ref)
 {
@@ -111,6 +112,7 @@
 	next = meas_find_next(lt, ref->vec->samples, min);
 	return coord_eq(next, ref->u.rect.end);
 }
+#endif
 
 
 /* ----- picker functions -------------------------------------------------- */

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c	2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/inst.c	2009-08-16 12:04:01 UTC (rev 5462)
@@ -879,14 +879,18 @@
     struct coord from, struct coord to, unit_type offset)
 {
 	struct inst *inst;
+	struct coord a1, b1;
 
 	inst = add_inst(&meas_ops, ip_meas, from);
 	inst->obj = obj;
 	inst->u.meas.end = to;
 	inst->u.meas.offset = offset;
 	inst->active = 1; /* measurements are always active */
-	/* @@@ our bbox is actually a bit more complex than this */
+	/* @@@ we still need to consider the text size as well */
 	update_bbox(&inst->bbox, to);
+	project_meas(inst, &a1, &b1);
+	update_bbox(&inst->bbox, a1);
+	update_bbox(&inst->bbox, b1);
 	propagate_bbox(inst);
 	return 1;
 }




More information about the commitlog mailing list