r5403 - in trunk/eda/fped: . icons

werner at docs.openmoko.org werner at docs.openmoko.org
Fri Aug 7 21:42:57 CEST 2009


Author: werner
Date: 2009-08-07 21:42:57 +0200 (Fri, 07 Aug 2009)
New Revision: 5403

Added:
   trunk/eda/fped/icons/delete.fig
Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/README
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_status.c
   trunk/eda/fped/gui_status.h
   trunk/eda/fped/gui_tools.c
   trunk/eda/fped/inst.c
Log:
- gui_tools.c:new_vec didn't initialize vec->samples, causing fped to crash
- we didn't dehover before deleting, which could cause a crash
- added delete tool to canvas. Thus ...
- we no longer need the Delete key on the canvas, so we can ...
- always focus the (first) entry field, and ...
- removed "focus" parameter to edit functions



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile	2009-08-07 18:53:01 UTC (rev 5402)
+++ trunk/eda/fped/Makefile	2009-08-07 19:42:57 UTC (rev 5403)
@@ -16,7 +16,7 @@
        gui.o gui_util.o gui_style.o gui_inst.o gui_status.o gui_canvas.o \
        gui_tools.o
 
-XPMS = point.xpm vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm \
+XPMS = point.xpm delete.xpm vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm \
        line.xpm rect.xpm pad.xpm circ.xpm meas.xpm
 
 CFLAGS_GTK = `pkg-config --cflags gtk+-2.0`

Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README	2009-08-07 18:53:01 UTC (rev 5402)
+++ trunk/eda/fped/README	2009-08-07 19:42:57 UTC (rev 5403)
@@ -399,7 +399,6 @@
 .	cursor position to screen center (like middle click)
 *	zoom and center to extents
 #	zoom and center to currently active frame instance
-Delete	delete the currently selected object
 U	undelete the previously deleted object
 
 

Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c	2009-08-07 18:53:01 UTC (rev 5402)
+++ trunk/eda/fped/gui.c	2009-08-07 19:42:57 UTC (rev 5403)
@@ -534,7 +534,7 @@
 	label_in_box_bg(var->widget, COLOR_VAR_EDITING);
 	status_set_type_entry("name =");
 	status_set_name("%s", var->name);
-	edit_unique(&var->name, validate_var_name, var, 1);
+	edit_unique(&var->name, validate_var_name, var);
 }
 
 
@@ -555,7 +555,7 @@
 {
 	inst_select_outside(value, unselect_value);
 	label_in_box_bg(value->widget, COLOR_EXPR_EDITING);
-	edit_expr(&value->expr, 1);
+	edit_expr(&value->expr);
 }
 
 
@@ -958,7 +958,7 @@
 		label_in_box_bg(widget, COLOR_PART_NAME_EDITING);
 		status_set_type_entry("part =");
 		status_set_name("%s", part_name);
-		edit_name(&part_name, validate_part_name, NULL, 1);
+		edit_name(&part_name, validate_part_name, NULL);
 		break;
 	}
 	return TRUE;
@@ -1019,7 +1019,7 @@
 	label_in_box_bg(frame->label, COLOR_FRAME_EDITING);
 	status_set_type_entry("name =");
 	status_set_name("%s", frame->name);
-	edit_unique(&frame->name, validate_frame_name, frame, 1);
+	edit_unique(&frame->name, validate_frame_name, frame);
 }
 
 

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c	2009-08-07 18:53:01 UTC (rev 5402)
+++ trunk/eda/fped/gui_canvas.c	2009-08-07 19:42:57 UTC (rev 5403)
@@ -307,6 +307,7 @@
 		break;
 	case GDK_BackSpace:
 	case GDK_Delete:
+#if 0
 	case GDK_KP_Delete:
 		if (selected_inst) {
 			inst_delete(selected_inst);
@@ -314,6 +315,7 @@
 			change_world();
 		}
 		break;
+#endif
 	case 'u':
 		if (undelete())
 			change_world();

Modified: trunk/eda/fped/gui_status.c
===================================================================
--- trunk/eda/fped/gui_status.c	2009-08-07 18:53:01 UTC (rev 5402)
+++ trunk/eda/fped/gui_status.c	2009-08-07 19:42:57 UTC (rev 5403)
@@ -168,8 +168,7 @@
 }
 
 
-static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx,
-    int focus)
+static void setup_edit(GtkWidget *widget, struct edit_ops *ops, void *ctx)
 {
 	gtk_object_set_data(GTK_OBJECT(widget), "edit-ops", ops);
 	gtk_object_set_data(GTK_OBJECT(widget), "edit-ctx", ctx);
@@ -177,7 +176,7 @@
 
 	reset_edit(widget);
 
-	if (focus)
+	if (!open_edits)
 		gtk_widget_grab_focus(GTK_WIDGET(widget));
 	gtk_widget_show(widget);
 
@@ -241,14 +240,14 @@
 
 
 void edit_unique(const char **s, int (*validate)(const char *s, void *ctx), 
-    void *ctx, int focus)
+    void *ctx)
 {
 	static struct edit_unique_ctx unique_ctx;
 
 	unique_ctx.s = s;
 	unique_ctx.validate = validate;
 	unique_ctx.ctx = ctx;
-	setup_edit(status_entry, &edit_ops_unique, &unique_ctx, focus);
+	setup_edit(status_entry, &edit_ops_unique, &unique_ctx);
 }
 
 
