[gimp] app: allowing to choose the paint tool used for stroking.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: allowing to choose the paint tool used for stroking.
- Date: Thu, 3 Mar 2022 17:45:42 +0000 (UTC)
commit ab8e7b635873f6ba7b0f3acfe60d86907ca67b55
Author: Jehan <jehan girinstud io>
Date: Wed Mar 2 18:16:17 2022 +0100
app: allowing to choose the paint tool used for stroking.
app/core/gimpdrawable-bucket-fill.c | 38 +++++--------
app/core/gimpdrawable-bucket-fill.h | 1 +
app/tools/gimpbucketfilloptions.c | 109 +++++++++++++++++++++++++++++++++---
app/tools/gimpbucketfilloptions.h | 5 +-
app/tools/gimpbucketfilltool.c | 1 +
5 files changed, 123 insertions(+), 31 deletions(-)
---
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index e4c08b8739..c08973e70d 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -349,20 +349,21 @@ gimp_drawable_get_bucket_fill_buffer (GimpDrawable *drawable,
* used in a drawable filter as preview.
*/
GeglBuffer *
-gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
- GimpLineArt *line_art,
- GimpFillOptions *options,
- gboolean sample_merged,
- gboolean fill_color_as_line_art,
- gdouble fill_color_threshold,
- gboolean line_art_stroke,
- gdouble seed_x,
- gdouble seed_y,
- GeglBuffer **mask_buffer,
- gdouble *mask_x,
- gdouble *mask_y,
- gint *mask_width,
- gint *mask_height)
+gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
+ GimpLineArt *line_art,
+ GimpFillOptions *options,
+ gboolean sample_merged,
+ gboolean fill_color_as_line_art,
+ gdouble fill_color_threshold,
+ gboolean line_art_stroke,
+ GimpStrokeOptions *stroke_options,
+ gdouble seed_x,
+ gdouble seed_y,
+ GeglBuffer **mask_buffer,
+ gdouble *mask_x,
+ gdouble *mask_y,
+ gint *mask_width,
+ gint *mask_height)
{
GimpImage *image;
GeglBuffer *buffer;
@@ -465,7 +466,6 @@ gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
GimpChannel *channel;
GimpChannel *stroked;
GList *drawables;
- GimpStrokeOptions *stroke_options;
GimpContext *context = gimp_get_user_context (image->gimp);
GError *error = NULL;
const GimpRGB white = {1.0, 1.0, 1.0, 1.0};
@@ -475,13 +475,6 @@ gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
gimp_context_set_foreground (GIMP_CONTEXT (context),
&white);
- /* This initial version uses the stroke option as used in other
- * stroke features. A future version should allow to set the
- * stroke directly from bucket fill tool options.
- */
- stroke_options = GIMP_DIALOG_CONFIG (image->gimp->config)->stroke_options;
- stroke_options = gimp_config_duplicate (GIMP_CONFIG (stroke_options));
-
channel = gimp_channel_new_from_buffer (image, new_mask, NULL, NULL);
stroked = gimp_channel_new_from_buffer (image, rendered_mask, NULL, NULL);
gimp_image_add_hidden_item (image, GIMP_ITEM (channel));
@@ -510,7 +503,6 @@ gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
gimp_image_remove_hidden_item (image, GIMP_ITEM (stroked));
g_object_unref (stroked);
- g_object_unref (stroke_options);
g_object_unref (context);
}
diff --git a/app/core/gimpdrawable-bucket-fill.h b/app/core/gimpdrawable-bucket-fill.h
index ffbf891c47..2793861e06 100644
--- a/app/core/gimpdrawable-bucket-fill.h
+++ b/app/core/gimpdrawable-bucket-fill.h
@@ -51,6 +51,7 @@ GeglBuffer * gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawa
gboolean fill_color_as_line_art,
gdouble fill_color_threshold,
gboolean line_art_stroke,
+ GimpStrokeOptions *stroke_options,
gdouble seed_x,
gdouble seed_y,
GeglBuffer **mask_buffer,
diff --git a/app/tools/gimpbucketfilloptions.c b/app/tools/gimpbucketfilloptions.c
index e86822dadd..9fdb094a80 100644
--- a/app/tools/gimpbucketfilloptions.c
+++ b/app/tools/gimpbucketfilloptions.c
@@ -27,13 +27,19 @@
#include "tools-types.h"
#include "config/gimpcoreconfig.h"
+#include "config/gimpdialogconfig.h"
#include "core/gimp.h"
+#include "core/gimpcontainer.h"
#include "core/gimpdatafactory.h"
+#include "core/gimppaintinfo.h"
+#include "core/gimpstrokeoptions.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay.h"
+#include "widgets/gimpcontainercombobox.h"
+#include "widgets/gimpcontainerview.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpviewablebox.h"
#include "widgets/gimpwidgets-utils.h"
@@ -60,6 +66,7 @@ enum
PROP_LINE_ART_THRESHOLD,
PROP_LINE_ART_MAX_GROW,
PROP_LINE_ART_STROKE,
+ PROP_LINE_ART_STROKE_TOOL,
PROP_LINE_ART_MAX_GAP_LENGTH,
PROP_FILL_CRITERION,
PROP_FILL_COLOR_AS_LINE_ART,
@@ -80,6 +87,7 @@ struct _GimpBucketFillOptionsPrivate
static void gimp_bucket_fill_options_config_iface_init (GimpConfigInterface *config_iface);
+static void gimp_bucket_fill_options_finalize (GObject *object);
static void gimp_bucket_fill_options_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -88,6 +96,11 @@ static void gimp_bucket_fill_options_get_property (GObject
guint property_id,
GValue *value,
GParamSpec *pspec);
+static gboolean
+ gimp_bucket_fill_options_select_stroke_tool (GimpContainerView *view,
+ GList *items,
+ GList *paths,
+ GimpBucketFillOptions *options);
static void gimp_bucket_fill_options_reset (GimpConfig *config);
static void gimp_bucket_fill_options_update_area (GimpBucketFillOptions *options);
@@ -109,6 +122,7 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = gimp_bucket_fill_options_finalize;
object_class->set_property = gimp_bucket_fill_options_set_property;
object_class->get_property = gimp_bucket_fill_options_get_property;
@@ -218,7 +232,6 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
1, 100, 3,
GIMP_PARAM_STATIC_STRINGS);
- /* TODO: we should be able to choose which tool to stroke with. */
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_LINE_ART_STROKE,
"line-art-stroke-border",
_("Stroke borders"),
@@ -226,6 +239,12 @@ gimp_bucket_fill_options_class_init (GimpBucketFillOptionsClass *klass)
FALSE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_STRING (object_class, PROP_LINE_ART_STROKE_TOOL,
+ "line-art-stroke-tool",
+ _("Stroke tool"),
+ _("The tool to stroke the fill borders with"),
+ "gimp-pencil", GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_INT (object_class, PROP_LINE_ART_MAX_GAP_LENGTH,
"line-art-max-gap-length",
_("Maximum gap length"),
@@ -254,6 +273,19 @@ static void
gimp_bucket_fill_options_init (GimpBucketFillOptions *options)
{
options->priv = gimp_bucket_fill_options_get_instance_private (options);
+
+ options->line_art_stroke_tool = NULL;
+}
+
+static void
+gimp_bucket_fill_options_finalize (GObject *object)
+{
+ GimpBucketFillOptions *options = GIMP_BUCKET_FILL_OPTIONS (object);
+
+ g_clear_object (&options->stroke_options);
+ g_clear_pointer (&options->line_art_stroke_tool, g_free);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
@@ -262,7 +294,8 @@ gimp_bucket_fill_options_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GimpBucketFillOptions *options = GIMP_BUCKET_FILL_OPTIONS (object);
+ GimpBucketFillOptions *options = GIMP_BUCKET_FILL_OPTIONS (object);
+ GimpToolOptions *tool_options = GIMP_TOOL_OPTIONS (object);
switch (property_id)
{
@@ -308,6 +341,28 @@ gimp_bucket_fill_options_set_property (GObject *object,
case PROP_LINE_ART_STROKE:
options->line_art_stroke = g_value_get_boolean (value);
break;
+ case PROP_LINE_ART_STROKE_TOOL:
+ g_clear_pointer (&options->line_art_stroke_tool, g_free);
+ options->line_art_stroke_tool = g_value_dup_string (value);
+
+ if (options->stroke_options)
+ {
+ GimpPaintInfo *paint_info = NULL;
+ Gimp *gimp = tool_options->tool_info->gimp;
+
+ if (! options->line_art_stroke_tool)
+ options->line_art_stroke_tool = g_strdup ("gimp-pencil");
+
+ paint_info = GIMP_PAINT_INFO (gimp_container_get_child_by_name (gimp->paint_info_list,
+ options->line_art_stroke_tool));
+ if (! paint_info && ! gimp_container_is_empty (gimp->paint_info_list))
+ paint_info = GIMP_PAINT_INFO (gimp_container_get_child_by_index (gimp->paint_info_list, 0));
+
+ g_object_set (options->stroke_options,
+ "paint-info", paint_info,
+ NULL);
+ }
+ break;
case PROP_LINE_ART_MAX_GAP_LENGTH:
options->line_art_max_gap_length = g_value_get_int (value);
break;
@@ -376,6 +431,9 @@ gimp_bucket_fill_options_get_property (GObject *object,
case PROP_LINE_ART_STROKE:
g_value_set_boolean (value, options->line_art_stroke);
break;
+ case PROP_LINE_ART_STROKE_TOOL:
+ g_value_set_string (value, options->line_art_stroke_tool);
+ break;
case PROP_LINE_ART_MAX_GAP_LENGTH:
g_value_set_int (value, options->line_art_max_gap_length);
break;
@@ -395,6 +453,26 @@ gimp_bucket_fill_options_get_property (GObject *object,
}
}
+static gboolean
+gimp_bucket_fill_options_select_stroke_tool (GimpContainerView *view,
+ GList *items,
+ GList *paths,
+ GimpBucketFillOptions *options)
+{
+ GList *iter;
+
+ for (iter = items; iter; iter = iter->next)
+ {
+ g_object_set (options,
+ "line-art-stroke-tool",
+ iter->data ? gimp_object_get_name (iter->data) : NULL,
+ NULL);
+ break;
+ }
+
+ return TRUE;
+}
+
static void
gimp_bucket_fill_options_reset (GimpConfig *config)
{
@@ -446,9 +524,10 @@ gimp_bucket_fill_options_update_area (GimpBucketFillOptions *options)
GtkWidget *
gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
{
- GimpBucketFillOptions *options = GIMP_BUCKET_FILL_OPTIONS (tool_options);
- GObject *config = G_OBJECT (tool_options);
- GtkWidget *vbox = gimp_paint_options_gui (tool_options);
+ GimpBucketFillOptions *options = GIMP_BUCKET_FILL_OPTIONS (tool_options);
+ GObject *config = G_OBJECT (tool_options);
+ Gimp *gimp = tool_options->tool_info->gimp;
+ GtkWidget *vbox = gimp_paint_options_gui (tool_options);
GtkWidget *box2;
GtkWidget *frame;
GtkWidget *hbox;
@@ -625,8 +704,24 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
/* Line Art Borders: stroke border with paint brush */
- widget = gimp_prop_check_button_new (config, "line-art-stroke-border", NULL);
- gtk_box_pack_start (GTK_BOX (box2), widget, FALSE, FALSE, 0);
+
+ options->stroke_options = gimp_stroke_options_new (gimp,
+ gimp_get_user_context (gimp),
+ TRUE);
+ gimp_config_sync (G_OBJECT (GIMP_DIALOG_CONFIG (gimp->config)->stroke_options),
+ G_OBJECT (options->stroke_options), 0);
+
+ widget = gimp_container_combo_box_new (gimp->paint_info_list,
+ GIMP_CONTEXT (options->stroke_options),
+ 16, 0);
+ g_signal_connect (widget, "select-items",
+ G_CALLBACK (gimp_bucket_fill_options_select_stroke_tool),
+ options);
+
+ frame = gimp_prop_expanding_frame_new (config, "line-art-stroke-border", NULL,
+ widget, NULL);
+ gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
gimp_bucket_fill_options_update_area (options);
diff --git a/app/tools/gimpbucketfilloptions.h b/app/tools/gimpbucketfilloptions.h
index 84345011f8..2b12dcd9da 100644
--- a/app/tools/gimpbucketfilloptions.h
+++ b/app/tools/gimpbucketfilloptions.h
@@ -52,9 +52,12 @@ struct _GimpBucketFillOptions
GimpLineArtSource line_art_source;
gdouble line_art_threshold;
gint line_art_max_grow;
- gboolean line_art_stroke;
gint line_art_max_gap_length;
+ gboolean line_art_stroke;
+ gchar *line_art_stroke_tool;
+ GimpStrokeOptions *stroke_options;
+
gboolean fill_as_line_art;
gdouble fill_as_line_art_threshold;
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 5478b61538..f9322915cc 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -458,6 +458,7 @@ gimp_bucket_fill_tool_preview (GimpBucketFillTool *tool,
options->fill_as_line_art,
options->fill_as_line_art_threshold / 255.0,
options->line_art_stroke,
+ options->stroke_options,
x, y,
&tool->priv->fill_mask,
&x, &y, NULL, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]