Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r5378 - trunk/eda/fped (wer...@docs.openmoko.org)
   2. r5379 - trunk/eda/fped (wer...@docs.openmoko.org)
   3. r5380 - trunk/eda/fped (wer...@docs.openmoko.org)
   4. r5381 - trunk/eda/fped (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2009-08-03 23:52:21 +0200 (Mon, 03 Aug 2009)
New Revision: 5378

Modified:
   trunk/eda/fped/README
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_status.c
   trunk/eda/fped/inst.c
   trunk/eda/fped/inst.h
Log:
- don't crash when editing a NULL expression (e.g., default width)
- bounding boxes of silk objects now include the width
- # zooms and centers to currently active frame instance



Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README       2009-08-03 21:10:49 UTC (rev 5377)
+++ trunk/eda/fped/README       2009-08-03 21:52:21 UTC (rev 5378)
@@ -349,3 +349,4 @@
 -      zoom out (like mouse wheel backward)
 .      cursor position to screen center (like middle click)
 *      zoom and center to extents
+#      zoom and center to currently active frame instance

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2009-08-03 21:10:49 UTC (rev 5377)
+++ trunk/eda/fped/gui_canvas.c 2009-08-03 21:52:21 UTC (rev 5378)
@@ -49,24 +49,24 @@
 /* ----- coordinate system ------------------------------------------------- */
 
 
-static void center(void)
+static void center(const struct bbox *this_bbox)
 {
        struct bbox bbox;
 
-       bbox = inst_get_bbox();
+       bbox = this_bbox ? *this_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)
+static void auto_scale(const struct bbox *this_bbox)
 {
        struct bbox bbox;
        unit_type h, w;
        int sx, sy;
        float aw, ah;
 
-       bbox = inst_get_bbox();
+       bbox = this_bbox ? *this_bbox : inst_get_bbox();
        aw = ctx.widget->allocation.width;
        ah = ctx.widget->allocation.height;
        h = bbox.max.x-bbox.min.x;
@@ -236,9 +236,15 @@
                zoom_out(pos);
                break;
        case '*':
-               center();
-               auto_scale();
+               center(NULL);
+               auto_scale(NULL);
                redraw();
+               break;
+       case '#':
+               center(&active_frame_bbox);
+               auto_scale(&active_frame_bbox);
+               redraw();
+               break;
        case '.':
                ctx.center = pos;
                redraw();
@@ -293,8 +299,8 @@
 
 void init_canvas(void)
 {
-       center();
-       auto_scale();
+       center(NULL);
+       auto_scale(NULL);
 }
 
 

Modified: trunk/eda/fped/gui_status.c
===================================================================
--- trunk/eda/fped/gui_status.c 2009-08-03 21:10:49 UTC (rev 5377)
+++ trunk/eda/fped/gui_status.c 2009-08-03 21:52:21 UTC (rev 5378)
@@ -310,7 +310,8 @@
        expr = try_parse_expr(s);
        if (!expr)
                return 0;
-       free_expr(*anchor);
+       if (*anchor)
+               free_expr(*anchor);
        *anchor = expr;
        entry_color(COLOR_EDIT_ASIS);
        return 1;

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-08-03 21:10:49 UTC (rev 5377)
+++ trunk/eda/fped/inst.c       2009-08-03 21:52:21 UTC (rev 5378)
@@ -62,6 +62,7 @@
 
 
 struct inst *selected_inst = NULL;
+struct bbox active_frame_bbox;
 
 static struct inst *curr_frame = NULL;
 static struct inst *insts[ip_n], **next_inst[ip_n];
@@ -224,6 +225,16 @@
        update_bbox(&curr_frame->bbox, inst->bbox.max);
 }
 
+
+static void grow_bbox_by_width(struct bbox *bbox, unit_type width)
+{
+       bbox->min.x -= width/2;
+       bbox->min.y -= width/2;
+       bbox->max.x += width/2;
+       bbox->max.y += width/2;
+}
+
+
 static struct inst *add_inst(const struct inst_ops *ops, enum inst_prio prio,
     struct coord base)
 {
@@ -331,6 +342,7 @@
        inst->u.rect.end = b;
        inst->u.rect.width = width;
        update_bbox(&inst->bbox, b);
+       grow_bbox_by_width(&inst->bbox, width);
        propagate_bbox(inst);
        return 1;
 }
@@ -371,6 +383,7 @@
        inst->u.rect.end = b;
        inst->u.rect.width = width;
        update_bbox(&inst->bbox, b);
+       grow_bbox_by_width(&inst->bbox, width);
        propagate_bbox(inst);
        return 1;
 }
