r5326 - developers/werner/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Tue Jul 28 13:38:14 CEST 2009


Author: werner
Date: 2009-07-28 13:38:13 +0200 (Tue, 28 Jul 2009)
New Revision: 5326

Added:
   developers/werner/fped/TODO
   developers/werner/fped/coord.c
   developers/werner/fped/gui_canvas.c
   developers/werner/fped/gui_canvas.h
   developers/werner/fped/gui_status.c
   developers/werner/fped/gui_status.h
Modified:
   developers/werner/fped/Makefile
   developers/werner/fped/coord.h
   developers/werner/fped/gui.c
   developers/werner/fped/gui_inst.c
   developers/werner/fped/gui_inst.h
   developers/werner/fped/gui_style.h
   developers/werner/fped/qfn.fpd
Log:
- added to do list
- vectors now have arrow heads
- breaking gui.c down into smaller parts
- added status area
- added zoom and centering

Still a lot more to do.



Modified: developers/werner/fped/Makefile
===================================================================
--- developers/werner/fped/Makefile	2009-07-27 07:30:59 UTC (rev 5325)
+++ developers/werner/fped/Makefile	2009-07-28 11:38:13 UTC (rev 5326)
@@ -1,5 +1,5 @@
-OBJS = fped.o expr.o obj.o inst.o util.o error.o lex.yy.o y.tab.o \
-       gui.o gui_style.o gui_inst.o
+OBJS = fped.o expr.o coord.o obj.o inst.o util.o error.o lex.yy.o y.tab.o \
+       gui.o gui_style.o gui_inst.o gui_status.o gui_canvas.o
 
 CFLAGS_GTK = `pkg-config --cflags gtk+-2.0`
 LIBS_GTK = `pkg-config --libs gtk+-2.0`

Added: developers/werner/fped/TODO
===================================================================
--- developers/werner/fped/TODO	                        (rev 0)
+++ developers/werner/fped/TODO	2009-07-28 11:38:13 UTC (rev 5326)
@@ -0,0 +1,23 @@
+- make frame selection work
+- add table/var/loop representation
+- Q: should loop be (start, last) or (start, iterations) ?
+- add row selection
+- change vector circle color (also, highlight on hover ?)
+- stack elements (1): frames, pads, silk, vecs
+- stack elements (2): all unselected below all selected
+- stack elements (3): circle on top of vec
+- detect recursive evaluation
+- eliminate duplicate instances
+- populate input area
+- bug: center moves in qfn.fpd
+- bug: pad and silk geometry doesn't match in qfn.fpd
+- add vec editor
+- add obj editor
+- decide on table presentation
+- add table/var/loop editor
+- add incremental expression parser (for editor)
+- make units part of value and check for conformity
+- add default unit (combine with grid unit selection ?)
+- consider adding auto/mm/mil selection for each dimension
+- syntax seems a little cryptic. too many dots and at signs.
+- added measurements

Added: developers/werner/fped/coord.c
===================================================================
--- developers/werner/fped/coord.c	                        (rev 0)
+++ developers/werner/fped/coord.c	2009-07-28 11:38:13 UTC (rev 5326)
@@ -0,0 +1,62 @@
+/*
+ * coord.c - Coordinate representation and basic operations
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#include <math.h>
+
+#include "coord.h"
+
+
+struct coord normalize(struct coord v, unit_type len)
+{
+	double f;
+
+	f = len/hypot(v.x, v.y);
+	v.x *= f;
+	v.y *= f;
+	return v;
+}
+
+
+struct coord rotate(struct coord v, double angle)
+{
+	double rad = M_PI*angle/180.0;
+	struct coord res;
+
+	res.x = v.x*cos(rad)-v.y*sin(rad);
+	res.y = v.y*cos(rad)+v.x*sin(rad);
+	return res;
+}
+
+
+struct coord add_vec(struct coord a, struct coord b)
+{
+	a.x += b.x;
+	a.y += b.y;
+	return a;
+}
+
+
+struct coord sub_vec(struct coord a, struct coord b)
+{
+	a.x -= b.x;
+	a.y -= b.y;
+	return a;
+}
+
+
+struct coord neg_vec(struct coord v)
+{
+	v.x = -v.x; 
+	v.y = -v.y;
+	return v;
+}

Modified: developers/werner/fped/coord.h
===================================================================
--- developers/werner/fped/coord.h	2009-07-27 07:30:59 UTC (rev 5325)
+++ developers/werner/fped/coord.h	2009-07-28 11:38:13 UTC (rev 5326)
@@ -1,5 +1,5 @@
 /*
- * coord.h - Coordinate representation
+ * coord.h - Coordinate representation and basic operations
  *
  * Written 2009 by Werner Almesberger
  * Copyright 2009 by Werner Almesberger
@@ -57,4 +57,11 @@
 	return (double) u/KICAD_UNIT;
 }
 
+
+struct coord normalize(struct coord v, unit_type len);
+struct coord rotate(struct coord v, double angle);
+struct coord add_vec(struct coord a, struct coord b);
+struct coord sub_vec(struct coord a, struct coord b);
+struct coord neg_vec(struct coord v);
+
 #endif /* !COORD_H */

