select_object() returns sel instead of sel.type (more info on return)

This commit is contained in:
stefan schippers 2023-10-04 00:09:12 +02:00
parent 822910fce7
commit 5ffc7bb5e4
3 changed files with 16 additions and 13 deletions

View File

@ -1045,7 +1045,6 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
char str[PATH_MAX + 100]; char str[PATH_MAX + 100];
struct stat buf; struct stat buf;
int redraw_only; int redraw_only;
unsigned short sel;
double c_snap; double c_snap;
#ifndef __unix__ #ifndef __unix__
short cstate = GetKeyState(VK_CAPITAL); short cstate = GetKeyState(VK_CAPITAL);
@ -2515,16 +2514,18 @@ int rstate; /* (reduced state, without ShiftMask) */
/* /*
* if(button == Button3 && tclgetvar("graph_selected")[0] && xctx->semaphore >=2 ) * if(button == Button3 && tclgetvar("graph_selected")[0] && xctx->semaphore >=2 )
* { * {
Selected sel;
* sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0); * sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
* if(sel) send_net_to_graph(1); * if(sel.type) send_net_to_graph(1);
* *
* } * }
* else * else
*/ */
if(button == Button3 && state == ControlMask && xctx->semaphore <2) if(button == Button3 && state == ControlMask && xctx->semaphore <2)
{ {
Selected sel;
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0); sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
if(sel) select_connected_nets(1); if(sel.type) select_connected_nets(1);
} }
else if(button == Button3 && EQUAL_MODMASK && xctx->semaphore <2) else if(button == Button3 && EQUAL_MODMASK && xctx->semaphore <2)
{ {
@ -2536,8 +2537,9 @@ int rstate; /* (reduced state, without ShiftMask) */
} }
else if(button == Button3 && state == ShiftMask && xctx->semaphore <2) else if(button == Button3 && state == ShiftMask && xctx->semaphore <2)
{ {
Selected sel;
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0); sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
if(sel) select_connected_nets(0); if(sel.type) select_connected_nets(0);
} }
else if(button == Button3 && state == 0 && xctx->semaphore <2) { else if(button == Button3 && state == 0 && xctx->semaphore <2) {
int ret; int ret;
@ -2890,6 +2892,7 @@ int rstate; /* (reduced state, without ShiftMask) */
break; break;
} }
if( !(xctx->ui_state & STARTSELECT) && !(xctx->ui_state & STARTWIRE) && !(xctx->ui_state & STARTLINE) ) { if( !(xctx->ui_state & STARTSELECT) && !(xctx->ui_state & STARTWIRE) && !(xctx->ui_state & STARTLINE) ) {
Selected sel;
int prev_last_sel = xctx->lastsel; int prev_last_sel = xctx->lastsel;
xctx->mx_save = mx; xctx->my_save = my; xctx->mx_save = mx; xctx->my_save = my;
xctx->mx_double_save=xctx->mousex_snap; xctx->mx_double_save=xctx->mousex_snap;
@ -2902,14 +2905,14 @@ int rstate; /* (reduced state, without ShiftMask) */
#ifndef __unix__ #ifndef __unix__
draw_selection(xctx->gc[SELLAYER], 0); draw_selection(xctx->gc[SELLAYER], 0);
#endif #endif
if(sel && state == ControlMask) { if(sel.type && state == ControlMask) {
int savesem = xctx->semaphore; int savesem = xctx->semaphore;
xctx->semaphore = 0; xctx->semaphore = 0;
launcher(); launcher();
xctx->semaphore = savesem; xctx->semaphore = savesem;
} }
if( !(state & ShiftMask) ) { if( !(state & ShiftMask) ) {
if(tclgetboolvar("auto_hilight") && xctx->hilight_nets && sel == 0 ) { if(tclgetboolvar("auto_hilight") && xctx->hilight_nets && sel.type == 0 ) {
if(!prev_last_sel) { if(!prev_last_sel) {
redraw_hilights(1); /* 1: clear all hilights, then draw */ redraw_hilights(1); /* 1: clear all hilights, then draw */
} }
@ -2968,12 +2971,12 @@ int rstate; /* (reduced state, without ShiftMask) */
if(xctx->semaphore >= 2) break; if(xctx->semaphore >= 2) break;
dbg(1, "callback(): DoubleClick ui_state=%d state=%d\n",xctx->ui_state,state); dbg(1, "callback(): DoubleClick ui_state=%d state=%d\n",xctx->ui_state,state);
if(button==Button1) { if(button==Button1) {
int sel; Selected sel;
if(!xctx->lastsel && xctx->ui_state == 0) { if(!xctx->lastsel && xctx->ui_state == 0) {
/* Following 5 lines do again a selection overriding lock, /* Following 5 lines do again a selection overriding lock,
* so locked instance attrs can be edited */ * so locked instance attrs can be edited */
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 1); sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 1);
if(sel) { if(sel.type) {
xctx->ui_state = SELECTION; xctx->ui_state = SELECTION;
rebuild_selected_array(); rebuild_selected_array();
} }

View File

@ -1198,7 +1198,7 @@ void select_line(int c, int i, unsigned short select_mode, int fast )
} }
/* 20160503 return type field */ /* 20160503 return type field */
unsigned short select_object(double mx,double my, unsigned short select_mode, int override_lock) Selected select_object(double mx,double my, unsigned short select_mode, int override_lock)
{ {
Selected sel; Selected sel;
sel = find_closest_obj(mx, my, override_lock); sel = find_closest_obj(mx, my, override_lock);
@ -1237,7 +1237,7 @@ unsigned short select_object(double mx,double my, unsigned short select_mode, in
drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0);
if(sel.type) xctx->ui_state |= SELECTION; if(sel.type) xctx->ui_state |= SELECTION;
return sel.type; return sel;
} }
/* Partial-select wire ends that land on instance pins and selected nets */ /* Partial-select wire ends that land on instance pins and selected nets */

View File

@ -1271,7 +1271,7 @@ extern int text_bbox_nocairo(const char * str,double xscale, double yscale,
double *rx2, double *ry2, int *cairo_lines, double *longest_line); double *rx2, double *ry2, int *cairo_lines, double *longest_line);
#endif #endif
extern unsigned short 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 unselect_all(int dr); extern void unselect_all(int dr);
extern void select_attached_nets(void); extern void select_attached_nets(void);