@@ -482,6 +495,7 @@
        inst->bbox.max.x = center.x+r;
        inst->bbox.min.y = center.y-r;
        inst->bbox.max.y = center.y+r;
+       grow_bbox_by_width(&inst->bbox, width);
        propagate_bbox(inst);
        return 1;
 }
@@ -581,6 +595,8 @@
        curr_frame = curr_frame->outer;
        if (curr_frame)
                propagate_bbox(inst);
+       if (inst->active && frame == active_frame)
+               active_frame_bbox = inst->bbox;
 }
 
 
@@ -609,8 +625,10 @@
 
 void inst_start(void)
 {
+       static struct bbox bbox_zero = { { 0, 0 }, { 0, 0 }};
        enum inst_prio prio;
 
+       active_frame_bbox = bbox_zero;
        FOR_INST_PRIOS_UP(prio) {
                prev_insts[prio] = insts[prio];
                insts[prio] = NULL;

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h       2009-08-03 21:10:49 UTC (rev 5377)
+++ trunk/eda/fped/inst.h       2009-08-03 21:52:21 UTC (rev 5378)
@@ -71,6 +71,7 @@
 
 
 extern struct inst *selected_inst;
+extern struct bbox active_frame_bbox;
 
 
 void inst_select_outside(void *item, void (*deselect)(void *item));




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-04 00:58:15 +0200 (Tue, 04 Aug 2009)
New Revision: 5379

Modified:
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_style.h
   trunk/eda/fped/obj.c
   trunk/eda/fped/obj.h
Log:
- moved building of an activator into new function add_activator
- added loop value selection (quick and dirty)



Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c        2009-08-03 21:52:21 UTC (rev 5378)
+++ trunk/eda/fped/gui.c        2009-08-03 22:58:15 UTC (rev 5379)
@@ -140,6 +140,33 @@
 }
 
 
+/* ----- activator --------------------------------------------------------- */
+
+
+static GtkWidget *add_activator(GtkWidget *hbox, int active,
+    gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
+    gpointer user, const char *fmt, ...)
+{
+       GtkWidget *label;
+       va_list ap;
+       char buf[100];
+
+       va_start(ap, fmt);
+       vsprintf(buf, fmt, ap);
+       va_end(ap);
+       label = label_in_box_new(buf);
+       gtk_misc_set_padding(GTK_MISC(label), 2, 2);
+       gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
+       label_in_box_bg(label,
+           active ? COLOR_CHOICE_SELECTED : COLOR_CHOICE_UNSELECTED);
+       gtk_box_pack_start(GTK_BOX(hbox), box_of_label(label),
+           FALSE, FALSE, 2);
+       g_signal_connect(G_OBJECT(box_of_label(label)),
+           "button_press_event", G_CALLBACK(cb), user);
+       return label;
+}
+
+
 /* ----- assignments ------------------------------------------------------- */
 
 
@@ -336,11 +363,23 @@
 }
 
 
+static gboolean loop_select_event(GtkWidget *widget, GdkEventButton *event,
+     gpointer data)
+{
+       struct loop *loop = data;
+
+       loop->active = (long) gtk_object_get_data(GTK_OBJECT(widget), "value");
+       change_world();
+       return TRUE;
+}
+
+
 static void build_loop(GtkWidget *vbox, struct frame *frame,
      struct loop *loop)
 {
-       GtkWidget *hbox, *field;
+       GtkWidget *hbox, *field, *label;
        char *expr;
+       int i;
 
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
@@ -378,6 +417,19 @@
            "button_press_event",
            G_CALLBACK(loop_to_select_event), loop);
        loop->to.widget = field;
+
+       gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(" ("),
+           FALSE, FALSE, 0);
+
+       for (i = 0; i != loop->iterations; i++) {
+               label = add_activator(hbox, loop->active == i,
+                   loop_select_event, loop, "%d", i);
+               gtk_object_set_data(GTK_OBJECT(box_of_label(label)), "value",
+                   (gpointer) (long) i);
+       }
+
+       gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(")"),
+           FALSE, FALSE, 0);
 }
 
 