Modified: developers/werner/fped/gui.c
===================================================================
--- developers/werner/fped/gui.c	2009-07-27 07:30:59 UTC (rev 5325)
+++ developers/werner/fped/gui.c	2009-07-28 11:38:13 UTC (rev 5326)
@@ -15,9 +15,8 @@
 #include <gtk/gtk.h>
 
 #include "obj.h"
-#include "inst.h"
-#include "gui_inst.h"
-#include "gui_style.h"
+#include "gui_status.h"
+#include "gui_canvas.h"
 #include "gui.h"
 
 
@@ -68,60 +67,42 @@
 }
 
 
-static gboolean expose_event_callback(GtkWidget *widget, GdkEventExpose *event,
-     gpointer data)
+static void show_vars(GtkWidget *var_list)
 {
-	static int need_style = 1;
-	struct bbox bbox;
-	unit_type h, w;
-	int sx, sy;
-	float aw, ah;
+	GtkListStore *list;
 
-	struct draw_ctx ctx = {
-		.widget = widget,
-		.scale = 1000,
-		.center = {
-			.x = 0,
-			.y = 0,
-		},
-	};
+	list = gtk_list_store_new(1, G_TYPE_STRING);
 
-	if (need_style) {
-		gui_setup_style(widget->window);
-		need_style = 0;
-	}
+	gtk_tree_view_set_model(GTK_TREE_VIEW(var_list),
+	    GTK_TREE_MODEL(list));
+	g_object_unref(list);
+}
 
-	aw = widget->allocation.width;
-	ah = widget->allocation.height;
-	gdk_draw_rectangle(widget->window, gc_bg, TRUE, 0, 0, aw, ah);
-	bbox = inst_get_bbox();
-	ctx.center.x = (bbox.min.x+bbox.max.x)/2;
-	ctx.center.y = (bbox.min.y+bbox.max.y)/2;
-	h = bbox.max.x-bbox.min.x;
-	w = bbox.max.y-bbox.min.y;
-	aw -= 2*CANVAS_CLEARANCE;
-	ah -= 2*CANVAS_CLEARANCE;
-	if (aw < 1)
-		aw = 1;
-	if (ah < 1)
-		ah = 1;
-	sx = ceil(h/aw);
-	sy = ceil(w/ah);
-	ctx.scale = sx > sy ? sx : sy > 0 ? sy : 1;
-	
-	inst_draw(&ctx);
-	return TRUE;
+
+static void show_rows(GtkWidget *row_list)
+{
+	GtkListStore *list;
+
+	list = gtk_list_store_new(1, G_TYPE_STRING);
+
+	gtk_tree_view_set_model(GTK_TREE_VIEW(row_list),
+	    GTK_TREE_MODEL(list));
+	g_object_unref(list);
 }
 
 
 static void make_center_area(GtkWidget *vbox)
 {
 	GtkWidget *hbox;
-	GtkWidget *frame_list, *sep, *canvas;
+	GtkWidget *frame_list, *var_list, *row_list;
+	GtkWidget *sep;
 	GdkColor black = { 0, 0, 0, 0 };
 
 	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
 
+	/* Frame list */
+
 	frame_list = gtk_tree_view_new();
 	gtk_box_pack_start(GTK_BOX(hbox), frame_list, FALSE, TRUE, 0);
 
@@ -134,22 +115,45 @@
 	gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, TRUE, 2);
 	gtk_widget_modify_bg(sep, GTK_STATE_NORMAL, &black);
 
