MotionNotify events with Shift key down (and draw_crosshair enabled) will position the crosshair to the closest available landing point (inst pin or wire endpoint)

This commit is contained in:
stefan schippers 2025-01-22 01:57:09 +01:00
parent ed2a4f61c8
commit 0c8631a101
3 changed files with 19 additions and 7 deletions

View File

@ -1340,7 +1340,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
void draw_crosshair(int what) void draw_crosshair(int what)
{ {
int sdw, sdp; int sdw, sdp;
int xhair_size = tclgetintvar("crosshair_size");; int xhair_size = tclgetintvar("crosshair_size");
dbg(1, "draw_crosshair(): what=%d\n", what); dbg(1, "draw_crosshair(): what=%d\n", what);
sdw = xctx->draw_window; sdw = xctx->draw_window;
sdp = xctx->draw_pixmap; sdp = xctx->draw_pixmap;
@ -2532,7 +2532,7 @@ int rstate; /* (reduced state, without ShiftMask) */
} }
} }
/* Select by area. Shift pressed */ /* Select by area. Shift pressed */
else if((state&Button1Mask) && (state & ShiftMask) && else if((state&Button1Mask) && (state & ShiftMask) && !(xctx->ui_state & STARTWIRE) &&
!(xctx->ui_state & (PLACE_SYMBOL | PLACE_TEXT)) && !xctx->shape_point_selected && !(xctx->ui_state & (PLACE_SYMBOL | PLACE_TEXT)) && !xctx->shape_point_selected &&
!xctx->drag_elements && !(xctx->ui_state & STARTPAN) ) { !xctx->drag_elements && !(xctx->ui_state & STARTPAN) ) {
if(mx != xctx->mx_save || my != xctx->my_save) { if(mx != xctx->mx_save || my != xctx->my_save) {
@ -2550,7 +2550,19 @@ int rstate; /* (reduced state, without ShiftMask) */
} }
} }
if(draw_xhair) { if(draw_xhair) {
draw_crosshair(2); if(/* (xctx->ui_state & STARTWIRE) && */ (state & ShiftMask) ) {
double x, y, sx, sy;
sx = xctx->mousex_snap;
sy = xctx->mousey_snap;
find_closest_net_or_symbol_pin(xctx->mousex, xctx->mousey, &x, &y);
xctx->mousex_snap = x;
xctx->mousey_snap = y;
draw_crosshair(2);
xctx->mousex_snap = sx;
xctx->mousey_snap = sy;
} else {
draw_crosshair(2);
}
} }
break; break;

View File

@ -9095,7 +9095,8 @@ set_ne flat_netlist 0
set_ne netlist_show 0 set_ne netlist_show 0
set_ne color_ps 1 set_ne color_ps 1
set_ne ps_page_title 1 ;# add a title in the top left page corner set_ne ps_page_title 1 ;# add a title in the top left page corner
set_ne crosshair_layer 3 ;# TEXTLAYER set_ne draw_crosshair 0
set_ne crosshair_layer 8 ;# Yellow
set_ne crosshair_size 0 set_ne crosshair_size 0
set_ne ps_paper_size {a4 842 595} set_ne ps_paper_size {a4 842 595}
set_ne transparent_svg 0 set_ne transparent_svg 0
@ -9120,7 +9121,6 @@ set_ne load_file_dialog_fullpath 1
set_ne incremental_select 1 set_ne incremental_select 1
set_ne select_touch 1 set_ne select_touch 1
set_ne draw_crosshair 0
set_ne draw_grid 1 set_ne draw_grid 1
set_ne big_grid_points 0 set_ne big_grid_points 0
set_ne draw_grid_axes 1 set_ne draw_grid_axes 1

View File

@ -267,8 +267,8 @@
#### enable drawing crosshairs at mouse coordinates. Default: disabled (0) #### enable drawing crosshairs at mouse coordinates. Default: disabled (0)
# set draw_crosshair 1 # set draw_crosshair 1
#### set crosshair layer; Default 3 (TEXTLAYER) #### set crosshair layer; Default 8 (Yellow)
# set crosshair_layer 3 # set crosshair_layer 8
#### set crosshair size; Default: 0 (full screen spanning crosshair) #### set crosshair size; Default: 0 (full screen spanning crosshair)
# set crosshair_size 5 # set crosshair_size 5