[gimp/wip/gradient-edit: 37/42] app: fix fg/bg color change handling in the blend tool
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/gradient-edit: 37/42] app: fix fg/bg color change handling in the blend tool
- Date: Fri, 6 Oct 2017 22:30:09 +0000 (UTC)
commit e538a95a52ae7a5c233cc21d7806012ca8696d5c
Author: Ell <ell_se yahoo com>
Date: Fri Aug 4 08:44:32 2017 -0400
app: fix fg/bg color change handling in the blend tool
Separate the handling of changes to the FG/BG color from the gradient
dirty signal handling, so that the gradient editor doesn't purge the
history in response. Additionally, correctly respond to such changes
whenever the gradient has segments that depend on the FG/BG colors,
even if the dependency is introduced after the gradient is selected.
app/tools/gimpblendtool-editor.c | 6 ++++
app/tools/gimpblendtool-editor.h | 2 +
app/tools/gimpblendtool.c | 53 +++++++++++++++++++++++++-------------
3 files changed, 43 insertions(+), 18 deletions(-)
---
diff --git a/app/tools/gimpblendtool-editor.c b/app/tools/gimpblendtool-editor.c
index 727af93..517ea50 100644
--- a/app/tools/gimpblendtool-editor.c
+++ b/app/tools/gimpblendtool-editor.c
@@ -2188,6 +2188,12 @@ gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
}
void
+gimp_blend_tool_editor_fg_bg_changed (GimpBlendTool *blend_tool)
+{
+ gimp_blend_tool_editor_update_gui (blend_tool);
+}
+
+void
gimp_blend_tool_editor_gradient_dirty (GimpBlendTool *blend_tool)
{
if (gimp_blend_tool_editor_are_handlers_blocked (blend_tool))
diff --git a/app/tools/gimpblendtool-editor.h b/app/tools/gimpblendtool-editor.h
index c72fa47..b9bbda4 100644
--- a/app/tools/gimpblendtool-editor.h
+++ b/app/tools/gimpblendtool-editor.h
@@ -28,6 +28,8 @@ void gimp_blend_tool_editor_halt (GimpBlendTool *blend_t
void gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool);
+void gimp_blend_tool_editor_fg_bg_changed (GimpBlendTool *blend_tool);
+
void gimp_blend_tool_editor_gradient_dirty (GimpBlendTool *blend_tool);
void gimp_blend_tool_editor_gradient_changed (GimpBlendTool *blend_tool);
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 9feea2d..43a63dc 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -121,6 +121,8 @@ static void gimp_blend_tool_precalc_shapeburst (GimpBlendTool *blend_
static void gimp_blend_tool_create_graph (GimpBlendTool *blend_tool);
static void gimp_blend_tool_update_graph (GimpBlendTool *blend_tool);
+static void gimp_blend_tool_fg_bg_changed (GimpBlendTool *blend_tool);
+
static void gimp_blend_tool_gradient_dirty (GimpBlendTool *blend_tool);
static void gimp_blend_tool_set_gradient (GimpBlendTool *blend_tool,
GimpGradient *gradient);
@@ -297,8 +299,7 @@ gimp_blend_tool_button_press (GimpTool *tool,
GimpButtonPressType press_type,
GimpDisplay *display)
{
- GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
- GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (tool);
+ GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
if (tool->display && display != tool->display)
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, tool->display);
@@ -577,6 +578,13 @@ gimp_blend_tool_start (GimpBlendTool *blend_tool,
G_CALLBACK (gimp_blend_tool_line_response),
blend_tool);
+ g_signal_connect_swapped (context, "background-changed",
+ G_CALLBACK (gimp_blend_tool_fg_bg_changed),
+ blend_tool);
+ g_signal_connect_swapped (context, "foreground-changed",
+ G_CALLBACK (gimp_blend_tool_fg_bg_changed),
+ blend_tool);
+
gimp_blend_tool_create_filter (blend_tool, drawable);
/* Initially sync all of the properties */
@@ -599,6 +607,7 @@ gimp_blend_tool_halt (GimpBlendTool *blend_tool)
{
GimpTool *tool = GIMP_TOOL (blend_tool);
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
+ GimpContext *context = GIMP_CONTEXT (options);
gimp_blend_tool_editor_halt (blend_tool);
@@ -628,6 +637,10 @@ gimp_blend_tool_halt (GimpBlendTool *blend_tool)
gimp_image_flush (gimp_display_get_image (tool->display));
}
+ g_signal_handlers_disconnect_by_func (context,
+ G_CALLBACK (gimp_blend_tool_fg_bg_changed),
+ blend_tool);
+
if (tool->display)
gimp_tool_pop_status (tool, tool->display);
@@ -828,6 +841,26 @@ gimp_blend_tool_update_graph (GimpBlendTool *blend_tool)
}
static void
+gimp_blend_tool_fg_bg_changed (GimpBlendTool *blend_tool)
+{
+ if (! blend_tool->filter || ! blend_tool->gradient)
+ return;
+
+ if (gimp_gradient_has_fg_bg_segments (blend_tool->gradient))
+ {
+ /* Set a property on the node. Otherwise it will cache and refuse to update */
+ gegl_node_set (blend_tool->render_node,
+ "gradient", blend_tool->gradient,
+ NULL);
+
+ /* Update the filter */
+ gimp_drawable_filter_apply (blend_tool->filter, NULL);
+
+ gimp_blend_tool_editor_fg_bg_changed (blend_tool);
+ }
+}
+
+static void
gimp_blend_tool_gradient_dirty (GimpBlendTool *blend_tool)
{
if (! blend_tool->filter)
@@ -848,17 +881,11 @@ static void
gimp_blend_tool_set_gradient (GimpBlendTool *blend_tool,
GimpGradient *gradient)
{
- GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
- GimpContext *context = GIMP_CONTEXT (options);
-
if (blend_tool->gradient)
{
g_signal_handlers_disconnect_by_func (blend_tool->gradient,
G_CALLBACK (gimp_blend_tool_gradient_dirty),
blend_tool);
- g_signal_handlers_disconnect_by_func (context,
- G_CALLBACK (gimp_blend_tool_gradient_dirty),
- blend_tool);
g_object_unref (blend_tool->gradient);
}
@@ -873,16 +900,6 @@ gimp_blend_tool_set_gradient (GimpBlendTool *blend_tool,
G_CALLBACK (gimp_blend_tool_gradient_dirty),
blend_tool);
- if (gimp_gradient_has_fg_bg_segments (blend_tool->gradient))
- {
- g_signal_connect_swapped (context, "background-changed",
- G_CALLBACK (gimp_blend_tool_gradient_dirty),
- blend_tool);
- g_signal_connect_swapped (context, "foreground-changed",
- G_CALLBACK (gimp_blend_tool_gradient_dirty),
- blend_tool);
- }
-
if (blend_tool->render_node)
gegl_node_set (blend_tool->render_node,
"gradient", blend_tool->gradient,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]