-	canvas = gtk_drawing_area_new();
-	gtk_box_pack_start(GTK_BOX(hbox), canvas, TRUE, TRUE, 0);
-	gtk_widget_modify_bg(canvas, GTK_STATE_NORMAL, &black);
-	g_signal_connect (G_OBJECT(canvas), "expose_event",
-	    G_CALLBACK(expose_event_callback), NULL);
+	/*
+	 * @@@ is this really a good way to present variables ?
+	 *
+	 * a way to show entire tables may be preferable. also, showing all
+	 * tables of a frame at the same time may be more convenient than such
+	 * a "peephole" access.
+	 */
 
-	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
-}
+	/* Variable list */
 
+	var_list = gtk_tree_view_new();
+	gtk_box_pack_start(GTK_BOX(hbox), var_list, FALSE, TRUE, 0);
 
-static void make_input_area(GtkWidget *vbox)
-{
-	GtkWidget *entry;
+	gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(var_list),
+	    -1, "Variable", gtk_cell_renderer_text_new(), "text", 0, NULL);
 
-	entry = gtk_entry_new();
-	gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
+	show_vars(var_list);
+
+	sep = gtk_drawing_area_new();
+	gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, TRUE, 2);
+	gtk_widget_modify_bg(sep, GTK_STATE_NORMAL, &black);
+
+	/* Row list */
+
+	row_list = gtk_tree_view_new();
+	gtk_box_pack_start(GTK_BOX(hbox), row_list, FALSE, TRUE, 0);
+
+	gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(row_list),
+	    -1, "Row", gtk_cell_renderer_text_new(), "text", 0, NULL);
+
+	show_rows(row_list);
+
+	sep = gtk_drawing_area_new();
+	gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, TRUE, 2);
+	gtk_widget_modify_bg(sep, GTK_STATE_NORMAL, &black);
+
+	/* Canvas */
+
+	make_canvas(hbox);
 }
 
 
@@ -162,7 +166,7 @@
 
 	make_menu_bar(vbox);
 	make_center_area(vbox);
-	make_input_area(vbox);
+	make_status_area(vbox);
 }
 
 

