[gimp] app: do not allow mandala center position out of the image dimensions.



commit e8aac6d5ac7761e5c2859a70e78e42193e0ae7a0
Author: Jehan <jehan girinstud io>
Date:   Fri Jul 1 14:49:32 2016 +0200

    app: do not allow mandala center position out of the image dimensions.

 app/core/gimpsymmetry-mandala.c |   52 ++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 22 deletions(-)
---
diff --git a/app/core/gimpsymmetry-mandala.c b/app/core/gimpsymmetry-mandala.c
index 77940c3..3f7d0a4 100644
--- a/app/core/gimpsymmetry-mandala.c
+++ b/app/core/gimpsymmetry-mandala.c
@@ -207,33 +207,41 @@ gimp_mandala_set_property (GObject      *object,
   switch (property_id)
     {
     case PROP_CENTER_X:
-      mandala->center_x = g_value_get_double (value);
-      if (mandala->vertical_guide)
+      if (g_value_get_double (value) > 0.0 &&
+          g_value_get_double (value) < (gdouble) gimp_image_get_width (image))
         {
-          g_signal_handlers_block_by_func (mandala->vertical_guide,
-                                           gimp_mandala_guide_position_cb,
-                                           mandala);
-          gimp_image_move_guide (image, mandala->vertical_guide,
-                                 mandala->center_x,
-                                 FALSE);
-          g_signal_handlers_unblock_by_func (mandala->vertical_guide,
-                                             gimp_mandala_guide_position_cb,
-                                             mandala);
+          mandala->center_x = g_value_get_double (value);
+          if (mandala->vertical_guide)
+            {
+              g_signal_handlers_block_by_func (mandala->vertical_guide,
+                                               gimp_mandala_guide_position_cb,
+                                               mandala);
+              gimp_image_move_guide (image, mandala->vertical_guide,
+                                     mandala->center_x,
+                                     FALSE);
+              g_signal_handlers_unblock_by_func (mandala->vertical_guide,
+                                                 gimp_mandala_guide_position_cb,
+                                                 mandala);
+            }
         }
       break;
     case PROP_CENTER_Y:
-      mandala->center_y = g_value_get_double (value);
-      if (mandala->horizontal_guide)
+      if (g_value_get_double (value) > 0.0 &&
+          g_value_get_double (value) < (gdouble) gimp_image_get_height (image))
         {
-          g_signal_handlers_block_by_func (mandala->horizontal_guide,
-                                           gimp_mandala_guide_position_cb,
-                                           mandala);
-          gimp_image_move_guide (image, mandala->horizontal_guide,
-                                 mandala->center_y,
-                                 FALSE);
-          g_signal_handlers_unblock_by_func (mandala->horizontal_guide,
-                                             gimp_mandala_guide_position_cb,
-                                             mandala);
+          mandala->center_y = g_value_get_double (value);
+          if (mandala->horizontal_guide)
+            {
+              g_signal_handlers_block_by_func (mandala->horizontal_guide,
+                                               gimp_mandala_guide_position_cb,
+                                               mandala);
+              gimp_image_move_guide (image, mandala->horizontal_guide,
+                                     mandala->center_y,
+                                     FALSE);
+              g_signal_handlers_unblock_by_func (mandala->horizontal_guide,
+                                                 gimp_mandala_guide_position_cb,
+                                                 mandala);
+            }
         }
       break;
     case PROP_SIZE:


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