@@ -503,26 +555,16 @@
 
 static GtkWidget *build_frame_refs(const struct frame *frame)
 {
-       GtkWidget *hbox, *label;
+       GtkWidget *hbox;
        struct obj *obj;
-       char buf[100];
 
        hbox = gtk_hbox_new(FALSE, 0);
        for (obj = frame->objs; obj; obj = obj->next)
-               if (obj->type == ot_frame && obj->u.frame.ref == active_frame) {
-                       sprintf(buf, "%d", obj->u.frame.lineno);
-                       label = label_in_box_new(buf);
-                       gtk_misc_set_padding(GTK_MISC(label), 2, 2);
-                       gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-                       label_in_box_bg(label,
-                           obj == obj->u.frame.ref->active_ref ?
-                           COLOR_REF_SELECTED : COLOR_REF_UNSELECTED);
-                       gtk_box_pack_start(GTK_BOX(hbox), box_of_label(label),
-                           FALSE, FALSE, 2);
-                       g_signal_connect(G_OBJECT(box_of_label(label)),
-                           "button_press_event",
-                           G_CALLBACK(frame_ref_select_event), obj);
-               }
+               if (obj->type == ot_frame && obj->u.frame.ref == active_frame)
+                       add_activator(hbox,
+                           obj == obj->u.frame.ref->active_ref,
+                           frame_ref_select_event, obj,
+                           "%d", obj->u.frame.lineno);
        return hbox;
 }
 

Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h  2009-08-03 21:52:21 UTC (rev 5378)
+++ trunk/eda/fped/gui_style.h  2009-08-03 22:58:15 UTC (rev 5379)
@@ -62,9 +62,6 @@
 #define COLOR_FRAME_SELECTED   "#fff0a0"
 #define COLOR_FRAME_EDITING    COLOR_EDITING
 
-#define        COLOR_REF_UNSELECTED    COLOR_CHOICE_UNSELECTED
-#define        COLOR_REF_SELECTED      COLOR_CHOICE_SELECTED
-
 #define        COLOR_VAR_PASSIVE       COLOR_FRAME_UNSELECTED
 #define        COLOR_VAR_EDITING       COLOR_EDITING
 #define        COLOR_EXPR_PASSIVE      "#f0f0ff"

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c        2009-08-03 21:52:21 UTC (rev 5378)
+++ trunk/eda/fped/obj.c        2009-08-03 22:58:15 UTC (rev 5379)
@@ -213,6 +213,7 @@
                n++;
        }
        loop->initialized = 0;
+       loop->iterations = n;
        return 1;
 
 fail:

Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h        2009-08-03 21:52:21 UTC (rev 5378)
+++ trunk/eda/fped/obj.h        2009-08-03 22:58:15 UTC (rev 5379)
@@ -76,6 +76,7 @@
 
        /* GUI use */
        int active;     /* n-th iteration is active, 0 based */
+       int iterations; /* iterations when it was active */
 
        /* for evaluation */
        int initialized;




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-04 01:23:00 +0200 (Tue, 04 Aug 2009)
New Revision: 5380

Modified:
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_inst.c
Log:
- before changing the world, always deselect (reported by Dave Ball)
- gui_draw_pad: add 10% of slack so that pad names are upright unless we really
  need to rotate



Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c        2009-08-03 22:58:15 UTC (rev 5379)
+++ trunk/eda/fped/gui.c        2009-08-03 23:23:00 UTC (rev 5380)
@@ -498,10 +498,8 @@
 
 static void select_frame(struct frame *frame)
 {
-       if (active_frame) {
+       if (active_frame)
                label_in_box_bg(active_frame->label, COLOR_FRAME_UNSELECTED);
-               inst_deselect();
-       }
        active_frame = frame;
        change_world();
 }
