[gimp] app: add gimp_canvas_item_untransform_viewport()



commit 23617c943b6c8e82b9b8b9d3aa78bb0d7362d4cf
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 454d9a58c7..d349c8b388 100644
--- a/app/display/gimpcanvasitem.c
+++ b/app/display/gimpcanvasitem.c
@@ -652,6 +652,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]