1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-29 00:11:32 +02:00

It can sometimes be unclear what exactly has been selected. To improve this,

we now display an icon for the currently selected instance in the status area.



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5757 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-12-15 21:24:30 +00:00
parent 83669c6db7
commit b37a8599d9
7 changed files with 86 additions and 2 deletions

View File

@ -23,7 +23,7 @@ OBJS = fped.o expr.o coord.o obj.o delete.o inst.o util.o error.o \
XPMS = point.xpm delete.xpm delete_off.xpm \ XPMS = point.xpm delete.xpm delete_off.xpm \
vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm \ vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm \
line.xpm rect.xpm pad.xpm rpad.xpm circ.xpm \ line.xpm rect.xpm pad.xpm rpad.xpm arc.xpm circ.xpm \
meas.xpm meas_x.xpm meas_y.xpm \ meas.xpm meas_x.xpm meas_y.xpm \
stuff.xpm stuff_off.xpm meas_off.xpm \ stuff.xpm stuff_off.xpm meas_off.xpm \
bright.xpm bright_off.xpm all.xpm all_off.xpm bright.xpm bright_off.xpm all.xpm all_off.xpm

View File

@ -55,6 +55,7 @@ static GtkWidget *last_edit = NULL;
/* ----- setter functions -------------------------------------------------- */ /* ----- setter functions -------------------------------------------------- */
static GtkWidget *status_icon;
static GtkWidget *status_name, *status_entry; static GtkWidget *status_name, *status_entry;
static GtkWidget *status_type_x, *status_type_y, *status_type_entry; static GtkWidget *status_type_x, *status_type_y, *status_type_entry;
static GtkWidget *status_box_x, *status_entry_y; static GtkWidget *status_box_x, *status_entry_y;
@ -144,6 +145,15 @@ void set_with_units(void (*set)(const char *fmt, ...), const char *prefix,
/* ----- complex status updates -------------------------------------------- */ /* ----- complex status updates -------------------------------------------- */
void status_set_icon(GtkWidget *image)
{
vacate_widget(status_icon);
if (image)
gtk_container_add(GTK_CONTAINER(status_icon), image);
gtk_widget_show_all(status_icon);
}
void status_set_xy(struct coord coord) void status_set_xy(struct coord coord)
{ {
/* do dX/dY etc. stuff later */ /* do dX/dY etc. stuff later */
@ -920,9 +930,19 @@ static GtkWidget *add_entry(GtkWidget *tab, int col, int row)
void make_status_area(GtkWidget *vbox) void make_status_area(GtkWidget *vbox)
{ {
GtkWidget *tab, *sep; GtkWidget *tab, *sep;
GtkWidget *hbox, *vbox2;
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
vbox2 = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 1);
status_icon = gtk_event_box_new();
gtk_box_pack_start(GTK_BOX(vbox2), status_icon, FALSE, FALSE, 0);
tab = gtk_table_new(7, 3, FALSE); tab = gtk_table_new(7, 3, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), tab, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), tab, TRUE, TRUE, 0);
/* types */ /* types */

View File

@ -84,6 +84,7 @@ void status_set_grid(const char *fmt, ...)
void status_set_unit(const char *fmt, ...) void status_set_unit(const char *fmt, ...)
__attribute__((format(printf, 1, 2))); __attribute__((format(printf, 1, 2)));
void status_set_icon(GtkWidget *image);
void status_set_xy(struct coord coord); void status_set_xy(struct coord coord);
void status_set_angle_xy(struct coord v); void status_set_angle_xy(struct coord v);

View File

@ -18,6 +18,7 @@
#include "util.h" #include "util.h"
#include "inst.h" #include "inst.h"
#include "meas.h"
#include "obj.h" #include "obj.h"
#include "gui_util.h" #include "gui_util.h"
#include "gui_style.h" #include "gui_style.h"
@ -30,6 +31,7 @@
#include "gui_tool.h" #include "gui_tool.h"
#include "icons/arc.xpm"
#include "icons/circ.xpm" #include "icons/circ.xpm"
#include "icons/frame.xpm" #include "icons/frame.xpm"
#include "icons/frame_locked.xpm" #include "icons/frame_locked.xpm"
@ -977,6 +979,61 @@ void tool_redraw(void)
} }
/* ----- Retrieve icons by instance characteristics ------------------------ */
GtkWidget *get_icon_by_inst(const struct inst *inst)
{
char **image;
switch (inst->prio) {
case ip_frame:
image = xpm_frame;
break;
case ip_pad_copper:
case ip_pad_special:
image = inst->obj->u.pad.rounded ? xpm_rpad : xpm_pad;
break;
case ip_circ:
image = xpm_circ;
break;
case ip_arc:
image = xpm_arc;
break;
case ip_rect:
image = xpm_rect;
break;
case ip_meas:
switch (inst->obj->u.meas.type) {
case mt_xy_next:
case mt_xy_max:
image = xpm_meas;
break;
case mt_x_next:
case mt_x_max:
image = xpm_meas_x;
break;
case mt_y_next:
case mt_y_max:
image = xpm_meas_y;
break;
default:
abort();
}
break;
case ip_line:
image = xpm_line;
break;
case ip_vec:
image = xpm_vec;
break;
default:
abort();
}
return make_image(DA, image);
}
/* ----- tool bar creation ------------------------------------------------- */ /* ----- tool bar creation ------------------------------------------------- */

View File

@ -74,6 +74,8 @@ void tool_frame_deleted(const struct frame *frame);
void tool_selected_inst(struct inst *inst); void tool_selected_inst(struct inst *inst);
GtkWidget *get_icon_by_inst(const struct inst *inst);
void tool_reset(void); void tool_reset(void);
GtkWidget *gui_setup_tools(GdkDrawable *drawable); GtkWidget *gui_setup_tools(GdkDrawable *drawable);

3
inst.c
View File

@ -158,6 +158,7 @@ static void inst_select_inst(struct inst *inst)
gui_frame_select_inst(inst); gui_frame_select_inst(inst);
if (inst->ops->select) if (inst->ops->select)
selected_inst->ops->select(inst); selected_inst->ops->select(inst);
status_set_icon(get_icon_by_inst(inst));
} }
@ -396,6 +397,7 @@ void inst_deselect(void)
selected_inst = NULL; selected_inst = NULL;
edit_nothing(); edit_nothing();
refresh_pos(); refresh_pos();
status_set_icon(NULL);
} }
@ -536,6 +538,7 @@ static struct inst *add_inst(const struct inst_ops *ops, enum inst_prio prio,
inst = alloc_type(struct inst); inst = alloc_type(struct inst);
inst->ops = ops; inst->ops = ops;
inst->prio = prio;
inst->vec = NULL; inst->vec = NULL;
inst->obj = NULL; inst->obj = NULL;
inst->base = inst->bbox.min = inst->bbox.max = base; inst->base = inst->bbox.min = inst->bbox.max = base;

1
inst.h
View File

@ -73,6 +73,7 @@ struct inst_ops {
struct inst { struct inst {
const struct inst_ops *ops; const struct inst_ops *ops;
enum inst_prio prio; /* currently only used for icon selection */
struct coord base; struct coord base;
struct bbox bbox; struct bbox bbox;
struct vec *vec; /* NULL if not vector */ struct vec *vec; /* NULL if not vector */