display, tools: use gimp_display_shell_untransform_xy_f...

... to get limits in image coordinates instead of gimp_ruler_get_range.
Rulers return values in the active unit (e.g. mm, inches), while the
overlay logic works in pixels. This unit mismatch caused incorrect
clamping of the text overlay position, making it jump
when dragging if the unit wasn't set to pixels.
This commit is contained in:
Gabriele Barbero 2025-12-16 16:06:34 +01:00 committed by Gabriele
parent 8e5f04a570
commit 651ec04744
2 changed files with 22 additions and 10 deletions

View file

@ -1281,13 +1281,22 @@ gimp_display_shell_overlay_allocate (GtkWidget *child,
GtkAllocation *allocation,
GimpDisplayShellOverlay *overlay)
{
gdouble tlx, tly, brx, bry;
gdouble llimit, rlimit, ulimit, blimit;
gdouble tlx;
gdouble tly;
gdouble brx;
gdouble bry;
gdouble llimit;
gdouble rlimit;
gdouble ulimit;
gdouble blimit;
gimp_ruler_get_range ((GimpRuler *) overlay->shell->hrule,
&llimit, &rlimit, NULL);
gimp_ruler_get_range ((GimpRuler *) overlay->shell->vrule,
&ulimit, &blimit, NULL);
gimp_display_shell_untransform_xy_f (overlay->shell,
0.0, 0.0,
&llimit, &ulimit);
gimp_display_shell_untransform_xy_f (overlay->shell,
(gdouble) overlay->shell->disp_width,
(gdouble) overlay->shell->disp_height,
&rlimit, &blimit);
gimp_display_shell_get_overlay_corners (overlay->shell,
child,

View file

@ -2091,10 +2091,13 @@ gimp_text_tool_style_overlay_button_motion (GtkWidget *widget,
x, y,
&x, &y);
gimp_ruler_get_range ((GimpRuler *) shell->hrule,
&llimit, &rlimit, NULL);
gimp_ruler_get_range ((GimpRuler *) shell->vrule,
&ulimit, &blimit, NULL);
gimp_display_shell_untransform_xy_f (shell,
0.0, 0.0,
&llimit, &ulimit);
gimp_display_shell_untransform_xy_f (shell,
(gdouble) shell->disp_width,
(gdouble) shell->disp_height,
&rlimit, &blimit);
gimp_display_shell_get_overlay_corners (shell, text_tool->style_overlay,
x, y,