Index: trunk/src/layer.h =================================================================== --- trunk/src/layer.h (revision 16184) +++ trunk/src/layer.h (revision 16185) @@ -137,6 +137,7 @@ } meta; unsigned is_bound:1; + unsigned propedit:1; /* temporary: let propedit know this layer is being edited */ }; /* returns the layer number for the passed copper or silk layer pointer */ Index: trunk/src_plugins/propedit/propedit.c =================================================================== --- trunk/src_plugins/propedit/propedit.c (revision 16184) +++ trunk/src_plugins/propedit/propedit.c (revision 16185) @@ -25,6 +25,8 @@ */ #include +#include "board.h" +#include "data.h" #include "plugins.h" #include "config.h" #include "props.h" @@ -42,6 +44,9 @@ { pe_ctx_t ctx; htsp_entry_t *pe; + int need_core = 0, need_layers = 0; + pcb_layer_t *ly = NULL; + pcb_layer_id_t lid; if ((pcb_gui == NULL) || (pcb_gui->propedit_start == NULL)) { pcb_message(PCB_MSG_ERROR, "Error: there's no GUI or the active GUI can't edit properties.\n"); @@ -48,9 +53,34 @@ return 1; } + if (argc > 0) { + int n; + for(n = 0; n < argc; n++) { + if (strcmp(argv[n], "layers") == 0) { + need_layers = 1; + } + else if (strncmp(argv[n], "layer:", 6) == 0) { + need_layers = 1; + ly = pcb_get_layer(PCB, atoi(argv[n]+6)); + if (ly == NULL) { + pcb_message(PCB_MSG_ERROR, "Invalid layer index %s\n", argv[n]); + return 1; + } + } + } + } + else + need_core = 1; + ctx.core_props = pcb_props_init(); - pcb_propsel_map_core(ctx.core_props); + for(lid = 0; lid < PCB->Data->LayerN; lid++) + PCB->Data->Layer[lid].propedit = 0; + if (need_core) + pcb_propsel_map_core(ctx.core_props); + if (need_layers) + pcb_propsel_map_layers(&ctx, ly); + pcb_gui->propedit_start(&ctx, ctx.core_props->fill, propedit_query); for (pe = htsp_first(ctx.core_props); pe; pe = htsp_next(ctx.core_props, pe)) propedit_ins_prop(&ctx, pe); Index: trunk/src_plugins/propedit/propsel.c =================================================================== --- trunk/src_plugins/propedit/propsel.c (revision 16184) +++ trunk/src_plugins/propedit/propsel.c (revision 16185) @@ -98,6 +98,24 @@ #warning TODO: flags } +static int map_layer_cb(void *ctx, pcb_board_t *pcb, pcb_layer_t *layer, int enter) +{ + /* layers can not be selected so do not check for skip */ + map_add_prop(ctx, "p/layer/name", String, layer->name); + map_add_prop(ctx, "p/layer/comb/negative", int, !!(layer->comb & PCB_LYC_SUB)); + map_add_prop(ctx, "p/layer/comb/auto", int, !!(layer->comb & PCB_LYC_AUTO)); +#warning layer TODO: when hardwired layer colors are gone make color selection possible +#if 0 + if (!layer->is_bound) { + map_add_prop(ctx, "p/layer/color", int, layer->meta.real.color); + map_add_prop(ctx, "p/layer/selected_color", int, layer->meta.real.selected_color); + } +#endif + map_attr(ctx, &layer->Attributes); + layer->propedit = 1; + return 0; +} + static void map_line_cb(void *ctx, pcb_board_t *pcb, pcb_layer_t *layer, pcb_line_t *line) { map_chk_skip(ctx, line); @@ -185,6 +203,20 @@ ); } +void pcb_propsel_map_layers(pe_ctx_t *pe, pcb_layer_t *ly) +{ + map_ctx_t ctx; + + ctx.props = pe->core_props; + + if (ly == NULL) { + pcb_loop_all(PCB, &ctx, map_layer_cb, + NULL, NULL, NULL, NULL, NULL, NULL); + } + else + map_layer_cb(&ctx, PCB, ly, 1); +} + /*******************/ typedef struct set_ctx_s { @@ -220,6 +252,26 @@ return 0; } +static void set_layer_cb(void *ctx, pcb_board_t *pcb, pcb_layer_t *layer) +{ + set_ctx_t *st = (set_ctx_t *)ctx; + const char *pn = st->name + 8; + + if (!layer->propedit) + return; + + if (st->is_attr) { + set_attr(st, &layer->Attributes); + return; + } + + if ((strcmp(pn, "name") == 0) && + (pcb_layer_rename_(layer, pcb_strdup(st->value)) == 0)) DONE; + + pcb_message(PCB_MSG_ERROR, "This property can not be changed from the property editor.\n"); +} + + static void set_line_cb(void *ctx, pcb_board_t *pcb, pcb_layer_t *layer, pcb_line_t *line) { set_ctx_t *st = (set_ctx_t *)ctx; @@ -445,7 +497,7 @@ pcb_undo_save_serial(); pcb_loop_all(PCB, &ctx, - NULL, + set_layer_cb, MAYBE_PROP(ctx.is_trace, "p/line/", set_line_cb), MAYBE_PROP(ctx.is_trace, "p/arc/", set_arc_cb), MAYBE_PROP(0, "p/text/", set_text_cb), @@ -453,6 +505,7 @@ MAYBE_PROP(0, "p/subc/", set_subc_cb), MAYBE_PROP(0, "p/padstack/", set_pstk_cb) ); + pcb_undo_inc_serial(); return ctx.set_cnt; } Index: trunk/src_plugins/propedit/propsel.h =================================================================== --- trunk/src_plugins/propedit/propsel.h (revision 16184) +++ trunk/src_plugins/propedit/propsel.h (revision 16185) @@ -26,5 +26,7 @@ /* This API builds a prop list by looking at all selected objects on a design. */ void pcb_propsel_map_core(htsp_t *props); +void pcb_propsel_map_layers(pe_ctx_t *ctx, pcb_layer_t *ly); + int pcb_propsel_set(const char *prop, const char *value); int pcb_propsel_del(const char *attr_name);