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"
|
1999-10-27 02:27:27 +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-11-21 07:00:47 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
2001-11-21 07:00:47 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
#include "gimperasertool.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "paint_options.h"
|
2001-03-12 12:40:17 +08:00
|
|
|
#include "tool_manager.h"
|
1997-11-25 06:05:25 +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
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
#define ERASER_DEFAULT_HARD FALSE
|
|
|
|
#define ERASER_DEFAULT_INCREMENTAL FALSE
|
1999-08-14 04:50:30 +08:00
|
|
|
#define ERASER_DEFAULT_ANTI_ERASE FALSE
|
1999-07-20 06:42:49 +08:00
|
|
|
|
1998-03-01 09:18:45 +08:00
|
|
|
|
|
|
|
typedef struct _EraserOptions EraserOptions;
|
2000-12-31 12:07:42 +08:00
|
|
|
|
1998-03-01 09:18:45 +08:00
|
|
|
struct _EraserOptions
|
|
|
|
{
|
1999-04-22 22:34:00 +08:00
|
|
|
PaintOptions paint_options;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
gboolean hard;
|
|
|
|
gboolean hard_d;
|
|
|
|
GtkWidget *hard_w;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
1999-08-14 04:50:30 +08:00
|
|
|
gboolean anti_erase;
|
|
|
|
gboolean anti_erase_d;
|
|
|
|
GtkWidget *anti_erase_w;
|
1998-03-01 09:18:45 +08:00
|
|
|
};
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2001-03-12 12:40:17 +08: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,
|
2001-11-09 03:14:51 +08:00
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
static void gimp_eraser_tool_paint (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintState state);
|
|
|
|
|
|
|
|
static void gimp_eraser_tool_motion (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintPressureOptions *pressure_options,
|
|
|
|
gboolean hard,
|
|
|
|
gboolean incremental,
|
2001-11-26 03:01:23 +08:00
|
|
|
gboolean anti_erase);
|
2001-03-12 12:40:17 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static GimpToolOptions * gimp_eraser_tool_options_new (GimpToolInfo *tool_info);
|
|
|
|
static void gimp_eraser_tool_options_reset (GimpToolOptions *tool_options);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* local variables */
|
2001-03-12 12:40:17 +08:00
|
|
|
static gboolean non_gui_hard = ERASER_DEFAULT_HARD;
|
|
|
|
static gboolean non_gui_incremental = ERASER_DEFAULT_INCREMENTAL;
|
|
|
|
static gboolean non_gui_anti_erase = ERASER_DEFAULT_ANTI_ERASE;
|
|
|
|
|
|
|
|
static GimpPaintToolClass *parent_class = NULL;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* functions */
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
void
|
2001-11-21 07:00:47 +08:00
|
|
|
gimp_eraser_tool_register (Gimp *gimp,
|
|
|
|
GimpToolRegisterCallback callback)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2001-11-21 07:00:47 +08:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_ERASER_TOOL,
|
|
|
|
gimp_eraser_tool_options_new,
|
|
|
|
TRUE,
|
|
|
|
"gimp:eraser_tool",
|
|
|
|
_("Eraser"),
|
|
|
|
_("Paint fuzzy brush strokes"),
|
|
|
|
N_("/Tools/Paint Tools/Eraser"), "<shift>E",
|
|
|
|
NULL, "tools/eraser.html",
|
|
|
|
GIMP_STOCK_TOOL_ERASER);
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-03-12 12:40:17 +08:00
|
|
|
gimp_eraser_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
1999-04-22 22:34:00 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpEraserToolClass),
|
2001-08-14 22:53:55 +08: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 12:40:17 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL,
|
|
|
|
"GimpEraserTool",
|
|
|
|
&tool_info, 0);
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
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
|
|
|
{
|
2001-03-12 12:40:17 +08:00
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpPaintToolClass *paint_tool_class;
|
1998-03-01 09:18:45 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
paint_tool_class = GIMP_PAINT_TOOL_CLASS (klass);
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1998-03-01 09:18:45 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
tool_class->modifier_key = gimp_eraser_tool_modifier_key;
|
1998-03-01 09:18:45 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
paint_tool_class->paint = gimp_eraser_tool_paint;
|
|
|
|
}
|
1999-08-20 03:53:30 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void
|
|
|
|
gimp_eraser_tool_init (GimpEraserTool *eraser)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpPaintTool *paint_tool;
|
1999-08-14 04:50:30 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
tool = GIMP_TOOL (eraser);
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (eraser);
|
|
|
|
|
|
|
|
tool->tool_cursor = GIMP_ERASER_TOOL_CURSOR;
|
|
|
|
|
|
|
|
paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH;
|
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,
|
|
|
|
GimpDisplay *gdisp)
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2001-11-21 07:00:47 +08:00
|
|
|
EraserOptions *options;
|
|
|
|
|
|
|
|
options = (EraserOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if ((key == GDK_CONTROL_MASK) &&
|
|
|
|
! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
gtk_toggle_button_set_active
|
2001-11-21 07:00:47 +08:00
|
|
|
(GTK_TOGGLE_BUTTON (options->anti_erase_w), ! options->anti_erase);
|
1999-08-14 04:50:30 +08:00
|
|
|
}
|
2000-06-14 22:22:47 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
tool->toggled = options->anti_erase;
|
1999-08-14 04:50:30 +08:00
|
|
|
}
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_eraser_tool_paint (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintState state)
|
|
|
|
{
|
2001-11-21 07:00:47 +08:00
|
|
|
EraserOptions *options;
|
2001-03-12 12:40:17 +08:00
|
|
|
PaintPressureOptions *pressure_options;
|
|
|
|
gboolean hard;
|
|
|
|
gboolean incremental;
|
|
|
|
gboolean anti_erase;
|
1999-08-14 04:50:30 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
options = (EraserOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options;
|
|
|
|
|
|
|
|
if (options)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2001-11-21 07:00:47 +08:00
|
|
|
pressure_options = options->paint_options.pressure_options;
|
|
|
|
hard = options->hard;
|
|
|
|
incremental = options->paint_options.incremental;
|
|
|
|
anti_erase = options->anti_erase;
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pressure_options = &non_gui_pressure_options;
|
|
|
|
hard = non_gui_hard;
|
|
|
|
incremental = non_gui_incremental;
|
|
|
|
anti_erase = non_gui_anti_erase;
|
|
|
|
}
|
1999-08-14 04:50:30 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
2000-04-28 01:27:28 +08:00
|
|
|
case INIT_PAINT:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
case MOTION_PAINT:
|
2001-03-12 12:40:17 +08:00
|
|
|
gimp_eraser_tool_motion (paint_tool,
|
|
|
|
drawable,
|
|
|
|
pressure_options,
|
|
|
|
hard,
|
|
|
|
incremental,
|
2001-11-26 03:01:23 +08:00
|
|
|
anti_erase);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
case FINISH_PAINT:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
default:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-03-12 12:40:17 +08:00
|
|
|
gimp_eraser_tool_motion (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintPressureOptions *pressure_options,
|
|
|
|
gboolean hard,
|
|
|
|
gboolean incremental,
|
2001-11-26 03:01:23 +08:00
|
|
|
gboolean anti_erase)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-07 20:17:23 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpContext *context;
|
|
|
|
gint opacity;
|
|
|
|
TempBuf *area;
|
|
|
|
guchar col[MAX_CHANNELS];
|
|
|
|
gdouble scale;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
if (! (gimage = gimp_drawable_gimage (drawable)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
gimp_image_get_background (gimage, drawable, col);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
context = gimp_get_current_context (gimage->gimp);
|
|
|
|
|
1999-09-09 09:47:54 +08:00
|
|
|
if (pressure_options->size)
|
2001-11-14 00:21:34 +08:00
|
|
|
scale = paint_tool->cur_coords.pressure;
|
1999-09-09 09:47:54 +08:00
|
|
|
else
|
|
|
|
scale = 1.0;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Get a region which can be used to paint to */
|
2001-03-12 12:40:17 +08:00
|
|
|
if (! (area = gimp_paint_tool_get_paint_area (paint_tool, drawable, scale)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2001-11-26 03:01:23 +08:00
|
|
|
/* set the alpha channel */
|
|
|
|
col[area->bytes - 1] = OPAQUE_OPACITY;
|
|
|
|
|
|
|
|
/* color the pixels */
|
|
|
|
color_pixels (temp_buf_data (area), col,
|
|
|
|
area->width * area->height, area->bytes);
|
|
|
|
|
|
|
|
opacity = 255 * gimp_context_get_opacity (context);
|
|
|
|
|
|
|
|
if (pressure_options->opacity)
|
|
|
|
opacity = opacity * 2.0 * paint_tool->cur_coords.pressure;
|
|
|
|
|
|
|
|
/* paste the newly painted canvas to the gimage which is being
|
|
|
|
* worked on */
|
|
|
|
gimp_paint_tool_paste_canvas (paint_tool, drawable,
|
|
|
|
MIN (opacity, 255),
|
|
|
|
gimp_context_get_opacity (context) * 255,
|
|
|
|
anti_erase ? ANTI_ERASE_MODE : ERASE_MODE,
|
|
|
|
hard ? HARD : (pressure_options->pressure ? PRESSURE : SOFT),
|
|
|
|
scale,
|
|
|
|
incremental ? INCREMENTAL : CONSTANT);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
/* non-gui stuff */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
gboolean
|
|
|
|
eraser_non_gui_default (GimpDrawable *drawable,
|
2000-12-31 12:07:42 +08:00
|
|
|
gint num_strokes,
|
|
|
|
gdouble *stroke_array)
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
2001-11-21 07:00:47 +08:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
EraserOptions *options;
|
|
|
|
gboolean hard = ERASER_DEFAULT_HARD;
|
|
|
|
gboolean incremental = ERASER_DEFAULT_INCREMENTAL;
|
|
|
|
gboolean anti_erase = ERASER_DEFAULT_ANTI_ERASE;
|
|
|
|
|
|
|
|
tool_info = tool_manager_get_info_by_type (drawable->gimage->gimp,
|
|
|
|
GIMP_TYPE_ERASER_TOOL);
|
1999-08-14 04:50:30 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
options = (EraserOptions *) tool_info->tool_options;
|
1999-07-20 06:42:49 +08:00
|
|
|
|
1999-08-20 03:53:30 +08:00
|
|
|
if (options)
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
2001-03-12 12:40:17 +08:00
|
|
|
hard = options->hard;
|
|
|
|
incremental = options->paint_options.incremental;
|
|
|
|
anti_erase = options->anti_erase;
|
1999-07-20 06:42:49 +08:00
|
|
|
}
|
|
|
|
|
1999-08-20 03:53:30 +08:00
|
|
|
return eraser_non_gui (drawable, num_strokes, stroke_array,
|
2001-11-26 03:01:23 +08:00
|
|
|
hard, incremental, anti_erase);
|
1999-07-20 06:42:49 +08:00
|
|
|
}
|
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
gboolean
|
|
|
|
eraser_non_gui (GimpDrawable *drawable,
|
2000-12-31 12:07:42 +08:00
|
|
|
gint num_strokes,
|
|
|
|
gdouble *stroke_array,
|
2001-03-12 12:40:17 +08:00
|
|
|
gint hard,
|
|
|
|
gint incremental,
|
2001-11-26 03:01:23 +08:00
|
|
|
gboolean anti_erase)
|
1998-03-01 09:18:45 +08:00
|
|
|
{
|
2001-03-12 12:40:17 +08:00
|
|
|
static GimpEraserTool *non_gui_eraser = NULL;
|
|
|
|
|
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
gint i;
|
1999-04-19 05:22:41 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
if (! non_gui_eraser)
|
1998-03-01 09:18:45 +08:00
|
|
|
{
|
2001-08-10 22:41:39 +08:00
|
|
|
non_gui_eraser = g_object_new (GIMP_TYPE_ERASER_TOOL, NULL);
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
1998-03-01 09:18:45 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
paint_tool = GIMP_PAINT_TOOL (non_gui_eraser);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
if (gimp_paint_tool_start (paint_tool, drawable,
|
|
|
|
stroke_array[0],
|
|
|
|
stroke_array[1]))
|
|
|
|
{
|
|
|
|
non_gui_hard = hard;
|
|
|
|
non_gui_incremental = incremental;
|
|
|
|
non_gui_anti_erase = anti_erase;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-14 00:21:34 +08:00
|
|
|
paint_tool->start_coords.x = paint_tool->last_coords.x = stroke_array[0];
|
|
|
|
paint_tool->start_coords.y = paint_tool->last_coords.y = stroke_array[1];
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
gimp_paint_tool_paint (paint_tool, drawable, MOTION_PAINT);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 1; i < num_strokes; i++)
|
|
|
|
{
|
2001-11-14 00:21:34 +08:00
|
|
|
paint_tool->cur_coords.x = stroke_array[i * 2 + 0];
|
|
|
|
paint_tool->cur_coords.y = stroke_array[i * 2 + 1];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
gimp_paint_tool_interpolate (paint_tool, drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-14 00:21:34 +08:00
|
|
|
paint_tool->last_coords.x = paint_tool->cur_coords.x;
|
|
|
|
paint_tool->last_coords.y = paint_tool->cur_coords.y;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
gimp_paint_tool_finish (paint_tool, drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* tool options stuff */
|
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static GimpToolOptions *
|
|
|
|
gimp_eraser_tool_options_new (GimpToolInfo *tool_info)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
|
|
|
EraserOptions *options;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
2001-04-01 04:41:39 +08:00
|
|
|
options = g_new0 (EraserOptions, 1);
|
2001-11-21 07:00:47 +08:00
|
|
|
|
|
|
|
paint_options_init ((PaintOptions *) options, tool_info);
|
|
|
|
|
|
|
|
((GimpToolOptions *) options)->reset_func = gimp_eraser_tool_options_reset;
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
options->hard = options->hard_d = ERASER_DEFAULT_HARD;
|
|
|
|
options->anti_erase = options->anti_erase_d = ERASER_DEFAULT_ANTI_ERASE;
|
|
|
|
|
|
|
|
/* the main vbox */
|
2001-07-18 04:50:01 +08:00
|
|
|
vbox = ((GimpToolOptions *) options)->main_vbox;
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
/* the hard toggle */
|
|
|
|
options->hard_w = gtk_check_button_new_with_label (_("Hard Edge"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), options->hard_w, FALSE, FALSE, 0);
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_connect (G_OBJECT (options->hard_w), "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->hard);
|
2001-03-12 12:40:17 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
|
|
|
|
options->hard_d);
|
|
|
|
gtk_widget_show (options->hard_w);
|
|
|
|
|
|
|
|
/* the anti_erase toggle */
|
2001-11-26 21:17:18 +08:00
|
|
|
options->anti_erase_w =
|
|
|
|
gtk_check_button_new_with_label (_("Anti Erase (<Ctrl>)"));
|
2001-03-12 12:40:17 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), options->anti_erase_w, FALSE, FALSE, 0);
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_connect (G_OBJECT (options->anti_erase_w), "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->anti_erase);
|
2001-03-12 12:40:17 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
|
|
|
|
options->anti_erase_d);
|
|
|
|
gtk_widget_show (options->anti_erase_w);
|
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
return (GimpToolOptions *) options;
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-18 04:50:01 +08:00
|
|
|
gimp_eraser_tool_options_reset (GimpToolOptions *tool_options)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2001-04-01 04:41:39 +08:00
|
|
|
EraserOptions *options;
|
|
|
|
|
|
|
|
options = (EraserOptions *) tool_options;
|
2001-03-12 12:40:17 +08:00
|
|
|
|
2001-04-01 04:41:39 +08:00
|
|
|
paint_options_reset (tool_options);
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->hard_w),
|
|
|
|
options->hard_d);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->anti_erase_w),
|
|
|
|
options->anti_erase_d);
|
2001-10-31 06:59:06 +08:00
|
|
|
}
|