app: Add "Diagonal neighbors" option to the bucket fill tool

When checked, diagonally neighboring pixels are considered connected
when calculating the affected area.

This commit also adds a corresponding diagonal_neighbors parameter to
gimp_drawable_bucket_fill(), and modifies the callers, other than the
bucket fill tool, to pass FALSE for this parameter, to retain the
current behavior.
This commit is contained in:
Ell 2016-01-08 13:18:10 +00:00 committed by Michael Natterer
parent 070007d891
commit 350c7ca338
7 changed files with 40 additions and 7 deletions

View File

@ -55,6 +55,7 @@ static void gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gboolean diagonal_neighbors,
gdouble x,
gdouble y,
const GimpRGB *color,
@ -73,6 +74,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gboolean diagonal_neighbors,
gdouble x,
gdouble y,
GError **error)
@ -96,7 +98,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
paint_mode, opacity,
fill_transparent, fill_criterion,
threshold, sample_merged,
x, y,
diagonal_neighbors, x, y,
&color, pattern);
return TRUE;
@ -114,6 +116,7 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gboolean diagonal_neighbors,
gdouble x,
gdouble y,
const GimpRGB *color,
@ -158,7 +161,7 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
threshold,
fill_transparent,
fill_criterion,
FALSE /* no diagonal neighbors */,
diagonal_neighbors,
(gint) x,
(gint) y);

View File

@ -28,6 +28,7 @@ gboolean gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpSelectCriterion fill_criterion,
gdouble threshold,
gboolean sample_merged,
gboolean diagonal_neighbors,
gdouble x,
gdouble y,
GError **error);

View File

@ -636,7 +636,9 @@ edit_bucket_fill_invoker (GimpProcedure *procedure,
FALSE /* don't fill transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
threshold / 255.0,
sample_merged, x, y,
sample_merged,
FALSE /* no diagonal neighbors */,
x, y,
error);
}
}
@ -720,7 +722,9 @@ edit_bucket_fill_full_invoker (GimpProcedure *procedure,
fill_transparent,
select_criterion,
threshold / 255.0,
sample_merged, x, y,
sample_merged,
FALSE /* no diagonal neighbors */,
x, y,
error);
}
}

View File

@ -50,6 +50,7 @@ enum
PROP_FILL_SELECTION,
PROP_FILL_TRANSPARENT,
PROP_SAMPLE_MERGED,
PROP_DIAGONAL_NEIGHBORS,
PROP_THRESHOLD,
PROP_FILL_CRITERION
};
@ -109,6 +110,12 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
"layers"),
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"),
@ -157,6 +164,9 @@ gimp_bucket_fill_options_set_property (GObject *object,
case PROP_SAMPLE_MERGED:
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;
@ -192,6 +202,9 @@ gimp_bucket_fill_options_get_property (GObject *object,
case PROP_SAMPLE_MERGED:
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;
@ -291,6 +304,12 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the diagonal neighbors toggle */
button = gimp_prop_check_button_new (config, "diagonal-neighbors",
_("Diagonal neighbors"));
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the threshold scale */
scale = gimp_prop_spin_scale_new (config, "threshold",
_("Threshold"),

View File

@ -41,6 +41,7 @@ struct _GimpBucketFillOptions
gboolean fill_selection;
gboolean fill_transparent;
gboolean sample_merged;
gboolean diagonal_neighbors;
gdouble threshold;
GimpSelectCriterion fill_criterion;
};

View File

@ -221,6 +221,7 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
options->fill_criterion,
options->threshold / 255.0,
options->sample_merged,
options->diagonal_neighbors,
x, y, &error);
}

View File

@ -671,8 +671,10 @@ HELP
paint_mode, opacity / 100.0,
FALSE /* don't fill transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
threshold / 255.0,
sample_merged, x, y,
threshold / 255.0,
sample_merged,
FALSE /* no diagonal neighbors */,
x, y,
error);
}
}
@ -784,7 +786,9 @@ HELP
fill_transparent,
select_criterion,
threshold / 255.0,
sample_merged, x, y,
sample_merged,
FALSE /* no diagonal neighbors */,
x, y,
error);
}
}