Commit 1416743b authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

app: use GimpFillType in gimp_drawable_bucket_fill()

GimpBucketFillMode is now tool- and pdb-only.
parent dcc60e12
......@@ -47,7 +47,7 @@
static void gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
GimpBucketFillMode fill_mode,
GimpFillType fill_type,
gint paint_mode,
gdouble opacity,
gboolean fill_transparent,
......@@ -65,7 +65,7 @@ static void gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
gboolean
gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpContext *context,
GimpBucketFillMode fill_mode,
GimpFillType fill_type,
gint paint_mode,
gdouble opacity,
gboolean fill_transparent,
......@@ -84,16 +84,25 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (fill_mode == GIMP_BUCKET_FILL_FG)
switch (fill_type)
{
case GIMP_FILL_FOREGROUND:
gimp_context_get_foreground (context, &color);
}
else if (fill_mode == GIMP_BUCKET_FILL_BG)
{
break;
case GIMP_FILL_BACKGROUND:
gimp_context_get_background (context, &color);
}
else if (fill_mode == GIMP_BUCKET_FILL_PATTERN)
{
break;
case GIMP_FILL_WHITE:
gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0);
break;
case GIMP_FILL_TRANSPARENT:
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
break;
case GIMP_FILL_PATTERN:
pattern = gimp_context_get_pattern (context);
if (! pattern)
......@@ -102,15 +111,15 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
_("No patterns available for this operation."));
return FALSE;
}
}
else
{
g_warning ("%s: invalid fill_mode passed", G_STRFUNC);
break;
default:
g_warning ("%s: invalid fill_type passed", G_STRFUNC);
return FALSE;
}
gimp_drawable_bucket_fill_internal (drawable,
fill_mode,
fill_type,
paint_mode, opacity,
fill_transparent, fill_criterion,
threshold, sample_merged,
......@@ -125,7 +134,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
static void
gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
GimpBucketFillMode fill_mode,
GimpFillType fill_type,
gint paint_mode,
gdouble opacity,
gboolean fill_transparent,
......@@ -148,9 +157,9 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
g_return_if_fail (fill_mode != GIMP_BUCKET_FILL_PATTERN ||
g_return_if_fail (fill_type != GIMP_FILL_PATTERN ||
GIMP_IS_PATTERN (pattern));
g_return_if_fail (fill_mode == GIMP_BUCKET_FILL_PATTERN ||
g_return_if_fail (fill_type == GIMP_FILL_PATTERN ||
color != NULL);
image = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -230,10 +239,12 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, x2 - x1, y2 - y1),
gimp_drawable_get_format_with_alpha (drawable));
switch (fill_mode)
switch (fill_type)
{
case GIMP_BUCKET_FILL_FG:
case GIMP_BUCKET_FILL_BG:
case GIMP_FILL_FOREGROUND:
case GIMP_FILL_BACKGROUND:
case GIMP_FILL_WHITE:
case GIMP_FILL_TRANSPARENT:
{
GeglColor *gegl_color = gimp_gegl_color_new (color);
......@@ -242,7 +253,7 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
}
break;
case GIMP_BUCKET_FILL_PATTERN:
case GIMP_FILL_PATTERN:
{
GeglBuffer *pattern_buffer = gimp_pattern_create_buffer (pattern);
......
......@@ -21,7 +21,7 @@
gboolean gimp_drawable_bucket_fill (GimpDrawable *drawable,
GimpContext *context,
GimpBucketFillMode fill_mode,
GimpFillType fill_type,
gint paint_mode,
gdouble opacity,
gboolean fill_transparent,
......
......@@ -600,33 +600,33 @@ edit_bucket_fill_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpFillType fill_type;
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
switch (fill_mode)
{
GimpFillType fill_type = GIMP_FILL_FOREGROUND;
switch (fill_mode)
{
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
default:
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
success = gimp_edit_fill (image, drawable, context, fill_type,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
}
else
{
success = gimp_drawable_bucket_fill (drawable, context, fill_mode,
success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0,
FALSE /* don't fill transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
......@@ -680,33 +680,33 @@ edit_bucket_fill_full_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpFillType fill_type;
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
switch (fill_mode)
{
GimpFillType fill_type = GIMP_FILL_FOREGROUND;
switch (fill_mode)
{
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
default:
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
success = gimp_edit_fill (image, drawable, context, fill_type,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
}
else
{
success = gimp_drawable_bucket_fill (drawable, context, fill_mode,
success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0,
fill_transparent,
select_criterion,
......
......@@ -173,8 +173,23 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
{
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpContext *context = GIMP_CONTEXT (options);
GimpFillType fill_type;
gint x, y;
switch (options->fill_mode)
{
default:
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
x = coords->x;
y = coords->y;
......@@ -190,22 +205,6 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
if (options->fill_selection)
{
GimpFillType fill_type;
switch (options->fill_mode)
{
default:
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
gimp_edit_fill (image, drawable, context, fill_type,
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context));
......@@ -217,7 +216,7 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool,
if (! gimp_drawable_bucket_fill (drawable,
context,
options->fill_mode,
fill_type,
gimp_context_get_paint_mode (context),
gimp_context_get_opacity (context),
options->fill_transparent,
......
......@@ -636,33 +636,33 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpFillType fill_type;
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
switch (fill_mode)
{
GimpFillType fill_type = GIMP_FILL_FOREGROUND;
switch (fill_mode)
{
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
default:
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
success = gimp_edit_fill (image, drawable, context, fill_type,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
}
else
{
success = gimp_drawable_bucket_fill (drawable, context, fill_mode,
success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0,
FALSE /* don't fill transparent */,
GIMP_SELECT_CRITERION_COMPOSITE,
......@@ -744,33 +744,33 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpFillType fill_type;
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
switch (fill_mode)
{
GimpFillType fill_type = GIMP_FILL_FOREGROUND;
switch (fill_mode)
{
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
default:
case GIMP_BUCKET_FILL_FG:
fill_type = GIMP_FILL_FOREGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_BG:
fill_type = GIMP_FILL_BACKGROUND;
break;
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
case GIMP_BUCKET_FILL_PATTERN:
fill_type = GIMP_FILL_PATTERN;
break;
}
if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
success = gimp_edit_fill (image, drawable, context, fill_type,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
}
else
{
success = gimp_drawable_bucket_fill (drawable, context, fill_mode,
success = gimp_drawable_bucket_fill (drawable, context, fill_type,
paint_mode, opacity / 100.0,
fill_transparent,
select_criterion,
......
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