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. r5769 - trunk/eda/fped (wer...@docs.openmoko.org)
   2. r5770 - trunk/eda/fped (wer...@docs.openmoko.org)
   3. r5771 - trunk/eda/fped (wer...@docs.openmoko.org)
   4. r5772 - trunk/eda/fped (wer...@docs.openmoko.org)
   5. r5773 - trunk/eda/fped (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2010-01-02 13:55:34 +0100 (Sat, 02 Jan 2010)
New Revision: 5769

Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_frame.c
   trunk/eda/fped/gui_over.c
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/gui_tool.h
   trunk/eda/fped/gui_util.c
   trunk/eda/fped/gui_util.h
Log:
More work on tooltips and a build fix.

- Makefile: use PID in temporary file name in PPM to XPM conversion, so that we
  don't get mysterious failures in parallel builds
- gui_util.c (debug_save_pixbuf, debug_save_widget): helper functions to debug
  pixbuf and widget content
- Makefile: added target "montage" to show the images recorded with
  debug_save_pixbuf and debug_save_widget
- gui_over.c: when debugging, record the saves pixbuf in files
- gui_tool.c (tool_hover): removed unnecessary initialization
- added infrastructure for tooltips on the canvas (doesn't work properly yet)



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2010-01-01 22:08:29 UTC (rev 5768)
+++ trunk/eda/fped/Makefile     2010-01-02 12:55:34 UTC (rev 5769)
@@ -1,8 +1,8 @@
 #
 # Makefile - Makefile of fped, the footprint editor
 #
-# Written 2009 by Werner Almesberger
-# Copyright 2009 by Werner Almesberger
+# Written 2009, 2010 by Werner Almesberger
+# Copyright 2009, 2010 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
@@ -78,7 +78,7 @@
 # ----- Rules -----------------------------------------------------------------
 
 .PHONY:                all dep depend clean install uninstall manual 
upload-manual
-.PHONY:                update
+.PHONY:                update montage
 
 .SUFFIXES:     .fig .xpm .ppm
 
@@ -92,10 +92,10 @@
 # ppmtoxpm is very chatty, so we suppress its stderr
 
 .ppm.xpm:
-               $(GEN) ppmcolormask white $< >_tmp && \
-                 ppmtoxpm -name xpm_`basename $@ .xpm` -alphamask _tmp \
-                 $< >$@ 2>/dev/null && rm -f _tmp || \
-                 { rm -f $@ _tmp; exit 1; }
+               $(GEN) export TMP=_tmp$$$$; ppmcolormask white $< >$$TMP && \
+                 ppmtoxpm -name xpm_`basename $@ .xpm` -alphamask $$TMP \
+                 $< >$@ 2>/dev/null && rm -f $$TMP || \
+                 { rm -f $@ $$TMP; exit 1; }
 
 all:           fped
 
@@ -129,6 +129,11 @@
                scp $(XPMS:%.xpm=manual/%.png) $(PNGS:%=manual/%) \
                  $(UPLOAD)/manual/
 
+# ----- Debugging help --------------------------------------------------------
+
+montage:
+               montage -label %f -frame 3 __dbg????.png png:- | display -
+
 # ----- Dependencies ----------------------------------------------------------
 
 dep depend .depend: lex.yy.c y.tab.h y.tab.c
@@ -143,6 +148,7 @@
 clean:
                rm -f $(OBJS) $(XPMS:%=icons/%) $(XPMS:%.xpm=icons/%.ppm)
                rm -f lex.yy.c y.tab.c y.tab.h y.output .depend
+               rm -f __dbg????.png _tmp*
 
 # ----- Install / uninstall ---------------------------------------------------
 

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2010-01-01 22:08:29 UTC (rev 5768)
+++ trunk/eda/fped/gui_canvas.c 2010-01-02 12:55:34 UTC (rev 5769)
@@ -1,8 +1,8 @@
 /*
  * gui_canvas.c - GUI, canvas
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 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
@@ -131,10 +131,13 @@
        gdk_draw_rectangle(draw_ctx.widget->window,
            instantiation_error ? gc_bg_error : gc_bg, TRUE, 0, 0, aw, ah);
 
+       DPRINTF("--- redraw: inst_draw ---");
        inst_draw();
        if (highlight)
                highlight();
+       DPRINTF("--- redraw: tool_redraw ---");
        tool_redraw();
+       DPRINTF("--- redraw: done ---");
 }
 
 
@@ -444,6 +447,23 @@
 }
 
 
+/* ----- tooltip ----------------------------------------------------------- */
+
+
+static gboolean canvas_tooltip(GtkWidget *widget, gint x, gint y,
+    gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
+{
+       struct coord pos = canvas_to_coord(x, y);
+       const char *res;
+
+       res = tool_tip(pos);
+       if (!res)
+               return FALSE;
+       gtk_tooltip_set_markup(tooltip, res);
+       return TRUE;
+}
+
+
 /* ----- canvas setup ------------------------------------------------------ */
 
 
@@ -491,6 +511,10 @@
        g_signal_connect(G_OBJECT(canvas), "leave_notify_event",
            G_CALLBACK(leave_notify_event), NULL);
 
+       gtk_widget_set(canvas, "has-tooltip", TRUE, NULL);
+       g_signal_connect(G_OBJECT(canvas), "query_tooltip",
+           G_CALLBACK(canvas_tooltip), NULL);
+
        gtk_widget_set_events(canvas,
            GDK_EXPOSE | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
            GDK_KEY_PRESS_MASK |

Modified: trunk/eda/fped/gui_frame.c
===================================================================
--- trunk/eda/fped/gui_frame.c  2010-01-01 22:08:29 UTC (rev 5768)
+++ trunk/eda/fped/gui_frame.c  2010-01-02 12:55:34 UTC (rev 5769)
@@ -1,8 +1,8 @@
 /*
  * gui_frame.c - GUI, frame window
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 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

Modified: trunk/eda/fped/gui_over.c
===================================================================
--- trunk/eda/fped/gui_over.c   2010-01-01 22:08:29 UTC (rev 5768)
+++ trunk/eda/fped/gui_over.c   2010-01-02 12:55:34 UTC (rev 5769)
@@ -1,8 +1,8 @@
 /*
  * gui_over.c - GUI, canvas overlays
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 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
@@ -27,8 +27,10 @@
 
 #if 0
 #define DPRINTF(fmt, ...)      fprintf(stderr, fmt "\n", ##__VA_ARGS__)
+#define DSAVE(pix_buf)         debug_save_pixbuf(pix_buf->buf)
 #else
 #define        DPRINTF(fmt, ...)
+#define        DSAVE(buf)
 #endif
 
 
@@ -59,12 +61,14 @@
 static void draw_D(void)
 {
        buf_D = over_D_save_and_draw(over_D_user, over_pos);
+       DSAVE(buf_D);
 }
 
 
 static void draw_H(void)
 {
        buf_H = over_H_save_and_draw(over_H_user);
+       DSAVE(buf_H);
 }
 
 

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2010-01-01 22:08:29 UTC (rev 5768)
+++ trunk/eda/fped/gui_tool.c   2010-01-02 12:55:34 UTC (rev 5769)
@@ -805,7 +805,7 @@
 
 void tool_hover(struct coord pos)
 {
-       struct inst *curr = NULL;
+       struct inst *curr;
 
        curr = get_hover_inst(pos);
 #if 0
@@ -837,6 +837,39 @@
 }
 
 
+/* ----- tooltip ----------------------------------------------------------- */
+
+
+const char *tool_tip(struct coord pos)
+{
+       struct inst *inst;
+
+       inst = get_hover_inst(pos);
+       if (!inst)
+               return NULL;
+
+       /*
+        * Tooltips don't work properly yet, so we return NULL here. The
+        * tooltips themselves are fine, but the expose event generated when
+        * removing the tooltip window upsets the overlay logic for some yet
+        * unknown reason.
+        */
+       return NULL;
+
+       /*
+        * The logic below follows exactly what happens in get_hover_inst.
+        */
+
+       if (drag.new)
+               return "End here";
+       if (drag.anchors_n)
+               return "Move here";
+       if (selected_inst)
+               return "Move this point";
+       return "Start here";
+}
+
+
 /* ----- mouse actions ----------------------------------------------------- */
 
 

Modified: trunk/eda/fped/gui_tool.h
===================================================================
--- trunk/eda/fped/gui_tool.h   2010-01-01 22:08:29 UTC (rev 5768)
+++ trunk/eda/fped/gui_tool.h   2010-01-02 12:55:34 UTC (rev 5769)
@@ -1,8 +1,8 @@
 /*
  * gui_tool.h - GUI, tool bar
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 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
@@ -47,6 +47,7 @@
 
 void tool_dehover(void);
 void tool_hover(struct coord pos);
+const char *tool_tip(struct coord pos);
 int tool_consider_drag(struct coord pos);
 void tool_drag(struct coord to);
 void tool_cancel_drag(void);

Modified: trunk/eda/fped/gui_util.c
===================================================================
--- trunk/eda/fped/gui_util.c   2010-01-01 22:08:29 UTC (rev 5768)
+++ trunk/eda/fped/gui_util.c   2010-01-02 12:55:34 UTC (rev 5769)
@@ -332,6 +332,48 @@
 }
 
 
+/* ----- Debugging support ------------------------------------------------- */
+
+
+/*
+ * View with  make montage  or something like
+ *
+ * montage -label %f -frame 3 __dbg????.png png:- | display -
+ */
+
+void debug_save_pixbuf(GdkPixbuf *buf)
+{
+       static int buf_num = 0;
+       char name[20]; /* plenty */
+
+       sprintf(name, "__dbg%04d.png", buf_num++);
+       gdk_pixbuf_save(buf, name, "png", NULL, NULL);
+       fprintf(stderr, "saved to %s\n", name);
+}
+
+
+/*
+ * gtk_widget_get_snapshot seems to use an expose event to do the drawing. This
+ * means that we can't call debug_save_widget from the expose event handler of
+ * the widget being dumped.
+ */
+
+void debug_save_widget(GtkWidget *widget)
+{
+       GdkPixmap *pixmap;
+       GdkPixbuf *pixbuf;
+       gint w, h;
+
+       pixmap = gtk_widget_get_snapshot(widget, NULL);
+       gdk_drawable_get_size(GDK_DRAWABLE(pixmap), &w, &h);
+       pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE(pixmap),
+           NULL, 0, 0, 0, 0, w, h);
+       debug_save_pixbuf(pixbuf);
+       gdk_pixmap_unref(pixmap);
+       g_object_unref(pixbuf);
+}
+
+
 /* ----- kill the content of a container ----------------------------------- */
 
 

Modified: trunk/eda/fped/gui_util.h
===================================================================
--- trunk/eda/fped/gui_util.h   2010-01-01 22:08:29 UTC (rev 5768)
+++ trunk/eda/fped/gui_util.h   2010-01-02 12:55:34 UTC (rev 5769)
@@ -74,6 +74,9 @@
     const char *s, const char *font, double xalign, double yalign,
     int xmax, int ymax);
 
+void debug_save_pixbuf(GdkPixbuf *buf);
+void debug_save_widget(GtkWidget *widget);
+
 void destroy_all_children(GtkContainer *container);
 
 #endif /* !GUI_UTIL_H */




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-01-02 16:47:46 +0100 (Sat, 02 Jan 2010)
New Revision: 5770

Modified:
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_tool.c
Log:
Canvas tooltips now work. The problem was that expose events set the paint
region to only cover the newly exposed area. This prevented the general 
redrawing from clearing areas that still contained hovering and dragging
items. However,the paint region has no effect on reading from the drawable.
Thus when rebuilding the hover and drag stack, the still tainted image was
stored.

This issue could be solved by either introducing a separate mode where the
stack is redrawn instead of rebuilt, or by turning off double-buffering. 
The former would complicate the already fickle logic of overlays, and not
having double-buffering doesn't seem to cause any ill effects.

- gui_canvas.c (make_canvas): disable double-buffering of canvas so that the
  paint region is not restricted in expose events
- gui_tool.c (tool_tip): enabled canvas tooltips



Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2010-01-02 12:55:34 UTC (rev 5769)
+++ trunk/eda/fped/gui_canvas.c 2010-01-02 15:47:46 UTC (rev 5770)
@@ -522,6 +522,8 @@
            GDK_SCROLL |
            GDK_POINTER_MOTION_MASK);
 
+       gtk_widget_set_double_buffered(canvas, FALSE);
+
        draw_ctx.widget = canvas;
 
        return canvas;

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2010-01-02 12:55:34 UTC (rev 5769)
+++ trunk/eda/fped/gui_tool.c   2010-01-02 15:47:46 UTC (rev 5770)
@@ -849,14 +849,6 @@
                return NULL;
 
        /*
-        * Tooltips don't work properly yet, so we return NULL here. The
-        * tooltips themselves are fine, but the expose event generated when
-        * removing the tooltip window upsets the overlay logic for some yet
-        * unknown reason.
-        */
-       return NULL;
-
-       /*
         * The logic below follows exactly what happens in get_hover_inst.
         */
 




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-01-02 22:38:15 +0100 (Sat, 02 Jan 2010)
New Revision: 5771

Modified:
   trunk/eda/fped/gui_canvas.c
Log:
When selecting a tool and then selecting an object, the tool still appeared to
be active, while in truth it had been reset internally.

- gui_canvas.c (button_press_event): if a click is used for selection (and not
  dragging), reset the tool first



Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2010-01-02 15:47:46 UTC (rev 5770)
+++ trunk/eda/fped/gui_canvas.c 2010-01-02 21:38:15 UTC (rev 5771)
@@ -214,6 +214,7 @@
                        drag_start = pos;
                        break;
                }
