From 652268c4d0c17f125c76d006e11b726515ebcf20 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Wed, 14 Aug 2024 20:43:47 +0200 Subject: [PATCH] add tcl xschemrc variable "select_touch" that enables selecting objects touched by the selection rectangle if dragging to the left. Previously this behavior was enabled by "incremental_select" that shows selected elements while dragging. These two optional behaviors are now enabled/disabled by separate variables --- src/actions.c | 14 ++++++++------ src/xschem.tcl | 3 ++- src/xschemrc | 4 ++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/actions.c b/src/actions.c index e0ed49b4..348b2cf5 100644 --- a/src/actions.c +++ b/src/actions.c @@ -3739,6 +3739,7 @@ void fix_restore_rect(double x1, double y1, double x2, double y2) void select_rect(int what, int select) { int incremental_select = tclgetboolvar("incremental_select"); + int sel_touch = tclgetboolvar("select_touch"); dbg(1, "select_rect(): what=%d, mousex_save=%g mousey_save=%g, mousex_snap=%g mousey_snap=%g\n", what, xctx->mx_double_save, xctx->my_double_save, xctx->mousex_snap, xctx->mousey_snap); if(what & RUBBER) @@ -3756,10 +3757,10 @@ void select_rect(int what, int select) rebuild_selected_array(); draw_selection(xctx->gc[SELLAYER], 0); - if(incremental_select || !xctx->nl_sel) { - if(xctx->nl_dir == 0) select_inside(xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2, xctx->nl_sel); - else select_touch(xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2, xctx->nl_sel); - } + if(!xctx->nl_sel || (incremental_select && xctx->nl_dir == 0)) + select_inside(xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2, xctx->nl_sel); + else if(incremental_select && xctx->nl_dir == 1 && sel_touch) + select_touch(xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2, xctx->nl_sel); xctx->nl_xx1=xctx->nl_xr;xctx->nl_xx2=xctx->nl_xr2;xctx->nl_yy1=xctx->nl_yr;xctx->nl_yy2=xctx->nl_yr2; RECTORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); drawtemprect(xctx->gc[SELLAYER],NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); @@ -3789,9 +3790,10 @@ void select_rect(int what, int select) { RECTORDER(xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2); drawtemprect(xctx->gctiled, NOW, xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2); - if(!incremental_select || xctx->nl_dir == 0) + + if(!sel_touch || xctx->nl_dir == 0) select_inside(xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2, xctx->nl_sel); - else + else select_touch(xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2, xctx->nl_sel); draw_selection(xctx->gc[SELLAYER], 0); diff --git a/src/xschem.tcl b/src/xschem.tcl index c2ecd8ca..0e66b7fe 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -6965,7 +6965,7 @@ set tctx::global_list { persistent_command preserve_unchanged_attrs prev_symbol ps_colors ps_paper_size rainbow_colors tctx::rcode recentfile retval retval_orig rotated_text search_case search_exact search_found search_schematic - search_select search_value selected_tok show_hidden_texts show_infowindow + search_select search_value select_touch selected_tok show_hidden_texts show_infowindow show_infowindow_after_netlist simconf_default_geometry simconf_vpos simulate_bg spiceprefix split_files svg_colors svg_font_name sym_txt symbol symbol_width tabstop tclcmd_txt tclstop text_line_default_geometry @@ -8406,6 +8406,7 @@ set_ne load_file_dialog_fullpath 1 # once selected these can not be unselected by retracting the selection rectangle # if not set show selected items at end of drag. set_ne incremental_select 1 +set_ne select_touch 1 set_ne draw_crosshair 0 set_ne draw_grid 1 diff --git a/src/xschemrc b/src/xschemrc index 8c1c7aab..24742ecf 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -200,6 +200,10 @@ #### default: not enabled (0) # set unselect_partial_sel_wires 0 +#### if set select objects if touched by selection rectangle while dragging to the left +#### Default: enabled (1) +# set select_touch 0 + #### if set show selected elements while dragging the selection rectangle. #### once selected these can not be unselected by retracting the selection rectangle #### if not set show selected items at end of drag. Default: enabled (1)