[gimp] app: Add "Diagonal neighbors" option to the fuzzy select tool



commit 070007d8914df8c586e679cb10726197b862d884
Author: Ell <ell_se yahoo com>
Date:   Fri Jan 8 13:09:45 2016 +0000

    app: Add "Diagonal neighbors" option to the fuzzy select tool
    
    When checked, diagonally neighboring pixels are considered connected
    when calculating the affected area.

 app/tools/gimpfuzzyselecttool.c     |    2 +-
 app/tools/gimpregionselectoptions.c |   29 +++++++++++++++++++++++++++++
 app/tools/gimpregionselectoptions.h |    1 +
 3 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c
index ea164f2..670d53b 100644
--- a/app/tools/gimpfuzzyselecttool.c
+++ b/app/tools/gimpfuzzyselecttool.c
@@ -127,6 +127,6 @@ gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
                                                   options->threshold / 255.0,
                                                   options->select_transparent,
                                                   options->select_criterion,
-                                                  FALSE /* no diagonal neighbors */,
+                                                  options->diagonal_neighbors,
                                                   x, y);
 }
diff --git a/app/tools/gimpregionselectoptions.c b/app/tools/gimpregionselectoptions.c
index 2262104..971f9c4 100644
--- a/app/tools/gimpregionselectoptions.c
+++ b/app/tools/gimpregionselectoptions.c
@@ -35,6 +35,7 @@
 
 #include "gimpregionselectoptions.h"
 #include "gimpregionselecttool.h"
+#include "gimpfuzzyselecttool.h"
 
 #include "gimp-intl.h"
 
@@ -44,6 +45,7 @@ enum
   PROP_0,
   PROP_SELECT_TRANSPARENT,
   PROP_SAMPLE_MERGED,
+  PROP_DIAGONAL_NEIGHBORS,
   PROP_THRESHOLD,
   PROP_SELECT_CRITERION,
   PROP_DRAW_MASK
@@ -95,6 +97,13 @@ gimp_region_select_options_class_init (GimpRegionSelectOptionsClass *klass)
                                     FALSE,
                                     GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DIAGONAL_NEIGHBORS,
+                                    "diagonal-neighbors",
+                                    _("Treat diagonally neighboring pixels as "
+                                      "connected"),
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_THRESHOLD,
                                    "threshold",
                                    _("Maximum color difference"),
@@ -148,6 +157,10 @@ gimp_region_select_options_set_property (GObject      *object,
       options->sample_merged = g_value_get_boolean (value);
       break;
 
+    case PROP_DIAGONAL_NEIGHBORS:
+      options->diagonal_neighbors = g_value_get_boolean (value);
+      break;
+
     case PROP_THRESHOLD:
       options->threshold = g_value_get_double (value);
       break;
@@ -184,6 +197,10 @@ gimp_region_select_options_get_property (GObject    *object,
       g_value_set_boolean (value, options->sample_merged);
       break;
 
+    case PROP_DIAGONAL_NEIGHBORS:
+      g_value_set_boolean (value, options->diagonal_neighbors);
+      break;
+
     case PROP_THRESHOLD:
       g_value_set_double (value, options->threshold);
       break;
@@ -226,6 +243,9 @@ gimp_region_select_options_gui (GimpToolOptions *tool_options)
   GtkWidget *button;
   GtkWidget *scale;
   GtkWidget *combo;
+  GType      tool_type;
+
+  tool_type = tool_options->tool_info->tool_type;
 
   /*  the select transparent areas toggle  */
   button = gimp_prop_check_button_new (config, "select-transparent",
@@ -239,6 +259,15 @@ gimp_region_select_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
   gtk_widget_show (button);
 
+  /*  the diagonal neighbors toggle  */
+  if (tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL)
+    {
+      button = gimp_prop_check_button_new (config, "diagonal-neighbors",
+                                           _("Diagonal neighbors"));
+      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+      gtk_widget_show (button);
+    }
+
   /*  the threshold scale  */
   scale = gimp_prop_spin_scale_new (config, "threshold",
                                     _("Threshold"),
diff --git a/app/tools/gimpregionselectoptions.h b/app/tools/gimpregionselectoptions.h
index 0661483..d683534 100644
--- a/app/tools/gimpregionselectoptions.h
+++ b/app/tools/gimpregionselectoptions.h
@@ -39,6 +39,7 @@ struct _GimpRegionSelectOptions
 
   gboolean              select_transparent;
   gboolean              sample_merged;
+  gboolean              diagonal_neighbors;
   gdouble               threshold;
   GimpSelectCriterion   select_criterion;
   gboolean              draw_mask;


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