set_first_sel(): returns first selected element (if any)
This commit is contained in:
parent
584f88fba1
commit
8231cd65db
|
|
@ -1760,25 +1760,8 @@ void edit_property(int x)
|
||||||
tclsetvar("preserve_unchanged_attrs", "0");
|
tclsetvar("preserve_unchanged_attrs", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve first selected element (if still selected)... */
|
j = set_first_sel(0, -2, 0);
|
||||||
if(xctx->first_sel.n >=0 && xctx->first_sel.type == ELEMENT &&
|
type = xctx->sel_array[j].type;
|
||||||
xctx->inst[xctx->first_sel.n].sel == SELECTED) {
|
|
||||||
type = ELEMENT;
|
|
||||||
for(j=0; j < xctx->lastsel; j++) {
|
|
||||||
if(xctx->sel_array[j].type == ELEMENT && xctx->sel_array[j].n == xctx->first_sel.n) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* ... otherwise get first from sel_array[] list */
|
|
||||||
} else {
|
|
||||||
type = xctx->sel_array[0].type;
|
|
||||||
for(j=0; j < xctx->lastsel; j++) {
|
|
||||||
if(xctx->sel_array[j].type == ELEMENT) {
|
|
||||||
type = ELEMENT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
32
src/select.c
32
src/select.c
|
|
@ -725,17 +725,43 @@ void bbox(int what,double x1,double y1, double x2, double y2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_first_sel(unsigned short type, int n, unsigned int col)
|
/* n = -1 : clear first selected info
|
||||||
|
* n = -2 : return first selected element if still selected, or get first from
|
||||||
|
* selected list. Id no elements selected return first selected item (j = 0)
|
||||||
|
* n >= 0 : store indicated element as first selected
|
||||||
|
*/
|
||||||
|
int set_first_sel(unsigned short type, int n, unsigned int col)
|
||||||
{
|
{
|
||||||
if(n == -1) { /* reset first_sel */
|
if(n == -2) {
|
||||||
|
int j;
|
||||||
|
/* retrieve first selected element (if still selected)... */
|
||||||
|
if(xctx->first_sel.n >=0 && xctx->first_sel.type == ELEMENT &&
|
||||||
|
xctx->inst[xctx->first_sel.n].sel == SELECTED) {
|
||||||
|
for(j=0; j < xctx->lastsel; j++) {
|
||||||
|
if(xctx->sel_array[j].type == ELEMENT && xctx->sel_array[j].n == xctx->first_sel.n) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* ... otherwise get first from sel_array[] list */
|
||||||
|
} else {
|
||||||
|
for(j=0; j < xctx->lastsel; j++) {
|
||||||
|
if(xctx->sel_array[j].type == ELEMENT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(j >= xctx->lastsel) j = 0;
|
||||||
|
return j;
|
||||||
|
} else if(n == -1) { /* reset first_sel */
|
||||||
xctx->first_sel.type = 0;
|
xctx->first_sel.type = 0;
|
||||||
xctx->first_sel.n = -1;
|
xctx->first_sel.n = -1;
|
||||||
xctx->first_sel.col = 0;
|
xctx->first_sel.col = 0;
|
||||||
}else if(xctx->first_sel.n == -1) {
|
} else if(xctx->first_sel.n == -1) {
|
||||||
xctx->first_sel.type = type;
|
xctx->first_sel.type = type;
|
||||||
xctx->first_sel.n = n;
|
xctx->first_sel.n = n;
|
||||||
xctx->first_sel.col = col;
|
xctx->first_sel.col = col;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unselect_all(int dr)
|
void unselect_all(int dr)
|
||||||
|
|
|
||||||
|
|
@ -1331,7 +1331,7 @@ extern int text_bbox_nocairo(const char * str,double xscale, double yscale,
|
||||||
|
|
||||||
extern Selected select_object(double mx,double my, unsigned short sel_mode,
|
extern Selected select_object(double mx,double my, unsigned short sel_mode,
|
||||||
int override_lock); /* return type 20160503 */
|
int override_lock); /* return type 20160503 */
|
||||||
extern void set_first_sel(unsigned short type, int n, unsigned int col);
|
extern int set_first_sel(unsigned short type, int n, unsigned int col);
|
||||||
extern void unselect_all(int dr);
|
extern void unselect_all(int dr);
|
||||||
extern void select_attached_nets(void);
|
extern void select_attached_nets(void);
|
||||||
extern void select_inside(double x1,double y1, double x2, double y2, int sel);
|
extern void select_inside(double x1,double y1, double x2, double y2, int sel);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue