add xschemrc variable "graph_select_to_zoom" (default set to 0). If set to 1 a graph must be selected to operate on it.

This commit is contained in:
stefan schippers 2026-08-10 12:26:33 +02:00
parent 8b0fccea18
commit 1563b0199b
4 changed files with 21 additions and 7 deletions

View File

@ -31,6 +31,7 @@ static int waves_selected(int event, KeySym key, int state, int button)
int rstate; /* state without ShiftMask */
int i, check;
int graph_use_ctrl_key = tclgetboolvar("graph_use_ctrl_key");
int graph_select_to_zoom = tclgetboolvar("graph_select_to_zoom");
int is_inside = 0, skip = 0;
static unsigned int excl = STARTZOOM | STARTRECT | STARTLINE | STARTWIRE |
STARTPAN | STARTSELECT | STARTMOVE | STARTCOPY;
@ -41,9 +42,11 @@ static int waves_selected(int event, KeySym key, int state, int button)
rstate &= ~ShiftMask; /* don't use ShiftMask, identifying characters is sufficient */
if(xctx->ui_state & excl) skip = 1;
/* else if(event != -3 && sch_waves_loaded() < 0 ) skip = 1; */
/* allow to work on graphs even if ctrl released while in GRAPHPAN mode
* This is useful on touchpads with TappingDragLock enabled */
else if(graph_use_ctrl_key && !(state & ControlMask) && !(xctx->ui_state & GRAPHPAN)) skip = 1;
else if(!graph_select_to_zoom && graph_use_ctrl_key &&
!(state & ControlMask) && !(xctx->ui_state & GRAPHPAN)) skip = 1;
else if(SET_MODMASK) skip = 1;
else if(event == MotionNotify && (state & Button2Mask)) skip = 1;
else if(event == MotionNotify && (state & Button1Mask) && (state & ShiftMask)) skip = 1;
@ -53,15 +56,16 @@ static int waves_selected(int event, KeySym key, int state, int button)
/* else if(event == KeyPress && (state & ShiftMask)) skip = 1; */
else if(!skip) for(i=0; i< xctx->rects[GRIDLAYER]; ++i) {
double lmargin;
int sel;
xRect *r;
r = &xctx->rect[GRIDLAYER][i];
if(!(r->flags & 1) ) continue;
sel = (r->sel == SELECTED);
lmargin = (r->x2 - r->x1) / 20.;
lmargin = lmargin < 3. ? 3. : lmargin;
lmargin = lmargin > 20. ? 20. : lmargin;
if(!(r->flags & 1) ) continue;
if( !graph_use_ctrl_key && !(state & ControlMask) &&
!strboolcmp(get_tok_value(xctx->rect[GRIDLAYER][i].prop_ptr, "lock", 0), "true")) continue;
check =
(xctx->ui_state & GRAPHPAN) ||
((event == ButtonPress || event == ButtonRelease) && button == Button3 &&
@ -80,7 +84,7 @@ static int waves_selected(int event, KeySym key, int state, int button)
)
);
if(check) {
if(check && (sel || !graph_select_to_zoom)) {
is_inside = 1;
if(! (xctx->ui_state & GRAPHPAN) ) {
xctx->graph_master = i;
@ -423,6 +427,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
Graph_ctx *gr;
int rstate; /* reduced state wit ShiftMask bit filtered out */
int graph_use_ctrl_key = tclgetboolvar("graph_use_ctrl_key");
int graph_select_to_zoom = tclgetboolvar("graph_select_to_zoom");
int i, dataset = 0;
int need_fullredraw = 0, need_all_redraw = 0, need_redraw = 0, need_redraw_master = 0;
double xx1 = 0.0, xx2 = 0.0, yy1, yy2;
@ -431,7 +436,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
int save_mouse_at_end = 0, clear_graphpan_at_end = 0;
int track_dset = -2; /* used to find dataset of closest wave to mouse if 't' is pressed */
xRect *r = NULL;
int access_cond = !graph_use_ctrl_key || (state & ControlMask);
int access_cond = graph_select_to_zoom && (!graph_use_ctrl_key || (state & ControlMask));
dbg(1, "uistate=%d, graph_flags=%d\n", xctx->ui_state, xctx->graph_flags);
/* if(event != -3 && !xctx->raw) return 0; */

View File

@ -3138,7 +3138,7 @@ static void draw_graph_grid(Graph_ctx *gr, void *ct)
/* background */
filledrect(0, NOW, gr->rx1, gr->ry1, gr->rx2, gr->ry2, 2, -1, -1);
/* graph bounding box */
drawrect(GRIDLAYER, NOW, gr->rx1, gr->ry1, gr->rx2, gr->ry2, 0.0, 2, -1, -1);
drawrect(WIRELAYER, NOW, gr->rx1, gr->ry1, gr->rx2, gr->ry2, 0.0, 2, -1, -1);
bbox(START, 0.0, 0.0, 0.0, 0.0);
bbox(ADD, gr->rx1, gr->ry1, gr->rx2, gr->ry2);

View File

@ -9767,7 +9767,7 @@ set tctx::global_list {
fix_broken_tiled_fill flat_netlist fullscreen gaw_fd gaw_tcp_address graph_autoload graph_bus
graph_change_done graph_dialog_default_geometry graph_digital graph_legend graph_linewidth_mult
graph_logx graph_logy graph_private_cursor graph_rainbow graph_schname graph_sel_color
graph_sel_wave graph_selected graph_sort graph_unlocked graph_use_ctrl_key
graph_sel_wave graph_selected graph_select_to_zoom graph_sort graph_unlocked graph_use_ctrl_key
graph_vlegend hide_empty_graphs
hide_symbols incr_hilight incremental_select infix_interface infowindow_text intuitive_interface
keep_symbols launcher_default_program light_colors line_width live_cursor2_backannotate
@ -11465,6 +11465,7 @@ set_ne uppercase_subckt 0
set_ne lvs_ignore 0
set_ne hide_empty_graphs 0 ;# if set to 1 waveform boxes will be hidden if no raw file loaded
set_ne graph_use_ctrl_key 0;# if set forces to use Control key to operate on graphs
set_ne graph_select_to_zoom 0; #if set requires graph box to be selected to allow to zoom / pan with mouse / keys.
set_ne spiceprefix 1
set_ne verilog_2001 1
set_ne verilog_bitblast 0

View File

@ -689,6 +689,14 @@
#### Default: 0 (not set)
# set graph_use_ctrl_key 1
###########################################################################
#### REQUIRE GRAPH TO BE SELECTED TO OPERATE ON IT.
###########################################################################
#### if enabled requires graph to be selected to allow panning / zooming
#### waveforms.
#### Default: 0 (not set)
# set graph_select_to_zoom 1
###########################################################################
#### HIDE GRAPHS IF NO SPICE DATA LOADED
###########################################################################