@@ -648,6 +646,7 @@
 
 void change_world(void)
 {
+       inst_deselect();
        status_begin_reporting();
        instantiate();
        label_in_box_bg(active_frame->label, COLOR_FRAME_SELECTED);

Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c   2009-08-03 22:58:15 UTC (rev 5379)
+++ trunk/eda/fped/gui_inst.c   2009-08-03 23:23:00 UTC (rev 5380)
@@ -257,7 +257,7 @@
        c = add_vec(min, max);
        h = min.y-max.y;
        w = max.x-min.x;
-       render_text(DA, gc, c.x/2, c.y/2, w <= h ? 0 : 90, self->u.name,
+       render_text(DA, gc, c.x/2, c.y/2, w <= h*1.1 ? 0 : 90, self->u.name,
            PAD_FONT, 0.5, 0.5,
            w-2*PAD_BORDER, h-2*PAD_BORDER);
 }




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-04 02:23:10 +0200 (Tue, 04 Aug 2009)
New Revision: 5381

Modified:
   trunk/eda/fped/TODO
   trunk/eda/fped/expr.c
   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/inst.c
Log:
- fixed stupid realloc(..., len) error
- rearranged input area and added vector component edit capability



Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO 2009-08-03 23:23:00 UTC (rev 5380)
+++ trunk/eda/fped/TODO 2009-08-04 00:23:10 UTC (rev 5381)
@@ -1,7 +1,5 @@
 Missing features:
 - populate input area (still needed: mm/mil, rezoom)
-- add vec editor (need to be able to edit name, x, and y)
-- add obj editor
 - add table/var/loop editor (missing: add col/row, add/del var/table/loop)
 - add default unit (combine with grid unit selection ?)
 - consider adding auto/mm/mil selection for each dimension
@@ -16,6 +14,7 @@
 
 Style:
 - make column of entry field greedily consume all unallocated space
+- status area looks awful
 
 Bugs:
 - default silk width has no business being hard-coded in obj.c

Modified: trunk/eda/fped/expr.c
===================================================================
--- trunk/eda/fped/expr.c       2009-08-03 23:23:00 UTC (rev 5380)
+++ trunk/eda/fped/expr.c       2009-08-04 00:23:10 UTC (rev 5381)
@@ -365,7 +365,7 @@
                value_len = snprintf(num_buf, sizeof(num_buf), "%lg%s",
                    value.n, str_unit(value));
                len += value_len;
-               buf = realloc(buf, len);
+               buf = realloc(buf, len+1);
                if (!buf)
                        abort();
                strcpy(buf+i, num_buf);

Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c        2009-08-03 23:23:00 UTC (rev 5380)
+++ trunk/eda/fped/gui.c        2009-08-04 00:23:10 UTC (rev 5381)
@@ -114,6 +114,7 @@
 {
        inst_select_outside(var, unselect_var);
         label_in_box_bg(var->widget, COLOR_VAR_EDITING);
+       status_set_type_entry("name =");
        status_set_name(var->name);
        edit_unique(&var->name, validate_var_name, var);
 }
@@ -491,6 +492,7 @@
 {
        inst_select_outside(frame, unselect_frame);
        label_in_box_bg(frame->label, COLOR_FRAME_EDITING);
+       status_set_type_entry("name =");
        status_set_name(frame->name);
        edit_unique(&frame->name, validate_frame_name, frame);
 }

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2009-08-03 23:23:00 UTC (rev 5380)
+++ trunk/eda/fped/gui_canvas.c 2009-08-04 00:23:10 UTC (rev 5381)
@@ -39,10 +39,10 @@
 
 static void update_pos(struct coord pos)
 {
-       status_set_sys_pos("X %5.2lf  Y %5.2lf mm",
-           units_to_mm(pos.x), units_to_mm(pos.y));
-       status_set_user_pos("x %5.2lf  y  %5.2lf mm",
-           units_to_mm(pos.x-user_origin.x), units_to_mm(pos.y-user_origin.y));
+       status_set_sys_x("X %5.2lf" , units_to_mm(pos.x));
+       status_set_sys_y("Y %5.2lf" , units_to_mm(pos.y));
+       status_set_user_x("x %5.2lf", units_to_mm(pos.x-user_origin.x));
+       status_set_user_y("y %5.2lf", units_to_mm(pos.y-user_origin.y));
 }
 
 

Modified: trunk/eda/fped/gui_status.c
===================================================================
--- trunk/eda/fped/gui_status.c 2009-08-03 23:23:00 UTC (rev 5380)
+++ trunk/eda/fped/gui_status.c 2009-08-04 00:23:10 UTC (rev 5381)
@@ -32,17 +32,17 @@
        int (*activate)(GtkWidget *widget, const char *s, void *ctx);
 };
 
-static struct edit_ops *edit_ops = NULL;
-static void *edit_ctx;
 
-
 /* ----- setter functions -------------------------------------------------- */
 
 
 static GtkWidget *status_name, *status_entry;
