r5375 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Mon Aug 3 19:58:32 CEST 2009


Author: werner
Date: 2009-08-03 19:58:32 +0200 (Mon, 03 Aug 2009)
New Revision: 5375

Added:
   trunk/eda/fped/tab.fpd
Modified:
   trunk/eda/fped/README
   trunk/eda/fped/TODO
   trunk/eda/fped/fpd.l
   trunk/eda/fped/fpd.y
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/obj.c
   trunk/eda/fped/obj.h
Log:
- keyboard functions for the canvas: - zoom out, + or = zoom in, . center,
  * zoom and center to extents
- variables in tables weren't properly initialized, causing stray recursive
  evaluation errors
- replaced table->active index with table->active_row pointer
- added row selection
- for fun, added tab.fpd row selection example 



Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README	2009-08-03 16:12:47 UTC (rev 5374)
+++ trunk/eda/fped/README	2009-08-03 17:58:32 UTC (rev 5375)
@@ -337,3 +337,15 @@
 Expressions can contain numeric constants (in non-exponential notation),
 variable names, the arithmetic operations +, -, *, /, and unary -.
 Parentheses can be used to change precedence.
+
+
+GUI
+---
+
+Keys:
+
+space	reset user coordinates
++, =	zoom in (like mouse wheel forward)
+-	zoom out (like mouse wheel backward)
+.	cursor position to screen center (like middle click)
+*	zoom and center to extents

Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO	2009-08-03 16:12:47 UTC (rev 5374)
+++ trunk/eda/fped/TODO	2009-08-03 17:58:32 UTC (rev 5375)
@@ -1,5 +1,4 @@
 Missing features:
-- add row selection
 - populate input area (still needed: mm/mil, rezoom)
 - add vec editor (need to be able to edit name, x, and y)
 - add obj editor

Modified: trunk/eda/fped/fpd.l
===================================================================
--- trunk/eda/fped/fpd.l	2009-08-03 16:12:47 UTC (rev 5374)
+++ trunk/eda/fped/fpd.l	2009-08-03 17:58:32 UTC (rev 5375)
@@ -121,6 +121,8 @@
 					BEGIN(INITIAL);
 				  lineno++; }
 
+;				BEGIN(INITIAL);
+
 "{"				{ BEGIN(NOKEYWORD);
 				  disable_keywords = is_table;
 				  return '{'; }

Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y	2009-08-03 16:12:47 UTC (rev 5374)
+++ trunk/eda/fped/fpd.y	2009-08-03 17:58:32 UTC (rev 5375)
@@ -249,7 +249,7 @@
 			$$ = $<table>2;
 			$$->vars = $4;
 			$$->rows = $6;
-			$$->active = 0;
+			$$->active_row = $6;
 			next_table = &$$->next;
 		}
 	;
@@ -272,7 +272,7 @@
 var:
 	ID
 		{
-			$$ = alloc_type(struct var);
+			$$ = zalloc_type(struct var);
 			$$->name = $1;
 			$$->frame = curr_frame;
 			$$->next = NULL;

Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c	2009-08-03 16:12:47 UTC (rev 5374)
+++ trunk/eda/fped/gui.c	2009-08-03 17:58:32 UTC (rev 5375)
@@ -128,8 +128,8 @@
 	struct value *value = data;
 
         label_in_box_bg(value->widget,
-	    value->row && value->row->table && value->row->table->curr_row ==
-	     value->row ? COLOR_CHOICE_SELECTED : COLOR_EXPR_PASSIVE);
+	    value->row && value->row->table->active_row == value->row ?
+	     COLOR_CHOICE_SELECTED : COLOR_EXPR_PASSIVE);
 }
 
 
@@ -141,7 +141,6 @@
 }
 
 
-
 /* ----- assignments ------------------------------------------------------- */
 
 
@@ -201,6 +200,19 @@
 /* ----- tables ------------------------------------------------------------ */
 
 