@@ -287,14 +286,14 @@
 
 
 void edit_unique_null(const char **s,
-    int (*validate)(const char *s, void *ctx), void *ctx, int focus)
+    int (*validate)(const char *s, void *ctx), void *ctx)
 {
 	static struct edit_unique_ctx unique_ctx;
 
 	unique_ctx.s = s;
 	unique_ctx.validate = validate;
 	unique_ctx.ctx = ctx;
-	setup_edit(status_entry, &edit_ops_null_unique, &unique_ctx, focus);
+	setup_edit(status_entry, &edit_ops_null_unique, &unique_ctx);
 }
 
 
@@ -343,15 +342,14 @@
 };
 
 
-void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx,
-    int focus)
+void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx)
 {
 	static struct edit_name_ctx name_ctx;
 
 	name_ctx.s = s;
 	name_ctx.validate = validate;
 	name_ctx.ctx = ctx;
-	setup_edit(status_entry, &edit_ops_name, &name_ctx, focus);
+	setup_edit(status_entry, &edit_ops_name, &name_ctx);
 }
 
 
@@ -405,27 +403,27 @@
 };
 
 
-static void edit_any_expr(GtkWidget *widget, struct expr **expr, int focus)
+static void edit_any_expr(GtkWidget *widget, struct expr **expr)
 {
-	setup_edit(widget, &edit_ops_expr, expr, focus);
+	setup_edit(widget, &edit_ops_expr, expr);
 }
 
 
-void edit_expr(struct expr **expr, int focus)
+void edit_expr(struct expr **expr)
 {
-	edit_any_expr(status_entry, expr, focus);
+	edit_any_expr(status_entry, expr);
 }
 
 
 void edit_x(struct expr **expr)
 {
-	edit_any_expr(status_entry_x, expr, 0);
+	edit_any_expr(status_entry_x, expr);
 }
 
 
 void edit_y(struct expr **expr)
 {
-	edit_any_expr(status_entry_y, expr, 0);
+	edit_any_expr(status_entry_y, expr);
 }
 
 

Modified: trunk/eda/fped/gui_status.h
===================================================================
--- trunk/eda/fped/gui_status.h	2009-08-07 18:53:01 UTC (rev 5402)
+++ trunk/eda/fped/gui_status.h	2009-08-07 19:42:57 UTC (rev 5403)
@@ -21,12 +21,11 @@
 
 
 void edit_unique(const char **s, int (*validate)(const char *s, void *ctx),
-    void *ctx, int focus);
+    void *ctx);
 void edit_unique_null(const char **s, int (*validate)(const char *s, void *ctx),
-    void *ctx, int focus);
-void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx,
-    int focus);
-void edit_expr(struct expr **expr, int focus);
+    void *ctx);
+void edit_name(char **s, int (*validate)(const char *s, void *ctx), void *ctx);
+void edit_expr(struct expr **expr);
 void edit_x(struct expr **expr);
 void edit_y(struct expr **expr);
 void edit_nothing(void);

Modified: trunk/eda/fped/gui_tools.c
===================================================================
--- trunk/eda/fped/gui_tools.c	2009-08-07 18:53:01 UTC (rev 5402)
+++ trunk/eda/fped/gui_tools.c	2009-08-07 19:42:57 UTC (rev 5403)
@@ -35,6 +35,7 @@
 #include "icons/meas.xpm"
 #include "icons/pad.xpm"
 #include "icons/point.xpm"
+#include "icons/delete.xpm"
 #include "icons/rect.xpm"
 #include "icons/vec.xpm"
 
@@ -44,6 +45,7 @@
 
 struct tool_ops {
 	void (*tool_selected)(void);
+	void (*click)(struct draw_ctx *ctx, struct coord pos);
 	struct pix_buf *(*drag_new)(struct draw_ctx *ctx, struct inst *from,
 	     struct coord to);
 	int (*end_new_raw)(struct draw_ctx *ctx, struct inst *from,
@@ -83,6 +85,7 @@
 	vec->base = inst_get_vec(base);
 	vec->next = NULL;
 	vec->frame = active_frame;
+	vec->samples = NULL;
 	for (walk = &active_frame->vecs; *walk; walk = &(*walk)->next);
 	*walk = vec;
 	return vec;
@@ -160,6 +163,27 @@
 }
 
 
+/* ----- delete ------------------------------------------------------------ */
+
+
+static void click_delete(struct draw_ctx *ctx, struct coord pos)
+{
+	inst_deselect();
+	inst_select(ctx, pos);
+	if (selected_inst) {
+		tool_dehover(ctx);
+		inst_delete(selected_inst);
+	}
+	change_world();
+	tool_reset();
+}
+
+
+static struct tool_ops delete_ops = {
+	.click		= click_delete,
+};
+
+
 /* ----- vec --------------------------------------------------------------- */
 
 
@@ -707,6 +731,10 @@
 	assert(!drag.new);
 	assert(!drag.anchors_n);
 	last_canvas_pos = translate(ctx, pos);
+	if (active_ops && active_ops->click) {
+		active_ops->click(ctx, pos);
+		return 0;
+	}
 	curr = inst_find_point(ctx, pos);
 	if (!curr)
 		return 0;
@@ -882,6 +910,16 @@
 }
 
 
