1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2003-09-03 22:22:38 +08:00
|
|
|
#include "core/gimpchannel.h"
|
2001-11-09 03:14:51 +08:00
|
|
|
#include "core/gimpdrawable-bucket-fill.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-11-20 21:53:21 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimpbucketfilloptions.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimpbucketfilltool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static GimpToolClass *parent_class = NULL;
|
2001-02-28 09:05:22 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* local function prototypes */
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2001-02-28 09:05:22 +08:00
|
|
|
static void gimp_bucket_fill_tool_class_init (GimpBucketFillToolClass *klass);
|
|
|
|
static void gimp_bucket_fill_tool_init (GimpBucketFillTool *bucket_fill_tool);
|
|
|
|
|
2001-07-18 04:50:01 +08:00
|
|
|
static void gimp_bucket_fill_tool_button_press (GimpTool *tool,
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
static void gimp_bucket_fill_tool_button_release (GimpTool *tool,
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
static void gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
|
2001-11-09 03:14:51 +08:00
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
/* public functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 09:05:22 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_bucket_fill_tool_register (GimpToolRegisterCallback callback,
|
2003-08-22 09:42:57 +08:00
|
|
|
gpointer data)
|
2001-02-28 09:05:22 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_BUCKET_FILL_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_BUCKET_FILL_OPTIONS,
|
|
|
|
gimp_bucket_fill_options_gui,
|
2003-06-28 19:20:37 +08:00
|
|
|
GIMP_CONTEXT_OPACITY_MASK |
|
|
|
|
GIMP_CONTEXT_PAINT_MODE_MASK |
|
|
|
|
GIMP_CONTEXT_PATTERN_MASK,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-bucket-fill-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Bucket Fill"),
|
|
|
|
_("Fill with a color or pattern"),
|
2003-07-02 00:22:03 +08:00
|
|
|
N_("/Tools/Paint Tools/_Bucket Fill"), "<shift>B",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_BUCKET_FILL,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_BUCKET_FILL,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-02-28 09:05:22 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-02-28 09:05:22 +08:00
|
|
|
gimp_bucket_fill_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
2001-02-28 09:05:22 +08:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-02-28 09:05:22 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpBucketFillToolClass),
|
2001-08-14 22:53:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_bucket_fill_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpBucketFillTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_bucket_fill_tool_init,
|
2001-02-28 09:05:22 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_TOOL,
|
2003-08-22 09:42:57 +08:00
|
|
|
"GimpBucketFillTool",
|
2001-08-14 22:53:55 +08:00
|
|
|
&tool_info, 0);
|
2001-02-28 09:05:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-02-28 09:05:22 +08:00
|
|
|
static void
|
|
|
|
gimp_bucket_fill_tool_class_init (GimpBucketFillToolClass *klass)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
GimpToolClass *tool_class;
|
2001-02-28 09:05:22 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
2001-02-28 09:05:22 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-02-28 09:05:22 +08:00
|
|
|
|
|
|
|
tool_class->button_press = gimp_bucket_fill_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_bucket_fill_tool_button_release;
|
|
|
|
tool_class->modifier_key = gimp_bucket_fill_tool_modifier_key;
|
|
|
|
tool_class->cursor_update = gimp_bucket_fill_tool_cursor_update;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_bucket_fill_tool_init (GimpBucketFillTool *bucket_fill_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (bucket_fill_tool);
|
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
2002-11-19 04:50:31 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_BUCKET_FILL_TOOL_CURSOR);
|
2001-02-28 09:05:22 +08:00
|
|
|
}
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_bucket_fill_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpBucketFillTool *bucket_tool;
|
|
|
|
GimpBucketFillOptions *options;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 09:05:22 +08:00
|
|
|
bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
|
2001-11-20 21:53:21 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
bucket_tool->target_x = coords->x;
|
|
|
|
bucket_tool->target_y = coords->y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (! options->sample_merged)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
gint off_x, off_y;
|
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (gimp_image_active_drawable (gdisp->gimage)),
|
|
|
|
&off_x, &off_y);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
|
|
|
bucket_tool->target_x -= off_x;
|
|
|
|
bucket_tool->target_y -= off_y;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
tool->gdisp = gdisp;
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_activate (tool->control);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_bucket_fill_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpBucketFillTool *bucket_tool;
|
|
|
|
GimpBucketFillOptions *options;
|
2003-02-06 00:59:04 +08:00
|
|
|
GimpContext *context;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 09:05:22 +08:00
|
|
|
bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
|
2003-02-06 00:59:04 +08:00
|
|
|
context = GIMP_CONTEXT (options);
|
2001-11-20 21:53:21 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* if the 3rd button isn't pressed, fill the selected region */
|
2001-11-09 03:14:51 +08:00
|
|
|
if (! (state & GDK_BUTTON3_MASK))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-10 23:18:08 +08:00
|
|
|
gimp_drawable_bucket_fill (gimp_image_active_drawable (gdisp->gimage),
|
2004-04-15 07:37:34 +08:00
|
|
|
context,
|
2002-02-10 23:18:08 +08:00
|
|
|
options->fill_mode,
|
|
|
|
gimp_context_get_paint_mode (context),
|
|
|
|
gimp_context_get_opacity (context),
|
2004-01-27 23:26:11 +08:00
|
|
|
! options->fill_selection,
|
2002-02-10 23:18:08 +08:00
|
|
|
options->fill_transparent,
|
|
|
|
options->threshold,
|
|
|
|
options->sample_merged,
|
|
|
|
bucket_tool->target_x,
|
|
|
|
bucket_tool->target_y);
|
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gdisp->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-01-03 21:59:23 +08:00
|
|
|
gimp_tool_control_halt (tool->control);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpBucketFillOptions *options;
|
2001-11-20 21:53:21 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
|
2001-11-20 21:53:21 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (key == GDK_CONTROL_MASK)
|
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
switch (options->fill_mode)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_FG_BUCKET_FILL:
|
2003-02-28 09:14:30 +08:00
|
|
|
g_object_set (options, "fill-mode", GIMP_BG_BUCKET_FILL, NULL);
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
2003-02-08 01:12:21 +08:00
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_BG_BUCKET_FILL:
|
2003-02-28 09:14:30 +08:00
|
|
|
g_object_set (options, "fill-mode", GIMP_FG_BUCKET_FILL, NULL);
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
2003-02-08 01:12:21 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-01-27 23:26:11 +08:00
|
|
|
else if (key == GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
g_object_set (options, "fill-selection", ! options->fill_selection, NULL);
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpBucketFillOptions *options;
|
|
|
|
GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
|
2001-11-20 21:53:21 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
if (gimp_display_coords_in_active_drawable (gdisp, coords))
|
1998-01-22 15:02:57 +08:00
|
|
|
{
|
2003-09-03 22:22:38 +08:00
|
|
|
GimpChannel *selection = gimp_image_get_mask (gdisp->gimage);
|
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
/* One more test--is there a selected region?
|
|
|
|
* if so, is cursor inside?
|
|
|
|
*/
|
2003-09-03 22:22:38 +08:00
|
|
|
if (gimp_channel_is_empty (selection) ||
|
|
|
|
gimp_channel_value (selection, coords->x, coords->y))
|
2003-05-08 22:06:03 +08:00
|
|
|
{
|
|
|
|
switch (options->fill_mode)
|
|
|
|
{
|
|
|
|
case GIMP_FG_BUCKET_FILL:
|
|
|
|
cmodifier = GIMP_CURSOR_MODIFIER_FOREGROUND;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_BG_BUCKET_FILL:
|
|
|
|
cmodifier = GIMP_CURSOR_MODIFIER_BACKGROUND;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PATTERN_BUCKET_FILL:
|
|
|
|
cmodifier = GIMP_CURSOR_MODIFIER_PATTERN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-01-22 15:02:57 +08:00
|
|
|
}
|
2000-07-30 00:12:40 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control, cmodifier);
|
2002-02-05 01:43:01 +08:00
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|