[gimp] app: when scaling, use the proper image api to move guides and sample points



commit 8ea6d3a94fb42bbabdd34ba5257b6f1d91b225e0
Author: Michael Natterer <mitch gimp org>
Date:   Fri Feb 24 00:26:14 2012 +0100

    app: when scaling, use the proper image api to move guides and sample points
    
    so the image's "foo-moved" signals are emitted and the display can
    follow. Moving them around manually was needed before the displayed
    guides and sample points were proper views of the resp. core objects.

 app/core/gimpimage-scale.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c
index 9bf4db3..bab1c65 100644
--- a/app/core/gimpimage-scale.c
+++ b/app/core/gimpimage-scale.c
@@ -102,7 +102,10 @@ gimp_image_scale (GimpImage             *image,
                                    new_width,
                                    new_height);
 
-  /*  Set the new width and height  */
+  /*  Set the new width and height early, so below image item setters
+   *  (esp. guides and sample points) don't choke about moving stuff
+   *  out of the image
+   */
   g_object_set (image,
                 "width",  new_width,
                 "height", new_height,
@@ -178,13 +181,15 @@ gimp_image_scale (GimpImage             *image,
       switch (gimp_guide_get_orientation (guide))
         {
         case GIMP_ORIENTATION_HORIZONTAL:
-          gimp_image_undo_push_guide (image, NULL, guide);
-          gimp_guide_set_position (guide, (position * new_height) / old_height);
+          gimp_image_move_guide (image, guide,
+                                 (position * new_height) / old_height,
+                                 TRUE);
           break;
 
         case GIMP_ORIENTATION_VERTICAL:
-          gimp_image_undo_push_guide (image, NULL, guide);
-          gimp_guide_set_position (guide, (position * new_width) / old_width);
+          gimp_image_move_guide (image, guide,
+                                 (position * new_width) / old_width,
+                                 TRUE);
           break;
 
         default:
@@ -199,9 +204,10 @@ gimp_image_scale (GimpImage             *image,
     {
       GimpSamplePoint *sample_point = list->data;
 
-      gimp_image_undo_push_sample_point (image, NULL, sample_point);
-      sample_point->x = sample_point->x * new_width / old_width;
-      sample_point->y = sample_point->y * new_height / old_height;
+      gimp_image_move_sample_point (image, sample_point,
+                                    sample_point->x * new_width  / old_width,
+                                    sample_point->y * new_height / old_height,
+                                    TRUE);
     }
 
   gimp_image_undo_group_end (image);



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