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:
@ -55,6 +55,7 @@ static void gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
|
|||||||
GimpSelectCriterion fill_criterion,
|
GimpSelectCriterion fill_criterion,
|
||||||
gdouble threshold,
|
gdouble threshold,
|
||||||
gboolean sample_merged,
|
gboolean sample_merged,
|
||||||
|
gboolean diagonal_neighbors,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
const GimpRGB *color,
|
const GimpRGB *color,
|
||||||
@ -73,6 +74,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
|
|||||||
GimpSelectCriterion fill_criterion,
|
GimpSelectCriterion fill_criterion,
|
||||||
gdouble threshold,
|
gdouble threshold,
|
||||||
gboolean sample_merged,
|
gboolean sample_merged,
|
||||||
|
gboolean diagonal_neighbors,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -96,7 +98,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
|
|||||||
paint_mode, opacity,
|
paint_mode, opacity,
|
||||||
fill_transparent, fill_criterion,
|
fill_transparent, fill_criterion,
|
||||||
threshold, sample_merged,
|
threshold, sample_merged,
|
||||||
x, y,
|
diagonal_neighbors, x, y,
|
||||||
&color, pattern);
|
&color, pattern);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -114,6 +116,7 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
|
|||||||
GimpSelectCriterion fill_criterion,
|
GimpSelectCriterion fill_criterion,
|
||||||
gdouble threshold,
|
gdouble threshold,
|
||||||
gboolean sample_merged,
|
gboolean sample_merged,
|
||||||
|
gboolean diagonal_neighbors,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
const GimpRGB *color,
|
const GimpRGB *color,
|
||||||
@ -158,7 +161,7 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
|
|||||||
threshold,
|
threshold,
|
||||||
fill_transparent,
|
fill_transparent,
|
||||||
fill_criterion,
|
fill_criterion,
|
||||||
FALSE /* no diagonal neighbors */,
|
diagonal_neighbors,
|
||||||
(gint) x,
|
(gint) x,
|
||||||
(gint) y);
|
(gint) y);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ gboolean gimp_drawable_bucket_fill (GimpDrawable *drawable,
|
|||||||
GimpSelectCriterion fill_criterion,
|
GimpSelectCriterion fill_criterion,
|
||||||
gdouble threshold,
|
gdouble threshold,
|
||||||
gboolean sample_merged,
|
gboolean sample_merged,
|
||||||
|
gboolean diagonal_neighbors,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
@ -636,7 +636,9 @@ edit_bucket_fill_invoker (GimpProcedure *procedure,
|
|||||||
FALSE /* don't fill transparent */,
|
FALSE /* don't fill transparent */,
|
||||||
GIMP_SELECT_CRITERION_COMPOSITE,
|
GIMP_SELECT_CRITERION_COMPOSITE,
|
||||||
threshold / 255.0,
|
threshold / 255.0,
|
||||||
sample_merged, x, y,
|
sample_merged,
|
||||||
|
FALSE /* no diagonal neighbors */,
|
||||||
|
x, y,
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -720,7 +722,9 @@ edit_bucket_fill_full_invoker (GimpProcedure *procedure,
|
|||||||
fill_transparent,
|
fill_transparent,
|
||||||
select_criterion,
|
select_criterion,
|
||||||
threshold / 255.0,
|
threshold / 255.0,
|
||||||
sample_merged, x, y,
|
sample_merged,
|
||||||
|
FALSE /* no diagonal neighbors */,
|
||||||
|
x, y,
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ enum
|
|||||||
PROP_FILL_SELECTION,
|
PROP_FILL_SELECTION,
|
||||||
PROP_FILL_TRANSPARENT,
|
PROP_FILL_TRANSPARENT,
|
||||||
PROP_SAMPLE_MERGED,
|
PROP_SAMPLE_MERGED,
|
||||||
|
PROP_DIAGONAL_NEIGHBORS,
|
||||||
PROP_THRESHOLD,
|
PROP_THRESHOLD,
|
||||||
PROP_FILL_CRITERION
|
PROP_FILL_CRITERION
|
||||||
};
|
};
|
||||||
@ -109,6 +110,12 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
|
|||||||
"layers"),
|
"layers"),
|
||||||
FALSE,
|
FALSE,
|
||||||
GIMP_PARAM_STATIC_STRINGS);
|
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,
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_THRESHOLD,
|
||||||
"threshold",
|
"threshold",
|
||||||
_("Maximum color difference"),
|
_("Maximum color difference"),
|
||||||
@ -157,6 +164,9 @@ gimp_bucket_fill_options_set_property (GObject *object,
|
|||||||
case PROP_SAMPLE_MERGED:
|
case PROP_SAMPLE_MERGED:
|
||||||
options->sample_merged = g_value_get_boolean (value);
|
options->sample_merged = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_DIAGONAL_NEIGHBORS:
|
||||||
|
options->diagonal_neighbors = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
case PROP_THRESHOLD:
|
case PROP_THRESHOLD:
|
||||||
options->threshold = g_value_get_double (value);
|
options->threshold = g_value_get_double (value);
|
||||||
break;
|
break;
|
||||||
@ -192,6 +202,9 @@ gimp_bucket_fill_options_get_property (GObject *object,
|
|||||||
case PROP_SAMPLE_MERGED:
|
case PROP_SAMPLE_MERGED:
|
||||||
g_value_set_boolean (value, options->sample_merged);
|
g_value_set_boolean (value, options->sample_merged);
|
||||||
break;
|
break;
|
||||||
|
case PROP_DIAGONAL_NEIGHBORS:
|
||||||
|
g_value_set_boolean (value, options->diagonal_neighbors);
|
||||||
|
break;
|
||||||
case PROP_THRESHOLD:
|
case PROP_THRESHOLD:
|
||||||
g_value_set_double (value, options->threshold);
|
g_value_set_double (value, options->threshold);
|
||||||
break;
|
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_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (button);
|
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 */
|
/* the threshold scale */
|
||||||
scale = gimp_prop_spin_scale_new (config, "threshold",
|
scale = gimp_prop_spin_scale_new (config, "threshold",
|
||||||
_("Threshold"),
|
_("Threshold"),
|
||||||
|
@ -41,6 +41,7 @@ struct _GimpBucketFillOptions
|
|||||||
gboolean fill_selection;
|
gboolean fill_selection;
|
||||||
gboolean fill_transparent;
|
gboolean fill_transparent;
|
||||||
gboolean sample_merged;
|
gboolean sample_merged;
|
||||||
|
gboolean diagonal_neighbors;
|
||||||
gdouble threshold;
|
gdouble threshold;
|
||||||
GimpSelectCriterion fill_criterion;
|
GimpSelectCriterion fill_criterion;
|
||||||
};
|
};
|
||||||
|
@ -221,6 +221,7 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
|
|||||||
options->fill_criterion,
|
options->fill_criterion,
|
||||||
options->threshold / 255.0,
|
options->threshold / 255.0,
|
||||||
options->sample_merged,
|
options->sample_merged,
|
||||||
|
options->diagonal_neighbors,
|
||||||
x, y, &error);
|
x, y, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,7 +672,9 @@ HELP
|
|||||||
FALSE /* don't fill transparent */,
|
FALSE /* don't fill transparent */,
|
||||||
GIMP_SELECT_CRITERION_COMPOSITE,
|
GIMP_SELECT_CRITERION_COMPOSITE,
|
||||||
threshold / 255.0,
|
threshold / 255.0,
|
||||||
sample_merged, x, y,
|
sample_merged,
|
||||||
|
FALSE /* no diagonal neighbors */,
|
||||||
|
x, y,
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -784,7 +786,9 @@ HELP
|
|||||||
fill_transparent,
|
fill_transparent,
|
||||||
select_criterion,
|
select_criterion,
|
||||||
threshold / 255.0,
|
threshold / 255.0,
|
||||||
sample_merged, x, y,
|
sample_merged,
|
||||||
|
FALSE /* no diagonal neighbors */,
|
||||||
|
x, y,
|
||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user