[gimp] Paint Select tool: add a temporary option to show painted scribbles
- From: Thomas Manni <tmanni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Paint Select tool: add a temporary option to show painted scribbles
- Date: Fri, 4 Dec 2020 18:01:16 +0000 (UTC)
commit 6a169e289fea8c9aad0f829ba309e1f012206f79
Author: Thomas Manni <thomas manni free fr>
Date: Fri Dec 4 18:56:28 2020 +0100
Paint Select tool: add a temporary option to show painted scribbles
For debugging purpose, will be removed on the final tool.
app/tools/gimppaintselectoptions.c | 21 +++++++++++++++++++++
app/tools/gimppaintselectoptions.h | 1 +
app/tools/gimppaintselecttool.c | 36 +++++++++++++++++++++++++++++++++++-
3 files changed, 57 insertions(+), 1 deletion(-)
---
diff --git a/app/tools/gimppaintselectoptions.c b/app/tools/gimppaintselectoptions.c
index 9c707036a4..902ffe8040 100644
--- a/app/tools/gimppaintselectoptions.c
+++ b/app/tools/gimppaintselectoptions.c
@@ -43,6 +43,7 @@ enum
PROP_0,
PROP_MODE,
PROP_STROKE_WIDTH,
+ PROP_SHOW_SCRIBBLES,
};
@@ -83,6 +84,13 @@ gimp_paint_select_options_class_init (GimpPaintSelectOptionsClass *klass)
_("Size of the brush used for refinements"),
1, 6000, 50,
GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_SCRIBBLES,
+ "show-scribbles",
+ _("Show scribbles"),
+ _("Show scribbles"),
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
}
static void
@@ -108,6 +116,10 @@ gimp_paint_select_options_set_property (GObject *object,
options->stroke_width = g_value_get_int (value);
break;
+ case PROP_SHOW_SCRIBBLES:
+ options->show_scribbles = g_value_get_boolean (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -132,6 +144,10 @@ gimp_paint_select_options_get_property (GObject *object,
g_value_set_int (value, options->stroke_width);
break;
+ case PROP_SHOW_SCRIBBLES:
+ g_value_set_boolean (value, options->show_scribbles);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -184,5 +200,10 @@ gimp_paint_select_options_gui (GimpToolOptions *tool_options)
gimp_help_set_help_data (button,
_("Reset stroke width native size"), NULL);
+ /* show scribbles */
+ button = gimp_prop_check_button_new (config, "show-scribbles", "Show scribbles");
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
return vbox;
}
diff --git a/app/tools/gimppaintselectoptions.h b/app/tools/gimppaintselectoptions.h
index 7c5cb201b6..ee9dd4068f 100644
--- a/app/tools/gimppaintselectoptions.h
+++ b/app/tools/gimppaintselectoptions.h
@@ -40,6 +40,7 @@ struct _GimpPaintSelectOptions
GimpPaintSelectMode mode;
gint stroke_width;
+ gboolean show_scribbles;
};
struct _GimpPaintSelectOptionsClass
diff --git a/app/tools/gimppaintselecttool.c b/app/tools/gimppaintselecttool.c
index a80d4325b6..4cc0ff1d87 100644
--- a/app/tools/gimppaintselecttool.c
+++ b/app/tools/gimppaintselecttool.c
@@ -124,6 +124,7 @@ static void gimp_paint_select_tool_init_buffers (GimpPaintSelectTool *
static void gimp_paint_select_tool_init_scribble (GimpPaintSelectTool *ps_tool);
static void gimp_paint_select_tool_create_graph (GimpPaintSelectTool *ps_tool);
static gboolean gimp_paint_select_tool_paint_scribble (GimpPaintSelectTool *ps_tool);
+static void gimp_paint_select_tool_toggle_scribbles_visibility (GimpPaintSelectTool *ps_tool);
static gfloat euclidean_distance (gint x1,
gint y1,
@@ -499,6 +500,10 @@ gimp_paint_select_tool_options_notify (GimpTool *tool,
g_object_unref (ps_tool->scribble);
ps_tool->scribble = NULL;
}
+ else if (! strcmp (pspec->name, "show-scribbles"))
+ {
+ gimp_paint_select_tool_toggle_scribbles_visibility (ps_tool);
+ }
}
static void
@@ -517,7 +522,11 @@ gimp_paint_select_tool_halt (GimpPaintSelectTool *ps_tool)
ps_tool->image_mask = NULL;
if (tool->display)
- gimp_image_flush (gimp_display_get_image (tool->display));
+ {
+ gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
+ NULL, 0, 0, NULL, FALSE);
+ gimp_image_flush (gimp_display_get_image (tool->display));
+ }
tool->display = NULL;
g_list_free (tool->drawables);
@@ -688,6 +697,8 @@ gimp_paint_select_tool_paint_scribble (GimpPaintSelectTool *ps_tool)
}
}
+ gimp_paint_select_tool_toggle_scribbles_visibility (ps_tool);
+
return overlap;
}
@@ -756,6 +767,29 @@ gimp_paint_select_tool_create_graph (GimpPaintSelectTool *ps_tool)
gegl_node_connect_to (t, "output", ps_tool->ps_node, "aux2");
}
+static void
+gimp_paint_select_tool_toggle_scribbles_visibility (GimpPaintSelectTool *ps_tool)
+{
+ GimpTool *tool = GIMP_TOOL (ps_tool);
+ GimpPaintSelectOptions *options = GIMP_PAINT_SELECT_TOOL_GET_OPTIONS (tool);
+
+ if (options->show_scribbles)
+ {
+ const GimpRGB black = {0.0, 0.0, 0.0, 1.0};
+ gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
+ ps_tool->trimap,
+ ps_tool->drawable_off_x,
+ ps_tool->drawable_off_y,
+ &black,
+ TRUE);
+ }
+ else
+ {
+ gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
+ NULL, 0, 0, NULL, FALSE);
+ }
+}
+
static gfloat
euclidean_distance (gint x1,
gint y1,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]