[gimp/wip/gradient-edit: 38/39] app: don't update blend tool filter upon irrelevant line changes



commit d49679c6f8e67605d7e28a5c2e4b3d36039d799f
Author: Ell <ell_se yahoo com>
Date:   Sat Aug 12 11:25:22 2017 -0400

    app: don't update blend tool filter upon irrelevant line changes
    
    When one of the line widget's properties changes, only update the
    blend tool filter if the property has an effect on the result.  In
    particular, don't update the filter when only the selection
    changes.

 app/tools/gimpblendtool-editor.c |   11 ++++++++---
 app/tools/gimpblendtool-editor.h |    2 +-
 app/tools/gimpblendtool.c        |   37 ++++++++++++++++++++++++++++++-------
 3 files changed, 39 insertions(+), 11 deletions(-)
---
diff --git a/app/tools/gimpblendtool-editor.c b/app/tools/gimpblendtool-editor.c
index 3b418b5..f3ef849 100644
--- a/app/tools/gimpblendtool-editor.c
+++ b/app/tools/gimpblendtool-editor.c
@@ -2090,7 +2090,7 @@ gimp_blend_tool_editor_halt (GimpBlendTool *blend_tool)
     }
 }
 
-void
+gboolean
 gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
 {
   GimpBlendOptions           *options       = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
@@ -2100,15 +2100,16 @@ gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
   gint                        n_sliders;
   gint                        i;
   GimpGradientSegment        *seg;
+  gboolean                    changed       = FALSE;
 
   if (offset == 1.0 || ! blend_tool->gradient || blend_tool->modifying)
-    return;
+    return FALSE;
 
   sliders = gimp_tool_line_get_sliders (GIMP_TOOL_LINE (blend_tool->widget),
                                         &n_sliders);
 
   if (n_sliders == 0)
-    return;
+    return FALSE;
 
   /* update the midpoints first, since moving the gradient stops may change the
    * gradient's midpoints w.r.t. the sliders, but not the other way around.
@@ -2188,9 +2189,13 @@ gimp_blend_tool_editor_line_changed (GimpBlendTool *blend_tool)
       blend_tool->modifying = FALSE;
 
       gimp_blend_tool_editor_update_sliders (blend_tool);
+
+      changed = TRUE;
     }
 
   gimp_blend_tool_editor_update_gui (blend_tool);
+
+  return changed;
 }
 
 void
diff --git a/app/tools/gimpblendtool-editor.h b/app/tools/gimpblendtool-editor.h
index b9bbda4..3388371 100644
--- a/app/tools/gimpblendtool-editor.h
+++ b/app/tools/gimpblendtool-editor.h
@@ -26,7 +26,7 @@ void          gimp_blend_tool_editor_options_notify   (GimpBlendTool    *blend_t
 void          gimp_blend_tool_editor_start            (GimpBlendTool    *blend_tool);
 void          gimp_blend_tool_editor_halt             (GimpBlendTool    *blend_tool);
 
-void          gimp_blend_tool_editor_line_changed     (GimpBlendTool    *blend_tool);
+gboolean      gimp_blend_tool_editor_line_changed     (GimpBlendTool    *blend_tool);
 
 void          gimp_blend_tool_editor_fg_bg_changed    (GimpBlendTool    *blend_tool);
 
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 43a63dc..e40e84d 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -680,17 +680,40 @@ static void
 gimp_blend_tool_line_changed (GimpToolWidget *widget,
                               GimpBlendTool  *blend_tool)
 {
+  gdouble  start_x;
+  gdouble  start_y;
+  gdouble  end_x;
+  gdouble  end_y;
+  gboolean update = FALSE;
+
   g_object_get (widget,
-                "x1", &blend_tool->start_x,
-                "y1", &blend_tool->start_y,
-                "x2", &blend_tool->end_x,
-                "y2", &blend_tool->end_y,
+                "x1", &start_x,
+                "y1", &start_y,
+                "x2", &end_x,
+                "y2", &end_y,
                 NULL);
 
-  gimp_blend_tool_update_graph (blend_tool);
-  gimp_drawable_filter_apply (blend_tool->filter, NULL);
+  if (start_x != blend_tool->start_x ||
+      start_y != blend_tool->start_y ||
+      end_x   != blend_tool->end_x   ||
+      end_y   != blend_tool->end_y)
+    {
+      blend_tool->start_x = start_x;
+      blend_tool->start_y = start_y;
+      blend_tool->end_x   = end_x;
+      blend_tool->end_y   = end_y;
+
+      update = TRUE;
+    }
+
+  if (gimp_blend_tool_editor_line_changed (blend_tool))
+    update = TRUE;
 
-  gimp_blend_tool_editor_line_changed (blend_tool);
+  if (update)
+    {
+      gimp_blend_tool_update_graph (blend_tool);
+      gimp_drawable_filter_apply (blend_tool->filter, NULL);
+    }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]