Added: developers/werner/fped/gui_canvas.c
===================================================================
--- developers/werner/fped/gui_canvas.c	                        (rev 0)
+++ developers/werner/fped/gui_canvas.c	2009-07-28 11:38:13 UTC (rev 5326)
@@ -0,0 +1,248 @@
+/*
+ * gui_canvas.c - GUI, canvas
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#include <math.h>
+#include <gtk/gtk.h>
+
+#include "obj.h"
+#include "inst.h"
+#include "gui_inst.h"
+#include "gui_style.h"
+#include "gui_status.h"
+#include "gui.h"
+
+
+struct draw_ctx ctx;
+
+
+/* ----- zoom display ------------------------------------------------------ */
+
+
+static void update_zoom(void)
+{
+	status_set_zoom("x%d", ctx.scale);
+}
+
+
+/* ----- coordinate system ------------------------------------------------- */
+
+
+static void center(void)
+{
+	struct bbox bbox;
+
+	bbox = inst_get_bbox();
+	ctx.center.x = (bbox.min.x+bbox.max.x)/2;
+	ctx.center.y = (bbox.min.y+bbox.max.y)/2;
+}
+
+
+static void auto_scale(void)
+{
+	struct bbox bbox;
+	unit_type h, w;
+	int sx, sy;
+	float aw, ah;
+
+	bbox = inst_get_bbox();
+	aw = ctx.widget->allocation.width;
+	ah = ctx.widget->allocation.height;
+	h = bbox.max.x-bbox.min.x;
+	w = bbox.max.y-bbox.min.y;
+	aw -= 2*CANVAS_CLEARANCE;
+	ah -= 2*CANVAS_CLEARANCE;
+	if (aw < 1)
+		aw = 1;
+	if (ah < 1)
+		ah = 1;
+	sx = ceil(h/aw);
+	sy = ceil(w/ah);
+	ctx.scale = sx > sy ? sx : sy > 0 ? sy : 1;
+
+	update_zoom();
+}
+
+
+/* ----- drawing ----------------------------------------------------------- */
+
+
+static void redraw(void)
+{
+	float aw, ah;
+
+	aw = ctx.widget->allocation.width;
+	ah = ctx.widget->allocation.height;
+	gdk_draw_rectangle(ctx.widget->window, gc_bg, TRUE, 0, 0, aw, ah);
+
+	inst_draw(&ctx);
+}
+
+
+/* ----- drag -------------------------------------------------------------- */
+
+
+static void drag_left(struct coord pos)
+{
+}
+
+
+static void drag_middle(struct coord pos)
+{
+}
+
+
+static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
+     gpointer data)
+{
+	struct coord pos = canvas_to_coord(&ctx, event->x, event->y);
+
+	if (event->state & GDK_BUTTON1_MASK)
+		drag_left(pos);
+	if (event->state & GDK_BUTTON2_MASK)
+		drag_middle(pos);
+	return TRUE;
+}
+
+
+/* ----- button press and release ------------------------------------------ */
+
+
+static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
+     gpointer data)
+{
+	struct coord pos = canvas_to_coord(&ctx, event->x, event->y);
+
+	switch (event->button) {
+	case 1:
+		/* select */ ;
+	case 2:
+		ctx.center = pos;
+		redraw();
+		break;
+	}
+	return TRUE;
+}
+
+
+static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
+     gpointer data)
+{
+printf("R %d\n", event->button);
+	return TRUE;
+}
+
+
+/* ----- zoom control ------------------------------------------------------ */
+
+
+static void zoom_in(struct coord pos)
+{
+	if (ctx.scale < 2)
+		return;
+	ctx.scale /= 2;
+	update_zoom();
+	redraw();
+}
+
+
+static void zoom_out(struct coord pos)
+{
+	struct bbox bbox;
+
+	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)
+		return;
+	ctx.scale *= 2;
+	update_zoom();
+	redraw();
+}
+
+
+static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
+     gpointer data)
+{
+	struct coord pos = canvas_to_coord(&ctx, event->x, event->y);
+
+	switch (event->direction) {
+	case GDK_SCROLL_UP:
+		zoom_in(pos);
+		break;
+	case GDK_SCROLL_DOWN:
+		zoom_out(pos);
+		break;
+	default:
+		/* ignore */;
+	}
+	return TRUE;
+}
+
+
+/* ----- expose event ------------------------------------------------------ */
+
+
+static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event,
+     gpointer data)
+{
+	static int first = 1;
+
+	if (first) {
+		gui_setup_style(widget->window);
+		center();
+		auto_scale();
+		first = 0;
+	}
+
+	redraw();
+
+	return TRUE;
+}
+
+
+/* ----- canvas setup ------------------------------------------------------ */
+
+
+void make_canvas(GtkWidget *hbox)
+{
+	GtkWidget *canvas;
+	GdkColor black = { 0, 0, 0, 0 };
+
+	/* Canvas */
+
+	canvas = gtk_drawing_area_new();
+	gtk_box_pack_start(GTK_BOX(hbox), canvas, TRUE, TRUE, 0);
+	gtk_widget_modify_bg(canvas, GTK_STATE_NORMAL, &black);
+
+	g_signal_connect(G_OBJECT(canvas), "motion_notify_event",
+	    G_CALLBACK(motion_notify_event), NULL);
+	g_signal_connect(G_OBJECT(canvas), "button_press_event",
+	    G_CALLBACK(button_press_event), NULL);
+	g_signal_connect(G_OBJECT(canvas), "button_release_event",
+	    G_CALLBACK(button_release_event), NULL);
+	g_signal_connect(G_OBJECT(canvas), "scroll_event",
+	    G_CALLBACK(scroll_event), NULL);
+
+	g_signal_connect(G_OBJECT(canvas), "expose_event",
+	    G_CALLBACK(expose_event), NULL);
+
+	gtk_widget_set_events(canvas,
+	    GDK_EXPOSE | GDK_LEAVE_NOTIFY_MASK |
+	    GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+	    GDK_SCROLL |
+	    GDK_POINTER_MOTION_MASK);
+
+	ctx.widget = canvas;
+}