+               tool_reset();
                prev = selected_inst;
                inst_select(pos);
                if (prev != selected_inst)




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-01-02 23:04:25 +0100 (Sat, 02 Jan 2010)
New Revision: 5772

Modified:
   trunk/eda/fped/gui_canvas.c
Log:
When repeatedly clicking on a stack of items to cycle through the stack, a 
click on an anchor point of the selected object would be treated as a drag, 
even if the click was very short. This created a very confusing user 
experience.

- gui_canvas.c (button_release_event): if we didn't "escape" the drag radius,
  don't treat the click as a drag but run the click-to-select process instead
  (note: the drag visualization still flickers briefly)
- gui_canvas.c (button_release_event): to find out if we've escaped the drag
  radius, just call drag_left instead of duplicating some of its code



Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2010-01-02 21:38:15 UTC (rev 5771)
+++ trunk/eda/fped/gui_canvas.c 2010-01-02 22:04:25 UTC (rev 5772)
@@ -40,8 +40,11 @@
 static struct coord user_origin = { 0, 0 };
 
 static int dragging = 0;
-static int drag_escaped = 0; /* 1 once we've made is out of the drag radius */
+static int drag_escaped = 0; /* 1 once we've made it out of the drag radius */
 static struct coord drag_start;
+static struct inst *selected_before_drag;
+    /* instance selected before dragging. we use it to do the click-to-select
+       routine in case we later find out the drag was really just a click. */
 
 
 /* ----- status display ---------------------------------------------------- */