+static void select_row(struct row *row)
+{
+	struct table *table = row->table;
+	struct value *value;
+
+	for (value = table->active_row->values; value; value = value->next)
+		label_in_box_bg(value->widget, COLOR_ROW_UNSELECTED);
+	table->active_row = row;
+	for (value = table->active_row->values; value; value = value->next)
+		label_in_box_bg(value->widget, COLOR_ROW_SELECTED);
+}
+
+
 static gboolean table_var_select_event(GtkWidget *widget,
      GdkEventButton *event, gpointer data)
 {
@@ -212,7 +224,14 @@
 static gboolean table_value_select_event(GtkWidget *widget,
      GdkEventButton *event, gpointer data)
 {
-	edit_value(data);
+	struct value *value = data;
+
+	if (!value->row || value->row->table->active_row == value->row)
+		edit_value(value);
+	else {
+		select_row(value->row);
+		change_world();
+	}
 	return TRUE;
 }
 
@@ -272,7 +291,7 @@
 			    box_of_label(field),
 			    n_vars, n_vars+1,
 			    n_rows+1, n_rows+2);
-			label_in_box_bg(field, table->active == n_rows ?
+			label_in_box_bg(field, table->active_row == row ?
 			    COLOR_ROW_SELECTED : COLOR_ROW_UNSELECTED);
 			g_signal_connect(G_OBJECT(box_of_label(field)),
 			    "button_press_event",

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c	2009-08-03 16:12:47 UTC (rev 5374)
+++ trunk/eda/fped/gui_canvas.c	2009-08-03 17:58:32 UTC (rev 5375)
@@ -228,6 +228,21 @@
 		user_origin = pos;
 		update_pos(pos);
 		break;
+	case '+':
+	case '=':
+		zoom_in(pos);
+		break;
+	case '-':
+		zoom_out(pos);
+		break;
+	case '*':
+		center();
+		auto_scale();
+		redraw();
+	case '.':
+		ctx.center = pos;
+		redraw();
+		break;
 	}
 	return TRUE;
 }

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c	2009-08-03 16:12:47 UTC (rev 5374)
+++ trunk/eda/fped/obj.c	2009-08-03 17:58:32 UTC (rev 5375)
@@ -223,18 +223,13 @@
 static int iterate_tables(struct frame *frame, struct table *table,
     struct coord base, int active)
 {
-	int n;
-
 	if (!table)
 		return run_loops(frame, frame->loops, base, active);
-	n = 0;
 	for (table->curr_row = table->rows; table->curr_row;
-	    table->curr_row = table->curr_row->next) {
+	    table->curr_row = table->curr_row->next)
 		if (!iterate_tables(frame, table->next, base,
-		    active && table->active == n))
+		    active && table->active_row == table->curr_row))
 			return 0;
-		n++;
-	}
 	return 1;
 }
 

Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h	2009-08-03 16:12:47 UTC (rev 5374)
+++ trunk/eda/fped/obj.h	2009-08-03 17:58:32 UTC (rev 5375)
@@ -62,7 +62,7 @@
 	struct row *curr_row;
 
 	/* GUI use */
-	int active;	/* n-th row is active, 0 based */
+	struct row *active_row;
 };
 
 struct loop {

Added: trunk/eda/fped/tab.fpd
===================================================================
--- trunk/eda/fped/tab.fpd	                        (rev 0)
+++ trunk/eda/fped/tab.fpd	2009-08-03 17:58:32 UTC (rev 5375)
@@ -0,0 +1,14 @@
+/*
+ * row selection example
+ */
+
+table
+    { x, x2 }
+    { 1mm, 1 }
+    { 2mm, 4 }
+    { 3mm, 9 }
+vec @(x, 0mm)
+circ @ .
+c: vec @(x-1mm, -4mm)
+vec c(0.5mm, 0.5mm)
+pad "$x2" c .




More information about the commitlog mailing list