[gimp/gimp-2-10] app: make deletion of cropped pixels in crop tool optional



commit 824a5a4580e603eb1d86c490db6ca2d9b406863e
Author: woob <thetoastcaper gmail com>
Date:   Sun Mar 29 02:22:56 2020 -0400

    app: make deletion of cropped pixels in crop tool optional
    
    Adds a new "Delete cropped pixels" toggle to the crop tool options,
    to allow turning off the deletion of layer data that falls out of the
    crop region.
    
    (cherry picked from commit ee97c25b87df2dd7f25e36eb52a7edf0dfb0b647)

 app/tools/gimpcropoptions.c | 28 +++++++++++++++++++++++++++-
 app/tools/gimpcropoptions.h |  3 +++
 app/tools/gimpcroptool.c    |  2 +-
 3 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/app/tools/gimpcropoptions.c b/app/tools/gimpcropoptions.c
index 9fb7a99c9f..e067a2016c 100644
--- a/app/tools/gimpcropoptions.c
+++ b/app/tools/gimpcropoptions.c
@@ -39,7 +39,8 @@ enum
 {
   PROP_LAYER_ONLY = GIMP_RECTANGLE_OPTIONS_PROP_LAST + 1,
   PROP_ALLOW_GROWING,
-  PROP_FILL_TYPE
+  PROP_FILL_TYPE,
+  PROP_DELETE_PIXELS
 };
 
 
@@ -95,6 +96,13 @@ gimp_crop_options_class_init (GimpCropOptionsClass *klass)
                             FALSE,
                             GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_DELETE_PIXELS,
+                            "delete-pixels",
+                            _("Delete cropped pixels"),
+                            _("Discard layer data that falls out of the crop region"),
+                            TRUE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ALLOW_GROWING,
                             "allow-growing",
                             _("Allow growing"),
@@ -138,6 +146,10 @@ gimp_crop_options_set_property (GObject      *object,
       options->layer_only = g_value_get_boolean (value);
       break;
 
+    case PROP_DELETE_PIXELS:
+      options->delete_pixels = g_value_get_boolean (value);
+      break;
+
     case PROP_ALLOW_GROWING:
       options->allow_growing = g_value_get_boolean (value);
       break;
@@ -166,6 +178,10 @@ gimp_crop_options_get_property (GObject    *object,
       g_value_set_boolean (value, options->layer_only);
       break;
 
+    case PROP_DELETE_PIXELS:
+      g_value_set_boolean (value, options->delete_pixels);
+      break;
+
     case PROP_ALLOW_GROWING:
       g_value_set_boolean (value, options->allow_growing);
       break;
@@ -187,6 +203,7 @@ gimp_crop_options_gui (GimpToolOptions *tool_options)
   GtkWidget *vbox   = gimp_tool_options_gui (tool_options);
   GtkWidget *vbox_rectangle;
   GtkWidget *button;
+  GtkWidget *button2;
   GtkWidget *combo;
   GtkWidget *frame;
 
@@ -195,6 +212,15 @@ gimp_crop_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
   gtk_widget_show (button);
 
+  /*  delete pixels toggle  */
+  button2 = gimp_prop_check_button_new (config, "delete-pixels", NULL);
+  gtk_box_pack_start (GTK_BOX (vbox), button2, FALSE, FALSE, 0);
+
+  g_object_bind_property (G_OBJECT (config),  "layer-only",
+                          G_OBJECT (button2), "sensitive",
+                          G_BINDING_SYNC_CREATE |
+                          G_BINDING_INVERT_BOOLEAN);
+
   /*  fill type combo  */
   combo = gimp_prop_enum_combo_box_new (config, "fill-type", 0, 0);
   gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Fill with"));
diff --git a/app/tools/gimpcropoptions.h b/app/tools/gimpcropoptions.h
index ca4b5d3ef6..e123dca789 100644
--- a/app/tools/gimpcropoptions.h
+++ b/app/tools/gimpcropoptions.h
@@ -47,6 +47,9 @@ struct _GimpCropOptions
 
   /* How to fill new areas created by 'allow_growing. */
   GimpFillType     fill_type;
+
+  /* Whether to discard layer data that falls out of the crop region */
+  gboolean         delete_pixels;
 };
 
 
diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c
index 40863f22f1..9e103a86b4 100644
--- a/app/tools/gimpcroptool.c
+++ b/app/tools/gimpcroptool.c
@@ -477,7 +477,7 @@ gimp_crop_tool_commit (GimpCropTool *crop_tool)
             {
               gimp_image_crop (image,
                                GIMP_CONTEXT (options), GIMP_FILL_TRANSPARENT,
-                               x, y, w, h, TRUE);
+                               x, y, w, h, options->delete_pixels);
             }
 
           gimp_image_flush (image);


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