Added: developers/werner/fped/gui_canvas.h
===================================================================
--- developers/werner/fped/gui_canvas.h	                        (rev 0)
+++ developers/werner/fped/gui_canvas.h	2009-07-28 11:38:13 UTC (rev 5326)
@@ -0,0 +1,22 @@
+/*
+ * gui_canvas.h - GUI, canvas
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#ifndef GUI_CANVAS_H
+#define GUI_CANVAS_H
+
+#include <gtk/gtk.h>
+
+
+void make_canvas(GtkWidget *vbox) ;
+
+#endif /* !GUI_CANVAS_H */

Modified: developers/werner/fped/gui_inst.c
===================================================================
--- developers/werner/fped/gui_inst.c	2009-07-27 07:30:59 UTC (rev 5325)
+++ developers/werner/fped/gui_inst.c	2009-07-28 11:38:13 UTC (rev 5326)
@@ -11,6 +11,7 @@
  */
 
 
+#include <stdlib.h>
 #include <gtk/gtk.h>
 
 #include "inst.h"
@@ -22,7 +23,7 @@
 #define DA	GDK_DRAWABLE(ctx->widget->window)
 
 
-static struct coord translate(const struct draw_ctx *ctx, struct coord pos)
+struct coord translate(const struct draw_ctx *ctx, struct coord pos)
 {
 	pos.x -= ctx->center.x;
 	pos.y -= ctx->center.y;
@@ -36,6 +37,19 @@
 }
 
 
+struct coord canvas_to_coord(const struct draw_ctx *ctx, int x, int y)
+{
+	struct coord pos;
+
+	x -= ctx->widget->allocation.width/2;
+	y -= ctx->widget->allocation.height/2;
+        y = -y;
+        pos.x = x*ctx->scale+ctx->center.x;
+        pos.y = y*ctx->scale+ctx->center.y;
+	return pos;
+}
+
+
 /* ----- drawing primitives ------------------------------------------------ */
 
 
@@ -62,6 +76,39 @@
 }
 
 
+#define MAX_POINTS	10
+
+
+static void draw_poly(struct draw_ctx *ctx, GdkGC *gc, int fill,
+    const struct coord *points, int n_points)
+{
+	GdkPoint gp[MAX_POINTS];
+	int i;
+
+	if (n_points > MAX_POINTS)
+		abort();
+	for (i = 0; i != n_points; i++) {
+		gp[i].x = points[i].x;
+		gp[i].y = points[i].y;
+	}
+	gdk_draw_polygon(DA, gc, fill, gp, n_points);
+}
+
+
+static void draw_arrow(struct draw_ctx *ctx, GdkGC *gc, int fill,
+    struct coord from, struct coord to, int len, double angle)
+{
+	struct coord p[3];
+	struct coord side;
+
+	side = normalize(sub_vec(to, from), VEC_ARROW_LEN);
+	p[0] = to;
+	p[1] = add_vec(to, rotate(side, 180-VEC_ARROW_ANGLE));
+	p[2] = add_vec(to, rotate(side, 180+VEC_ARROW_ANGLE));
+	draw_poly(ctx, gc, fill, p, 3);
+}
+
+
 /* ----- vec --------------------------------------------------------------- */
 
 
@@ -71,8 +118,9 @@
 	struct coord to = translate(ctx, self->u.end);
 
 	draw_circle(ctx, gc_vec_bg, FALSE, to.x, to.y, VEC_EYE_R);
+	draw_arrow(ctx, gc_vec_bg, TRUE, from, to,
+	  VEC_ARROW_LEN, VEC_ARROW_ANGLE);
 	gdk_draw_line(DA, gc_vec_bg, from.x, from.y, to.x, to.y);