+static GtkWidget *status_type_x, *status_type_y, *status_type_entry;
+static GtkWidget *status_entry_x, *status_entry_y;
 static GtkWidget *status_x, *status_y;
 static GtkWidget *status_r, *status_angle;
-static GtkWidget *status_sys_pos, *status_user_pos;
+static GtkWidget *status_sys_x, *status_sys_y;
+static GtkWidget *status_user_x, *status_user_y;
 static GtkWidget *status_zoom, *status_grid;
 static GtkWidget *status_msg;
 
@@ -67,13 +67,18 @@
                va_end(ap);                             \
        }
 
+SETTER(type_x)
+SETTER(type_y)
+SETTER(type_entry)
 SETTER(name)
 SETTER(x)
 SETTER(y)
 SETTER(r)
 SETTER(angle)
-SETTER(sys_pos)
-SETTER(user_pos)
+SETTER(sys_x)
+SETTER(sys_y)
+SETTER(user_x)
+SETTER(user_y)
 SETTER(zoom)
 SETTER(grid)
 
@@ -83,21 +88,38 @@
 
 void status_set_xy(struct coord coord)
 {
-       status_set_x("x = %5.2f mm", units_to_mm(coord.x));
-       status_set_y("y = %5.2f mm", units_to_mm(coord.y));
+       /* do dX/dY etc. stuff later */
+       status_set_type_x("X =");
+       status_set_type_y("Y =");
+
+       status_set_x("%5.2f mm", units_to_mm(coord.x));
+       status_set_y("%5.2f mm", units_to_mm(coord.y));
 }
 
 
-static void entry_color(const char *color)
+static void entry_color(GtkWidget *widget, const char *color)
 {
        GdkColor col;
 
        col = get_color(color);
-       gtk_widget_modify_base(GTK_WIDGET(status_entry),
-           GTK_STATE_NORMAL, &col);
+       gtk_widget_modify_base(widget, GTK_STATE_NORMAL, &col);
 }
 
 
+/* ----- helper functions -------------------------------------------------- */
+
+
+static void setup_edit(GtkWidget *widget, const char *s,
+    struct edit_ops *ops, void *ctx)
+{
+       gtk_entry_set_text(GTK_ENTRY(widget), s);
+       entry_color(widget, COLOR_EDIT_ASIS);
+       gtk_widget_show(widget);
+       gtk_object_set_data(GTK_OBJECT(widget), "edit-ops", ops);
+       gtk_object_set_data(GTK_OBJECT(widget), "edit-ctx", ctx);
+}
+
+
 /* ----- identifier fields ------------------------------------------------- */
 
 
@@ -114,11 +136,11 @@
        int ok;
 
        if (!strcmp(s, *unique_ctx->s)) {
-               entry_color(COLOR_EDIT_ASIS);
+               entry_color(widget, COLOR_EDIT_ASIS);
                return 1;
        }
        ok = !unique_ctx->validate || unique_ctx->validate(s, unique_ctx->ctx);
-       entry_color(ok ? COLOR_EDIT_GOOD : COLOR_EDIT_BAD);
+       entry_color(widget, ok ? COLOR_EDIT_GOOD : COLOR_EDIT_BAD);
        return ok;
 }
 
@@ -131,7 +153,7 @@
             unique_ctx->validate && !unique_ctx->validate(s, unique_ctx->ctx))
                return 0;
        *unique_ctx->s = unique(s);
-       entry_color(COLOR_EDIT_ASIS);
+       entry_color(widget, COLOR_EDIT_ASIS);
        return 1;
 }
 
@@ -150,11 +172,7 @@
        unique_ctx.s = s;
        unique_ctx.validate = validate;
        unique_ctx.ctx = ctx;
-       edit_ops = &edit_ops_unique;
-       edit_ctx = &unique_ctx;
-       gtk_entry_set_text(GTK_ENTRY(status_entry), *s);
-       entry_color(COLOR_EDIT_ASIS);
-       gtk_widget_show(status_entry);
+       setup_edit(status_entry, *s, &edit_ops_unique, &unique_ctx);
 }
 
 
