1997-11-24 22:05:25 +00: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 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
#include "config.h"
|
2000-01-14 12:41:00 +00:00
|
|
|
|
2000-12-16 21:37:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 12:41:00 +00:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-03 12:45:22 +00:00
|
|
|
#include "tools-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2002-11-18 20:50:31 +00:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdrawable.h"
|
2001-11-08 19:14:51 +00:00
|
|
|
#include "core/gimpdrawable-bucket-fill.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimpimage-mask.h"
|
2001-11-20 13:53:21 +00:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
#include "paint/gimppaintoptions.h"
|
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2002-03-18 22:26:41 +00:00
|
|
|
#include "widgets/gimpenummenu.h"
|
2002-12-19 16:33:29 +00:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-03-18 22:26:41 +00:00
|
|
|
|
2001-03-08 01:07:03 +00:00
|
|
|
#include "gimpbucketfilltool.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "paint_options.h"
|
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-10 19:16:16 +00:00
|
|
|
#include "undo.h"
|
2001-01-21 21:58:16 +00:00
|
|
|
|
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-14 23:23:52 +00:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
typedef struct _BucketOptions BucketOptions;
|
2000-12-29 15:22:01 +00:00
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
struct _BucketOptions
|
|
|
|
{
|
2002-03-18 11:07:34 +00:00
|
|
|
GimpPaintOptions paint_options;
|
1999-04-08 22:25:54 +00:00
|
|
|
|
2002-03-18 11:07:34 +00:00
|
|
|
gboolean fill_transparent;
|
|
|
|
gboolean fill_transparent_d;
|
|
|
|
GtkWidget *fill_transparent_w;
|
2002-02-10 15:18:08 +00:00
|
|
|
|
2002-03-18 11:07:34 +00:00
|
|
|
gboolean sample_merged;
|
|
|
|
gboolean sample_merged_d;
|
|
|
|
GtkWidget *sample_merged_w;
|
1999-04-17 23:18:43 +00:00
|
|
|
|
2002-03-18 11:07:34 +00:00
|
|
|
gdouble threshold;
|
|
|
|
GtkObject *threshold_w;
|
2000-04-20 15:57:13 +00:00
|
|
|
|
2002-03-18 11:07:34 +00:00
|
|
|
GimpBucketFillMode fill_mode;
|
|
|
|
GimpBucketFillMode fill_mode_d;
|
2002-03-18 22:26:41 +00:00
|
|
|
GtkWidget *fill_mode_w;
|
1999-04-08 22:25:54 +00:00
|
|
|
};
|
|
|
|
|
1999-04-12 17:55:06 +00:00
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
static GimpToolClass *parent_class = NULL;
|
2001-02-28 01:05:22 +00:00
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* local function prototypes */
|
1999-06-21 22:12:07 +00:00
|
|
|
|
2001-02-28 01:05:22 +00:00
|
|
|
static void gimp_bucket_fill_tool_class_init (GimpBucketFillToolClass *klass);
|
|
|
|
static void gimp_bucket_fill_tool_init (GimpBucketFillTool *bucket_fill_tool);
|
|
|
|
|
2001-07-17 20:50:01 +00:00
|
|
|
static void gimp_bucket_fill_tool_button_press (GimpTool *tool,
|
2001-11-08 19:14:51 +00:00
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2001-10-22 12:13:44 +00:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-17 20:50:01 +00:00
|
|
|
static void gimp_bucket_fill_tool_button_release (GimpTool *tool,
|
2001-11-08 19:14:51 +00:00
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2001-10-22 12:13:44 +00:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-17 20:50:01 +00:00
|
|
|
static void gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
|
2001-11-08 19:14:51 +00: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 12:13:44 +00:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-17 20:50:01 +00:00
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
static GimpToolOptions * bucket_options_new (GimpToolInfo *tool_info);
|
|
|
|
static void bucket_options_reset (GimpToolOptions *tool_options);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
/* public functions */
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-02-28 01:05:22 +00:00
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_bucket_fill_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 11:31:08 +00:00
|
|
|
gpointer data)
|
2001-02-28 01:05:22 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_BUCKET_FILL_TOOL,
|
2001-11-20 23:00:47 +00:00
|
|
|
bucket_options_new,
|
|
|
|
TRUE,
|
2002-03-21 12:17:17 +00:00
|
|
|
"gimp-bucket-fill-tool",
|
2001-11-20 23:00:47 +00:00
|
|
|
_("Bucket Fill"),
|
|
|
|
_("Fill with a color or pattern"),
|
|
|
|
N_("/Tools/Paint Tools/Bucket Fill"), "<shift>B",
|
|
|
|
NULL, "tools/bucket_fill.html",
|
2002-03-29 03:50:29 +00:00
|
|
|
GIMP_STOCK_TOOL_BUCKET_FILL,
|
2002-05-03 11:31:08 +00:00
|
|
|
data);
|
2001-02-28 01:05:22 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
GType
|
2001-02-28 01:05:22 +00:00
|
|
|
gimp_bucket_fill_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static GType tool_type = 0;
|
2001-02-28 01:05:22 +00:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static const GTypeInfo tool_info =
|
2001-02-28 01:05:22 +00:00
|
|
|
{
|
|
|
|
sizeof (GimpBucketFillToolClass),
|
2001-08-14 14:53:55 +00: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 01:05:22 +00:00
|
|
|
};
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_TOOL,
|
|
|
|
"GimpBucketFillTool",
|
|
|
|
&tool_info, 0);
|
2001-02-28 01:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-02-28 01:05:22 +00:00
|
|
|
static void
|
|
|
|
gimp_bucket_fill_tool_class_init (GimpBucketFillToolClass *klass)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
GimpToolClass *tool_class;
|
2001-02-28 01:05:22 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
2001-02-28 01:05:22 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-02-28 01:05:22 +00: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 11:31:08 +00:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
2002-11-18 20:50:31 +00:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_BUCKET_FILL_TOOL_CURSOR);
|
2001-02-28 01:05:22 +00:00
|
|
|
}
|
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
gimp_bucket_fill_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-02-28 01:05:22 +00:00
|
|
|
GimpBucketFillTool *bucket_tool;
|
2001-11-20 13:53:21 +00:00
|
|
|
BucketOptions *options;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-02-28 01:05:22 +00:00
|
|
|
bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-20 13:53:21 +00:00
|
|
|
options = (BucketOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
bucket_tool->target_x = coords->x;
|
|
|
|
bucket_tool->target_y = coords->y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-20 13:53:21 +00:00
|
|
|
if (! options->sample_merged)
|
2001-11-08 19:14:51 +00:00
|
|
|
{
|
|
|
|
gint off_x, off_y;
|
|
|
|
|
|
|
|
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
|
|
|
|
&off_x, &off_y);
|
|
|
|
|
|
|
|
bucket_tool->target_x -= off_x;
|
|
|
|
bucket_tool->target_y -= off_y;
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2000-12-31 04:07:42 +00:00
|
|
|
tool->gdisp = gdisp;
|
2002-05-03 11:31:08 +00:00
|
|
|
gimp_tool_control_activate (tool->control);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
1998-03-18 22:35:31 +00:00
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
gimp_bucket_fill_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-02-28 01:05:22 +00:00
|
|
|
GimpBucketFillTool *bucket_tool;
|
2001-11-20 13:53:21 +00:00
|
|
|
BucketOptions *options;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-02-28 01:05:22 +00:00
|
|
|
bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-20 13:53:21 +00:00
|
|
|
options = (BucketOptions *) tool->tool_info->tool_options;
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* if the 3rd button isn't pressed, fill the selected region */
|
2001-11-08 19:14:51 +00:00
|
|
|
if (! (state & GDK_BUTTON3_MASK))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-07-07 12:17:23 +00:00
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = gimp_get_current_context (gdisp->gimage->gimp);
|
|
|
|
|
2002-02-10 15:18:08 +00:00
|
|
|
gimp_drawable_bucket_fill (gimp_image_active_drawable (gdisp->gimage),
|
|
|
|
options->fill_mode,
|
|
|
|
gimp_context_get_paint_mode (context),
|
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
options->fill_transparent,
|
|
|
|
options->threshold,
|
|
|
|
options->sample_merged,
|
|
|
|
bucket_tool->target_x,
|
|
|
|
bucket_tool->target_y);
|
|
|
|
|
2002-05-08 17:48:24 +00:00
|
|
|
gimp_image_flush (gdisp->gimage);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-03 13:59:23 +00:00
|
|
|
gimp_tool_control_halt (tool->control);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
2001-11-20 13:53:21 +00:00
|
|
|
BucketOptions *options;
|
|
|
|
|
|
|
|
options = (BucketOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
if (key == GDK_CONTROL_MASK)
|
|
|
|
{
|
2001-11-20 13:53:21 +00:00
|
|
|
switch (options->fill_mode)
|
2001-11-08 19:14:51 +00:00
|
|
|
{
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_FG_BUCKET_FILL:
|
2002-03-18 22:26:41 +00:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w),
|
|
|
|
GINT_TO_POINTER (GIMP_BG_BUCKET_FILL));
|
2001-11-08 19:14:51 +00:00
|
|
|
break;
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_BG_BUCKET_FILL:
|
2002-03-18 22:26:41 +00:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w),
|
|
|
|
GINT_TO_POINTER (GIMP_FG_BUCKET_FILL));
|
2001-11-08 19:14:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-20 13:53:21 +00:00
|
|
|
BucketOptions *options;
|
2001-02-24 19:29:47 +00:00
|
|
|
GimpLayer *layer;
|
|
|
|
GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE;
|
|
|
|
gint off_x, off_y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-20 13:53:21 +00:00
|
|
|
options = (BucketOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
if ((layer = gimp_image_get_active_layer (gdisp->gimage)))
|
1998-01-22 07:02:57 +00:00
|
|
|
{
|
2001-01-14 21:11:52 +00:00
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
|
2000-07-29 16:12:40 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
if (coords->x >= off_x &&
|
|
|
|
coords->y >= off_y &&
|
|
|
|
coords->x < (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer))) &&
|
|
|
|
coords->y < (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer))))
|
1998-01-22 07:02:57 +00:00
|
|
|
{
|
|
|
|
/* One more test--is there a selected region?
|
|
|
|
* if so, is cursor inside?
|
|
|
|
*/
|
2001-11-28 22:42:19 +00:00
|
|
|
if (gimp_image_mask_is_empty (gdisp->gimage) ||
|
|
|
|
gimp_image_mask_value (gdisp->gimage, coords->x, coords->y))
|
2000-07-29 16:12:40 +00:00
|
|
|
{
|
2001-11-20 13:53:21 +00:00
|
|
|
switch (options->fill_mode)
|
2000-07-29 16:12:40 +00:00
|
|
|
{
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_FG_BUCKET_FILL:
|
2001-02-24 19:29:47 +00:00
|
|
|
cmodifier = GIMP_CURSOR_MODIFIER_FOREGROUND;
|
2000-07-29 16:12:40 +00:00
|
|
|
break;
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_BG_BUCKET_FILL:
|
2001-02-24 19:29:47 +00:00
|
|
|
cmodifier = GIMP_CURSOR_MODIFIER_BACKGROUND;
|
2000-07-29 16:12:40 +00:00
|
|
|
break;
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_PATTERN_BUCKET_FILL:
|
2001-02-24 19:29:47 +00:00
|
|
|
cmodifier = GIMP_CURSOR_MODIFIER_PATTERN;
|
2000-07-29 16:12:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-01-22 07:02:57 +00:00
|
|
|
}
|
|
|
|
}
|
2000-07-29 16:12:40 +00:00
|
|
|
|
2002-05-03 11:31:08 +00:00
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control, cmodifier);
|
2002-02-04 17:43:01 +00:00
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
static GimpToolOptions *
|
|
|
|
bucket_options_new (GimpToolInfo *tool_info)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-08 19:14:51 +00:00
|
|
|
BucketOptions *options;
|
2002-12-19 16:33:29 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *vbox2;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *frame;
|
|
|
|
gchar *str;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
options = g_new0 (BucketOptions, 1);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-11-27 22:55:03 +00:00
|
|
|
gimp_paint_options_init ((GimpPaintOptions *) options, tool_info->context);
|
2002-02-21 16:02:30 +00:00
|
|
|
|
|
|
|
paint_options_init ((GimpPaintOptions *) options, tool_info);
|
2001-11-20 23:00:47 +00:00
|
|
|
|
|
|
|
((GimpToolOptions *) options)->reset_func = bucket_options_reset;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-02-10 15:18:08 +00:00
|
|
|
options->fill_transparent = options->fill_transparent_d = TRUE;
|
2002-02-11 16:22:26 +00:00
|
|
|
options->sample_merged = options->sample_merged_d = FALSE;
|
2002-11-18 20:50:31 +00:00
|
|
|
options->threshold =
|
|
|
|
GIMP_GUI_CONFIG (tool_info->gimp->config)->default_threshold;
|
2002-03-18 11:07:34 +00:00
|
|
|
options->fill_mode = options->fill_mode_d = GIMP_FG_BUCKET_FILL;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
/* the main vbox */
|
|
|
|
vbox = ((GimpToolOptions *) options)->main_vbox;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-12-19 16:33:29 +00:00
|
|
|
str = g_strdup_printf (_("Fill Type %s"), gimp_get_mod_name_control ());
|
|
|
|
|
2002-03-10 15:05:58 +00:00
|
|
|
/* fill type */
|
2002-03-18 22:26:41 +00:00
|
|
|
frame = gimp_enum_radio_frame_new (GIMP_TYPE_BUCKET_FILL_MODE,
|
2002-12-19 16:33:29 +00:00
|
|
|
gtk_label_new (str),
|
2002-03-18 22:26:41 +00:00
|
|
|
2,
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&options->fill_mode,
|
|
|
|
&options->fill_mode_w);
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w),
|
|
|
|
GINT_TO_POINTER (options->fill_mode));
|
2002-03-10 15:05:58 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-12-19 16:33:29 +00:00
|
|
|
g_free (str);
|
|
|
|
|
2002-02-10 15:18:08 +00:00
|
|
|
frame = gtk_frame_new (_("Finding Similar Colors"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
vbox2 = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox2);
|
|
|
|
gtk_widget_show (vbox2);
|
|
|
|
|
|
|
|
/* the fill transparent areas toggle */
|
|
|
|
options->fill_transparent_w =
|
|
|
|
gtk_check_button_new_with_label (_("Fill Transparent Areas"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->fill_transparent_w),
|
2002-04-28 14:35:01 +00:00
|
|
|
options->fill_transparent);
|
2002-02-10 15:18:08 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), options->fill_transparent_w,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (options->fill_transparent_w);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (options->fill_transparent_w,
|
|
|
|
_("Allow completely transparent regions "
|
|
|
|
"to be filled"), NULL);
|
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_connect (options->fill_transparent_w, "toggled",
|
2002-02-10 15:18:08 +00:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->fill_transparent);
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
/* the sample merged toggle */
|
|
|
|
options->sample_merged_w =
|
|
|
|
gtk_check_button_new_with_label (_("Sample Merged"));
|
2002-02-10 15:18:08 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), options->sample_merged_w,
|
|
|
|
FALSE, FALSE, 0);
|
2001-11-08 19:14:51 +00:00
|
|
|
gtk_widget_show (options->sample_merged_w);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-02-11 16:22:26 +00:00
|
|
|
gimp_help_set_help_data (options->sample_merged_w,
|
|
|
|
_("Base filled area on all visible layers"), NULL);
|
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_connect (options->sample_merged_w, "toggled",
|
2002-02-11 16:22:26 +00:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->sample_merged);
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
/* the threshold scale */
|
2002-03-08 18:30:40 +00:00
|
|
|
table = gtk_table_new (1, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
options->threshold_w = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
|
2002-09-06 20:44:47 +00:00
|
|
|
_("Threshold:"), -1, -1,
|
2002-11-18 20:50:31 +00:00
|
|
|
options->threshold,
|
2002-03-08 18:30:40 +00:00
|
|
|
0.0, 255.0, 1.0, 16.0, 1,
|
|
|
|
TRUE, 0.0, 0.0,
|
|
|
|
_("Maximum color difference"),
|
|
|
|
NULL);
|
2002-02-11 16:22:26 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_connect (options->threshold_w, "value_changed",
|
2001-11-08 19:14:51 +00:00
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&options->threshold);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-09 16:54:56 +00:00
|
|
|
bucket_options_reset ((GimpToolOptions *) options);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
return (GimpToolOptions *) options;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
bucket_options_reset (GimpToolOptions *tool_options)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-08 19:14:51 +00:00
|
|
|
BucketOptions *options;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
options = (BucketOptions *) tool_options;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
paint_options_reset (tool_options);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-02-11 16:22:26 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->fill_transparent_w),
|
|
|
|
options->fill_transparent_d);
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_merged_w),
|
|
|
|
options->sample_merged_d);
|
2001-11-22 13:01:26 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->threshold_w),
|
2002-11-18 20:50:31 +00:00
|
|
|
GIMP_GUI_CONFIG (tool_options->tool_info->gimp->config)->default_threshold);
|
2001-11-22 13:01:26 +00:00
|
|
|
|
2002-03-18 22:26:41 +00:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->fill_mode_w),
|
2001-11-22 13:01:26 +00:00
|
|
|
GINT_TO_POINTER (options->fill_mode_d));
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|