[gimp/gimp-2-10] app: add "show all" support to the bucket-fill tool in "fill similar colors" mode



commit 09c771402136dc52c537f230501577d9c6e0452a
Author: Ell <ell_se yahoo com>
Date:   Thu Sep 5 17:58:17 2019 +0300

    app: add "show all" support to the bucket-fill tool in "fill similar colors" mode
    
    In the bucket-fill tool, allow using the tool outside the canvas
    bounds with "sample merged" active in "fill similar colors" mode,
    when the current display is in "show all" mode.  Additionally,
    ignore "sample merged" in "fill whole selection" mode, on which it
    has no effect.
    
    (cherry picked from commit 17f8cff6f60e6353ebdc4590ff6fb1ca3686aba8)

 app/core/gimpdrawable-bucket-fill.c | 15 ++++++--
 app/core/gimpdrawable-bucket-fill.h |  1 +
 app/tools/gimpbucketfilltool.c      | 72 +++++++++++++++++++++++++------------
 3 files changed, 63 insertions(+), 25 deletions(-)
---
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index c79e6a8031..1cef758886 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -75,7 +75,7 @@ gimp_drawable_bucket_fill (GimpDrawable         *drawable,
 
   buffer = gimp_drawable_get_bucket_fill_buffer (drawable, options,
                                                  fill_transparent, fill_criterion,
-                                                 threshold, sample_merged,
+                                                 threshold, FALSE, sample_merged,
                                                  diagonal_neighbors,
                                                  seed_x, seed_y, NULL,
                                                  &mask_x, &mask_y, &width, &height);
@@ -108,6 +108,7 @@ gimp_drawable_bucket_fill (GimpDrawable         *drawable,
  * @fill_transparent:
  * @fill_criterion:
  * @threshold:
+ * @show_all:
  * @sample_merged:
  * @diagonal_neighbors:
  * @seed_x: X coordinate to start the fill.
@@ -136,6 +137,7 @@ gimp_drawable_get_bucket_fill_buffer (GimpDrawable         *drawable,
                                       gboolean              fill_transparent,
                                       GimpSelectCriterion   fill_criterion,
                                       gdouble               threshold,
+                                      gboolean              show_all,
                                       gboolean              sample_merged,
                                       gboolean              diagonal_neighbors,
                                       gdouble               seed_x,
@@ -182,9 +184,16 @@ gimp_drawable_get_bucket_fill_buffer (GimpDrawable         *drawable,
   gimp_set_busy (image->gimp);
 
   if (sample_merged)
-    pickable = GIMP_PICKABLE (image);
+    {
+      if (! show_all)
+        pickable = GIMP_PICKABLE (image);
+      else
+        pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
+    }
   else
-    pickable = GIMP_PICKABLE (drawable);
+    {
+      pickable = GIMP_PICKABLE (drawable);
+    }
 
   antialias = gimp_fill_options_get_antialias (options);
 
diff --git a/app/core/gimpdrawable-bucket-fill.h b/app/core/gimpdrawable-bucket-fill.h
index ef9acfb13f..148de97b5f 100644
--- a/app/core/gimpdrawable-bucket-fill.h
+++ b/app/core/gimpdrawable-bucket-fill.h
@@ -33,6 +33,7 @@ GeglBuffer * gimp_drawable_get_bucket_fill_buffer   (GimpDrawable         *drawa
                                                      gboolean              fill_transparent,
                                                      GimpSelectCriterion   fill_criterion,
                                                      gdouble               threshold,
+                                                     gboolean              show_all,
                                                      gboolean              sample_merged,
                                                      gboolean              diagonal_neighbors,
                                                      gdouble               seed_x,
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 2c9fa166e5..6518a6921a 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -53,6 +53,7 @@
 #include "widgets/gimpwidgets-utils.h"
 
 #include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
 
 #include "gimpbucketfilloptions.h"
 #include "gimpbucketfilltool.h"
@@ -121,6 +122,11 @@ static void     gimp_bucket_fill_tool_options_notify   (GimpTool              *t
 static void gimp_bucket_fill_tool_line_art_computing_start (GimpBucketFillTool *tool);
 static void gimp_bucket_fill_tool_line_art_computing_end   (GimpBucketFillTool *tool);
 
+static gboolean gimp_bucket_fill_tool_coords_in_active_pickable
+                                                       (GimpBucketFillTool    *tool,
+                                                        GimpDisplay           *display,
+                                                        const GimpCoords      *coords);
+
 static void     gimp_bucket_fill_tool_start            (GimpBucketFillTool    *tool,
                                                         const GimpCoords      *coords,
                                                         GimpDisplay           *display);
@@ -276,6 +282,37 @@ gimp_bucket_fill_tool_finalize (GObject *object)
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+static gboolean
+gimp_bucket_fill_tool_coords_in_active_pickable (GimpBucketFillTool *tool,
+                                                 GimpDisplay        *display,
+                                                 const GimpCoords   *coords)
+{
+  GimpBucketFillOptions *options       = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
+  GimpDisplayShell      *shell         = gimp_display_get_shell (display);
+  GimpImage             *image         = gimp_display_get_image (display);
+  gboolean               show_all      = FALSE;
+  gboolean               sample_merged = FALSE;
+
+  switch (options->fill_area)
+    {
+    case GIMP_BUCKET_FILL_SELECTION:
+      break;
+
+    case GIMP_BUCKET_FILL_SIMILAR_COLORS:
+      show_all      = shell->show_all;
+      sample_merged = options->sample_merged;
+      break;
+
+    case GIMP_BUCKET_FILL_LINE_ART:
+      sample_merged = options->line_art_source ==
+                      GIMP_LINE_ART_SOURCE_SAMPLE_MERGED;
+      break;
+    }
+
+  return gimp_image_coords_in_active_pickable (image, coords,
+                                               show_all, sample_merged, TRUE);
+}
+
 static void
 gimp_bucket_fill_tool_start (GimpBucketFillTool *tool,
                              const GimpCoords   *coords,
@@ -325,6 +362,7 @@ gimp_bucket_fill_tool_preview (GimpBucketFillTool *tool,
                                GimpFillOptions    *fill_options)
 {
   GimpBucketFillOptions *options  = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
+  GimpDisplayShell      *shell    = gimp_display_get_shell (display);
   GimpImage             *image    = gimp_display_get_image (display);
   GimpDrawable          *drawable = gimp_image_get_active_drawable (image);
 
@@ -350,6 +388,7 @@ gimp_bucket_fill_tool_preview (GimpBucketFillTool *tool,
                                                        options->fill_transparent,
                                                        options->fill_criterion,
                                                        options->threshold / 255.0,
+                                                       shell->show_all,
                                                        options->sample_merged,
                                                        options->diagonal_neighbors,
                                                        x, y,
@@ -477,7 +516,6 @@ gimp_bucket_fill_tool_button_press (GimpTool            *tool,
   GimpGuiConfig         *config      = GIMP_GUI_CONFIG (display->gimp->config);
   GimpImage             *image       = gimp_display_get_image (display);
   GimpDrawable          *drawable    = gimp_image_get_active_drawable (image);
-  gboolean               sample_merged;
 
   if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
     {
@@ -517,12 +555,9 @@ gimp_bucket_fill_tool_button_press (GimpTool            *tool,
       return;
     }
 
-  sample_merged = (options->fill_area == GIMP_BUCKET_FILL_LINE_ART ?
-                   options->line_art_source == GIMP_LINE_ART_SOURCE_SAMPLE_MERGED :
-                   options->sample_merged);
   if (press_type == GIMP_BUTTON_PRESS_NORMAL &&
-      gimp_image_coords_in_active_pickable (image, coords,
-                                            FALSE, sample_merged, TRUE))
+      gimp_bucket_fill_tool_coords_in_active_pickable (bucket_tool,
+                                                       display, coords))
     {
       GimpContext     *context  = GIMP_CONTEXT (options);
       GimpFillOptions *fill_options;
@@ -579,18 +614,14 @@ gimp_bucket_fill_tool_motion (GimpTool         *tool,
   GimpBucketFillTool    *bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
   GimpBucketFillOptions *options     = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
   GimpImage             *image       = gimp_display_get_image (display);
-  gboolean               sample_merged;
 
   GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display);
 
   if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
     return;
 
-  sample_merged = (options->fill_area == GIMP_BUCKET_FILL_LINE_ART ?
-                   options->line_art_source == GIMP_LINE_ART_SOURCE_SAMPLE_MERGED :
-                   options->sample_merged);
-  if (gimp_image_coords_in_active_pickable (image, coords,
-                                            FALSE, sample_merged, TRUE) &&
+  if (gimp_bucket_fill_tool_coords_in_active_pickable (bucket_tool,
+                                                       display, coords) &&
       /* Fill selection only needs to happen once. */
       options->fill_area != GIMP_BUCKET_FILL_SELECTION)
     {
@@ -763,17 +794,14 @@ gimp_bucket_fill_tool_cursor_update (GimpTool         *tool,
                                      GdkModifierType   state,
                                      GimpDisplay      *display)
 {
-  GimpBucketFillOptions *options  = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
-  GimpGuiConfig         *config   = GIMP_GUI_CONFIG (display->gimp->config);
-  GimpCursorModifier     modifier = GIMP_CURSOR_MODIFIER_BAD;
-  GimpImage             *image    = gimp_display_get_image (display);
-  gboolean               sample_merged;
+  GimpBucketFillTool    *bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
+  GimpBucketFillOptions *options     = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
+  GimpGuiConfig         *config      = GIMP_GUI_CONFIG (display->gimp->config);
+  GimpCursorModifier     modifier    = GIMP_CURSOR_MODIFIER_BAD;
+  GimpImage             *image       = gimp_display_get_image (display);
 
-  sample_merged = (options->fill_area == GIMP_BUCKET_FILL_LINE_ART ?
-                   options->line_art_source == GIMP_LINE_ART_SOURCE_SAMPLE_MERGED :
-                   options->sample_merged);
-  if (gimp_image_coords_in_active_pickable (image, coords,
-                                            FALSE, sample_merged, TRUE))
+  if (gimp_bucket_fill_tool_coords_in_active_pickable (bucket_tool,
+                                                       display, coords))
     {
       GimpDrawable *drawable = gimp_image_get_active_drawable (image);
 


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