@@ -167,14 +185,14 @@
        int ok;
 
        if (!strcmp(s, *unique_ctx->s ? *unique_ctx->s : "")) {
-               entry_color(COLOR_EDIT_ASIS);
+               entry_color(widget, COLOR_EDIT_ASIS);
                return 1;
        }
        ok = !*s;
        if (!ok)
                ok = !unique_ctx->validate ||
                     unique_ctx->validate(s, unique_ctx->ctx);
-       entry_color(ok ? COLOR_EDIT_GOOD : COLOR_EDIT_BAD);
+       entry_color(widget, ok ? COLOR_EDIT_GOOD : COLOR_EDIT_BAD);
        return ok;
 }
 
@@ -191,7 +209,7 @@
                        return 0;
                *unique_ctx->s = unique(s);
        }
-       entry_color(COLOR_EDIT_ASIS);
+       entry_color(widget, COLOR_EDIT_ASIS);
        return 1;
 }
 
@@ -210,11 +228,8 @@
        unique_ctx.s = s;
        unique_ctx.validate = validate;
        unique_ctx.ctx = ctx;
-       edit_ops = &edit_ops_null_unique;
-       edit_ctx = &unique_ctx;
-       gtk_entry_set_text(GTK_ENTRY(status_entry), *s ? *s : "");
-       entry_color(COLOR_EDIT_ASIS);
-       gtk_widget_show(status_entry);
+       setup_edit(status_entry, *s ? *s : "",
+           &edit_ops_null_unique, &unique_ctx);
 }
 
 
@@ -234,11 +249,11 @@
        int ok;
 
        if (!strcmp(s, *name_ctx->s)) {
-               entry_color(COLOR_EDIT_ASIS);
+               entry_color(widget, COLOR_EDIT_ASIS);
                return 1;
        }
        ok = !name_ctx->validate || name_ctx->validate(s, name_ctx->ctx);
-       entry_color(ok ? COLOR_EDIT_GOOD : COLOR_EDIT_BAD);
+       entry_color(widget, ok ? COLOR_EDIT_GOOD : COLOR_EDIT_BAD);
        return ok;
 }
 
@@ -251,7 +266,7 @@
                return 0;
        free(*name_ctx->s);
        *name_ctx->s = stralloc(s);
-       entry_color(COLOR_EDIT_ASIS);
+       entry_color(widget, COLOR_EDIT_ASIS);
        return 1;
 }
 
@@ -269,11 +284,7 @@
        name_ctx.s = s;
        name_ctx.validate = validate;
        name_ctx.ctx = ctx;
-       edit_ops = &edit_ops_name;
-       edit_ctx = &name_ctx;
-       gtk_entry_set_text(GTK_ENTRY(status_entry), *s);
-       entry_color(COLOR_EDIT_ASIS);
-       gtk_widget_show(status_entry);
+       setup_edit(status_entry, *s, &edit_ops_name, &name_ctx);
 }
 
 
@@ -293,10 +304,10 @@
 
        expr = try_parse_expr(s);
        if (!expr) {
-               entry_color(COLOR_EDIT_BAD);
+               entry_color(widget, COLOR_EDIT_BAD);
                return 0;
        }
-       entry_color(COLOR_EDIT_GOOD);
+       entry_color(widget, COLOR_EDIT_GOOD);
        free_expr(expr);
        return 1;
 }
@@ -313,7 +324,7 @@
        if (*anchor)
                free_expr(*anchor);
        *anchor = expr;
-       entry_color(COLOR_EDIT_ASIS);
+       entry_color(widget, COLOR_EDIT_ASIS);
        return 1;
 }
 
@@ -324,29 +335,47 @@
 };
 
 
-void edit_expr(struct expr **expr)
+static void edit_any_expr(GtkWidget *widget, struct expr **expr)
 {
        char *s;
 
-       edit_ops = &edit_ops_expr;
-       edit_ctx = expr;
        s = unparse(*expr);
-       gtk_entry_set_text(GTK_ENTRY(status_entry), s);
+       setup_edit(widget, s, &edit_ops_expr, expr);
        free(s);
-       entry_color(COLOR_EDIT_ASIS);
-       gtk_widget_show(status_entry);
 }
 
 
