Commit 17f8cff6 authored by Ell's avatar Ell

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.
parent 99759a57
Pipeline #111961 passed with stages
in 13 minutes and 34 seconds
......@@ -74,7 +74,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);
......@@ -107,6 +107,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.
......@@ -135,6 +136,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,
......@@ -181,9 +183,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);
......
......@@ -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,
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment