2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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"
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2012-03-29 03:37:59 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
|
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
|
|
|
|
2018-05-08 05:12:10 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "paint/gimperaseroptions.h"
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-12-20 00:33:29 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
#include "gimperasertool.h"
|
2003-06-30 04:40:45 +08:00
|
|
|
#include "gimppaintoptions-gui.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
1997-11-25 06:05:25 +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
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-08 04:40:27 +08:00
|
|
|
static void gimp_eraser_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_eraser_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-08 04:40:27 +08:00
|
|
|
static gboolean gimp_eraser_tool_is_alpha_only (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable);
|
|
|
|
|
|
|
|
static GtkWidget * gimp_eraser_options_gui (GimpToolOptions *tool_options);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2006-08-16 05:46:22 +08:00
|
|
|
G_DEFINE_TYPE (GimpEraserTool, gimp_eraser_tool, GIMP_TYPE_BRUSH_TOOL)
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_eraser_tool_parent_class
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_eraser_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_ERASER_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_ERASER_OPTIONS,
|
|
|
|
gimp_eraser_options_gui,
|
2003-06-30 04:40:45 +08:00
|
|
|
GIMP_PAINT_OPTIONS_CONTEXT_MASK,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-eraser-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Eraser"),
|
2006-09-19 02:00:22 +08:00
|
|
|
_("Eraser Tool: Erase to background or transparency using a brush"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("_Eraser"), "<shift>E",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_ERASER,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_ERASER,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void
|
|
|
|
gimp_eraser_tool_class_init (GimpEraserToolClass *klass)
|
1998-03-01 09:18:45 +08:00
|
|
|
{
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-08 04:40:27 +08:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpPaintToolClass *paint_tool_class = GIMP_PAINT_TOOL_CLASS (klass);
|
|
|
|
|
|
|
|
tool_class->modifier_key = gimp_eraser_tool_modifier_key;
|
|
|
|
tool_class->cursor_update = gimp_eraser_tool_cursor_update;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-08 04:40:27 +08:00
|
|
|
paint_tool_class->is_alpha_only = gimp_eraser_tool_is_alpha_only;
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
1999-08-20 03:53:30 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void
|
|
|
|
gimp_eraser_tool_init (GimpEraserTool *eraser)
|
|
|
|
{
|
2006-08-02 07:42:12 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (eraser);
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (eraser);
|
2001-03-12 12:40:17 +08:00
|
|
|
|
2002-06-17 01:13:39 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
2004-06-05 07:08:29 +08:00
|
|
|
GIMP_TOOL_CURSOR_ERASER);
|
2002-06-17 01:13:39 +08:00
|
|
|
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
|
|
|
|
GIMP_CURSOR_MODIFIER_MINUS);
|
2003-10-26 03:00:49 +08:00
|
|
|
|
2006-08-02 07:42:12 +08:00
|
|
|
gimp_paint_tool_enable_color_picker (paint_tool,
|
2018-07-15 20:32:53 +08:00
|
|
|
GIMP_COLOR_PICK_TARGET_BACKGROUND);
|
2006-08-02 07:42:12 +08:00
|
|
|
|
2006-09-12 14:37:54 +08:00
|
|
|
paint_tool->status = _("Click to erase");
|
|
|
|
paint_tool->status_line = _("Click to erase the line");
|
2006-08-02 07:42:12 +08:00
|
|
|
paint_tool->status_ctrl = _("%s to pick a background color");
|
1998-03-01 09:18:45 +08:00
|
|
|
}
|
1999-08-14 04:50:30 +08:00
|
|
|
|
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_eraser_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2003-10-19 01:27:11 +08:00
|
|
|
if (key == GDK_MOD1_MASK)
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpEraserOptions *options = GIMP_ERASER_TOOL_GET_OPTIONS (tool);
|
2003-06-05 23:43:49 +08:00
|
|
|
|
2003-02-28 09:14:30 +08:00
|
|
|
g_object_set (options,
|
2003-02-08 01:12:21 +08:00
|
|
|
"anti-erase", ! options->anti_erase,
|
|
|
|
NULL);
|
1999-08-14 04:50:30 +08:00
|
|
|
}
|
2003-06-05 23:43:49 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state, display);
|
1999-08-14 04:50:30 +08:00
|
|
|
}
|
2003-07-15 23:38:24 +08:00
|
|
|
|
2001-12-02 06:59:48 +08:00
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_eraser_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
2001-12-02 06:59:48 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpEraserOptions *options = GIMP_ERASER_TOOL_GET_OPTIONS (tool);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
2005-11-24 03:14:05 +08:00
|
|
|
gimp_tool_control_set_toggled (tool->control, options->anti_erase);
|
2001-12-02 06:59:48 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
2001-12-02 06:59:48 +08:00
|
|
|
}
|
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-08 04:40:27 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_eraser_tool_is_alpha_only (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
2018-05-08 22:47:31 +08:00
|
|
|
GimpEraserOptions *options = GIMP_ERASER_TOOL_GET_OPTIONS (paint_tool);
|
|
|
|
|
|
|
|
if (! options->anti_erase)
|
|
|
|
return gimp_drawable_has_alpha (drawable);
|
|
|
|
else
|
|
|
|
return TRUE;
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-08 04:40:27 +08:00
|
|
|
}
|
|
|
|
|
1999-08-14 04:50:30 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
/* tool options stuff */
|
|
|
|
|
2003-02-10 01:32:52 +08:00
|
|
|
static GtkWidget *
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_eraser_options_gui (GimpToolOptions *tool_options)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2006-08-16 05:46:22 +08:00
|
|
|
GObject *config = G_OBJECT (tool_options);
|
2006-08-28 06:19:35 +08:00
|
|
|
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
|
2003-02-08 01:12:21 +08:00
|
|
|
GtkWidget *button;
|
|
|
|
gchar *str;
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
/* the anti_erase toggle */
|
2005-09-14 06:17:05 +08:00
|
|
|
str = g_strdup_printf (_("Anti erase (%s)"),
|
2004-06-29 07:30:57 +08:00
|
|
|
gimp_get_mod_string (GDK_MOD1_MASK));
|
2002-12-20 00:33:29 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
button = gimp_prop_check_button_new (config, "anti-erase", str);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2002-12-20 00:33:29 +08:00
|
|
|
g_free (str);
|
|
|
|
|
2003-02-10 01:32:52 +08:00
|
|
|
return vbox;
|
2001-10-31 06:59:06 +08:00
|
|
|
}
|