better threshold for selecting rectangle vertices

This commit is contained in:
stefan schippers 2024-03-04 17:44:35 +01:00
parent 4a418924eb
commit 73ab9de8da
2 changed files with 8 additions and 5 deletions

View File

@ -1347,19 +1347,19 @@ static int edit_rect_point(int state)
xRect *p = &xctx->rect[rect_c][rect_n]; xRect *p = &xctx->rect[rect_c][rect_n];
xctx->need_reb_sel_arr=1; xctx->need_reb_sel_arr=1;
if(POINTINSIDE(xctx->mousex, xctx->mousey, p->x1, p->y1, p->x1 + ds, p->y1 + ds)) { if(POINTINSIDE(xctx->mousex_snap, xctx->mousey_snap, p->x1, p->y1, p->x1 + ds, p->y1 + ds)) {
xctx->shape_point_selected = 1; xctx->shape_point_selected = 1;
p->sel = SELECTED1; p->sel = SELECTED1;
} }
else if(POINTINSIDE(xctx->mousex, xctx->mousey, p->x2 - ds, p->y1, p->x2, p->y1 + ds)) { else if(POINTINSIDE(xctx->mousex_snap, xctx->mousey_snap, p->x2 - ds, p->y1, p->x2, p->y1 + ds)) {
xctx->shape_point_selected = 1; xctx->shape_point_selected = 1;
p->sel = SELECTED2; p->sel = SELECTED2;
} }
else if(POINTINSIDE(xctx->mousex, xctx->mousey, p->x1, p->y2 - ds, p->x1 + ds, p->y2)) { else if(POINTINSIDE(xctx->mousex_snap, xctx->mousey_snap, p->x1, p->y2 - ds, p->x1 + ds, p->y2)) {
xctx->shape_point_selected = 1; xctx->shape_point_selected = 1;
p->sel = SELECTED3; p->sel = SELECTED3;
} }
else if(POINTINSIDE(xctx->mousex, xctx->mousey, p->x2 - ds, p->y2 - ds, p->x2, p->y2)) { else if(POINTINSIDE(xctx->mousex_snap, xctx->mousey_snap, p->x2 - ds, p->y2 - ds, p->x2, p->y2)) {
xctx->shape_point_selected = 1; xctx->shape_point_selected = 1;
p->sel = SELECTED4; p->sel = SELECTED4;
} }

View File

@ -289,13 +289,16 @@ static void find_closest_arc(double mx,double my)
static void find_closest_box(double mx,double my, int override_lock) static void find_closest_box(double mx,double my, int override_lock)
{ {
double tmp; double tmp;
double ds = xctx->cadhalfdotsize;
int i,c,r=-1, col = 0; int i,c,r=-1, col = 0;
for(c=0;c<cadlayers; ++c) for(c=0;c<cadlayers; ++c)
{ {
if(!xctx->enable_layer[c]) continue; if(!xctx->enable_layer[c]) continue;
for(i=0;i<xctx->rects[c]; ++i) for(i=0;i<xctx->rects[c]; ++i)
{ {
if( POINTINSIDE(mx,my,xctx->rect[c][i].x1,xctx->rect[c][i].y1,xctx->rect[c][i].x2,xctx->rect[c][i].y2) ) if( POINTINSIDE(mx,my,xctx->rect[c][i].x1 - ds, xctx->rect[c][i].y1 - ds,
xctx->rect[c][i].x2 + ds, xctx->rect[c][i].y2 + ds) )
{ {
tmp=dist_from_rect(mx,my,xctx->rect[c][i].x1,xctx->rect[c][i].y1, tmp=dist_from_rect(mx,my,xctx->rect[c][i].x1,xctx->rect[c][i].y1,
xctx->rect[c][i].x2,xctx->rect[c][i].y2); xctx->rect[c][i].x2,xctx->rect[c][i].y2);