Index: trunk/doc/TODO =================================================================== --- trunk/doc/TODO (revision 29679) +++ trunk/doc/TODO (revision 29680) @@ -8,8 +8,7 @@ - CLEANUP/FEATURE: undo: boardflip doesn't function properly with undo -- repro: open pcb-rnd, place 1206, boardflip(), { u u } removes placed part instead of boardflip [report: Miloh] - CLEANUP/BUG: undo operation while drawing a multiple segment line doesn't change segment attached to the crosshair [report:wojciechk8] - tool_line.c depends on pcb_undo()'s return value; can be fixed only when the old undo system is removed -- CLEANUP: undo on layer group add/remove/move -- CLEANUP: undo on layer group rename +- CLEANUP: undo on layer group add/remove + BUG: add new layer in main window, pcb-rnd issues pcb_warning yet action is placed on undo stack [report: Miloh] - FEATURE/BUG: fungw: call getxy("x", "x") from fawk - the result is coord and is not converted because custom args are converted to NIL [report: Igor2] - BUG: footprint library window tree not refreshing properly after changing filter criteria. repro: type '1206' into filter to filter for 1206.fp part, add a char to the filter criteria '1206x' that removes the match, then delete single char to get '1206' again, and library subdirs refresh closed instead of open. behavior changed sometime between 2.1.2(good) and 2.1.3(bad) [report: Miloh] Index: trunk/src/layer_grp.c =================================================================== --- trunk/src/layer_grp.c (revision 29679) +++ trunk/src/layer_grp.c (revision 29680) @@ -991,6 +991,59 @@ return pcb_layergrp_set_purpose_(lg, pcb_strdup(purpose), undoable); } +/*** undoable flags/type set ***/ + +typedef struct { + pcb_layergrp_t *grp; + pcb_layer_type_t ltype; +} undo_layergrp_ltype_t; + +static int undo_layergrp_ltype_swap(void *udata) +{ + pcb_layer_type_t old; + undo_layergrp_ltype_t *r = udata; + + old = r->grp->ltype; + r->grp->ltype = r->ltype; + r->ltype = old; + + return 0; +} + +static void undo_layergrp_ltype_print(void *udata, char *dst, size_t dst_len) +{ + undo_layergrp_ltype_t *r = udata; + pcb_snprintf(dst, dst_len, "layergrp type: '%lx' -> '%lx'", r->grp->ltype, r->ltype); +} + +static const uundo_oper_t undo_layergrp_ltype = { + core_layergrp_cookie, + NULL, + undo_layergrp_ltype_swap, + undo_layergrp_ltype_swap, + undo_layergrp_ltype_print +}; + + + +int pcb_layergrp_set_ltype(pcb_layergrp_t *grp, pcb_layer_type_t lyt, pcb_bool undoable) +{ + undo_layergrp_ltype_t rtmp, *r = &rtmp; + + if (undoable) + r = pcb_undo_alloc(grp->parent.board, &undo_layergrp_ltype, sizeof(undo_layergrp_ltype_t)); + + r->grp = grp; + r->ltype = lyt; + + undo_layergrp_ltype_swap(r); + if (undoable) + pcb_undo_inc_serial(); + + return 0; + +} + pcb_layergrp_id_t pcb_layergrp_by_name(pcb_board_t *pcb, const char *name) { pcb_layergrp_id_t n; Index: trunk/src/layer_grp.h =================================================================== --- trunk/src/layer_grp.h (revision 29679) +++ trunk/src/layer_grp.h (revision 29680) @@ -178,6 +178,8 @@ int pcb_layergrp_set_purpose_(pcb_layergrp_t *lg, char *purpose, pcb_bool undoable); /* no strdup, send layer change event */ int pcb_layergrp_set_purpose(pcb_layergrp_t *lg, const char *purpose, pcb_bool undoable); /* strdup, send event */ +/* Change layer group flags (layer-type) */ +int pcb_layergrp_set_ltype(pcb_layergrp_t *g, pcb_layer_type_t lyt, pcb_bool undoable); /* Slow linear search for a layer group by name */ pcb_layergrp_id_t pcb_layergrp_by_name(pcb_board_t *pcb, const char *name); Index: trunk/src_plugins/dialogs/dlg_layer_flags.c =================================================================== --- trunk/src_plugins/dialogs/dlg_layer_flags.c (revision 29679) +++ trunk/src_plugins/dialogs/dlg_layer_flags.c (revision 29680) @@ -172,18 +172,20 @@ } if (dlg[wtype].val.lng != orig_type) { - pcb_layer_type_t lyt = 0; - pcb_get_ly_type_(dlg[wtype].val.lng, &lyt); - g->ltype &= ~PCB_LYT_ANYTHING; - g->ltype |= lyt; + pcb_layer_type_t lyt = g->ltype, olyt = 0; + pcb_get_ly_type_(dlg[wtype].val.lng, &olyt); + lyt &= ~PCB_LYT_ANYTHING; + lyt |= olyt; + pcb_layergrp_set_ltype(g, lyt, 1); changed = 1; } if ((!omit_loc) && (dlg[wloc].val.lng != orig_loc)) { if (PCB_LAYER_SIDED(g->ltype)) { - g->ltype &= ~PCB_LYT_ANYWHERE; + pcb_layer_type_t lyt = (g->ltype & ~PCB_LYT_ANYWHERE); if (dlg[wloc].val.lng >= 0) - g->ltype |= ltype_bits[dlg[wloc].val.lng]; + lyt |= ltype_bits[dlg[wloc].val.lng]; + pcb_layergrp_set_ltype(g, lyt, 1); changed = 1; } else