From 5ffc7bb5e4717b1b7e50556de9b19ab63074ffde Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Wed, 4 Oct 2023 00:09:12 +0200 Subject: [PATCH] select_object() returns sel instead of sel.type (more info on return) --- src/callback.c | 23 +++++++++++++---------- src/select.c | 4 ++-- src/xschem.h | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/callback.c b/src/callback.c index b92615af..aa787e82 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1045,7 +1045,6 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, char str[PATH_MAX + 100]; struct stat buf; int redraw_only; - unsigned short sel; double c_snap; #ifndef __unix__ 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 ) * { + Selected sel; * 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 */ if(button == Button3 && state == ControlMask && xctx->semaphore <2) { + Selected sel; 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) { @@ -2536,8 +2537,9 @@ int rstate; /* (reduced state, without ShiftMask) */ } else if(button == Button3 && state == ShiftMask && xctx->semaphore <2) { + Selected sel; 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) { int ret; @@ -2890,6 +2892,7 @@ int rstate; /* (reduced state, without ShiftMask) */ break; } if( !(xctx->ui_state & STARTSELECT) && !(xctx->ui_state & STARTWIRE) && !(xctx->ui_state & STARTLINE) ) { + Selected sel; int prev_last_sel = xctx->lastsel; xctx->mx_save = mx; xctx->my_save = my; xctx->mx_double_save=xctx->mousex_snap; @@ -2899,17 +2902,17 @@ int rstate; /* (reduced state, without ShiftMask) */ } sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0); rebuild_selected_array(); -#ifndef __unix__ + #ifndef __unix__ draw_selection(xctx->gc[SELLAYER], 0); -#endif - if(sel && state == ControlMask) { + #endif + if(sel.type && state == ControlMask) { int savesem = xctx->semaphore; xctx->semaphore = 0; launcher(); xctx->semaphore = savesem; } 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) { redraw_hilights(1); /* 1: clear all hilights, then draw */ } @@ -2968,12 +2971,12 @@ int rstate; /* (reduced state, without ShiftMask) */ if(xctx->semaphore >= 2) break; dbg(1, "callback(): DoubleClick ui_state=%d state=%d\n",xctx->ui_state,state); if(button==Button1) { - int sel; + Selected sel; if(!xctx->lastsel && xctx->ui_state == 0) { /* Following 5 lines do again a selection overriding lock, * so locked instance attrs can be edited */ sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 1); - if(sel) { + if(sel.type) { xctx->ui_state = SELECTION; rebuild_selected_array(); } diff --git a/src/select.c b/src/select.c index 712b496b..6d521c8f 100644 --- a/src/select.c +++ b/src/select.c @@ -1198,7 +1198,7 @@ void select_line(int c, int i, unsigned short select_mode, int fast ) } /* 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; 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); if(sel.type) xctx->ui_state |= SELECTION; - return sel.type; + return sel; } /* Partial-select wire ends that land on instance pins and selected nets */ diff --git a/src/xschem.h b/src/xschem.h index d690ddf4..297d84d8 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -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); #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 */ extern void unselect_all(int dr); extern void select_attached_nets(void);