+void edit_expr(struct expr **expr)
+{
+       edit_any_expr(status_entry, expr);
+}
+
+
+void edit_x(struct expr **expr)
+{
+       edit_any_expr(status_entry_x, expr);
+}
+
+
+void edit_y(struct expr **expr)
+{
+       edit_any_expr(status_entry_y, expr);
+}
+
+
 /* ----- text entry -------------------------------------------------------- */
 
 
 static gboolean changed(GtkWidget *widget, GdkEventMotion *event,
      gpointer data)
 {
-       if (edit_ops && edit_ops->changed)
-               edit_ops->changed(widget,
-                   gtk_entry_get_text(GTK_ENTRY(widget)), edit_ctx);
+       struct edit_ops *ops =
+           gtk_object_get_data(GTK_OBJECT(widget), "edit-ops");
+       void *ctx = gtk_object_get_data(GTK_OBJECT(widget), "edit-ctx");
+
+       if (ops && ops->changed)
+               ops->changed(widget, gtk_entry_get_text(GTK_ENTRY(widget)),
+                   ctx);
        return TRUE;
 }
 
@@ -354,9 +383,13 @@
 static gboolean activate(GtkWidget *widget, GdkEventMotion *event,
      gpointer data)
 {
-       if (edit_ops && edit_ops->activate)
-               if (edit_ops->activate(widget,
-                   gtk_entry_get_text(GTK_ENTRY(widget)), edit_ctx)) {
+       struct edit_ops *ops =
+           gtk_object_get_data(GTK_OBJECT(widget), "edit-ops");
+       void *ctx = gtk_object_get_data(GTK_OBJECT(widget), "edit-ctx");
+
+       if (ops && ops->activate)
+               if (ops->activate(widget,
+                   gtk_entry_get_text(GTK_ENTRY(widget)), ctx)) {
                        inst_deselect();
                        change_world();
                }
@@ -366,8 +399,9 @@
 
 void edit_nothing(void)
 {
-       edit_ops = NULL;
        gtk_widget_hide(status_entry);
+       gtk_widget_hide(status_entry_x);
+       gtk_widget_hide(status_entry_y);
 }
 
 
@@ -418,54 +452,65 @@
 }
 
 
-void make_status_area(GtkWidget *vbox)
+static GtkWidget *add_entry(GtkWidget *tab, int col, int row)
 {
-       GtkWidget *tab, *hbox;
+       GtkWidget *entry;
 
-       tab = gtk_table_new(5, 2, FALSE);
-       gtk_box_pack_start(GTK_BOX(vbox), tab, FALSE, TRUE, 0);
+       entry = gtk_entry_new();
+       gtk_entry_set_has_frame(GTK_ENTRY(entry), FALSE);
+       gtk_table_attach_defaults(GTK_TABLE(tab), entry,
+           col, col+1, row, row+1);
 
-       /* name and input */
+       g_signal_connect(G_OBJECT(entry), "changed",
+            G_CALLBACK(changed), entry);
+       g_signal_connect(G_OBJECT(entry), "activate",
+            G_CALLBACK(activate), entry);
 
-       status_name = add_label(tab, 0, 0);
+       return entry;
+}
 
-       /*
-        * @@@ this should make the entry consume all available space. alas, it
-        * doesn't work like that :-(
-        */
-       hbox = gtk_hbox_new(TRUE, 0);
-       gtk_table_attach_defaults(GTK_TABLE(tab), hbox,
-           0, 1, 1, 2);
-       
-       status_entry = gtk_entry_new();
-       gtk_box_pack_start(GTK_BOX(hbox), status_entry, TRUE, TRUE, 0);
 
-       gtk_entry_set_has_frame(GTK_ENTRY(status_entry), FALSE);
+void make_status_area(GtkWidget *vbox)
+{
+       GtkWidget *tab;
 
-       g_signal_connect(G_OBJECT(status_entry), "changed",
-            G_CALLBACK(changed), status_entry);
-       g_signal_connect(G_OBJECT(status_entry), "activate",
-            G_CALLBACK(activate), status_entry);
+       tab = gtk_table_new(6, 3, FALSE);
+       gtk_box_pack_start(GTK_BOX(vbox), tab, FALSE, TRUE, 0);
 
+       /* types */
+
+       status_type_x = add_label(tab, 0, 0);
+       status_type_y = add_label(tab, 0, 1);
+       status_type_entry = add_label(tab, 0, 2);
+
        /* x / y */
 
        status_x = add_label(tab, 1, 0);
+       status_entry_x = add_entry(tab, 2, 0);
        status_y = add_label(tab, 1, 1);
+       status_entry_y = add_entry(tab, 2, 1);
 
-       /* r / angle */
+       /* name and input */
 
-       status_r = add_label(tab, 2, 0);
-       status_angle = add_label(tab, 2, 1);
+       status_name = add_label(tab, 1, 2);
+       status_entry = add_entry(tab, 2, 2);
 
        /* sys / user pos */
 
-       status_sys_pos = add_label(tab, 3, 0);
-       status_user_pos = add_label(tab, 3, 1);
+       status_sys_x = add_label(tab, 3, 0);
+       status_sys_y = add_label(tab, 3, 1);
+       status_user_x = add_label(tab, 4, 0);
+       status_user_y = add_label(tab, 4, 1);
 
+       /* r / angle */
+
+       status_r = add_label(tab, 3, 2);
+       status_angle = add_label(tab, 4, 2);
+
        /* zoom / grid */
 
-       status_zoom = add_label(tab, 4, 0);
-       status_grid = add_label(tab, 4, 1);
+       status_zoom = add_label(tab, 5, 0);
+       status_grid = add_label(tab, 5, 1);
 
        /* message bar */
 

Modified: trunk/eda/fped/gui_status.h
===================================================================
--- trunk/eda/fped/gui_status.h 2009-08-03 23:23:00 UTC (rev 5380)
+++ trunk/eda/fped/gui_status.h 2009-08-04 00:23:10 UTC (rev 5381)
@@ -26,15 +26,22 @@
     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);
 
+void status_set_type_x(const char *fmt, ...);
+void status_set_type_y(const char *fmt, ...);
+void status_set_type_entry(const char *fmt, ...);
 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_sys_x(const char *fmt, ...);
+void status_set_sys_y(const char *fmt, ...);
+void status_set_user_x(const char *fmt, ...);
+void status_set_user_y(const char *fmt, ...);
 void status_set_zoom(const char *fmt, ...);
 void status_set_grid(const char *fmt, ...);
 

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-08-03 23:23:00 UTC (rev 5380)
+++ trunk/eda/fped/inst.c       2009-08-04 00:23:10 UTC (rev 5381)
@@ -173,6 +173,9 @@
        if (selected_inst)
                set_path(0);
        deselect_outside();
+       status_set_type_x("");
+       status_set_type_y("");
+       status_set_type_entry("");
        status_set_name("");
        status_set_x("");
        status_set_y("");
@@ -198,8 +201,10 @@
                status_set_angle("a = %3.1f deg", angle);
        }
        status_set_r("r = %5.2f mm", hypot(units_to_mm(d.x), units_to_mm(d.y)));
