[gimp/gimp-2-10] app: add gimp_canvas_item_untransform_viewport()
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add gimp_canvas_item_untransform_viewport()
- Date: Wed, 4 Sep 2019 17:59:22 +0000 (UTC)
commit a0bdb2541dee320a63a0c48e49d484d4d7d39e24
Author: Ell <ell_se yahoo com>
Date: Wed Sep 4 18:28:21 2019 +0300
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).
app/display/gimpcanvasitem.c | 27 +++++++++++++++++++++++++++
app/display/gimpcanvasitem.h | 6 ++++++
2 files changed, 33 insertions(+)
---
diff --git a/app/display/gimpcanvasitem.c b/app/display/gimpcanvasitem.c
index 3c90237183..560210ab13 100644
--- a/app/display/gimpcanvasitem.c
+++ b/app/display/gimpcanvasitem.c
@@ -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 */
diff --git a/app/display/gimpcanvasitem.h b/app/display/gimpcanvasitem.h
index 9bd87e16b2..20042601cc 100644
--- a/app/display/gimpcanvasitem.h
+++ b/app/display/gimpcanvasitem.h
@@ -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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]