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
|
|
|
|
2013-10-15 07:58:39 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2012-04-01 00:33:04 +08:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
2001-04-07 23:58:26 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2015-09-29 19:43:15 +08:00
|
|
|
#include "core/gimp-palettes.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
2009-10-11 21:41:54 +08:00
|
|
|
#include "core/gimpdynamics.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2016-05-29 23:49:37 +08:00
|
|
|
#include "core/gimppickable.h"
|
2016-01-28 02:13:17 +08:00
|
|
|
#include "core/gimpsymmetry.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "gimperaser.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimperaseroptions.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2003-02-14 22:14:29 +08: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-15 07:23:52 +08:00
|
|
|
|
2019-05-29 16:25:38 +08:00
|
|
|
static gboolean gimp_eraser_get_color_history_color (GimpPaintbrush *paintbrush,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpRGB *color);
|
|
|
|
static void gimp_eraser_get_paint_params (GimpPaintbrush *paintbrush,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpSymmetry *sym,
|
2019-08-03 03:25:00 +08:00
|
|
|
gdouble grad_point,
|
2019-05-29 16:25:38 +08:00
|
|
|
GimpLayerMode *paint_mode,
|
|
|
|
GimpPaintApplicationMode *paint_appl_mode,
|
|
|
|
const GimpTempBuf **paint_pixmap,
|
|
|
|
GimpRGB *paint_color);
|
1999-07-20 06:42:49 +08:00
|
|
|
|
2019-05-27 02:38:24 +08:00
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpEraser, gimp_eraser, GIMP_TYPE_PAINTBRUSH)
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2002-02-27 21:57:49 +08:00
|
|
|
void
|
|
|
|
gimp_eraser_register (Gimp *gimp,
|
|
|
|
GimpPaintRegisterCallback callback)
|
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_ERASER,
|
|
|
|
GIMP_TYPE_ERASER_OPTIONS,
|
2005-12-28 02:57:01 +08:00
|
|
|
"gimp-eraser",
|
|
|
|
_("Eraser"),
|
|
|
|
"gimp-tool-eraser");
|
2002-02-27 21:57:49 +08:00
|
|
|
}
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_eraser_class_init (GimpEraserClass *klass)
|
1998-03-01 09:18:45 +08:00
|
|
|
{
|
2019-05-27 02:38:24 +08:00
|
|
|
GimpPaintbrushClass *paintbrush_class = GIMP_PAINTBRUSH_CLASS (klass);
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2019-05-29 16:25:38 +08:00
|
|
|
paintbrush_class->get_color_history_color = gimp_eraser_get_color_history_color;
|
|
|
|
paintbrush_class->get_paint_params = gimp_eraser_get_paint_params;
|
1998-03-01 09:18:45 +08:00
|
|
|
}
|
1999-08-14 04:50:30 +08:00
|
|
|
|
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_eraser_init (GimpEraser *eraser)
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2001-12-02 06:59:48 +08:00
|
|
|
}
|
|
|
|
|
2019-05-29 16:25:38 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_eraser_get_color_history_color (GimpPaintbrush *paintbrush,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpRGB *color)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2019-05-29 16:25:38 +08:00
|
|
|
/* Erasing on a drawable without alpha is equivalent to
|
|
|
|
* drawing with background color. So let's save history.
|
|
|
|
*/
|
|
|
|
if (! gimp_drawable_has_alpha (drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-05-29 16:25:38 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
|
|
|
|
|
|
gimp_context_get_background (context, color);
|
|
|
|
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2019-05-27 02:38:24 +08:00
|
|
|
|
2019-05-29 16:25:38 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2019-05-27 02:38:24 +08:00
|
|
|
gimp_eraser_get_paint_params (GimpPaintbrush *paintbrush,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpSymmetry *sym,
|
2019-08-03 03:25:00 +08:00
|
|
|
gdouble grad_point,
|
2019-05-27 02:38:24 +08:00
|
|
|
GimpLayerMode *paint_mode,
|
|
|
|
GimpPaintApplicationMode *paint_appl_mode,
|
|
|
|
const GimpTempBuf **paint_pixmap,
|
|
|
|
GimpRGB *paint_color)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2019-05-27 02:38:24 +08:00
|
|
|
GimpEraserOptions *options = GIMP_ERASER_OPTIONS (paint_options);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
|
|
|
|
|
|
gimp_context_get_background (context, paint_color);
|
2016-05-29 23:49:37 +08:00
|
|
|
gimp_pickable_srgb_to_image_color (GIMP_PICKABLE (drawable),
|
2019-05-27 02:38:24 +08:00
|
|
|
paint_color, paint_color);
|
2004-05-26 17:32:03 +08:00
|
|
|
|
2012-05-20 23:14:09 +08:00
|
|
|
if (options->anti_erase)
|
2019-05-27 02:38:24 +08:00
|
|
|
*paint_mode = GIMP_LAYER_MODE_ANTI_ERASE;
|
2012-05-20 23:14:09 +08:00
|
|
|
else if (gimp_drawable_has_alpha (drawable))
|
2019-05-27 02:38:24 +08:00
|
|
|
*paint_mode = GIMP_LAYER_MODE_ERASE;
|
2012-05-20 23:14:09 +08:00
|
|
|
else
|
2019-05-27 02:38:24 +08:00
|
|
|
*paint_mode = GIMP_LAYER_MODE_NORMAL_LEGACY;
|
2001-10-31 06:59:06 +08:00
|
|
|
}
|