Skip to content

Commit

Permalink
add crosshair_layer tcl variable, so user can change crosshair layer.…
Browse files Browse the repository at this point in the history
…Crosshair is deleted on LeaveNotify events.
  • Loading branch information
StefanSchippers committed Sep 28, 2023
1 parent db1bf88 commit 64cb20d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/xinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -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<cadlayers; ++i)
Expand Down
1 change: 1 addition & 0 deletions src/xschem.h
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ typedef struct {
int *enable_layer;
int n_active_layers;
int *active_layer;
int crosshair_layer;
char *undo_dirname;
char *infowindow_text; /* ERC messages */
int cur_undo_ptr;
Expand Down
5 changes: 3 additions & 2 deletions src/xschem.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -5589,7 +5589,7 @@ set tctx::global_list {
add_all_windows_drives auto_hilight autofocus_mainwindow
autotrim_wires bespice_listen_port big_grid_points bus_replacement_char cadgrid cadlayers
cadsnap cairo_font_name change_lw color_ps colors compare_sch constrained_move
copy_cell custom_label_prefix custom_token dark_colors dark_colorscheme
copy_cell crosshair_layer custom_label_prefix custom_token dark_colors dark_colorscheme
delay_flag dim_bg dim_value
disable_unique_names do_all_inst draw_crosshair draw_grid draw_window edit_prop_pos edit_prop_size
edit_symbol_prop_new_sel editprop_sympath en_hilight_conn_inst enable_dim_bg enable_stretch
Expand Down Expand Up @@ -5762,7 +5762,7 @@ global env has_x OS autofocus_mainwindow
}
}
"
bind $topwin <Leave> "graph_show_measure stop"
bind $topwin <Leave> "xschem callback %W %T %x %y 0 0 0 %s; graph_show_measure stop"
bind $topwin <Expose> "xschem callback %W %T %x %y 0 %w %h %s"
bind $topwin <Double-Button-1> "xschem callback %W -3 %x %y 0 %b 0 %s"
bind $topwin <Double-Button-2> "xschem callback %W -3 %x %y 0 %b 0 %s"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/xschemrc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 64cb20d

Please sign in to comment.