-
 }
 
 
@@ -97,7 +145,7 @@
 	struct coord max = translate(ctx, self->bbox.max);
 
 	gdk_draw_rectangle(DA, gc_rect_bg, FALSE,
-	    min.x, max.y, max.x-min.x+1, min.y-max.y+1);
+	    min.x, max.y, max.x-min.x, min.y-max.y);
 }
 
 
@@ -111,7 +159,7 @@
 
 	/* @@@ name */
 	gdk_draw_rectangle(DA, gc_pad_bg, TRUE,
-	    min.x, max.y, max.x-min.x+1, min.y-max.y+1);
+	    min.x, max.y, max.x-min.x, min.y-max.y);
 }
 
 

Modified: developers/werner/fped/gui_inst.h
===================================================================
--- developers/werner/fped/gui_inst.h	2009-07-27 07:30:59 UTC (rev 5325)
+++ developers/werner/fped/gui_inst.h	2009-07-28 11:38:13 UTC (rev 5326)
@@ -27,6 +27,9 @@
 };
 
 
+struct coord translate(const struct draw_ctx *ctx, struct coord pos);
+struct coord canvas_to_coord(const struct draw_ctx *ctx, int x, int y);
+
 void gui_draw_vec(struct inst *self, struct draw_ctx *ctx);
 void gui_draw_line(struct inst *self, struct draw_ctx *ctx);
 void gui_draw_rect(struct inst *self, struct draw_ctx *ctx);

Added: developers/werner/fped/gui_status.c
===================================================================
--- developers/werner/fped/gui_status.c	                        (rev 0)
+++ developers/werner/fped/gui_status.c	2009-07-28 11:38:13 UTC (rev 5326)
@@ -0,0 +1,128 @@
+/*
+ * gui_status.c - GUI, status area
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <gtk/gtk.h>
+
+#include "gui_status.h"
+
+
+static GtkWidget *status_name, *status_entry;
+static GtkWidget *status_x, *status_y;
+static GtkWidget *status_r, *status_angle;
+static GtkWidget *status_sys_pos, *status_user_pos;
+static GtkWidget *status_zoom, *status_grid;
+static GtkWidget *status_msg;
+
+
+static void set_label(GtkWidget *label, const char *fmt, va_list ap)
+{
+	char buf[100]; /* @@@ enough :-) */
+
+	vsprintf(buf, fmt, ap);
+	gtk_label_set_text(GTK_LABEL(label), buf);
+}
+
+
+#define	SETTER(name)					\
+	void status_set_##name(const char *fmt, ...)	\
+	{						\
+		va_list ap;				\
+							\
+		va_start(ap, fmt);			\
+		set_label(status_##name, fmt, ap);	\
+		va_end(ap);				\
+	}
+
+SETTER(name)
+SETTER(x)
+SETTER(y)
+SETTER(r)
+SETTER(angle)
+SETTER(sys_pos)
+SETTER(user_pos)
+SETTER(zoom)
+SETTER(grid)
+
+
+void make_status_area(GtkWidget *vbox)
+{
+	GtkWidget *hbox, *v2box;
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+	/* name and input */
+
+	v2box = gtk_vbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), v2box, TRUE, TRUE, 1);
+
+	status_name = gtk_label_new("<name>");
+	gtk_box_pack_start(GTK_BOX(v2box), status_name, FALSE, FALSE, 1);
+	/* @@@ how to make label fill the space on the right - add a hbox ? */
+//	gtk_label_set_justify(GTK_LABEL(status_name), GTK_JUSTIFY_LEFT);
+	gtk_label_set_selectable(GTK_LABEL(status_name), TRUE);
+
+	status_entry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(v2box), status_entry, TRUE, FALSE, 1);
+
+	/* x / y */
+
+	v2box = gtk_vbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), v2box, FALSE, FALSE, 1);
+
+	status_x = gtk_label_new("x = ...");
+	gtk_box_pack_start(GTK_BOX(v2box), status_x, TRUE, FALSE, 1);
+
+	status_y = gtk_label_new("y = ...");
+	gtk_box_pack_start(GTK_BOX(v2box), status_y, FALSE, FALSE, 1);
+
+	/* r / angle */
+
+	v2box = gtk_vbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), v2box, FALSE, FALSE, 1);
+
+	status_r = gtk_label_new("r = ...");
+	gtk_box_pack_start(GTK_BOX(v2box), status_r, TRUE, FALSE, 1);
+
+	status_angle = gtk_label_new("a = ...");
+	gtk_box_pack_start(GTK_BOX(v2box), status_angle, TRUE, FALSE, 1);
+
+	/* sys / user pos */
+
+	v2box = gtk_vbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), v2box, TRUE, TRUE, 1);
+
+	status_sys_pos = gtk_label_new("1 / 2");
+	gtk_box_pack_start(GTK_BOX(v2box), status_sys_pos, TRUE, FALSE, 1);
+
+	status_user_pos = gtk_label_new("1 / 2");
+	gtk_box_pack_start(GTK_BOX(v2box), status_user_pos, TRUE, FALSE, 1);
+
+	/* zoom / grid */
+
+	v2box = gtk_vbox_new(FALSE, 0);
+	gtk_box_pack_end(GTK_BOX(hbox), v2box, FALSE, FALSE, 1);
+
+	status_zoom = gtk_label_new("1x");
+	gtk_box_pack_start(GTK_BOX(v2box), status_zoom, TRUE, FALSE, 1);
+
+	status_grid = gtk_label_new("10mil");
+	gtk_box_pack_start(GTK_BOX(v2box), status_grid, TRUE, FALSE, 1);
+
+	/* message bar */
+
+	status_msg = gtk_statusbar_new();
+	gtk_box_pack_start(GTK_BOX(vbox), status_msg, FALSE, FALSE, 0);
+}

