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

When checked, diagonally neighboring pixels are considered connected
when calculating the affected area.
This commit is contained in:
Ell
2016-01-08 13:09:45 +00:00
committed by Michael Natterer
parent 93bf78b83e
commit 070007d891
3 changed files with 31 additions and 1 deletions

View File

@ -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);
}

View File

@ -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"),

View File

@ -39,6 +39,7 @@ struct _GimpRegionSelectOptions
gboolean select_transparent;
gboolean sample_merged;
gboolean diagonal_neighbors;
gdouble threshold;
GimpSelectCriterion select_criterion;
gboolean draw_mask;