From 64cb20dab9819d40ae17d7c2bd60eb8d5495c954 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 29 Sep 2023 00:30:43 +0200 Subject: [PATCH] add crosshair_layer tcl variable, so user can change crosshair layer.Crosshair is deleted on LeaveNotify events. --- src/callback.c | 11 +++++++---- src/draw.c | 4 ++++ src/xinit.c | 8 ++++++++ src/xschem.h | 1 + src/xschem.tcl | 5 +++-- src/xschemrc | 3 +++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/callback.c b/src/callback.c index 2e82955e..28a2872c 100644 --- a/src/callback.c +++ b/src/callback.c @@ -997,7 +997,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int void draw_crosshair(int del) { int sdw, sdp; - dbg(1, "draw_crosshair()\n"); + dbg(1, "draw_crosshair(): del=%d\n", del); sdw = xctx->draw_window; sdp = xctx->draw_pixmap; @@ -1015,18 +1015,18 @@ void draw_crosshair(int del) 4 * INT_WIDTH(xctx->lw), xctx->xrect[0].height, (int)X_TO_SCREEN(xctx->prev_crossx) - 2 * INT_WIDTH(xctx->lw), 0); } - draw_selection(xctx->gc[SELLAYER], 0); drawtempline(xctx->gctiled, NOW, X_TO_XSCHEM(xctx->areax1), xctx->prev_crossy, X_TO_XSCHEM(xctx->areax2), xctx->prev_crossy); drawtempline(xctx->gctiled, NOW, xctx->prev_crossx, Y_TO_XSCHEM(xctx->areay1), xctx->prev_crossx, Y_TO_XSCHEM(xctx->areay2)); if(!del) { - drawline(TEXTLAYER, NOW,X_TO_XSCHEM( xctx->areax1), xctx->mousey_snap, + drawline(xctx->crosshair_layer, NOW,X_TO_XSCHEM( xctx->areax1), xctx->mousey_snap, X_TO_XSCHEM(xctx->areax2), xctx->mousey_snap, 3, NULL); - drawline(TEXTLAYER, NOW, xctx->mousex_snap, Y_TO_XSCHEM(xctx->areay1), + drawline(xctx->crosshair_layer, NOW, xctx->mousex_snap, Y_TO_XSCHEM(xctx->areay1), xctx->mousex_snap, Y_TO_XSCHEM(xctx->areay2), 3, NULL); } + draw_selection(xctx->gc[SELLAYER], 0); xctx->prev_crossx = xctx->mousex_snap; xctx->prev_crossy = xctx->mousey_snap; @@ -1142,6 +1142,9 @@ int rstate; /* (reduced state, without ShiftMask) */ dbg(1, "key=%d EQUAL_MODMASK=%d, SET_MODMASK=%d\n", key, SET_MODMASK, EQUAL_MODMASK); switch(event) { + case LeaveNotify: + draw_crosshair(1); + break; case EnterNotify: if(tclgetboolvar("draw_crosshair")) tclvareval(xctx->top_path, ".drw configure -cursor none" , NULL); diff --git a/src/draw.c b/src/draw.c index 4f660c5e..6d80ec9d 100644 --- a/src/draw.c +++ b/src/draw.c @@ -3657,7 +3657,11 @@ void draw(void) #endif dbg(1, "draw()\n"); + if(!xctx || xctx->no_draw) return; + xctx->crosshair_layer = tclgetintvar("crosshair_layer"); + if(xctx->crosshair_layer < 0 ) xctx->crosshair_layer = 2; + if(xctx->crosshair_layer >= cadlayers ) xctx->crosshair_layer = 2; #if HAS_CAIRO==1 #ifndef __unix__ clear_cairo_surface(xctx->cairo_save_ctx, diff --git a/src/xinit.c b/src/xinit.c index 093ad942..0b8261fe 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -630,6 +630,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path) xctx->gcstipple=my_calloc(_ALLOC_ID_, cadlayers, sizeof(GC)); xctx->color_array=my_calloc(_ALLOC_ID_, cadlayers, sizeof(char*)); xctx->enable_layer=my_calloc(_ALLOC_ID_, cadlayers, sizeof(int)); + xctx->crosshair_layer = TEXTLAYER; xctx->n_active_layers = 0; xctx->active_layer=my_calloc(_ALLOC_ID_, cadlayers, sizeof(int)); xctx->hide_symbols = 0; @@ -2481,6 +2482,7 @@ int Tcl_AppInit(Tcl_Interp *inter) /* get xschem globals from tcl variables set in xschemrc/xschem.tcl */ cairo_font_line_spacing = tclgetdoublevar("cairo_font_line_spacing"); + if(color_ps==-1) color_ps=atoi(tclgetvar("color_ps")); else { @@ -2489,7 +2491,9 @@ int Tcl_AppInit(Tcl_Interp *inter) } l_width=atoi(tclgetvar("line_width")); if(tclgetboolvar("change_lw")) l_width = 0.0; + cadlayers=atoi(tclgetvar("cadlayers")); + fix_broken_tiled_fill = tclgetboolvar("fix_broken_tiled_fill"); if(debug_var==-10) debug_var=0; my_snprintf(tmp, S(tmp), "%.16g",CADGRID); @@ -2507,6 +2511,10 @@ int Tcl_AppInit(Tcl_Interp *inter) /* initialize current schematic name to empty string to avoid gazillion checks in the code for NULL */ my_strdup2(_ALLOC_ID_, &xctx->sch[xctx->currsch], ""); + xctx->crosshair_layer = tclgetintvar("crosshair_layer"); + if(xctx->crosshair_layer < 0 ) xctx->crosshair_layer = 2; + if(xctx->crosshair_layer >= cadlayers ) xctx->crosshair_layer = 2; + /* global context / graphic preferences/settings */ pixdata=my_calloc(_ALLOC_ID_, cadlayers, sizeof(char*)); for(i=0;i "graph_show_measure stop" + bind $topwin "xschem callback %W %T %x %y 0 0 0 %s; graph_show_measure stop" bind $topwin "xschem callback %W %T %x %y 0 %w %h %s" bind $topwin "xschem callback %W -3 %x %y 0 %b 0 %s" bind $topwin "xschem callback %W -3 %x %y 0 %b 0 %s" @@ -6761,6 +6761,7 @@ set_ne split_files 0 set_ne flat_netlist 0 set_ne netlist_show 0 set_ne color_ps 1 +set_ne crosshair_layer 3 ;# TEXTLAYER set_ne ps_paper_size {a4 842 595} set_ne transparent_svg 0 set_ne only_probes 0 ; # 20110112 diff --git a/src/xschemrc b/src/xschemrc index d2cc02c4..c82ecbe7 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -213,6 +213,9 @@ #### enable drawing crosshairs at mouse coordinates. Default: disabled (0) # set draw_crosshair 1 +#### set crosshair layer; Default 3 (TEXTLAYER) +# set crosshair_layer 3 + #### enable to scale grid point size as done with lines at close zoom, default: 0 # set big_grid_points 0