[gimp] app: make the "Automatic closure" a settings of its own.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make the "Automatic closure" a settings of its own.
- Date: Thu, 3 Mar 2022 19:11:44 +0000 (UTC)
commit d3686fdb9c65f6b333aea1fe92e355ab8c58a1af
Author: Jehan <jehan girinstud io>
Date: Thu Mar 3 20:05:14 2022 +0100
app: make the "Automatic closure" a settings of its own.
This is the same thing as setting the max gap length to 0, except that
it would mean constantly having to play with the gap length and possibly
losing settings you carefully tweaked. Instead with this additional
settings, we hide the gap length settings when automatic closure is
disabled.
Also it makes kind of a nice parallel with the "Manual closure" settings
which can also be enabled/disabled similarly.
app/core/gimplineart.c | 30 +++++++++++++++++++++++++++++-
app/tools/gimpbucketfilloptions.c | 22 +++++++++++++++++-----
app/tools/gimpbucketfilloptions.h | 2 ++
app/tools/gimpbucketfilltool.c | 4 ++++
4 files changed, 52 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimplineart.c b/app/core/gimplineart.c
index b05d850e3e..beac888b1b 100644
--- a/app/core/gimplineart.c
+++ b/app/core/gimplineart.c
@@ -59,6 +59,7 @@ enum
PROP_SELECT_TRANSPARENT,
PROP_MAX_GROW,
PROP_THRESHOLD,
+ PROP_AUTOMATIC_CLOSURE,
PROP_SPLINE_MAX_LEN,
PROP_SEGMENT_MAX_LEN,
};
@@ -81,6 +82,7 @@ struct _GimpLineArtPrivate
/* Used in the closing step. */
gboolean select_transparent;
gdouble threshold;
+ gboolean automatic_closure;
gint spline_max_len;
gint segment_max_len;
gboolean max_len_bound;
@@ -95,6 +97,7 @@ typedef struct
gboolean select_transparent;
gdouble threshold;
+ gboolean automatic_closure;
gint spline_max_len;
gint segment_max_len;
} LineArtData;
@@ -182,6 +185,7 @@ static void gimp_line_art_input_invalidate_preview (GimpViewable
static GeglBuffer * gimp_line_art_close (GeglBuffer *buffer,
gboolean select_transparent,
gdouble stroke_threshold,
+ gboolean automatic_closure,
gint spline_max_length,
gint segment_max_length,
gint minimal_lineart_area,
@@ -354,6 +358,13 @@ gimp_line_art_class_init (GimpLineArtClass *klass)
1, 100, 3,
G_PARAM_CONSTRUCT | GIMP_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_AUTOMATIC_CLOSURE,
+ g_param_spec_boolean ("automatic-closure",
+ _("Whether or not we should perform the closing
step"),
+ _("Whether or not we should perform the closing
step"),
+ TRUE,
+ G_PARAM_CONSTRUCT | GIMP_PARAM_READWRITE));
+
g_object_class_install_property (object_class, PROP_SPLINE_MAX_LEN,
g_param_spec_int ("spline-max-length",
_("Maximum curved closing length"),
@@ -414,6 +425,13 @@ gimp_line_art_set_property (GObject *object,
gimp_line_art_compute (line_art);
}
break;
+ case PROP_AUTOMATIC_CLOSURE:
+ if (line_art->priv->automatic_closure != g_value_get_boolean (value))
+ {
+ line_art->priv->automatic_closure = g_value_get_boolean (value);
+ gimp_line_art_compute (line_art);
+ }
+ break;
case PROP_SPLINE_MAX_LEN:
if (line_art->priv->spline_max_len != g_value_get_int (value))
{
@@ -458,6 +476,9 @@ gimp_line_art_get_property (GObject *object,
case PROP_THRESHOLD:
g_value_set_double (value, line_art->priv->threshold);
break;
+ case PROP_AUTOMATIC_CLOSURE:
+ g_value_set_boolean (value, line_art->priv->automatic_closure);
+ break;
case PROP_SPLINE_MAX_LEN:
g_value_set_int (value, line_art->priv->spline_max_len);
break;
@@ -754,6 +775,7 @@ gimp_line_art_prepare_async_func (GimpAsync *async,
closed = gimp_line_art_close (buffer,
select_transparent,
data->threshold,
+ data->automatic_closure,
data->spline_max_len,
data->segment_max_len,
/*minimal_lineart_area,*/
@@ -816,6 +838,7 @@ line_art_data_new (GeglBuffer *buffer,
data->buffer = g_object_ref (buffer);
data->select_transparent = line_art->priv->select_transparent;
data->threshold = line_art->priv->threshold;
+ data->automatic_closure = line_art->priv->automatic_closure;
data->spline_max_len = line_art->priv->spline_max_len;
data->segment_max_len = line_art->priv->segment_max_len;
@@ -884,6 +907,9 @@ gimp_line_art_input_invalidate_preview (GimpViewable *viewable,
* luminosity.
* @stroke_threshold: [0-1] threshold value for detecting stroke pixels
* (higher values will detect more stroke pixels).
+ * @automatic_closure: whether the closing step should be performed or
+ * not. @spline_max_length and @segment_max_len are
+ * used only if @automatic_closure is %TRUE.
* @spline_max_length: the maximum length for creating splines between
* end points.
* @segment_max_length: the maximum length for creating segments
@@ -928,6 +954,7 @@ static GeglBuffer *
gimp_line_art_close (GeglBuffer *buffer,
gboolean select_transparent,
gdouble stroke_threshold,
+ gboolean automatic_closure,
gint spline_max_length,
gint segment_max_length,
gint minimal_lineart_area,
@@ -1031,7 +1058,8 @@ gimp_line_art_close (GeglBuffer *buffer,
closed = g_object_ref (strokes);
- if (spline_max_length > 0 || segment_max_length > 0)
+ if (automatic_closure &&
+ (spline_max_length > 0 || segment_max_length > 0))
{
GArray *keypoints = NULL;
GHashTable *visited = NULL;
diff --git a/app/tools/gimpbucketfilloptions.c b/app/tools/gimpbucketfilloptions.c
index a3c9f23c24..cb7a6cb62d 100644
--- a/app/tools/gimpbucketfilloptions.c
+++ b/app/tools/gimpbucketfilloptions.c
@@ -71,6 +71,7 @@ enum
PROP_LINE_ART_MAX_GROW,
PROP_LINE_ART_STROKE,
PROP_LINE_ART_STROKE_TOOL,
+ PROP_LINE_ART_AUTOMATIC_CLOSURE,
PROP_LINE_ART_MAX_GAP_LENGTH,
PROP_FILL_CRITERION,
PROP_FILL_COLOR_AS_LINE_ART,
@@ -254,6 +255,13 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
_("The tool to stroke the fill borders with"),
"gimp-pencil", GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_LINE_ART_AUTOMATIC_CLOSURE,
+ "line-art-automatic-closure",
+ _("Automatic closure"),
+ _("Geometric analysis of the stroke contours to close line arts by
splines/segments"),
+ TRUE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_INT (object_class, PROP_LINE_ART_MAX_GAP_LENGTH,
"line-art-max-gap-length",
_("Maximum gap length"),
@@ -372,6 +380,9 @@ gimp_bucket_fill_options_set_property (GObject *object,
NULL);
}
break;
+ case PROP_LINE_ART_AUTOMATIC_CLOSURE:
+ options->line_art_automatic_closure = g_value_get_boolean (value);
+ break;
case PROP_LINE_ART_MAX_GAP_LENGTH:
options->line_art_max_gap_length = g_value_get_int (value);
break;
@@ -443,6 +454,9 @@ gimp_bucket_fill_options_get_property (GObject *object,
case PROP_LINE_ART_STROKE_TOOL:
g_value_set_string (value, options->line_art_stroke_tool);
break;
+ case PROP_LINE_ART_AUTOMATIC_CLOSURE:
+ g_value_set_boolean (value, options->line_art_automatic_closure);
+ break;
case PROP_LINE_ART_MAX_GAP_LENGTH:
g_value_set_int (value, options->line_art_max_gap_length);
break;
@@ -691,13 +705,11 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (box2);
/* Line Art Closure: max gap length */
- frame = gimp_frame_new (_("Automatic closure"));
- gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
- gtk_widget_show (frame);
-
scale = gimp_prop_spin_scale_new (config, "line-art-max-gap-length",
1, 5, 0);
- gtk_container_add (GTK_CONTAINER (frame), scale);
+ frame = gimp_prop_expanding_frame_new (config, "line-art-automatic-closure", NULL,
+ scale, NULL);
+ gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
/* Line Art Closure: manual line art closure */
scale = gimp_prop_spin_scale_new (config, "fill-color-as-line-art-threshold",
diff --git a/app/tools/gimpbucketfilloptions.h b/app/tools/gimpbucketfilloptions.h
index 2b12dcd9da..2148f6cca0 100644
--- a/app/tools/gimpbucketfilloptions.h
+++ b/app/tools/gimpbucketfilloptions.h
@@ -52,6 +52,8 @@ struct _GimpBucketFillOptions
GimpLineArtSource line_art_source;
gdouble line_art_threshold;
gint line_art_max_grow;
+
+ gboolean line_art_automatic_closure;
gint line_art_max_gap_length;
gboolean line_art_stroke;
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 7c7a0de069..44c3752bb7 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -239,6 +239,10 @@ gimp_bucket_fill_tool_constructed (GObject *object)
line_art, "max-grow",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
bindings = g_list_prepend (bindings, binding);
+ binding = g_object_bind_property (options, "line-art-automatic-closure",
+ line_art, "automatic-closure",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+ bindings = g_list_prepend (bindings, binding);
binding = g_object_bind_property (options, "line-art-max-gap-length",
line_art, "spline-max-length",
G_BINDING_SYNC_CREATE | G_BINDING_DEFAULT);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]