From 70ebbb7e071107468abadbac9acbcfda4a68cdaf Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Sun, 22 Nov 2020 16:17:58 -0500 Subject: [PATCH] position [cnv] drag anchor inside the bottom-right corner of the rectangle --- pd/src/g_all_guis.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 1da777dd9..92ca771a7 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -897,9 +897,20 @@ void scalehandle_draw_select2(t_iemgui *x) the one for the label. Special case for [cnv] which for some reason allows a smaller selection area than its painted rectangle. */ if (c == my_canvas_class) + { + /* We're drawing the anchor rectangle by abusing the <line> svg elem + with a width equal to SCALEHANDLE_WIDTH. + + This simplifies the CSS, but unfortunately makes the positioning + a little wonky: + + For example-- a vertical line from sy to sy+10 with a width of 10 + will straddle the horizontal point sx. So to get the leftmost part + of our rect at sx, we multiply the width by 0.5 and add that to sx. + */ scalehandle_draw_select(x->x_handle, - (int)(sx + SCALEHANDLE_WIDTH * 1.5) + 1, - sy + SCALEHANDLE_HEIGHT); + (int)(sx + SCALEHANDLE_WIDTH * 0.5), sy); + } if (x->x_lab != s_empty) scalehandle_draw_select(x->x_lhandle, x->x_ldx + 5, x->x_ldy + 10); } -- GitLab