Index: trunk/src/layer_grp.c =================================================================== --- trunk/src/layer_grp.c (revision 8680) +++ trunk/src/layer_grp.c (revision 8681) @@ -340,6 +340,38 @@ memmove(&stk->grp[from + delta], &stk->grp[from], sizeof(pcb_layer_group_t) * remaining); } +int pcb_layergrp_step_layer(pcb_layer_group_t *grp, pcb_layer_id_t lid, int delta) +{ + int idx, idx2; + pcb_layer_id_t tmp; + + for(idx = 0; idx < grp->len; idx++) { + if (grp->lid[idx] == lid) { + if (delta > 0) { + if (idx == grp->len - 1) /* already the last */ + return 0; + idx2 = idx+1; + goto swap; + } + else if (delta < 0) { + if (idx == 0) /* already the last */ + return 0; + idx2 = idx-1; + goto swap; + } + else + return -1; + } + } + return -1; + + swap:; + tmp = grp->lid[idx]; + grp->lid[idx] =grp->lid[idx2]; + grp->lid[idx2] = tmp; + return 0; +} + int pcb_layergrp_del(pcb_board_t *pcb, pcb_layergrp_id_t gid, int del_layers) { int n; Index: trunk/src/layer_grp.h =================================================================== --- trunk/src/layer_grp.h (revision 8680) +++ trunk/src/layer_grp.h (revision 8681) @@ -107,6 +107,10 @@ /* Insert a new layer group in the layer stack after the specified group */ pcb_layer_group_t *pcb_layergrp_insert_after(pcb_board_t *pcb, pcb_layergrp_id_t where); +/* Move lid 1 step towards the front (delta=-1) or end (delta=+1) of the + layer list of the group. Return 0 on success (even when already reached + the end of the list) or -1 on error */ +int pcb_layergrp_step_layer(pcb_layer_group_t *grp, pcb_layer_id_t lid, int delta); /* Enable/disable inhibition of layer changed events during layer group updates */ void pcb_layergrp_inhibit_inc(void);