app: add gimp_canvas_item_untransform_viewport()

... which untransforms the viewport from display space to the
item's coordinate space (i.e., scaled and translated image space).
This commit is contained in:
Ell
2019-09-04 18:28:21 +03:00
parent 5e59e5c002
commit a0bdb2541d
2 changed files with 33 additions and 0 deletions

View File

@ -651,6 +651,33 @@ gimp_canvas_item_transform_distance_square (GimpCanvasItem *item,
return SQR (tx2 - tx1) + SQR (ty2 - ty1);
}
void
gimp_canvas_item_untransform_viewport (GimpCanvasItem *item,
gint *x,
gint *y,
gint *w,
gint *h)
{
GimpDisplayShell *shell;
gdouble x1, y1;
gdouble x2, y2;
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
shell = item->private->shell;
gimp_display_shell_unrotate_bounds (shell,
0.0, 0.0,
shell->disp_width, shell->disp_height,
&x1, &y1,
&x2, &y2);
*x = floor (x1);
*y = floor (y1);
*w = ceil (x2) - *x;
*h = ceil (y2) - *y;
}
/* protected functions */

View File

@ -125,6 +125,12 @@ gdouble gimp_canvas_item_transform_distance_square
gdouble y1,
gdouble x2,
gdouble y2);
void gimp_canvas_item_untransform_viewport
(GimpCanvasItem *item,
gint *x,
gint *y,
gint *w,
gint *h);
/* protected */