included TheSUPERCD commit 260beff, if (full and only full) crosshair is displayed use snap mouse coordinates since mouse pointer is turned off; fixed an issue when selecting ridicolously small rectangles in find_closest_box()

This commit is contained in:
stefan schippers 2025-01-25 23:41:39 +01:00
parent dad3b78931
commit 1bee3d766f
2 changed files with 14 additions and 3 deletions

View File

@ -2252,6 +2252,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
XKeyboardState kbdstate;
#endif
int draw_xhair = tclgetboolvar("draw_crosshair");
int crosshair_size = tclgetintvar("crosshair_size");
int infix_interface = tclgetboolvar("infix_interface");
int rstate; /* (reduced state, without ShiftMask) */
@ -2373,7 +2374,7 @@ int rstate; /* (reduced state, without ShiftMask) */
dbg(2, "callback(): Enter event, ui_state=%d\n", xctx->ui_state);
xctx->mouse_inside = 1;
if(draw_xhair) {
if(tclgetintvar("crosshair_size") == 0) {
if(crosshair_size == 0) {
tclvareval(xctx->top_path, ".drw configure -cursor none" , NULL);
}
} else
@ -4140,7 +4141,12 @@ int rstate; /* (reduced state, without ShiftMask) */
}
if(!xctx->intuitive_interface && no_shift_no_ctrl ) unselect_all(1);
sel = find_closest_obj(xctx->mousex, xctx->mousey, 0);
if(draw_xhair && crosshair_size == 0) {
sel = find_closest_obj(xctx->mousex_snap, xctx->mousey_snap, 0);
} else {
sel = find_closest_obj(xctx->mousex, xctx->mousey, 0);
}
switch(sel.type) {
case WIRE: if(xctx->wire[sel.n].sel) already_selected = 1; break;

View File

@ -375,8 +375,12 @@ static void find_closest_box(double mx ,double my, int override_lock)
{
double tmp;
double ds = xctx->cadhalfdotsize;
int i, c, r=-1, col = 0;
/* correction for very small boxes */
double min = MINOR(xctx->rect[c][i].x2 - xctx->rect[c][i].x1,
xctx->rect[c][i].y2 - xctx->rect[c][i].y1);
ds = (ds * 8 <= min ) ? ds : min / 8;
for(c=0;c<cadlayers; ++c)
{
if(!xctx->enable_layer[c]) continue;
@ -471,6 +475,7 @@ Selected find_closest_obj(double mx, double my, int override_lock)
distance = DBL_MAX;
find_closest_line(mx, my);
find_closest_polygon(mx, my);
dbg(0, "find_closest_obj(): mx=%g, my=%g\n", mx, my);
/* dbg(1, "1 find_closest_obj(): sel.n=%d, sel.col=%d, sel.type=%d\n", sel.n, sel.col, sel.type); */
find_closest_box(mx, my, override_lock);
find_closest_arc(mx, my);