@@ -183,11 +186,22 @@
 /* ----- button press and release ------------------------------------------ */
 
 
+static void click_to_select(struct coord pos)
+{
+       const struct inst *prev;
+
+       tool_reset();
+       prev = selected_inst;
+       inst_select(pos);
+       if (prev != selected_inst)
+               redraw();
+}
+
+
 static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
     gpointer data)
 {
        struct coord pos = canvas_to_coord(event->x, event->y);
-       const struct inst *prev;
        int res;
 
        DPRINTF("--- button press ---");
@@ -207,6 +221,7 @@
                        break;
                }
                if (res) {
+                       selected_before_drag = selected_inst;
                        inst_deselect();
                        redraw();
                        dragging = 1;
@@ -214,11 +229,7 @@
                        drag_start = pos;
                        break;
                }
-               tool_reset();
-               prev = selected_inst;
-               inst_select(pos);
-               if (prev != selected_inst)
-                       redraw();
+               click_to_select(pos);
                break;
        case 2:
                tool_dehover();
@@ -241,14 +252,16 @@
        case 1:
                if (!dragging)
                        break;
+               drag_left(pos);
                dragging = 0;
-               if (hypot(pos.x-drag_start.x,
-                   pos.y-drag_start.y)/draw_ctx.scale < DRAG_MIN_R)
+               if (!drag_escaped) {
                        tool_cancel_drag();
-               else {
-                       if (tool_end_drag(pos))
-                               change_world();
+                       selected_inst = selected_before_drag;
+                       click_to_select(pos);
+                       break;
                }
+               if (tool_end_drag(pos))
+                       change_world();
                break;
        }
        return TRUE;




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-01-03 00:27:36 +0100 (Sun, 03 Jan 2010)
New Revision: 5773