+static void tool_separator(GtkWidget *bar)
+{
+	GtkToolItem *item;
+
+	item = gtk_separator_tool_item_new();
+	gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(item), FALSE);
+	gtk_toolbar_insert(GTK_TOOLBAR(bar), item, -1);
+}
+
+
 GtkWidget *gui_setup_tools(GdkDrawable *drawable)
 {
 	GtkWidget *bar;
@@ -893,7 +931,9 @@
 	    GTK_ORIENTATION_VERTICAL);
 
 	ev_point = tool_button(bar, drawable, xpm_point, NULL, NULL);
-	last = tool_button(bar, drawable, xpm_vec, ev_point, &vec_ops);
+	last = tool_button(bar, drawable, xpm_delete, ev_point, &delete_ops);
+	tool_separator(bar);
+	last = tool_button(bar, drawable, xpm_vec, last, &vec_ops);
 	ev_frame = tool_button(bar, drawable, NULL, last, &frame_ops);
 	last = ev_frame;
 	last = tool_button(bar, drawable, xpm_pad, last, &pad_ops);

Added: trunk/eda/fped/icons/delete.fig
===================================================================
--- trunk/eda/fped/icons/delete.fig	                        (rev 0)
+++ trunk/eda/fped/icons/delete.fig	2009-08-07 19:42:57 UTC (rev 5403)
@@ -0,0 +1,15 @@
+#FIG 3.2  Produced by xfig version 3.2.5a
+Landscape
+Center
+Inches
+A4      
+100.00
+Single
+-2
+1200 2
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+	 3600 2400 6000 2400 6000 4800 3600 4800 3600 2400
+2 1 0 15 18 7 50 -1 -1 0.000 0 1 -1 0 0 2
+	 4125 2925 5475 4275
+2 1 0 15 18 7 50 -1 -1 0.000 0 1 -1 0 0 2
+	 4125 4275 5475 2925

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c	2009-08-07 18:53:01 UTC (rev 5402)
+++ trunk/eda/fped/inst.c	2009-08-07 19:42:57 UTC (rev 5403)
@@ -358,7 +358,7 @@
 	rect_status(self->base, self->u.rect.end, -1);
 	edit_x(&self->vec->x);
 	edit_y(&self->vec->y);
-	edit_unique_null(&self->vec->name, validate_vec_name, self->vec, 0);
+	edit_unique_null(&self->vec->name, validate_vec_name, self->vec);
 }
 
 
@@ -407,7 +407,7 @@
 static void line_op_select(struct inst *self)
 {
 	rect_status(self->bbox.min, self->bbox.max, self->u.rect.width);
-	edit_expr(&self->obj->u.line.width, 0);
+	edit_expr(&self->obj->u.line.width);
 }
 
 
@@ -460,7 +460,7 @@
 static void rect_op_select(struct inst *self)
 {
 	rect_status(self->bbox.min, self->bbox.max, self->u.rect.width);
-	edit_expr(&self->obj->u.rect.width, 0);
+	edit_expr(&self->obj->u.rect.width);
 }
 
 
@@ -517,7 +517,7 @@
 	status_set_type_entry("label =");
 	status_set_name("%s", self->u.pad.name);
 	rect_status(self->base, self->u.pad.other, -1);
-	edit_name(&self->obj->u.pad.name, validate_pad_name, NULL, 0);
+	edit_name(&self->obj->u.pad.name, validate_pad_name, NULL);
 }
 
 
@@ -575,7 +575,7 @@
 	status_set_r("r = %5.2f mm", units_to_mm(self->u.arc.r));
 	status_set_type_entry("width =");
 	status_set_name("%5.2f mm", units_to_mm(self->u.arc.width));
-	edit_expr(&self->obj->u.arc.width, 0);
+	edit_expr(&self->obj->u.arc.width);
 }
 
 
@@ -645,7 +645,7 @@
 	status_set_name("%5.2f mm", units_to_mm(self->u.meas.offset));
 	if (!self->obj)
 		return; /* @@@ new-style measurements */
-	edit_expr(&self->obj->u.meas.offset, 0);
+	edit_expr(&self->obj->u.meas.offset);
 }
 
 




More information about the commitlog mailing list