diff --git a/Makefile b/Makefile index 5ca09b1..3147a7f 100644 --- a/Makefile +++ b/Makefile @@ -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 \ 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 \ stuff.xpm stuff_off.xpm meas_off.xpm \ bright.xpm bright_off.xpm all.xpm all_off.xpm diff --git a/gui_status.c b/gui_status.c index d6da674..2aa0d56 100644 --- a/gui_status.c +++ b/gui_status.c @@ -55,6 +55,7 @@ static GtkWidget *last_edit = NULL; /* ----- setter functions -------------------------------------------------- */ +static GtkWidget *status_icon; static GtkWidget *status_name, *status_entry; static GtkWidget *status_type_x, *status_type_y, *status_type_entry; 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 -------------------------------------------- */ +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) { /* 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) { 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); - gtk_box_pack_start(GTK_BOX(vbox), tab, FALSE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), tab, TRUE, TRUE, 0); /* types */ diff --git a/gui_status.h b/gui_status.h index e137b77..133c6b4 100644 --- a/gui_status.h +++ b/gui_status.h @@ -84,6 +84,7 @@ void status_set_grid(const char *fmt, ...) void status_set_unit(const char *fmt, ...) __attribute__((format(printf, 1, 2))); +void status_set_icon(GtkWidget *image); void status_set_xy(struct coord coord); void status_set_angle_xy(struct coord v); diff --git a/gui_tool.c b/gui_tool.c index 148019f..c3d16ff 100644 --- a/gui_tool.c +++ b/gui_tool.c @@ -18,6 +18,7 @@ #include "util.h" #include "inst.h" +#include "meas.h" #include "obj.h" #include "gui_util.h" #include "gui_style.h" @@ -30,6 +31,7 @@ #include "gui_tool.h" +#include "icons/arc.xpm" #include "icons/circ.xpm" #include "icons/frame.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 ------------------------------------------------- */ diff --git a/gui_tool.h b/gui_tool.h index 05e1705..1ec6c3b 100644 --- a/gui_tool.h +++ b/gui_tool.h @@ -74,6 +74,8 @@ void tool_frame_deleted(const struct frame *frame); void tool_selected_inst(struct inst *inst); +GtkWidget *get_icon_by_inst(const struct inst *inst); + void tool_reset(void); GtkWidget *gui_setup_tools(GdkDrawable *drawable); diff --git a/inst.c b/inst.c index 6fa992e..92e140c 100644 --- a/inst.c +++ b/inst.c @@ -158,6 +158,7 @@ static void inst_select_inst(struct inst *inst) gui_frame_select_inst(inst); if (inst->ops->select) selected_inst->ops->select(inst); + status_set_icon(get_icon_by_inst(inst)); } @@ -396,6 +397,7 @@ void inst_deselect(void) selected_inst = NULL; edit_nothing(); 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->ops = ops; + inst->prio = prio; inst->vec = NULL; inst->obj = NULL; inst->base = inst->bbox.min = inst->bbox.max = base; diff --git a/inst.h b/inst.h index 94a34aa..ead6f00 100644 --- a/inst.h +++ b/inst.h @@ -73,6 +73,7 @@ struct inst_ops { struct inst { const struct inst_ops *ops; + enum inst_prio prio; /* currently only used for icon selection */ struct coord base; struct bbox bbox; struct vec *vec; /* NULL if not vector */