Modified:
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_frame.c
   trunk/eda/fped/gui_status.c
   trunk/eda/fped/gui_status.h
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/inst.c
Log:
Yet more tooltips. This time, for all non-editable fields in the status area.

- gui_status.h: use macro to generate status_set_* delarations, just as we use
  a macro for their definitions
- added tooltips for all non-editable fields in the status area



Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2010-01-02 22:04:25 UTC (rev 5772)
+++ trunk/eda/fped/gui_canvas.c 2010-01-02 23:27:36 UTC (rev 5773)
@@ -52,7 +52,7 @@
 
 static void update_zoom(void)
 {
-       status_set_zoom("x%d", draw_ctx.scale);
+       status_set_zoom("Zoom factor", "x%d", draw_ctx.scale);
 }
 
 
@@ -61,18 +61,21 @@
        struct coord user;
        unit_type diag;
 
-       set_with_units(status_set_sys_x, "X ", pos.x);
-       set_with_units(status_set_sys_y, "Y ", pos.y);
+       set_with_units(status_set_sys_x, "X ", pos.x, "Absolute X position");
+       set_with_units(status_set_sys_y, "Y ", pos.y, "Absolute Y position");
 
        user.x = pos.x-user_origin.x;
        user.y = pos.y-user_origin.y;
-       set_with_units(status_set_user_x, "x ", user.x);
-       set_with_units(status_set_user_y, "y ", user.y);
+       set_with_units(status_set_user_x, "x ", user.x,
+           "User X position. Press SPACE to zero.");
+       set_with_units(status_set_user_y, "y ", user.y,
+           "User Y position. Press SPACE to zero.");
 
        if (!selected_inst) {
                diag = hypot(user.x, user.y);
-               set_with_units(status_set_r, "r = ", diag);
-               status_set_angle_xy(user);
+               set_with_units(status_set_r, "r = ", diag,
+                   "Distance from user origin");
+               status_set_angle_xy("Angle from user origin", user);
        }
 }
 

