[Integrated Upstream + Temporary Bugfix]: Integrated the upstream changes for adding a custom rectangular grid-snap cursor, and re-implemented the temporary bugfix from commit ed1a471

This commit is contained in:
Chayan Deb 2025-01-21 22:18:19 +05:30
parent ad89151100
commit 634213d3c9
2 changed files with 9 additions and 38 deletions

View File

@ -1502,33 +1502,6 @@ void draw_snap_cursor(int cursor_type)
xctx->draw_pixmap = sdp;
}
/* what == 0 : erase and draw a new cursor
* what == 1 : erase the cursor
* what == 2 : draw a dot-cursor that snaps to a nearest grid-point */
void draw_grid_cursor(int what)
{
int sdw, sdp;
dbg(1, "draw_grid_cursor(): what=%d\n", what);
sdw = xctx->draw_window;
sdp = xctx->draw_pixmap;
if(!xctx->mouse_inside) return;
xctx->draw_pixmap = 0;
xctx->draw_window = 1;
if(what != 2) {
MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], 0, 0, xctx->xrect[0].width, xctx->xrect[0].height, 0, 0);
}
if(what != 1) {
filledrect(8, NOW, xctx->prev_crossx-1, xctx->prev_crossy-1, xctx->prev_crossx+1, xctx->prev_crossy+1, 3, -1, -1);
}
draw_selection(xctx->gc[SELLAYER], 0);
xctx->prev_crossx = xctx->mousex_snap;
xctx->prev_crossy = xctx->mousey_snap;
xctx->draw_window = sdw;
xctx->draw_pixmap = sdp;
}
/* complete the STARTWIRE, STARTRECT, STARTZOOM, STARTCOPY ... operations */
static int end_place_move_copy_zoom()
{
@ -2473,7 +2446,6 @@ int rstate; /* (reduced state, without ShiftMask) */
case LeaveNotify:
if(draw_xhair) draw_crosshair(1);
else draw_grid_cursor(1);
if(snap_cursor && wire_draw_active) draw_snap_cursor(1);
tclvareval(xctx->top_path, ".drw configure -cursor {}" , NULL);
xctx->mouse_inside = 0;
@ -2544,13 +2516,13 @@ int rstate; /* (reduced state, without ShiftMask) */
}
if(draw_xhair) {
draw_crosshair(1);
} else draw_grid_cursor(1);
}
if(snap_cursor && wire_draw_active) draw_snap_cursor(1);
if(xctx->ui_state & STARTPAN) pan(RUBBER, mx, my);
if(xctx->semaphore >= 2) {
if(draw_xhair) {
draw_crosshair(2);
} else draw_grid_cursor(2);
}
if(snap_cursor && wire_draw_active) draw_snap_cursor(2);
break;
}
@ -2645,7 +2617,7 @@ int rstate; /* (reduced state, without ShiftMask) */
}
if(draw_xhair) {
draw_crosshair(2);
} else draw_grid_cursor(2);
}
if(snap_cursor && wire_draw_active) draw_snap_cursor(2);
break;
@ -4352,9 +4324,9 @@ int rstate; /* (reduced state, without ShiftMask) */
}
/* end wire creation when dragging in intuitive interface from an inst pin ow wire endpoint */
else if(state == Button1Mask && xctx->intuitive_interface && (xctx->ui_state & STARTWIRE)) {
if(end_place_move_copy_zoom()) break;
}
/*else if(state == Button1Mask && xctx->intuitive_interface && (xctx->ui_state & STARTWIRE)) {*/
/* if(end_place_move_copy_zoom()) break;*/
/*}*/
/* end intuitive_interface copy or move */
if(xctx->ui_state & STARTCOPY && xctx->drag_elements) {
@ -4404,7 +4376,6 @@ int rstate; /* (reduced state, without ShiftMask) */
statusmsg(str,1);
}
if(draw_xhair) draw_crosshair(0);
else draw_grid_cursor(0);
if(snap_cursor && wire_draw_active) draw_snap_cursor(0);
break;
case -3: /* double click : edit prop */

View File

@ -277,13 +277,13 @@
# set enable_stretch 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 3
set crosshair_layer 8
#### set crosshair size; Default: 0 (full screen spanning crosshair)
# set crosshair_size 5
set crosshair_size 4
#### enable to scale grid point size as done with lines at close zoom, default: 0
# set big_grid_points 0