Index: layersel/layersel.c =================================================================== --- layersel/layersel.c (revision 8534) +++ layersel/layersel.c (revision 8535) @@ -3,8 +3,9 @@ #include "layersel.h" #include "lib_gtk_common/compat.h" -#warning TEMPORARY HACK: +#warning TEMPORARY HACKs: #define pcb_hid_actionl(a, b, c) printf("action: " a b "\n") +static layersel_layer_t *current = NULL; /*** Layer visibility widget rendering ***/ #define set_pixel(dst, r, g, b, a) \ @@ -78,6 +79,10 @@ gtk_widget_show(lsl->vis_off); gtk_widget_hide(lsl->vis_on); } + if (lsl == current) + pcb_gtk_set_bg_color(lsl->name_box, 65535, 0, 0); + else + pcb_gtk_set_bg_color(lsl->name_box, 50000, 50000, 50000); } static void group_vis_sync(layersel_grp_t *lsg) @@ -119,11 +124,14 @@ static gboolean layer_select_press_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) { - layersel_layer_t *lsl = user_data; + layersel_layer_t *lsl = user_data, *old_curr; switch(event->button.button) { case 1: printf("layer select!\n"); -#warning TODO: refresh both old selection and new selection + old_curr = current; + current = lsl; + if (old_curr != NULL) + layer_vis_sync(old_curr); layer_vis_sync(lsl); break; case 3: @@ -170,7 +178,7 @@ static GtkWidget *build_layer(layersel_grp_t *lsg, layersel_layer_t *lsl, const char *name) { - GtkWidget *vis_box, *vis_ebox, *ly_name, *ly_name_bx, *lab; + GtkWidget *vis_box, *vis_ebox, *ly_name_bx, *lab; lsl->lsg = lsg; lsl->box = gtkc_hbox_new(0, 0); @@ -185,18 +193,11 @@ gtk_box_pack_start(GTK_BOX(lsl->box), vis_ebox, FALSE, FALSE, 0); ly_name_bx = gtkc_hbox_new(0, 0); - ly_name = wrap_bind_click(ly_name_bx, G_CALLBACK(layer_select_press_cb), lsl); + lsl->name_box = wrap_bind_click(ly_name_bx, G_CALLBACK(layer_select_press_cb), lsl); -{ /* temporary example on selection visualisation */ - static int ctr = 0; - ctr++; - if (ctr == 4) - pcb_gtk_set_bg_color(ly_name, 65535, 0, 0); -} - lab = gtk_label_new(name); gtk_box_pack_start(GTK_BOX(ly_name_bx), lab, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(lsl->box), ly_name, TRUE, TRUE, 10); + gtk_box_pack_start(GTK_BOX(lsl->box), lsl->name_box, TRUE, TRUE, 10); gtk_misc_set_alignment(GTK_MISC(lab), 0, 0.5); Index: layersel/layersel.h =================================================================== --- layersel/layersel.h (revision 8534) +++ layersel/layersel.h (revision 8535) @@ -8,7 +8,7 @@ typedef struct layersel_layer_s layersel_layer_t; struct layersel_layer_s { - GtkWidget *box, *vis_on, *vis_off; + GtkWidget *box, *vis_on, *vis_off, *name_box; unsigned on:1; /* TODO: temporary hack: should be extracted from the layer struct */