mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-22 06:34:05 +02:00
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) git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5769 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
329b8306aa
commit
14f21c0aee
20
Makefile
20
Makefile
@ -1,8 +1,8 @@
|
|||||||
#
|
#
|
||||||
# Makefile - Makefile of fped, the footprint editor
|
# Makefile - Makefile of fped, the footprint editor
|
||||||
#
|
#
|
||||||
# Written 2009 by Werner Almesberger
|
# Written 2009, 2010 by Werner Almesberger
|
||||||
# Copyright 2009 by Werner Almesberger
|
# Copyright 2009, 2010 by Werner Almesberger
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -78,7 +78,7 @@ endif
|
|||||||
# ----- Rules -----------------------------------------------------------------
|
# ----- Rules -----------------------------------------------------------------
|
||||||
|
|
||||||
.PHONY: all dep depend clean install uninstall manual upload-manual
|
.PHONY: all dep depend clean install uninstall manual upload-manual
|
||||||
.PHONY: update
|
.PHONY: update montage
|
||||||
|
|
||||||
.SUFFIXES: .fig .xpm .ppm
|
.SUFFIXES: .fig .xpm .ppm
|
||||||
|
|
||||||
@ -92,10 +92,10 @@ endif
|
|||||||
# ppmtoxpm is very chatty, so we suppress its stderr
|
# ppmtoxpm is very chatty, so we suppress its stderr
|
||||||
|
|
||||||
.ppm.xpm:
|
.ppm.xpm:
|
||||||
$(GEN) ppmcolormask white $< >_tmp && \
|
$(GEN) export TMP=_tmp$$$$; ppmcolormask white $< >$$TMP && \
|
||||||
ppmtoxpm -name xpm_`basename $@ .xpm` -alphamask _tmp \
|
ppmtoxpm -name xpm_`basename $@ .xpm` -alphamask $$TMP \
|
||||||
$< >$@ 2>/dev/null && rm -f _tmp || \
|
$< >$@ 2>/dev/null && rm -f $$TMP || \
|
||||||
{ rm -f $@ _tmp; exit 1; }
|
{ rm -f $@ $$TMP; exit 1; }
|
||||||
|
|
||||||
all: fped
|
all: fped
|
||||||
|
|
||||||
@ -129,6 +129,11 @@ upload-manual: manual
|
|||||||
scp $(XPMS:%.xpm=manual/%.png) $(PNGS:%=manual/%) \
|
scp $(XPMS:%.xpm=manual/%.png) $(PNGS:%=manual/%) \
|
||||||
$(UPLOAD)/manual/
|
$(UPLOAD)/manual/
|
||||||
|
|
||||||
|
# ----- Debugging help --------------------------------------------------------
|
||||||
|
|
||||||
|
montage:
|
||||||
|
montage -label %f -frame 3 __dbg????.png png:- | display -
|
||||||
|
|
||||||
# ----- Dependencies ----------------------------------------------------------
|
# ----- Dependencies ----------------------------------------------------------
|
||||||
|
|
||||||
dep depend .depend: lex.yy.c y.tab.h y.tab.c
|
dep depend .depend: lex.yy.c y.tab.h y.tab.c
|
||||||
@ -143,6 +148,7 @@ endif
|
|||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) $(XPMS:%=icons/%) $(XPMS:%.xpm=icons/%.ppm)
|
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 lex.yy.c y.tab.c y.tab.h y.output .depend
|
||||||
|
rm -f __dbg????.png _tmp*
|
||||||
|
|
||||||
# ----- Install / uninstall ---------------------------------------------------
|
# ----- Install / uninstall ---------------------------------------------------
|
||||||
|
|
||||||
|
28
gui_canvas.c
28
gui_canvas.c
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* gui_canvas.c - GUI, canvas
|
* gui_canvas.c - GUI, canvas
|
||||||
*
|
*
|
||||||
* Written 2009 by Werner Almesberger
|
* Written 2009, 2010 by Werner Almesberger
|
||||||
* Copyright 2009 by Werner Almesberger
|
* Copyright 2009, 2010 by Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -131,10 +131,13 @@ void redraw(void)
|
|||||||
gdk_draw_rectangle(draw_ctx.widget->window,
|
gdk_draw_rectangle(draw_ctx.widget->window,
|
||||||
instantiation_error ? gc_bg_error : gc_bg, TRUE, 0, 0, aw, ah);
|
instantiation_error ? gc_bg_error : gc_bg, TRUE, 0, 0, aw, ah);
|
||||||
|
|
||||||
|
DPRINTF("--- redraw: inst_draw ---");
|
||||||
inst_draw();
|
inst_draw();
|
||||||
if (highlight)
|
if (highlight)
|
||||||
highlight();
|
highlight();
|
||||||
|
DPRINTF("--- redraw: tool_redraw ---");
|
||||||
tool_redraw();
|
tool_redraw();
|
||||||
|
DPRINTF("--- redraw: done ---");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -444,6 +447,23 @@ static gboolean leave_notify_event(GtkWidget *widget, GdkEventCrossing *event,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- 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 ------------------------------------------------------ */
|
/* ----- canvas setup ------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
@ -491,6 +511,10 @@ GtkWidget *make_canvas(void)
|
|||||||
g_signal_connect(G_OBJECT(canvas), "leave_notify_event",
|
g_signal_connect(G_OBJECT(canvas), "leave_notify_event",
|
||||||
G_CALLBACK(leave_notify_event), NULL);
|
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,
|
gtk_widget_set_events(canvas,
|
||||||
GDK_EXPOSE | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
|
GDK_EXPOSE | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
|
||||||
GDK_KEY_PRESS_MASK |
|
GDK_KEY_PRESS_MASK |
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* gui_frame.c - GUI, frame window
|
* gui_frame.c - GUI, frame window
|
||||||
*
|
*
|
||||||
* Written 2009 by Werner Almesberger
|
* Written 2009, 2010 by Werner Almesberger
|
||||||
* Copyright 2009 by Werner Almesberger
|
* Copyright 2009, 2010 by Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* gui_over.c - GUI, canvas overlays
|
* gui_over.c - GUI, canvas overlays
|
||||||
*
|
*
|
||||||
* Written 2009 by Werner Almesberger
|
* Written 2009, 2010 by Werner Almesberger
|
||||||
* Copyright 2009 by Werner Almesberger
|
* Copyright 2009, 2010 by Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -27,8 +27,10 @@
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define DPRINTF(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
|
#define DPRINTF(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
|
||||||
|
#define DSAVE(pix_buf) debug_save_pixbuf(pix_buf->buf)
|
||||||
#else
|
#else
|
||||||
#define DPRINTF(fmt, ...)
|
#define DPRINTF(fmt, ...)
|
||||||
|
#define DSAVE(buf)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -59,12 +61,14 @@ static struct coord over_pos;
|
|||||||
static void draw_D(void)
|
static void draw_D(void)
|
||||||
{
|
{
|
||||||
buf_D = over_D_save_and_draw(over_D_user, over_pos);
|
buf_D = over_D_save_and_draw(over_D_user, over_pos);
|
||||||
|
DSAVE(buf_D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void draw_H(void)
|
static void draw_H(void)
|
||||||
{
|
{
|
||||||
buf_H = over_H_save_and_draw(over_H_user);
|
buf_H = over_H_save_and_draw(over_H_user);
|
||||||
|
DSAVE(buf_H);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
35
gui_tool.c
35
gui_tool.c
@ -805,7 +805,7 @@ static struct inst *get_hover_inst(struct coord pos)
|
|||||||
|
|
||||||
void tool_hover(struct coord pos)
|
void tool_hover(struct coord pos)
|
||||||
{
|
{
|
||||||
struct inst *curr = NULL;
|
struct inst *curr;
|
||||||
|
|
||||||
curr = get_hover_inst(pos);
|
curr = get_hover_inst(pos);
|
||||||
#if 0
|
#if 0
|
||||||
@ -837,6 +837,39 @@ got:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- 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 ----------------------------------------------------- */
|
/* ----- mouse actions ----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* gui_tool.h - GUI, tool bar
|
* gui_tool.h - GUI, tool bar
|
||||||
*
|
*
|
||||||
* Written 2009 by Werner Almesberger
|
* Written 2009, 2010 by Werner Almesberger
|
||||||
* Copyright 2009 by Werner Almesberger
|
* Copyright 2009, 2010 by Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -47,6 +47,7 @@ void do_move_to_arc(struct inst *inst, struct inst *to, int i);
|
|||||||
|
|
||||||
void tool_dehover(void);
|
void tool_dehover(void);
|
||||||
void tool_hover(struct coord pos);
|
void tool_hover(struct coord pos);
|
||||||
|
const char *tool_tip(struct coord pos);
|
||||||
int tool_consider_drag(struct coord pos);
|
int tool_consider_drag(struct coord pos);
|
||||||
void tool_drag(struct coord to);
|
void tool_drag(struct coord to);
|
||||||
void tool_cancel_drag(void);
|
void tool_cancel_drag(void);
|
||||||
|
42
gui_util.c
42
gui_util.c
@ -332,6 +332,48 @@ void render_text(GdkDrawable *da, GdkGC *gc, int x, int y, double angle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- 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 ----------------------------------- */
|
/* ----- kill the content of a container ----------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,6 +74,9 @@ void render_text(GdkDrawable *da, GdkGC *gc, int x, int y, double angle,
|
|||||||
const char *s, const char *font, double xalign, double yalign,
|
const char *s, const char *font, double xalign, double yalign,
|
||||||
int xmax, int ymax);
|
int xmax, int ymax);
|
||||||
|
|
||||||
|
void debug_save_pixbuf(GdkPixbuf *buf);
|
||||||
|
void debug_save_widget(GtkWidget *widget);
|
||||||
|
|
||||||
void destroy_all_children(GtkContainer *container);
|
void destroy_all_children(GtkContainer *container);
|
||||||
|
|
||||||
#endif /* !GUI_UTIL_H */
|
#endif /* !GUI_UTIL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user