[gimp] app: add separate opacity and mode API to GimpDrawableFilter



commit 201b11e23097ed05956a48988b130bf9636039c2
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 18 09:47:58 2016 +0200

    app: add separate opacity and mode API to GimpDrawableFilter

 app/core/gimpdrawablefilter.c |   31 ++++++++++++++++++++++++++-----
 app/core/gimpdrawablefilter.h |    3 ++-
 app/tools/gimpblendtool.c     |   19 ++++++++++++-------
 3 files changed, 40 insertions(+), 13 deletions(-)
---
diff --git a/app/core/gimpdrawablefilter.c b/app/core/gimpdrawablefilter.c
index ccf50c2..64ba871 100644
--- a/app/core/gimpdrawablefilter.c
+++ b/app/core/gimpdrawablefilter.c
@@ -86,6 +86,7 @@ static void       gimp_drawable_filter_sync_preview     (GimpDrawableFilter  *fi
                                                          gboolean             old_enabled,
                                                          GimpAlignmentType    old_alignment,
                                                          gdouble              old_position);
+static void       gimp_drawable_filter_sync_opacity     (GimpDrawableFilter  *filter);
 static void       gimp_drawable_filter_sync_mode        (GimpDrawableFilter  *filter);
 static void       gimp_drawable_filter_sync_affect      (GimpDrawableFilter  *filter);
 static void       gimp_drawable_filter_sync_mask        (GimpDrawableFilter  *filter);
@@ -298,16 +299,30 @@ gimp_drawable_filter_set_preview (GimpDrawableFilter  *filter,
 }
 
 void
+gimp_drawable_filter_set_opacity (GimpDrawableFilter *filter,
+                                  gdouble             opacity)
+{
+  g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
+
+  if (opacity != filter->opacity)
+    {
+      filter->opacity = opacity;
+
+      gimp_drawable_filter_sync_opacity (filter);
+
+      if (gimp_drawable_filter_is_filtering (filter))
+        gimp_drawable_filter_update_drawable (filter, NULL);
+    }
+}
+
+void
 gimp_drawable_filter_set_mode (GimpDrawableFilter   *filter,
-                               gdouble               opacity,
                                GimpLayerModeEffects  paint_mode)
 {
   g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
 
-  if (opacity    != filter->opacity ||
-      paint_mode != filter->paint_mode)
+  if (paint_mode != filter->paint_mode)
     {
-      filter->opacity    = opacity;
       filter->paint_mode = paint_mode;
 
       gimp_drawable_filter_sync_mode (filter);
@@ -528,10 +543,15 @@ gimp_drawable_filter_sync_preview (GimpDrawableFilter *filter,
 }
 
 static void
-gimp_drawable_filter_sync_mode (GimpDrawableFilter *filter)
+gimp_drawable_filter_sync_opacity (GimpDrawableFilter *filter)
 {
   gimp_applicator_set_opacity (filter->applicator,
                                filter->opacity);
+}
+
+static void
+gimp_drawable_filter_sync_mode (GimpDrawableFilter *filter)
+{
   gimp_applicator_set_mode (filter->applicator,
                             filter->paint_mode);
 }
@@ -647,6 +667,7 @@ gimp_drawable_filter_add_filter (GimpDrawableFilter *filter)
                                          filter->preview_enabled,
                                          filter->preview_alignment,
                                          filter->preview_position);
+      gimp_drawable_filter_sync_opacity (filter);
       gimp_drawable_filter_sync_mode (filter);
       gimp_drawable_filter_sync_affect (filter);
       gimp_drawable_filter_sync_gamma_hack (filter);
diff --git a/app/core/gimpdrawablefilter.h b/app/core/gimpdrawablefilter.h
index b868742..d0bcf94 100644
--- a/app/core/gimpdrawablefilter.h
+++ b/app/core/gimpdrawablefilter.h
@@ -61,8 +61,9 @@ void       gimp_drawable_filter_set_preview    (GimpDrawableFilter   *filter,
                                                 gboolean              enabled,
                                                 GimpAlignmentType     alignment,
                                                 gdouble               split_position);
+void       gimp_drawable_filter_set_opacity    (GimpDrawableFilter   *filter,
+                                                gdouble               opacity);
 void       gimp_drawable_filter_set_mode       (GimpDrawableFilter   *filter,
-                                                gdouble               opacity,
                                                 GimpLayerModeEffects  paint_mode);
 
 void       gimp_drawable_filter_set_gamma_hack (GimpDrawableFilter   *filter,
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 3d8bcb3..e0491d1 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -608,6 +608,7 @@ gimp_blend_tool_options_notify (GimpTool         *tool,
     {
       /* Sync any property changes on the config object that match the op */
       GValue value = G_VALUE_INIT;
+
       g_value_init (&value, pspec->value_type);
 
       g_object_get_property (G_OBJECT (options), pspec->name, &value);
@@ -626,11 +627,15 @@ gimp_blend_tool_options_notify (GimpTool         *tool,
       gimp_drawable_filter_apply (blend_tool->filter, NULL);
     }
   else if (blend_tool->filter &&
-           (! strcmp (pspec->name, "opacity") ||
-            ! strcmp (pspec->name, "paint-mode")))
+           ! strcmp (pspec->name, "opacity"))
+    {
+      gimp_drawable_filter_set_opacity (blend_tool->filter,
+                                        gimp_context_get_opacity (context));
+    }
+  else if (blend_tool->filter &&
+           ! strcmp (pspec->name, "paint-mode"))
     {
       gimp_drawable_filter_set_mode (blend_tool->filter,
-                                     gimp_context_get_opacity (context),
                                      gimp_context_get_paint_mode (context));
     }
 }
@@ -1181,14 +1186,14 @@ gimp_blend_tool_create_filter (GimpBlendTool *blend_tool,
 
   gimp_drawable_filter_set_region (blend_tool->filter,
                                    GIMP_FILTER_REGION_DRAWABLE);
+  gimp_drawable_filter_set_opacity (blend_tool->filter,
+                                    gimp_context_get_opacity (context));
+  gimp_drawable_filter_set_mode (blend_tool->filter,
+                                 gimp_context_get_paint_mode (context));
 
   g_signal_connect (blend_tool->filter, "flush",
                     G_CALLBACK (gimp_blend_tool_filter_flush),
                     blend_tool);
-
-  gimp_drawable_filter_set_mode (blend_tool->filter,
-                                 gimp_context_get_opacity (context),
-                                 gimp_context_get_paint_mode (context));
 }
 
 static void


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