[gimp] app: fix transform-tool preview/bounds in show-all mode when transforming entire image



commit b7674faef88e1a364cc7e6b5998a8f7b80104e6f
Author: Ell <ell_se yahoo com>
Date:   Wed Sep 4 18:33:47 2019 +0300

    app: fix transform-tool preview/bounds in show-all mode when transforming entire image
    
    In the transform tools, when transforming the entire image in show-
    all mode, don't crop the preview and the transform bounds to the
    size of the canvas.

 app/tools/gimptransformgridtool.c | 12 ++++++++++--
 app/tools/gimptransformtool.c     | 33 ++++++++++++++++++++++++++++-----
 2 files changed, 38 insertions(+), 7 deletions(-)
---
diff --git a/app/tools/gimptransformgridtool.c b/app/tools/gimptransformgridtool.c
index b7fdbf381f..bc9ad171cf 100644
--- a/app/tools/gimptransformgridtool.c
+++ b/app/tools/gimptransformgridtool.c
@@ -653,6 +653,7 @@ gimp_transform_grid_tool_draw (GimpDrawTool *draw_tool)
   GimpTransformGridTool    *tg_tool    = GIMP_TRANSFORM_GRID_TOOL (draw_tool);
   GimpTransformGridOptions *options    = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tool);
   GimpTransformOptions     *tr_options = GIMP_TRANSFORM_OPTIONS (options);
+  GimpDisplayShell         *shell      = gimp_display_get_shell (tool->display);
   GimpImage                *image      = gimp_display_get_image (tool->display);
   GimpMatrix3               matrix     = tr_tool->transform;
   GimpCanvasItem           *item;
@@ -666,9 +667,16 @@ gimp_transform_grid_tool_draw (GimpDrawTool *draw_tool)
       gboolean      show_preview;
 
       if (tr_options->type == GIMP_TRANSFORM_TYPE_IMAGE)
-        pickable = GIMP_PICKABLE (image);
+        {
+          if (! shell->show_all)
+            pickable = GIMP_PICKABLE (image);
+          else
+            pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
+        }
       else
-        pickable = GIMP_PICKABLE (tool->drawable);
+        {
+          pickable = GIMP_PICKABLE (tool->drawable);
+        }
 
       show_preview = gimp_transform_grid_options_show_preview (options) &&
                      tr_tool->transform_valid;
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 6ba1675d9b..2441033998 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -43,6 +43,7 @@
 #include "vectors/gimpvectors.h"
 
 #include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
 
 #include "widgets/gimpmessagedialog.h"
 #include "widgets/gimpmessagebox.h"
@@ -259,6 +260,11 @@ gimp_transform_tool_halt (GimpTransformTool *tr_tool)
 {
   GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
 
+  tr_tool->x1 = 0;
+  tr_tool->y1 = 0;
+  tr_tool->x2 = 0;
+  tr_tool->y2 = 0;
+
   if (tr_tool->restore_type)
     {
       g_object_set (options,
@@ -486,6 +492,7 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
                             GimpDisplay       *display)
 {
   GimpTransformOptions *options;
+  GimpDisplayShell     *shell;
   GimpImage            *image;
   gboolean              non_empty = TRUE;
 
@@ -493,6 +500,7 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
 
   options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
   image   = gimp_display_get_image (display);
+  shell   = gimp_display_get_shell (display);
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
 
@@ -568,10 +576,24 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
       break;
 
     case GIMP_TRANSFORM_TYPE_IMAGE:
-      tr_tool->x1 = 0;
-      tr_tool->y1 = 0;
-      tr_tool->x2 = gimp_image_get_width  (image);
-      tr_tool->y2 = gimp_image_get_height (image);
+      if (! shell->show_all)
+        {
+          tr_tool->x1 = 0;
+          tr_tool->y1 = 0;
+          tr_tool->x2 = gimp_image_get_width  (image);
+          tr_tool->y2 = gimp_image_get_height (image);
+        }
+      else
+        {
+          GeglRectangle bounding_box;
+
+          bounding_box = gimp_display_shell_get_bounding_box (shell);
+
+          tr_tool->x1 = bounding_box.x;
+          tr_tool->y1 = bounding_box.y;
+          tr_tool->x2 = bounding_box.x + bounding_box.width;
+          tr_tool->y2 = bounding_box.y + bounding_box.height;
+        }
       break;
     }
 
@@ -585,7 +607,8 @@ gimp_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
   g_return_if_fail (GIMP_IS_TRANSFORM_TOOL (tr_tool));
   g_return_if_fail (GIMP_IS_DISPLAY (display));
 
-  gimp_transform_tool_bounds (tr_tool, display);
+  if (tr_tool->x1 == tr_tool->x2 && tr_tool->y1 == tr_tool->y2)
+    gimp_transform_tool_bounds (tr_tool, display);
 
   if (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->recalc_matrix)
     GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->recalc_matrix (tr_tool);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]