r5769 - trunk/eda/fped
werner at docs.openmoko.org
werner at docs.openmoko.org
Sat Jan 2 13:55:35 CET 2010
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 */
More information about the commitlog
mailing list