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"
|
1999-10-26 18:27:27 +00:00
|
|
|
|
2000-12-16 21:37:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 12:41:00 +00:00
|
|
|
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-03-29 03:50:29 +00:00
|
|
|
#include "core/core-types.h"
|
|
|
|
#include "libgimptool/gimptooltypes.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
#include "paint/gimperaser.h"
|
|
|
|
|
2001-03-12 04:40:17 +00:00
|
|
|
#include "gimperasertool.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "paint_options.h"
|
1997-11-24 22:05:25 +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"
|
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
|
2001-12-01 22:59:48 +00:00
|
|
|
static void gimp_eraser_tool_class_init (GimpEraserToolClass *klass);
|
|
|
|
static void gimp_eraser_tool_init (GimpEraserTool *eraser);
|
|
|
|
|
|
|
|
static void gimp_eraser_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_eraser_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
static GimpToolOptions * gimp_eraser_tool_options_new (GimpToolInfo *tool_info);
|
|
|
|
static void gimp_eraser_tool_options_reset (GimpToolOptions *tool_options);
|
2000-12-31 04:07:42 +00:00
|
|
|
|
|
|
|
|
2001-03-12 04:40:17 +00:00
|
|
|
static GimpPaintToolClass *parent_class = NULL;
|
1999-04-08 22:25:54 +00:00
|
|
|
|
|
|
|
|
2001-03-12 04:40:17 +00:00
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_eraser_tool_register (GimpToolRegisterCallback callback,
|
|
|
|
Gimp *gimp)
|
1999-04-08 22:25:54 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_ERASER_TOOL,
|
2001-11-20 23:00:47 +00:00
|
|
|
gimp_eraser_tool_options_new,
|
|
|
|
TRUE,
|
2002-03-21 12:17:17 +00:00
|
|
|
"gimp-eraser-tool",
|
2001-11-20 23:00:47 +00:00
|
|
|
_("Eraser"),
|
2002-03-17 22:54:26 +00:00
|
|
|
_("Erase to background or transparency"),
|
2001-11-20 23:00:47 +00:00
|
|
|
N_("/Tools/Paint Tools/Eraser"), "<shift>E",
|
|
|
|
NULL, "tools/eraser.html",
|
2002-03-29 03:50:29 +00:00
|
|
|
GIMP_STOCK_TOOL_ERASER,
|
|
|
|
gimp);
|
2001-03-12 04:40:17 +00:00
|
|
|
}
|
1999-04-08 22:25:54 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
GType
|
2001-03-12 04:40:17 +00:00
|
|
|
gimp_eraser_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static GType tool_type = 0;
|
1999-04-22 14:34:00 +00:00
|
|
|
|
2001-03-12 04:40:17 +00:00
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static const GTypeInfo tool_info =
|
2001-03-12 04:40:17 +00:00
|
|
|
{
|
|
|
|
sizeof (GimpEraserToolClass),
|
2001-08-14 14:53:55 +00:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_eraser_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpEraserTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_eraser_tool_init,
|
2001-03-12 04:40:17 +00:00
|
|
|
};
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL,
|
|
|
|
"GimpEraserTool",
|
|
|
|
&tool_info, 0);
|
2001-03-12 04:40:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
1999-04-08 22:25:54 +00:00
|
|
|
}
|
2001-03-12 04:40:17 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_eraser_tool_class_init (GimpEraserToolClass *klass)
|
1998-03-01 01:18:45 +00:00
|
|
|
{
|
2002-02-14 19:31:16 +00:00
|
|
|
GimpToolClass *tool_class;
|
1998-03-01 01:18:45 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
1999-04-12 17:55:06 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1998-03-01 01:18:45 +00:00
|
|
|
|
2001-12-01 22:59:48 +00:00
|
|
|
tool_class->modifier_key = gimp_eraser_tool_modifier_key;
|
|
|
|
tool_class->cursor_update = gimp_eraser_tool_cursor_update;
|
2001-03-12 04:40:17 +00:00
|
|
|
}
|
1999-08-19 19:53:30 +00:00
|
|
|
|
2001-03-12 04:40:17 +00:00
|
|
|
static void
|
|
|
|
gimp_eraser_tool_init (GimpEraserTool *eraser)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpPaintTool *paint_tool;
|
1999-08-13 20:50:30 +00:00
|
|
|
|
2001-03-12 04:40:17 +00:00
|
|
|
tool = GIMP_TOOL (eraser);
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (eraser);
|
|
|
|
|
2002-03-29 03:50:29 +00:00
|
|
|
tool->control = gimp_tool_control_new (FALSE, /* scroll_lock */
|
|
|
|
TRUE, /* auto_snap_to */
|
|
|
|
TRUE, /* preserve */
|
|
|
|
FALSE, /* handle_empty_image */
|
2002-04-21 07:31:12 +00:00
|
|
|
GIMP_MOTION_MODE_EXACT, /* motion_mode */
|
2002-03-29 03:50:29 +00:00
|
|
|
GIMP_MOUSE_CURSOR, /* cursor */
|
|
|
|
GIMP_ERASER_TOOL_CURSOR, /* tool_cursor */
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE, /* cursor_modifier */
|
|
|
|
GIMP_MOUSE_CURSOR, /* toggle_cursor */
|
|
|
|
GIMP_ERASER_TOOL_CURSOR, /* toggle_tool_cursor */
|
|
|
|
GIMP_CURSOR_MODIFIER_MINUS /* toggle_cursor_modifier */);
|
2001-03-12 04:40:17 +00:00
|
|
|
|
2002-02-14 19:31:16 +00:00
|
|
|
paint_tool->core = g_object_new (GIMP_TYPE_ERASER, NULL);
|
1998-03-01 01:18:45 +00:00
|
|
|
}
|
1999-08-13 20:50:30 +00:00
|
|
|
|
|
|
|
static void
|
2001-11-08 19:14:51 +00:00
|
|
|
gimp_eraser_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1999-08-13 20:50:30 +00:00
|
|
|
{
|
2002-02-21 16:02:30 +00:00
|
|
|
GimpEraserOptions *options;
|
2001-11-20 23:00:47 +00:00
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
options = (GimpEraserOptions *) tool->tool_info->tool_options;
|
2001-11-20 23:00:47 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
if ((key == GDK_CONTROL_MASK) &&
|
|
|
|
! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
|
1999-08-13 20:50:30 +00:00
|
|
|
{
|
2001-11-29 16:44:51 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
|
|
|
|
! options->anti_erase);
|
1999-08-13 20:50:30 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-12 04:40:17 +00:00
|
|
|
|
2001-12-01 22:59:48 +00:00
|
|
|
static void
|
|
|
|
gimp_eraser_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
2002-02-21 16:02:30 +00:00
|
|
|
GimpEraserOptions *options;
|
2001-12-01 22:59:48 +00:00
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
options = (GimpEraserOptions *) tool->tool_info->tool_options;
|
2001-12-01 22:59:48 +00:00
|
|
|
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_tool_control_set_toggle(tool->control, options->anti_erase);
|
2001-12-01 22:59:48 +00:00
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
|
|
|
}
|
|
|
|
|
1999-08-13 20:50:30 +00:00
|
|
|
|
2001-03-12 04:40:17 +00:00
|
|
|
/* tool options stuff */
|
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
static GimpToolOptions *
|
|
|
|
gimp_eraser_tool_options_new (GimpToolInfo *tool_info)
|
2001-03-12 04:40:17 +00:00
|
|
|
{
|
2002-02-21 16:02:30 +00:00
|
|
|
GimpEraserOptions *options;
|
|
|
|
GtkWidget *vbox;
|
2001-03-12 04:40:17 +00:00
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
options = gimp_eraser_options_new ();
|
2001-11-20 23:00:47 +00:00
|
|
|
|
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 = gimp_eraser_tool_options_reset;
|
2001-03-12 04:40:17 +00:00
|
|
|
|
|
|
|
/* the main vbox */
|
2001-07-17 20:50:01 +00:00
|
|
|
vbox = ((GimpToolOptions *) options)->main_vbox;
|
2001-03-12 04:40:17 +00:00
|
|
|
|
|
|
|
/* the anti_erase toggle */
|
2001-11-26 13:17:18 +00:00
|
|
|
options->anti_erase_w =
|
|
|
|
gtk_check_button_new_with_label (_("Anti Erase (<Ctrl>)"));
|
2002-03-10 15:05:58 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
|
2002-04-28 14:35:01 +00:00
|
|
|
options->anti_erase);
|
2001-03-12 04:40:17 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0);
|
2002-03-10 15:05:58 +00:00
|
|
|
gtk_widget_show (options->anti_erase_w);
|
|
|
|
|
2001-08-01 02:57:58 +00:00
|
|
|
g_signal_connect (G_OBJECT (options->anti_erase_w), "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->anti_erase);
|
2002-03-10 15:05:58 +00:00
|
|
|
|
|
|
|
/* the hard toggle */
|
|
|
|
options->hard_w = gtk_check_button_new_with_label (_("Hard Edge"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
|
2002-04-28 14:35:01 +00:00
|
|
|
options->hard);
|
2002-03-10 15:05:58 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), options->hard_w, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (options->hard_w);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (options->hard_w), "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->hard);
|
2001-03-12 04:40:17 +00:00
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
return (GimpToolOptions *) options;
|
2001-03-12 04:40:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-17 20:50:01 +00:00
|
|
|
gimp_eraser_tool_options_reset (GimpToolOptions *tool_options)
|
2001-03-12 04:40:17 +00:00
|
|
|
{
|
2002-02-21 16:02:30 +00:00
|
|
|
GimpEraserOptions *options;
|
2001-03-31 20:41:39 +00:00
|
|
|
|
2002-02-21 16:02:30 +00:00
|
|
|
options = (GimpEraserOptions *) tool_options;
|
2001-03-12 04:40:17 +00:00
|
|
|
|
2001-03-31 20:41:39 +00:00
|
|
|
paint_options_reset (tool_options);
|
2001-03-12 04:40:17 +00:00
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
|
|
|
|
options->anti_erase_d);
|
2002-03-10 15:05:58 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
|
|
|
|
options->hard_d);
|
2001-10-30 22:59:06 +00:00
|
|
|
}
|