Modified: trunk/eda/fped/gui_frame.c
===================================================================
--- trunk/eda/fped/gui_frame.c  2010-01-02 22:04:25 UTC (rev 5772)
+++ trunk/eda/fped/gui_frame.c  2010-01-02 23:27:36 UTC (rev 5773)
@@ -541,8 +541,8 @@
 {
        inst_select_outside(var, unselect_var);
        label_in_box_bg(var->widget, COLOR_VAR_EDITING);
-       status_set_type_entry("name =");
-       status_set_name("%s", var->name);
+       status_set_type_entry("Variable name", "name =");
+       status_set_name("Variable name", "%s", var->name);
        edit_nothing();
        edit_unique_with_values(&var->name, validate_var_name, var,
            set_values, user, max_values);
@@ -1336,8 +1336,8 @@
        case 1:
                inst_select_outside(widget, unselect_pkg_name);
                label_in_box_bg(widget, COLOR_PART_NAME_EDITING);
-               status_set_type_entry("package =");
-               status_set_name("%s", pkg_name);
+               status_set_type_entry("Package name", "package =");
+               status_set_name("Package name (actual)", "%s", pkg_name);
                edit_nothing();
                edit_name(&pkg_name, validate_pkg_name, NULL);
                break;
@@ -1465,10 +1465,13 @@
 
 static void edit_frame(struct frame *frame)
 {
+       const char *tip;
+
        inst_select_outside(frame, unselect_frame);
        label_in_box_bg(frame->label, COLOR_FRAME_EDITING);
-       status_set_type_entry("name =");
-       status_set_name("%s", frame->name);
+       tip = "Frame name";
+       status_set_type_entry(tip, "name =");
+       status_set_name(tip, "%s", frame->name);
        edit_nothing();
        edit_unique(&frame->name, validate_frame_name, frame);
 }

Modified: trunk/eda/fped/gui_status.c
===================================================================
--- trunk/eda/fped/gui_status.c 2010-01-02 22:04:25 UTC (rev 5772)
+++ trunk/eda/fped/gui_status.c 2010-01-02 23:27:36 UTC (rev 5773)
@@ -71,24 +71,26 @@
 static GtkWidget *status_entry_x;
 
 
-static void set_label(GtkWidget *label, const char *fmt, va_list ap)
+static void set_label(GtkWidget *label, const char *tooltip,
+    const char *fmt, va_list ap)
 {
        char *s;
 
        s = stralloc_vprintf(fmt, ap);
        gtk_label_set_text(GTK_LABEL(label), s);
+       gtk_widget_set_tooltip_markup(label, tooltip);
        free(s);
 }
 
 
-#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);                             \
+#define        SETTER(name)                                                    
\
+       void status_set_##name(const char *tooltip, const char *fmt, ...)\
+       {                                                               \
+               va_list ap;                                             \
+                                                                       \
+               va_start(ap, fmt);                                      \
+               set_label(status_##name, tooltip, fmt, ap);             \
+               va_end(ap);                                             \
        }
 
 SETTER(type_x)
@@ -111,8 +113,8 @@
 /* ----- set things with units --------------------------------------------- */
 
 
-void set_with_units(void (*set)(const char *fmt, ...), const char *prefix,
-    unit_type u)
+void set_with_units(void (*set)(const char *tooltip, const char *fmt, ...),
+    const char *prefix, unit_type u, const char *tooltip)
 {
        double n;
        int mm;
@@ -134,10 +136,10 @@
        }
        if (mm) {
                /* -NNN.NNN mm */
-               set("%s" MM_FORMAT_FIXED " mm", prefix, n);
+               set(tooltip, "%s" MM_FORMAT_FIXED " mm", prefix, n);
        } else {
                /* -NNNN.N mil */
-               set("%s" MIL_FORMAT_FIXED " mil", prefix, n);
+               set(tooltip, "%s" MIL_FORMAT_FIXED " mil", prefix, n);
        }
 }
 
@@ -157,20 +159,20 @@
 void status_set_xy(struct coord coord)
 {
        /* do dX/dY etc. stuff later */
-       status_set_type_x("X =");
-       status_set_type_y("Y =");
+       status_set_type_x("Width", "X =");
+       status_set_type_y("Height", "Y =");
 
-       set_with_units(status_set_x, "", coord.x);
-       set_with_units(status_set_y, "", coord.y);
+       set_with_units(status_set_x, "", coord.x, "Width");
+       set_with_units(status_set_y, "", coord.y, "Height");
 }
 
 
-void status_set_angle_xy(struct coord v)
+void status_set_angle_xy(const char *tooltip, struct coord v)
 {
        if (!v.x && !v.y)
-               status_set_angle("a = 0 deg");
+               status_set_angle(tooltip, "a = 0 deg");
        else
-               status_set_angle("a = %3.1f deg", theta_vec(v));
+               status_set_angle(tooltip, "a = %3.1f deg", theta_vec(v));
 
 }
 
@@ -831,15 +833,17 @@
 
 static void show_curr_unit(void)
 {
+       static const char *tip = "Display unit. Click to cycle.";
+
        switch (curr_unit) {
        case curr_unit_mm:
-               status_set_unit("mm");
+               status_set_unit(tip, "mm");
                break;
        case curr_unit_mil:
-               status_set_unit("mil");
+               status_set_unit(tip, "mil");
                break;
        case curr_unit_auto:
-               status_set_unit("auto");
+               status_set_unit(tip, "auto");
                break;
        default:
                abort();

Modified: trunk/eda/fped/gui_status.h
===================================================================
--- trunk/eda/fped/gui_status.h 2010-01-02 22:04:25 UTC (rev 5772)
+++ trunk/eda/fped/gui_status.h 2010-01-02 23:27:36 UTC (rev 5773)
@@ -1,8 +1,8 @@
 /*
  * gui_status.h - GUI, status area
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 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
@@ -50,43 +50,34 @@
 void edit_y(struct expr **expr);
 void edit_nothing(void);
 
-void set_with_units(void (*set)(const char *fmt, ...), const char *prefix,
-    unit_type u);
+void set_with_units(void (*set)(const char *tooltip, const char *fmt, ...),
+    const char *prefix, unit_type u, const char *tooltip);
 
-void status_set_type_x(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_type_y(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_type_entry(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_name(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_x(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_y(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_r(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_angle(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_sys_x(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_sys_y(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_user_x(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_user_y(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_zoom(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_grid(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
-void status_set_unit(const char *fmt, ...)
-    __attribute__((format(printf, 1, 2)));
+#define SETTER(name)                                                   \
+       void status_set_##name(const char *tooltip, const char *fmt, ...) \
+          __attribute__((format(printf, 2, 3)))                        \
 
+SETTER(type_x);
+SETTER(type_y);
+SETTER(type_entry);
+SETTER(name);
+SETTER(x);
+SETTER(y);
+SETTER(r);
+SETTER(angle);
+SETTER(sys_x);
+SETTER(sys_y);
+SETTER(user_x);
+SETTER(user_y);
+SETTER(zoom);
+SETTER(grid);
+SETTER(unit);
+
+#undef SETTER
+
 void status_set_icon(GtkWidget *image);
 void status_set_xy(struct coord coord);
-void status_set_angle_xy(struct coord v);
+void status_set_angle_xy(const char *tooltip, struct coord v);
 
 void status_begin_reporting(void);
 

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2010-01-02 22:04:25 UTC (rev 5772)
+++ trunk/eda/fped/gui_tool.c   2010-01-02 23:27:36 UTC (rev 5773)
@@ -249,18 +249,18 @@
 
        pos = inst_get_point(from);
        to = gridify(pos, to);
-       status_set_type_x("dX =");
-       status_set_type_y("dX =");
+       status_set_type_x(NULL, "dX =");
+       status_set_type_y(NULL, "dX =");
        /* @@@ use status_set_xy */
        switch (curr_unit) {
        case curr_unit_mm:
        case curr_unit_auto:
-               status_set_x("%lg mm", units_to_mm(to.x-pos.x));
-               status_set_y("%lg mm", units_to_mm(to.y-pos.y));
+               status_set_x(NULL, "%lg mm", units_to_mm(to.x-pos.x));
+               status_set_y(NULL, "%lg mm", units_to_mm(to.y-pos.y));
                break;
        case curr_unit_mil:
-               status_set_x("%lg mil", units_to_mil(to.x-pos.x));
-               status_set_y("%lg mil", units_to_mil(to.y-pos.y));
+               status_set_x(NULL, "%lg mil", units_to_mil(to.x-pos.x));
+               status_set_y(NULL, "%lg mil", units_to_mil(to.y-pos.y));
                break;
        default:
                abort();

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2010-01-02 22:04:25 UTC (rev 5772)
+++ trunk/eda/fped/inst.c       2010-01-02 23:27:36 UTC (rev 5773)
@@ -1,8 +1,8 @@
 /*
  * inst.c - Instance structures
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 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
@@ -386,14 +386,14 @@
                gui_frame_deselect_inst(selected_inst);
        }
        deselect_outside();
-       status_set_type_x("");
-       status_set_type_y("");
-       status_set_type_entry("");
-       status_set_name("");
-       status_set_x("");
-       status_set_y("");
-       status_set_r("");
-       status_set_angle("");
+       status_set_type_x(NULL, "");
+       status_set_type_y(NULL, "");
+       status_set_type_entry(NULL, "");
+       status_set_name(NULL, "");
+       status_set_x(NULL, "");
+       status_set_y(NULL, "");
+       status_set_r(NULL, "");
+       status_set_angle(NULL, "");
        selected_inst = NULL;
        edit_nothing();
        refresh_pos();
@@ -452,15 +452,17 @@
 static void rect_status(struct coord a, struct coord b, unit_type width,
     int rounded)
 {
+       const char *tip;
        struct coord d = sub_vec(b, a);
        double r;
        unit_type diag;
-       
+
        status_set_xy(d);
+       tip = "Angle of diagonal";
        if (!d.x && !d.y)
-               status_set_angle("a = 0 deg");
+               status_set_angle(tip, "a = 0 deg");
        else {
-               status_set_angle("a = %3.1f deg", theta(a, b));
+               status_set_angle(tip, "a = %3.1f deg", theta(a, b));
        }
        if (d.x < 0)
                d.x = -d.x;
@@ -488,10 +490,11 @@
                r = (d.x > d.y ? d.y : d.x)/2;
                diag -= 2*r*(d.x+d.y-sqrt(2*d.x*d.y))/diag;
        }
-       set_with_units(status_set_r, "d = ", diag);
+       set_with_units(status_set_r, "d = ", diag, "Length of diagonal");
        if (width != -1) {
-               status_set_type_entry("width =");
-               set_with_units(status_set_name, "", width);
+               tip = "Line width";
+               status_set_type_entry(tip, "width =");
+               set_with_units(status_set_name, "", width, tip);
        }
 }
 
@@ -578,8 +581,11 @@
 
 static void vec_op_select(struct inst *self)
 {
-       status_set_type_entry("ref =");
-       status_set_name("%s", self->vec->name ? self->vec->name : "");
+       const char *tip;
+
+       tip = "Vector reference (name)";
+       status_set_type_entry(tip, "ref =");
+       status_set_name(tip, "%s", self->vec->name ? self->vec->name : "");
        rect_status(self->base, self->u.vec.end, -1, 0);
        vec_edit(self->vec);
 }
@@ -814,8 +820,8 @@
 
 static void pad_op_select(struct inst *self)
 {
-       status_set_type_entry("label =");
-       status_set_name("%s", self->u.pad.name);
+       status_set_type_entry("Pad name", "label =");
+       status_set_name("Pad name (actual)", "%s", self->u.pad.name);
        rect_status(self->base, self->u.pad.other, -1, 0);
        obj_pad_edit(self->obj);
 }
@@ -842,8 +848,8 @@
 
 static void rpad_op_select(struct inst *self)
 {
-       status_set_type_entry("label =");
-       status_set_name("%s", self->u.pad.name);
+       status_set_type_entry("Pad name", "label =");
+       status_set_name("Pad name (actual)", "%s", self->u.pad.name);
        rect_status(self->base, self->u.pad.other, -1, 1);
        obj_pad_edit(self->obj);
 }
@@ -886,13 +892,16 @@
 
 static void arc_op_select(struct inst *self)
 {
+       const char *tip;
+
        status_set_xy(self->base);
-       status_set_angle("a = %3.1f deg",
+       status_set_angle("Angle", "a = %3.1f deg",
            self->u.arc.a1 == self->u.arc.a2 ? 360 :
            self->u.arc.a2-self->u.arc.a1);
-       set_with_units(status_set_r, "r = ", self->u.arc.r);
-       status_set_type_entry("width =");
-       set_with_units(status_set_name, "", self->u.arc.width);
+       set_with_units(status_set_r, "r = ", self->u.arc.r, "Radius");
+       tip = "Line width";
+       status_set_type_entry(tip, "width =");
+       set_with_units(status_set_name, "", self->u.arc.width, tip);
        obj_arc_edit(self->obj);
 }
 
@@ -959,9 +968,12 @@
 
 static void meas_op_select(struct inst *self)
 {
+       const char *tip;
+
        rect_status(self->bbox.min, self->bbox.max, -1, 0);
-       status_set_type_entry("offset =");
-       set_with_units(status_set_name, "", self->u.meas.offset);
+       tip = "Measurement line offset";
+       status_set_type_entry(tip, "offset =");
+       set_with_units(status_set_name, "", self->u.meas.offset, tip);
        obj_meas_edit(self->obj);
 }
 
@@ -1084,9 +1096,12 @@
 
 static void frame_op_select(struct inst *self)
 {
+       const char *tip;
+
+       tip = "Frame name";
        rect_status(self->bbox.min, self->bbox.max, -1, 0);
-       status_set_type_entry("name =");
-       status_set_name("%s", self->u.frame.ref->name);
+       status_set_type_entry(tip, "name =");
+       status_set_name(tip, "%s", self->u.frame.ref->name);
 }
 
 




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

Reply via email to