Added: developers/werner/fped/gui_status.h
===================================================================
--- developers/werner/fped/gui_status.h	                        (rev 0)
+++ developers/werner/fped/gui_status.h	2009-07-28 11:38:13 UTC (rev 5326)
@@ -0,0 +1,32 @@
+/*
+ * gui_status.h - GUI, status area
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#ifndef GUI_STATUS_H
+#define GUI_STATUS_H
+
+#include <gtk/gtk.h>
+
+
+void status_set_name(const char *fmt, ...);
+void status_set_x(const char *fmt, ...);
+void status_set_y(const char *fmt, ...);
+void status_set_r(const char *fmt, ...);
+void status_set_angle(const char *fmt, ...);
+void status_set_sys_pos(const char *fmt, ...);
+void status_set_user_pos(const char *fmt, ...);
+void status_set_zoom(const char *fmt, ...);
+void status_set_grid(const char *fmt, ...);
+
+void make_status_area(GtkWidget *vbox) ;
+
+#endif /* !GUI_STATUS_H */

Modified: developers/werner/fped/gui_style.h
===================================================================
--- developers/werner/fped/gui_style.h	2009-07-27 07:30:59 UTC (rev 5325)
+++ developers/werner/fped/gui_style.h	2009-07-28 11:38:13 UTC (rev 5326)
@@ -16,8 +16,9 @@
 
 #define	CANVAS_CLEARANCE	10
 
-#define	VEC_ARROW		6
-#define	VEC_EYE_R		4
+#define	VEC_ARROW_LEN		10
+#define	VEC_ARROW_ANGLE		20
+#define	VEC_EYE_R		5
 
 #define	FRAME_CLEARANCE		5
 #define	FRAME_EYE_R1		3

Modified: developers/werner/fped/qfn.fpd
===================================================================
--- developers/werner/fped/qfn.fpd	2009-07-27 07:30:59 UTC (rev 5325)
+++ developers/werner/fped/qfn.fpd	2009-07-28 11:38:13 UTC (rev 5326)
@@ -23,5 +23,5 @@
 
 n = 0, N/4-1
 
-.vec @ P*(n-(N-1)/2), -Ay/2
+.vec @ P*(n-N/4/2), -Ay/2
 .frame pad_up .




More information about the commitlog mailing list