-       if (width != -1)
-               status_set_name("width = %5.2f mm", units_to_mm(width));
+       if (width != -1) {
+               status_set_type_entry("width =");
+               status_set_name("%5.2f mm", units_to_mm(width));
+       }
 }
 
 
@@ -280,9 +285,12 @@
 
 static void vec_op_select(struct inst *self)
 {
+       status_set_type_entry("ref =");
        status_set_name(self->vec->name ? self->vec->name : "");
        rect_status(self->base, self->u.rect.end, -1);
        edit_unique_null(&self->vec->name, validate_vec_name, self->vec);
+       edit_x(&self->vec->x);
+       edit_y(&self->vec->y);
 }
 
 
@@ -414,6 +422,7 @@
 
 static void pad_op_select(struct inst *self)
 {
+       status_set_type_entry("label =");
        status_set_name(self->u.name);
        rect_status(self->bbox.min, self->bbox.max, -1);
        edit_name(&self->obj->u.pad.name, validate_pad_name, NULL);
@@ -459,7 +468,8 @@
            self->u.arc.a1 == self->u.arc.a2 ? 360 :
            self->u.arc.a2-self->u.arc.a1);
        status_set_r("r = %5.2f mm", units_to_mm(self->u.arc.r));
-       status_set_name("width = %5.2f mm", units_to_mm(self->u.arc.width));
+       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);
 }
 
@@ -516,7 +526,8 @@
 static void meas_op_select(struct inst *self)
 {
        rect_status(self->bbox.min, self->bbox.max, -1);
-       status_set_name("offset = %5.2f mm", units_to_mm(self->u.meas.offset));
+       status_set_type_entry("width =");
+       status_set_name("%5.2f mm", units_to_mm(self->u.meas.offset));
        edit_expr(&self->obj->u.meas.offset);
 }
 




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to