From 75c8376a049a6c2bf06c390c8d3c484682be5665 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Wed, 8 Nov 2023 22:45:31 +0100 Subject: [PATCH] fix draw_crosshair when xctx->semaphore not zero, fix tabs context menu issues with `open schematc/symbol`; set_modify: do not attempt to reconfigure menu buttons (Simulate-Netlist-Waves) if invoked from preview dialog --- src/actions.c | 7 ++++--- src/callback.c | 10 ++++++++-- src/xinit.c | 14 ++++++++------ src/xschem.tcl | 31 +++++++++++++++++++++---------- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/actions.c b/src/actions.c index 74769fd3..15069dfe 100644 --- a/src/actions.c +++ b/src/actions.c @@ -149,7 +149,8 @@ int set_modify(int mod) xctx->modified = mod; } if(mod == 1 || (mod == 0 && xctx->prev_set_modify) || mod == -2) { - if(has_x) { + /* Do not configure buttons if displaying in preview window */ + if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) { char s[256]; tclvareval(xctx->top_path, ".menubar.netlist configure -bg $simulate_bg", NULL); tclvareval("set tctx::", xctx->current_win_path, "_netlist $simulate_bg", NULL); @@ -163,12 +164,12 @@ int set_modify(int mod) } } if(sch_waves_loaded() >= 0) { - if(has_x) { + if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) { tclvareval("set tctx::", xctx->current_win_path, "_waves LightGreen", NULL); tclvareval(xctx->top_path, ".menubar.waves configure -bg LightGreen", NULL); } } else { - if(has_x) { + if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) { tclvareval("set tctx::", xctx->current_win_path, "_waves $simulate_bg", NULL); tclvareval(xctx->top_path, ".menubar.waves configure -bg $simulate_bg", NULL); } diff --git a/src/callback.c b/src/callback.c index 18709143..2084a6c9 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1010,7 +1010,6 @@ void draw_crosshair(int del) if(!xctx->mouse_inside) return; xctx->draw_pixmap = 0; xctx->draw_window = 1; - if(del != 2) { if(fix_broken_tiled_fill || !_unix) { MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], @@ -1233,7 +1232,13 @@ int rstate; /* (reduced state, without ShiftMask) */ draw_crosshair(1); } if(xctx->ui_state & STARTPAN) pan(RUBBER, mx, my); - if(xctx->semaphore >= 2) break; + if(xctx->semaphore >= 2) { + if(draw_xhair) { + draw_crosshair(2); + } + break; + } + if(xctx->ui_state) { if(abs(mx-xctx->mx_save) > 8 || abs(my-xctx->my_save) > 8 ) { my_snprintf(str, S(str), "mouse = %.16g %.16g - selected: %d w=%.16g h=%.16g", @@ -1314,6 +1319,7 @@ int rstate; /* (reduced state, without ShiftMask) */ } } } + if(draw_xhair) { draw_crosshair(2); } diff --git a/src/xinit.c b/src/xinit.c index 593c400c..af9d3383 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1486,12 +1486,13 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch Window win_id = 0LU; char toppath[WINDOW_PATH_SIZE]; char prev_window[WINDOW_PATH_SIZE]; - int i, n; + int i, n, confirm = 1; dbg(1, "new_schematic() create: fname=%s *window_count = %d\n", fname, *window_count); + if(noconfirm && noconfirm[0]) confirm = 0; my_strncpy(prev_window, xctx->current_win_path, S(prev_window)); - if((!noconfirm || !noconfirm[0]) && fname && fname[0] && check_loaded(fname, toppath)) { + if(confirm && fname && fname[0] && check_loaded(fname, toppath)) { char msg[PATH_MAX+100]; my_snprintf(msg, S(msg), "tk_messageBox -type okcancel -icon warning -parent [xschem get topwindow] " @@ -1563,7 +1564,7 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch xctx->mooz=1/CADINITIALZOOM; xctx->xorigin=CADINITIALX; xctx->yorigin=CADINITIALY; - load_schematic(1, fname, 1, 1); + load_schematic(1, fname, 1, confirm); zoom_full(1, 0, 1 + 2 * tclgetboolvar("zoom_full_center"), 0.97); /* draw */ tclvareval("set_bindings ", window_path[n], NULL); tclvareval("save_ctx ", window_path[n], NULL); @@ -1580,13 +1581,14 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch /* non NULL and not empty noconfirm is used to avoid warning for duplicated filenames */ static void create_new_tab(int *window_count, const char *noconfirm, const char *fname) { - int i; + int i, confirm = 1; char open_path[WINDOW_PATH_SIZE]; char nn[WINDOW_PATH_SIZE]; char win_path[WINDOW_PATH_SIZE]; dbg(1, "new_schematic() new_tab, creating...\n"); - if((!noconfirm || !noconfirm[0]) && fname && fname[0] && check_loaded(fname, open_path)) { + if(noconfirm && noconfirm[0]) confirm = 0; + if(confirm && fname && fname[0] && check_loaded(fname, open_path)) { char msg[PATH_MAX+100]; my_snprintf(msg, S(msg), "tk_messageBox -type okcancel -icon warning -parent [xschem get topwindow] " @@ -1669,7 +1671,7 @@ static void create_new_tab(int *window_count, const char *noconfirm, const char xctx->mooz=1/CADINITIALZOOM; xctx->xorigin=CADINITIALX; xctx->yorigin=CADINITIALY; - load_schematic(1,fname, 1, 1); + load_schematic(1,fname, 1, confirm); zoom_full(1, 0, 1 + 2 * tclgetboolvar("zoom_full_center"), 0.97); /* draw */ /* xctx->pending_fullzoom=1; */ } diff --git a/src/xschem.tcl b/src/xschem.tcl index e66e0cf6..8896941e 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -5812,6 +5812,24 @@ proc tab_ctx_cmd {tab_but what} { # don't switch if we were on the tab that has been closed. xschem new_schematic switch $old {} 1 ;# draw } + } elseif {[regexp {^open } $what]} { + set counterpart [lindex $what 1] + set filetype [lindex $what 2] + + # see if $counterpart already open, in this case switch to it + set found 0 + foreach {tabname filename} $tablist { + if {$filename eq $counterpart} { + set found 1 + break + } + } + if {$found} { + xschem new_schematic switch $tabname {} 1 ;# draw + } else { + xschem new_schematic create {1} $counterpart + if {$filetype ne {symbol} } { xschem set netlist_type symbol} + } } } # puts $filename @@ -5831,9 +5849,6 @@ proc tab_context_menu {tab_but} { } } if {!$found} { set filename {}} - - - set old [xschem get current_win_path] xschem new_schematic switch $win_path {} 0 ;# no draw set filetype [xschem get netlist_type] ;# symbol or spice or vhdl or tedax or verilog @@ -5874,16 +5889,12 @@ proc tab_context_menu {tab_but} { -font [subst $font] -command "set retval 3; tab_ctx_cmd $tab_but term; destroy .ctxmenu" button .ctxmenu.b4 -text {Open sim. dir. term.} -padx 3 -pady 0 -anchor w -activebackground grey50 \ -highlightthickness 0 -image CtxmenuTerm -compound left \ - -font [subst $font] -command "set retval 3; tab_ctx_cmd $tab_but simterm; destroy .ctxmenu" + -font [subst $font] -command "set retval 4; tab_ctx_cmd $tab_but simterm; destroy .ctxmenu" if {$counterpart ne {}} { button .ctxmenu.b6 -text $msg -padx 3 -pady 0 -anchor w -activebackground grey50 \ -highlightthickness 0 -image $img -compound left \ -font [subst $font] \ - -command " - set retval 6 - xschem new_schematic create {} {$counterpart} - destroy .ctxmenu - " + -command "set retval 6; tab_ctx_cmd $tab_but {open {$counterpart} $filetype} ; destroy .ctxmenu" } if {$filetype ne {symbol}} { button .ctxmenu.b5 -text {Edit netlist} -padx 3 -pady 0 -anchor w -activebackground grey50 \ @@ -5895,7 +5906,7 @@ proc tab_context_menu {tab_but} { -font [subst $font] -command "set retval 7; tab_ctx_cmd $tab_but save; destroy .ctxmenu" button .ctxmenu.b8 -text {Close tab} -padx 3 -pady 0 -anchor w -activebackground grey50 \ -highlightthickness 0 -image CtxmenuDelete -compound left \ - -font [subst $font] -command "set retval 7; tab_ctx_cmd $tab_but close; destroy .ctxmenu" + -font [subst $font] -command "set retval 8; tab_ctx_cmd $tab_but close; destroy .ctxmenu" pack .ctxmenu.b0 -fill x -expand true pack .ctxmenu.b1 -fill x -expand true