[gimp] Bug 794854 - Brush color is not added to color history in smudge tool



commit e55c94eff0a9b2715b052b61fdc95bb071882c8c
Author: shark0r <b91502038 ntu edu tw>
Date:   Fri Mar 30 01:53:12 2018 +0800

    Bug 794854 - Brush color is not added to color history in smudge tool
    
    Add the color in gimp_smudge_paint(INIT) like GimpPaintbrush does.
    
    Achieve this by calling gimp_palettes_add_color_history() directly,
    not by inheriting GimpPaintbrush because GimpPaintbrush and GimpSmudge seem to share few common features.

 app/paint/gimpsmudge.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c
index b15da03..5c31703 100644
--- a/app/paint/gimpsmudge.c
+++ b/app/paint/gimpsmudge.c
@@ -27,6 +27,7 @@
 #include "gegl/gimp-gegl-loops.h"
 #include "gegl/gimp-gegl-utils.h"
 
+#include "core/gimp-palettes.h"
 #include "core/gimpbrush.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpdynamics.h"
@@ -141,6 +142,29 @@ gimp_smudge_paint (GimpPaintCore    *paint_core,
 
   switch (paint_state)
     {
+    case GIMP_PAINT_STATE_INIT:
+      {
+        GimpContext       *context    = GIMP_CONTEXT (paint_options);
+        GimpSmudgeOptions *options    = GIMP_SMUDGE_OPTIONS (paint_options);
+        GimpBrushCore     *brush_core = GIMP_BRUSH_CORE (paint_core);
+        GimpDynamics      *dynamics   = gimp_context_get_dynamics (context);
+
+        /* Don't add to color history when
+         * 1. pure smudging (flow=0)
+         * 2. color is from gradient or pixmap brushes
+         */
+        if (options->flow > 0.0 &&
+            ! gimp_dynamics_is_output_enabled (dynamics, GIMP_DYNAMICS_OUTPUT_COLOR) &&
+            ! (brush_core->brush && gimp_brush_get_pixmap (brush_core->brush)))
+          {
+            GimpRGB foreground;
+
+            gimp_context_get_foreground (context, &foreground);
+            gimp_palettes_add_color_history (context->gimp, &foreground);
+          }
+      }
+      break;
+
     case GIMP_PAINT_STATE_MOTION:
       /* initialization fails if the user starts outside the drawable */
       if (! smudge->initialized)


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