From the Changelog:

* Makefile.am: don't do docs generation by default

        * configure.in: -lXt for webbrowser plugin

        * libgimp/gimp.c
        * libgimp/gimpprotocol.c
        * libgimp/gimptile.c
        * libgimp/gimpwire.c
        * app/plug_in.c: applied memory leak patch from Mattias Gronlund

        * app/eraser.c
        * app/eraser.h
        * app/internal_procs.c
        * app/paintbrush.c
        * app/paintbrush.h: incremental modes for eraser and paintbrush,
        as well as a "hard eraser"

        * plug-ins/ifscompose/ifscompose.c: pixmap visual fixups

-Yosh
This commit is contained in:
Manish Singh 1998-03-01 01:18:45 +00:00
parent 65c81c94ea
commit 2afd3ffb75
46 changed files with 1320 additions and 117 deletions

View File

@ -1,3 +1,24 @@
Sat Feb 28 16:57:49 PST 1998 Manish Singh <yosh@gimp.org>
* Makefile.am: don't do docs generation by default
* configure.in: -lXt for webbrowser plugin
* libgimp/gimp.c
* libgimp/gimpprotocol.c
* libgimp/gimptile.c
* libgimp/gimpwire.c
* app/plug_in.c: applied memory leak patch from Mattias Gronlund
* app/eraser.c
* app/eraser.h
* app/internal_procs.c
* app/paintbrush.c
* app/paintbrush.h: incremental modes for eraser and paintbrush,
as well as a "hard eraser"
* plug-ins/ifscompose/ifscompose.c: pixmap visual fixups
Sat Feb 28 00:09:46 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* app/gimage_cmds.c (duplicate): Duplicate image wasn't copying

View File

@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = libgimp plug-ins app docs
SUBDIRS = libgimp plug-ins app
EXTRA_DIST = TODO TODO-DIST NOTES gtkrc gimp_logo.ppm gimp_splash.ppm rmshm user_install gimp_tips.txt ps-menurc

View File

@ -492,12 +492,3 @@ about_dialog_timer (gpointer data)
return return_val;
}

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -492,12 +492,3 @@ about_dialog_timer (gpointer data)
return return_val;
}

View File

@ -29,11 +29,81 @@
#include "tools.h"
/* forward function declarations */
static void eraser_motion (PaintCore *, GimpDrawable *);
static void eraser_motion (PaintCore *, GimpDrawable *, gboolean, gboolean);
static Argument * eraser_invoker (Argument *);
static Argument * eraser_extended_invoker (Argument *);
static void * eraser_options = NULL;
static gboolean non_gui_hard, non_gui_incremental;
typedef struct _EraserOptions EraserOptions;
struct _EraserOptions
{
gboolean hard;
gboolean incremental;
};
static EraserOptions *eraser_options = NULL;
static void
eraser_toggle_update (GtkWidget *w,
gpointer data)
{
gboolean *toggle_val;
toggle_val = (gboolean *) data;
if (GTK_TOGGLE_BUTTON (w)->active)
*toggle_val = TRUE;
else
*toggle_val = FALSE;
}
static EraserOptions *
create_eraser_options (void)
{
EraserOptions *options;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *hard_toggle;
GtkWidget *incremental_toggle;
options = (EraserOptions *) g_malloc (sizeof (EraserOptions));
options->hard = FALSE;
options->incremental = FALSE;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 1);
/* the main label */
label = gtk_label_new ("Eraser Options");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
/* the hard toggle */
hard_toggle = gtk_check_button_new_with_label ("Hard edge");
gtk_box_pack_start (GTK_BOX (vbox), hard_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (hard_toggle), "toggled",
(GtkSignalFunc) eraser_toggle_update,
&options->hard);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (hard_toggle), options->hard);
gtk_widget_show (hard_toggle);
/* the incremental toggle */
incremental_toggle = gtk_check_button_new_with_label ("Incremental");
gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled",
(GtkSignalFunc) eraser_toggle_update,
&options->incremental);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental);
gtk_widget_show (incremental_toggle);
/* Register this eraser options widget with the main tools options dialog */
tools_register_options (ERASER, vbox);
return options;
}
void *
eraser_paint_func (paint_core, drawable, state)
PaintCore *paint_core;
@ -46,7 +116,7 @@ eraser_paint_func (paint_core, drawable, state)
break;
case MOTION_PAINT :
eraser_motion (paint_core, drawable);
eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental);
break;
case FINISH_PAINT :
@ -67,7 +137,7 @@ tools_new_eraser ()
PaintCore * private;
if (! eraser_options)
eraser_options = tools_register_no_options (ERASER, "Eraser Options");
eraser_options = create_eraser_options ();
tool = paint_core_new (ERASER);
@ -87,9 +157,11 @@ tools_free_eraser (tool)
void
eraser_motion (paint_core, drawable)
eraser_motion (paint_core, drawable, hard, incremental)
PaintCore *paint_core;
GimpDrawable *drawable;
gboolean hard;
gboolean incremental;
{
GImage *gimage;
TempBuf * area;
@ -114,20 +186,48 @@ eraser_motion (paint_core, drawable)
/* paste the newly painted canvas to the gimage which is being worked on */
paint_core_paste_canvas (paint_core, drawable, OPAQUE_OPACITY,
(int) (get_brush_opacity () * 255),
ERASE_MODE, SOFT, CONSTANT);
ERASE_MODE, hard? HARD : SOFT, incremental ? INCREMENTAL : CONSTANT);
}
static void *
eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state)
{
eraser_motion (paint_core, drawable);
eraser_motion (paint_core, drawable, non_gui_hard, non_gui_incremental);
return NULL;
}
/* The eraser procedure definition */
ProcArg eraser_extended_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
},
{ PDB_DRAWABLE,
"drawable",
"the drawable"
},
{ PDB_INT32,
"num_strokes",
"number of stroke control points (count each coordinate as 2 points)"
},
{ PDB_FLOATARRAY,
"strokes",
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
},
{ PDB_INT32,
"hardness",
"SOFT(0) or HARD(1)"
},
{ PDB_INT32,
"method",
"CONTINUOUS(0) or INCREMENTAL(1)"
}
};
ProcArg eraser_args[] =
{
{ PDB_IMAGE,
@ -171,6 +271,27 @@ ProcRecord eraser_proc =
{ { eraser_invoker } },
};
ProcRecord eraser_extended_proc =
{
"gimp_eraser_extended",
"Erase using the current brush",
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
6,
eraser_extended_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { eraser_extended_invoker } },
};
static Argument *
eraser_invoker (args)
@ -221,6 +342,94 @@ eraser_invoker (args)
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_hard=0; non_gui_incremental = 0;
/* set the paint core's paint func */
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
if (num_strokes == 1)
eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
for (i = 1; i < num_strokes; i++)
{
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
paint_core_interpolate (&non_gui_paint_core, drawable);
non_gui_paint_core.lastx = non_gui_paint_core.curx;
non_gui_paint_core.lasty = non_gui_paint_core.cury;
}
/* finish the painting */
paint_core_finish (&non_gui_paint_core, drawable, -1);
/* cleanup */
paint_core_cleanup ();
}
return procedural_db_return_args (&eraser_proc, success);
}
static Argument *
eraser_extended_invoker (args)
Argument *args;
{
int success = TRUE;
GImage *gimage;
GimpDrawable *drawable;
int num_strokes;
double *stroke_array;
int int_value;
int i;
drawable = NULL;
num_strokes = 0;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* the drawable */
if (success)
{
int_value = args[1].value.pdb_int;
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* num strokes */
if (success)
{
int_value = args[2].value.pdb_int;
if (int_value > 0)
num_strokes = int_value / 2;
else
success = FALSE;
}
/* point array */
if (success)
stroke_array = (double *) args[3].value.pdb_pointer;
if (success)
/* init the paint core */
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_hard = args[4].value.pdb_int;
non_gui_incremental = args[5].value.pdb_int;
}
if (success)
{
/* set the paint core's paint func */

View File

@ -28,5 +28,6 @@ void tools_free_eraser (Tool *);
/* Procedure definition and marshalling function */
extern ProcRecord eraser_proc;
extern ProcRecord eraser_extended_proc;
#endif /* __ERASER_H__ */

View File

@ -492,12 +492,3 @@ about_dialog_timer (gpointer data)
return return_val;
}

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -92,10 +92,12 @@ internal_procs_init ()
procedural_db_register (&crop_proc); pcount++;
procedural_db_register (&ellipse_select_proc); pcount++;
procedural_db_register (&eraser_proc); pcount++;
procedural_db_register (&eraser_extended_proc); pcount++;
procedural_db_register (&flip_proc); pcount++;
procedural_db_register (&free_select_proc); pcount++;
procedural_db_register (&fuzzy_select_proc); pcount++;
procedural_db_register (&paintbrush_proc); pcount++;
procedural_db_register (&paintbrush_extended_proc); pcount++;
procedural_db_register (&pencil_proc); pcount++;
procedural_db_register (&perspective_proc); pcount++;
procedural_db_register (&rect_select_proc); pcount++;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -29,11 +29,81 @@
#include "tools.h"
/* forward function declarations */
static void eraser_motion (PaintCore *, GimpDrawable *);
static void eraser_motion (PaintCore *, GimpDrawable *, gboolean, gboolean);
static Argument * eraser_invoker (Argument *);
static Argument * eraser_extended_invoker (Argument *);
static void * eraser_options = NULL;
static gboolean non_gui_hard, non_gui_incremental;
typedef struct _EraserOptions EraserOptions;
struct _EraserOptions
{
gboolean hard;
gboolean incremental;
};
static EraserOptions *eraser_options = NULL;
static void
eraser_toggle_update (GtkWidget *w,
gpointer data)
{
gboolean *toggle_val;
toggle_val = (gboolean *) data;
if (GTK_TOGGLE_BUTTON (w)->active)
*toggle_val = TRUE;
else
*toggle_val = FALSE;
}
static EraserOptions *
create_eraser_options (void)
{
EraserOptions *options;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *hard_toggle;
GtkWidget *incremental_toggle;
options = (EraserOptions *) g_malloc (sizeof (EraserOptions));
options->hard = FALSE;
options->incremental = FALSE;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 1);
/* the main label */
label = gtk_label_new ("Eraser Options");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
/* the hard toggle */
hard_toggle = gtk_check_button_new_with_label ("Hard edge");
gtk_box_pack_start (GTK_BOX (vbox), hard_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (hard_toggle), "toggled",
(GtkSignalFunc) eraser_toggle_update,
&options->hard);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (hard_toggle), options->hard);
gtk_widget_show (hard_toggle);
/* the incremental toggle */
incremental_toggle = gtk_check_button_new_with_label ("Incremental");
gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled",
(GtkSignalFunc) eraser_toggle_update,
&options->incremental);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental);
gtk_widget_show (incremental_toggle);
/* Register this eraser options widget with the main tools options dialog */
tools_register_options (ERASER, vbox);
return options;
}
void *
eraser_paint_func (paint_core, drawable, state)
PaintCore *paint_core;
@ -46,7 +116,7 @@ eraser_paint_func (paint_core, drawable, state)
break;
case MOTION_PAINT :
eraser_motion (paint_core, drawable);
eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental);
break;
case FINISH_PAINT :
@ -67,7 +137,7 @@ tools_new_eraser ()
PaintCore * private;
if (! eraser_options)
eraser_options = tools_register_no_options (ERASER, "Eraser Options");
eraser_options = create_eraser_options ();
tool = paint_core_new (ERASER);
@ -87,9 +157,11 @@ tools_free_eraser (tool)
void
eraser_motion (paint_core, drawable)
eraser_motion (paint_core, drawable, hard, incremental)
PaintCore *paint_core;
GimpDrawable *drawable;
gboolean hard;
gboolean incremental;
{
GImage *gimage;
TempBuf * area;
@ -114,20 +186,48 @@ eraser_motion (paint_core, drawable)
/* paste the newly painted canvas to the gimage which is being worked on */
paint_core_paste_canvas (paint_core, drawable, OPAQUE_OPACITY,
(int) (get_brush_opacity () * 255),
ERASE_MODE, SOFT, CONSTANT);
ERASE_MODE, hard? HARD : SOFT, incremental ? INCREMENTAL : CONSTANT);
}
static void *
eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state)
{
eraser_motion (paint_core, drawable);
eraser_motion (paint_core, drawable, non_gui_hard, non_gui_incremental);
return NULL;
}
/* The eraser procedure definition */
ProcArg eraser_extended_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
},
{ PDB_DRAWABLE,
"drawable",
"the drawable"
},
{ PDB_INT32,
"num_strokes",
"number of stroke control points (count each coordinate as 2 points)"
},
{ PDB_FLOATARRAY,
"strokes",
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
},
{ PDB_INT32,
"hardness",
"SOFT(0) or HARD(1)"
},
{ PDB_INT32,
"method",
"CONTINUOUS(0) or INCREMENTAL(1)"
}
};
ProcArg eraser_args[] =
{
{ PDB_IMAGE,
@ -171,6 +271,27 @@ ProcRecord eraser_proc =
{ { eraser_invoker } },
};
ProcRecord eraser_extended_proc =
{
"gimp_eraser_extended",
"Erase using the current brush",
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
6,
eraser_extended_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { eraser_extended_invoker } },
};
static Argument *
eraser_invoker (args)
@ -221,6 +342,94 @@ eraser_invoker (args)
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_hard=0; non_gui_incremental = 0;
/* set the paint core's paint func */
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
if (num_strokes == 1)
eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
for (i = 1; i < num_strokes; i++)
{
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
paint_core_interpolate (&non_gui_paint_core, drawable);
non_gui_paint_core.lastx = non_gui_paint_core.curx;
non_gui_paint_core.lasty = non_gui_paint_core.cury;
}
/* finish the painting */
paint_core_finish (&non_gui_paint_core, drawable, -1);
/* cleanup */
paint_core_cleanup ();
}
return procedural_db_return_args (&eraser_proc, success);
}
static Argument *
eraser_extended_invoker (args)
Argument *args;
{
int success = TRUE;
GImage *gimage;
GimpDrawable *drawable;
int num_strokes;
double *stroke_array;
int int_value;
int i;
drawable = NULL;
num_strokes = 0;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* the drawable */
if (success)
{
int_value = args[1].value.pdb_int;
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* num strokes */
if (success)
{
int_value = args[2].value.pdb_int;
if (int_value > 0)
num_strokes = int_value / 2;
else
success = FALSE;
}
/* point array */
if (success)
stroke_array = (double *) args[3].value.pdb_pointer;
if (success)
/* init the paint core */
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_hard = args[4].value.pdb_int;
non_gui_incremental = args[5].value.pdb_int;
}
if (success)
{
/* set the paint core's paint func */

View File

@ -28,5 +28,6 @@ void tools_free_eraser (Tool *);
/* Procedure definition and marshalling function */
extern ProcRecord eraser_proc;
extern ProcRecord eraser_extended_proc;
#endif /* __ERASER_H__ */

View File

@ -30,10 +30,11 @@
#include "tools.h"
/* forward function declarations */
static void paintbrush_motion (PaintCore *, GimpDrawable *, double);
static void paintbrush_motion (PaintCore *, GimpDrawable *, double, gboolean);
static Argument * paintbrush_invoker (Argument *);
static Argument * paintbrush_extended_invoker (Argument *);
static double non_gui_fade_out;
static double non_gui_fade_out, non_gui_incremental;
/* defines */
@ -43,12 +44,27 @@ typedef struct _PaintOptions PaintOptions;
struct _PaintOptions
{
double fade_out;
gboolean incremental;
};
/* local variables */
static PaintOptions *paint_options = NULL;
static void
paintbrush_toggle_update (GtkWidget *w,
gpointer data)
{
gboolean *toggle_val;
toggle_val = (gboolean *) data;
if (GTK_TOGGLE_BUTTON (w)->active)
*toggle_val = TRUE;
else
*toggle_val = FALSE;
}
static void
paintbrush_scale_update (GtkAdjustment *adjustment,
double *scale_val)
@ -65,10 +81,12 @@ create_paint_options (void)
GtkWidget *label;
GtkWidget *fade_out_scale;
GtkObject *fade_out_scale_data;
GtkWidget *incremental_toggle;
/* the new options structure */
options = (PaintOptions *) g_malloc (sizeof (PaintOptions));
options->fade_out = 0.0;
options->incremental = FALSE;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 1);
@ -97,6 +115,16 @@ create_paint_options (void)
gtk_widget_show (fade_out_scale);
gtk_widget_show (hbox);
/* the incremental toggle */
incremental_toggle = gtk_check_button_new_with_label ("Incremental");
gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled",
(GtkSignalFunc) paintbrush_toggle_update,
&options->incremental);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental);
gtk_widget_show (incremental_toggle);
/* Register this selection options widget with the main tools options dialog */
tools_register_options (PAINTBRUSH, vbox);
@ -114,7 +142,7 @@ paintbrush_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
paintbrush_motion (paint_core, drawable, paint_options->fade_out);
paintbrush_motion (paint_core, drawable, paint_options->fade_out, paint_options->incremental);
break;
case FINISH_PAINT :
@ -156,7 +184,8 @@ tools_free_paintbrush (Tool *tool)
void
paintbrush_motion (PaintCore *paint_core,
GimpDrawable *drawable,
double fade_out)
double fade_out,
gboolean incremental)
{
GImage *gimage;
TempBuf * area;
@ -195,7 +224,8 @@ paintbrush_motion (PaintCore *paint_core,
/* paste the newly painted canvas to the gimage which is being worked on */
paint_core_paste_canvas (paint_core, drawable, blend,
(int) (get_brush_opacity () * 255),
get_brush_paint_mode (), SOFT, CONSTANT);
get_brush_paint_mode (), SOFT,
incremental ? INCREMENTAL : CONSTANT);
}
}
@ -204,8 +234,8 @@ static void *
paintbrush_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
paintbrush_motion (paint_core, drawable, non_gui_fade_out);
{
paintbrush_motion (paint_core, drawable, non_gui_fade_out, non_gui_incremental);
return NULL;
}
@ -236,6 +266,34 @@ ProcArg paintbrush_args[] =
}
};
ProcArg paintbrush_extended_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
},
{ PDB_DRAWABLE,
"drawable",
"the drawable"
},
{ PDB_FLOAT,
"fade_out",
"fade out parameter: fade_out > 0"
},
{ PDB_INT32,
"num_strokes",
"number of stroke control points (count each coordinate as 2 points)"
},
{ PDB_FLOATARRAY,
"strokes",
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
},
{ PDB_INT32,
"method",
"CONTINUOUS(0) or INCREMENTAL(1)"
}
};
ProcRecord paintbrush_proc =
{
@ -259,6 +317,28 @@ ProcRecord paintbrush_proc =
{ { paintbrush_invoker } },
};
ProcRecord paintbrush_extended_proc =
{
"gimp_paintbrush_exteneded",
"Paint in the current brush with optional fade out parameter",
"This tool is the standard paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The \"fade_out\" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
6,
paintbrush_extended_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { paintbrush_extended_invoker } },
};
static Argument *
paintbrush_invoker (Argument *args)
{
@ -319,6 +399,97 @@ paintbrush_invoker (Argument *args)
if (success)
{
non_gui_incremental = 0;
/* set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
if (num_strokes == 1)
paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
for (i = 1; i < num_strokes; i++)
{
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
paint_core_interpolate (&non_gui_paint_core, drawable);
non_gui_paint_core.lastx = non_gui_paint_core.curx;
non_gui_paint_core.lasty = non_gui_paint_core.cury;
}
/* finish the painting */
paint_core_finish (&non_gui_paint_core, drawable, -1);
/* cleanup */
paint_core_cleanup ();
}
return procedural_db_return_args (&paintbrush_proc, success);
}
static Argument *
paintbrush_extended_invoker (Argument *args)
{
int success = TRUE;
GImage *gimage;
GimpDrawable *drawable;
int num_strokes;
double *stroke_array;
int int_value;
double fp_value;
int i;
drawable = NULL;
num_strokes = 0;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* the drawable */
if (success)
{
int_value = args[1].value.pdb_int;
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* fade out */
if (success)
{
fp_value = args[2].value.pdb_float;
if (fp_value >= 0.0)
non_gui_fade_out = fp_value;
else
success = FALSE;
}
/* num strokes */
if (success)
{
int_value = args[3].value.pdb_int;
if (int_value > 0)
num_strokes = int_value / 2;
else
success = FALSE;
}
/* point array */
if (success)
stroke_array = (double *) args[4].value.pdb_pointer;
if (success)
/* init the paint core */
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_incremental = args[5].value.pdb_int;
/* set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;

View File

@ -28,5 +28,6 @@ void tools_free_paintbrush (Tool *);
/* Procedure definition and marshalling function */
extern ProcRecord paintbrush_proc;
extern ProcRecord paintbrush_extended_proc;
#endif /* __PAINTBRUSH_H__ */

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -1539,7 +1539,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
break;
case PDB_TEMPORARY:
prog = g_strdup ("none");
prog = "none";
tmp = current_plug_in->temp_proc_defs;
break;
@ -1631,7 +1631,7 @@ plug_in_handle_proc_install (GPProcInstall *proc_install)
/* If there is a menu path specified, create a menu entry */
if (proc_install->menu_path)
{
entry.path = g_strdup (proc_install->menu_path);
entry.path = proc_install->menu_path;
entry.accelerator = NULL;
entry.callback = plug_in_callback;
entry.callback_data = proc;

View File

@ -29,11 +29,81 @@
#include "tools.h"
/* forward function declarations */
static void eraser_motion (PaintCore *, GimpDrawable *);
static void eraser_motion (PaintCore *, GimpDrawable *, gboolean, gboolean);
static Argument * eraser_invoker (Argument *);
static Argument * eraser_extended_invoker (Argument *);
static void * eraser_options = NULL;
static gboolean non_gui_hard, non_gui_incremental;
typedef struct _EraserOptions EraserOptions;
struct _EraserOptions
{
gboolean hard;
gboolean incremental;
};
static EraserOptions *eraser_options = NULL;
static void
eraser_toggle_update (GtkWidget *w,
gpointer data)
{
gboolean *toggle_val;
toggle_val = (gboolean *) data;
if (GTK_TOGGLE_BUTTON (w)->active)
*toggle_val = TRUE;
else
*toggle_val = FALSE;
}
static EraserOptions *
create_eraser_options (void)
{
EraserOptions *options;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *hard_toggle;
GtkWidget *incremental_toggle;
options = (EraserOptions *) g_malloc (sizeof (EraserOptions));
options->hard = FALSE;
options->incremental = FALSE;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 1);
/* the main label */
label = gtk_label_new ("Eraser Options");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
/* the hard toggle */
hard_toggle = gtk_check_button_new_with_label ("Hard edge");
gtk_box_pack_start (GTK_BOX (vbox), hard_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (hard_toggle), "toggled",
(GtkSignalFunc) eraser_toggle_update,
&options->hard);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (hard_toggle), options->hard);
gtk_widget_show (hard_toggle);
/* the incremental toggle */
incremental_toggle = gtk_check_button_new_with_label ("Incremental");
gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled",
(GtkSignalFunc) eraser_toggle_update,
&options->incremental);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental);
gtk_widget_show (incremental_toggle);
/* Register this eraser options widget with the main tools options dialog */
tools_register_options (ERASER, vbox);
return options;
}
void *
eraser_paint_func (paint_core, drawable, state)
PaintCore *paint_core;
@ -46,7 +116,7 @@ eraser_paint_func (paint_core, drawable, state)
break;
case MOTION_PAINT :
eraser_motion (paint_core, drawable);
eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental);
break;
case FINISH_PAINT :
@ -67,7 +137,7 @@ tools_new_eraser ()
PaintCore * private;
if (! eraser_options)
eraser_options = tools_register_no_options (ERASER, "Eraser Options");
eraser_options = create_eraser_options ();
tool = paint_core_new (ERASER);
@ -87,9 +157,11 @@ tools_free_eraser (tool)
void
eraser_motion (paint_core, drawable)
eraser_motion (paint_core, drawable, hard, incremental)
PaintCore *paint_core;
GimpDrawable *drawable;
gboolean hard;
gboolean incremental;
{
GImage *gimage;
TempBuf * area;
@ -114,20 +186,48 @@ eraser_motion (paint_core, drawable)
/* paste the newly painted canvas to the gimage which is being worked on */
paint_core_paste_canvas (paint_core, drawable, OPAQUE_OPACITY,
(int) (get_brush_opacity () * 255),
ERASE_MODE, SOFT, CONSTANT);
ERASE_MODE, hard? HARD : SOFT, incremental ? INCREMENTAL : CONSTANT);
}
static void *
eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state)
{
eraser_motion (paint_core, drawable);
eraser_motion (paint_core, drawable, non_gui_hard, non_gui_incremental);
return NULL;
}
/* The eraser procedure definition */
ProcArg eraser_extended_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
},
{ PDB_DRAWABLE,
"drawable",
"the drawable"
},
{ PDB_INT32,
"num_strokes",
"number of stroke control points (count each coordinate as 2 points)"
},
{ PDB_FLOATARRAY,
"strokes",
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
},
{ PDB_INT32,
"hardness",
"SOFT(0) or HARD(1)"
},
{ PDB_INT32,
"method",
"CONTINUOUS(0) or INCREMENTAL(1)"
}
};
ProcArg eraser_args[] =
{
{ PDB_IMAGE,
@ -171,6 +271,27 @@ ProcRecord eraser_proc =
{ { eraser_invoker } },
};
ProcRecord eraser_extended_proc =
{
"gimp_eraser_extended",
"Erase using the current brush",
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
6,
eraser_extended_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { eraser_extended_invoker } },
};
static Argument *
eraser_invoker (args)
@ -221,6 +342,94 @@ eraser_invoker (args)
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_hard=0; non_gui_incremental = 0;
/* set the paint core's paint func */
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
if (num_strokes == 1)
eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
for (i = 1; i < num_strokes; i++)
{
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
paint_core_interpolate (&non_gui_paint_core, drawable);
non_gui_paint_core.lastx = non_gui_paint_core.curx;
non_gui_paint_core.lasty = non_gui_paint_core.cury;
}
/* finish the painting */
paint_core_finish (&non_gui_paint_core, drawable, -1);
/* cleanup */
paint_core_cleanup ();
}
return procedural_db_return_args (&eraser_proc, success);
}
static Argument *
eraser_extended_invoker (args)
Argument *args;
{
int success = TRUE;
GImage *gimage;
GimpDrawable *drawable;
int num_strokes;
double *stroke_array;
int int_value;
int i;
drawable = NULL;
num_strokes = 0;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* the drawable */
if (success)
{
int_value = args[1].value.pdb_int;
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* num strokes */
if (success)
{
int_value = args[2].value.pdb_int;
if (int_value > 0)
num_strokes = int_value / 2;
else
success = FALSE;
}
/* point array */
if (success)
stroke_array = (double *) args[3].value.pdb_pointer;
if (success)
/* init the paint core */
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_hard = args[4].value.pdb_int;
non_gui_incremental = args[5].value.pdb_int;
}
if (success)
{
/* set the paint core's paint func */

View File

@ -28,5 +28,6 @@ void tools_free_eraser (Tool *);
/* Procedure definition and marshalling function */
extern ProcRecord eraser_proc;
extern ProcRecord eraser_extended_proc;
#endif /* __ERASER_H__ */

View File

@ -29,11 +29,81 @@
#include "tools.h"
/* forward function declarations */
static void eraser_motion (PaintCore *, GimpDrawable *);
static void eraser_motion (PaintCore *, GimpDrawable *, gboolean, gboolean);
static Argument * eraser_invoker (Argument *);
static Argument * eraser_extended_invoker (Argument *);
static void * eraser_options = NULL;
static gboolean non_gui_hard, non_gui_incremental;
typedef struct _EraserOptions EraserOptions;
struct _EraserOptions
{
gboolean hard;
gboolean incremental;
};
static EraserOptions *eraser_options = NULL;
static void
eraser_toggle_update (GtkWidget *w,
gpointer data)
{
gboolean *toggle_val;
toggle_val = (gboolean *) data;
if (GTK_TOGGLE_BUTTON (w)->active)
*toggle_val = TRUE;
else
*toggle_val = FALSE;
}
static EraserOptions *
create_eraser_options (void)
{
EraserOptions *options;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *hard_toggle;
GtkWidget *incremental_toggle;
options = (EraserOptions *) g_malloc (sizeof (EraserOptions));
options->hard = FALSE;
options->incremental = FALSE;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 1);
/* the main label */
label = gtk_label_new ("Eraser Options");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
/* the hard toggle */
hard_toggle = gtk_check_button_new_with_label ("Hard edge");
gtk_box_pack_start (GTK_BOX (vbox), hard_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (hard_toggle), "toggled",
(GtkSignalFunc) eraser_toggle_update,
&options->hard);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (hard_toggle), options->hard);
gtk_widget_show (hard_toggle);
/* the incremental toggle */
incremental_toggle = gtk_check_button_new_with_label ("Incremental");
gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled",
(GtkSignalFunc) eraser_toggle_update,
&options->incremental);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental);
gtk_widget_show (incremental_toggle);
/* Register this eraser options widget with the main tools options dialog */
tools_register_options (ERASER, vbox);
return options;
}
void *
eraser_paint_func (paint_core, drawable, state)
PaintCore *paint_core;
@ -46,7 +116,7 @@ eraser_paint_func (paint_core, drawable, state)
break;
case MOTION_PAINT :
eraser_motion (paint_core, drawable);
eraser_motion (paint_core, drawable, eraser_options->hard, eraser_options->incremental);
break;
case FINISH_PAINT :
@ -67,7 +137,7 @@ tools_new_eraser ()
PaintCore * private;
if (! eraser_options)
eraser_options = tools_register_no_options (ERASER, "Eraser Options");
eraser_options = create_eraser_options ();
tool = paint_core_new (ERASER);
@ -87,9 +157,11 @@ tools_free_eraser (tool)
void
eraser_motion (paint_core, drawable)
eraser_motion (paint_core, drawable, hard, incremental)
PaintCore *paint_core;
GimpDrawable *drawable;
gboolean hard;
gboolean incremental;
{
GImage *gimage;
TempBuf * area;
@ -114,20 +186,48 @@ eraser_motion (paint_core, drawable)
/* paste the newly painted canvas to the gimage which is being worked on */
paint_core_paste_canvas (paint_core, drawable, OPAQUE_OPACITY,
(int) (get_brush_opacity () * 255),
ERASE_MODE, SOFT, CONSTANT);
ERASE_MODE, hard? HARD : SOFT, incremental ? INCREMENTAL : CONSTANT);
}
static void *
eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state)
{
eraser_motion (paint_core, drawable);
eraser_motion (paint_core, drawable, non_gui_hard, non_gui_incremental);
return NULL;
}
/* The eraser procedure definition */
ProcArg eraser_extended_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
},
{ PDB_DRAWABLE,
"drawable",
"the drawable"
},
{ PDB_INT32,
"num_strokes",
"number of stroke control points (count each coordinate as 2 points)"
},
{ PDB_FLOATARRAY,
"strokes",
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
},
{ PDB_INT32,
"hardness",
"SOFT(0) or HARD(1)"
},
{ PDB_INT32,
"method",
"CONTINUOUS(0) or INCREMENTAL(1)"
}
};
ProcArg eraser_args[] =
{
{ PDB_IMAGE,
@ -171,6 +271,27 @@ ProcRecord eraser_proc =
{ { eraser_invoker } },
};
ProcRecord eraser_extended_proc =
{
"gimp_eraser_extended",
"Erase using the current brush",
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
6,
eraser_extended_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { eraser_extended_invoker } },
};
static Argument *
eraser_invoker (args)
@ -221,6 +342,94 @@ eraser_invoker (args)
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_hard=0; non_gui_incremental = 0;
/* set the paint core's paint func */
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
if (num_strokes == 1)
eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
for (i = 1; i < num_strokes; i++)
{
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
paint_core_interpolate (&non_gui_paint_core, drawable);
non_gui_paint_core.lastx = non_gui_paint_core.curx;
non_gui_paint_core.lasty = non_gui_paint_core.cury;
}
/* finish the painting */
paint_core_finish (&non_gui_paint_core, drawable, -1);
/* cleanup */
paint_core_cleanup ();
}
return procedural_db_return_args (&eraser_proc, success);
}
static Argument *
eraser_extended_invoker (args)
Argument *args;
{
int success = TRUE;
GImage *gimage;
GimpDrawable *drawable;
int num_strokes;
double *stroke_array;
int int_value;
int i;
drawable = NULL;
num_strokes = 0;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* the drawable */
if (success)
{
int_value = args[1].value.pdb_int;
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* num strokes */
if (success)
{
int_value = args[2].value.pdb_int;
if (int_value > 0)
num_strokes = int_value / 2;
else
success = FALSE;
}
/* point array */
if (success)
stroke_array = (double *) args[3].value.pdb_pointer;
if (success)
/* init the paint core */
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_hard = args[4].value.pdb_int;
non_gui_incremental = args[5].value.pdb_int;
}
if (success)
{
/* set the paint core's paint func */

View File

@ -28,5 +28,6 @@ void tools_free_eraser (Tool *);
/* Procedure definition and marshalling function */
extern ProcRecord eraser_proc;
extern ProcRecord eraser_extended_proc;
#endif /* __ERASER_H__ */

View File

@ -30,10 +30,11 @@
#include "tools.h"
/* forward function declarations */
static void paintbrush_motion (PaintCore *, GimpDrawable *, double);
static void paintbrush_motion (PaintCore *, GimpDrawable *, double, gboolean);
static Argument * paintbrush_invoker (Argument *);
static Argument * paintbrush_extended_invoker (Argument *);
static double non_gui_fade_out;
static double non_gui_fade_out, non_gui_incremental;
/* defines */
@ -43,12 +44,27 @@ typedef struct _PaintOptions PaintOptions;
struct _PaintOptions
{
double fade_out;
gboolean incremental;
};
/* local variables */
static PaintOptions *paint_options = NULL;
static void
paintbrush_toggle_update (GtkWidget *w,
gpointer data)
{
gboolean *toggle_val;
toggle_val = (gboolean *) data;
if (GTK_TOGGLE_BUTTON (w)->active)
*toggle_val = TRUE;
else
*toggle_val = FALSE;
}
static void
paintbrush_scale_update (GtkAdjustment *adjustment,
double *scale_val)
@ -65,10 +81,12 @@ create_paint_options (void)
GtkWidget *label;
GtkWidget *fade_out_scale;
GtkObject *fade_out_scale_data;
GtkWidget *incremental_toggle;
/* the new options structure */
options = (PaintOptions *) g_malloc (sizeof (PaintOptions));
options->fade_out = 0.0;
options->incremental = FALSE;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 1);
@ -97,6 +115,16 @@ create_paint_options (void)
gtk_widget_show (fade_out_scale);
gtk_widget_show (hbox);
/* the incremental toggle */
incremental_toggle = gtk_check_button_new_with_label ("Incremental");
gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (incremental_toggle), "toggled",
(GtkSignalFunc) paintbrush_toggle_update,
&options->incremental);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (incremental_toggle), options->incremental);
gtk_widget_show (incremental_toggle);
/* Register this selection options widget with the main tools options dialog */
tools_register_options (PAINTBRUSH, vbox);
@ -114,7 +142,7 @@ paintbrush_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
paintbrush_motion (paint_core, drawable, paint_options->fade_out);
paintbrush_motion (paint_core, drawable, paint_options->fade_out, paint_options->incremental);
break;
case FINISH_PAINT :
@ -156,7 +184,8 @@ tools_free_paintbrush (Tool *tool)
void
paintbrush_motion (PaintCore *paint_core,
GimpDrawable *drawable,
double fade_out)
double fade_out,
gboolean incremental)
{
GImage *gimage;
TempBuf * area;
@ -195,7 +224,8 @@ paintbrush_motion (PaintCore *paint_core,
/* paste the newly painted canvas to the gimage which is being worked on */
paint_core_paste_canvas (paint_core, drawable, blend,
(int) (get_brush_opacity () * 255),
get_brush_paint_mode (), SOFT, CONSTANT);
get_brush_paint_mode (), SOFT,
incremental ? INCREMENTAL : CONSTANT);
}
}
@ -204,8 +234,8 @@ static void *
paintbrush_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
paintbrush_motion (paint_core, drawable, non_gui_fade_out);
{
paintbrush_motion (paint_core, drawable, non_gui_fade_out, non_gui_incremental);
return NULL;
}
@ -236,6 +266,34 @@ ProcArg paintbrush_args[] =
}
};
ProcArg paintbrush_extended_args[] =
{
{ PDB_IMAGE,
"image",
"the image"
},
{ PDB_DRAWABLE,
"drawable",
"the drawable"
},
{ PDB_FLOAT,
"fade_out",
"fade out parameter: fade_out > 0"
},
{ PDB_INT32,
"num_strokes",
"number of stroke control points (count each coordinate as 2 points)"
},
{ PDB_FLOATARRAY,
"strokes",
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
},
{ PDB_INT32,
"method",
"CONTINUOUS(0) or INCREMENTAL(1)"
}
};
ProcRecord paintbrush_proc =
{
@ -259,6 +317,28 @@ ProcRecord paintbrush_proc =
{ { paintbrush_invoker } },
};
ProcRecord paintbrush_extended_proc =
{
"gimp_paintbrush_exteneded",
"Paint in the current brush with optional fade out parameter",
"This tool is the standard paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The \"fade_out\" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
/* Input arguments */
6,
paintbrush_extended_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { paintbrush_extended_invoker } },
};
static Argument *
paintbrush_invoker (Argument *args)
{
@ -319,6 +399,97 @@ paintbrush_invoker (Argument *args)
if (success)
{
non_gui_incremental = 0;
/* set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
if (num_strokes == 1)
paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
for (i = 1; i < num_strokes; i++)
{
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
paint_core_interpolate (&non_gui_paint_core, drawable);
non_gui_paint_core.lastx = non_gui_paint_core.curx;
non_gui_paint_core.lasty = non_gui_paint_core.cury;
}
/* finish the painting */
paint_core_finish (&non_gui_paint_core, drawable, -1);
/* cleanup */
paint_core_cleanup ();
}
return procedural_db_return_args (&paintbrush_proc, success);
}
static Argument *
paintbrush_extended_invoker (Argument *args)
{
int success = TRUE;
GImage *gimage;
GimpDrawable *drawable;
int num_strokes;
double *stroke_array;
int int_value;
double fp_value;
int i;
drawable = NULL;
num_strokes = 0;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
/* the drawable */
if (success)
{
int_value = args[1].value.pdb_int;
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* fade out */
if (success)
{
fp_value = args[2].value.pdb_float;
if (fp_value >= 0.0)
non_gui_fade_out = fp_value;
else
success = FALSE;
}
/* num strokes */
if (success)
{
int_value = args[3].value.pdb_int;
if (int_value > 0)
num_strokes = int_value / 2;
else
success = FALSE;
}
/* point array */
if (success)
stroke_array = (double *) args[4].value.pdb_pointer;
if (success)
/* init the paint core */
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
{
non_gui_incremental = args[5].value.pdb_int;
/* set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;

View File

@ -28,5 +28,6 @@ void tools_free_paintbrush (Tool *);
/* Procedure definition and marshalling function */
extern ProcRecord paintbrush_proc;
extern ProcRecord paintbrush_extended_proc;
#endif /* __PAINTBRUSH_H__ */

View File

@ -121,7 +121,7 @@ fi
dnl Test for Xmu
if test -z "$LIBXMU_LIB"; then
AC_CHECK_LIB(Xmu, XmuClientWindow,
WEBBROWSER="webbrowser"; LIBXMU_LIB='-lXmu -lSM -lICE',
WEBBROWSER="webbrowser"; LIBXMU_LIB='-lXmu -lXt -lSM -lICE',
AC_MSG_WARN(*** webbrowser plug-in will not be built ***), -lXt -lSM -lICE)
fi

View File

@ -677,6 +677,7 @@ gimp_run_procedure (char *name,
}
g_free (proc_run.params);
g_free (proc_return->name);
g_free (proc_return);
return return_vals;

View File

@ -504,7 +504,10 @@ _gp_proc_run_read (int fd, WireMessage *msg)
proc_run = g_new (GPProcRun, 1);
if (!wire_read_string (fd, &proc_run->name, 1))
return;
{
g_free (proc_run);
return;
}
_gp_params_read (fd, &proc_run->params, (guint*) &proc_run->nparams);
msg->data = proc_run;
@ -529,6 +532,7 @@ _gp_proc_run_destroy (WireMessage *msg)
proc_run = msg->data;
_gp_params_destroy (proc_run->params, proc_run->nparams);
g_free (proc_run->name);
g_free (proc_run);
}
@ -743,6 +747,8 @@ _gp_proc_install_destroy (WireMessage *msg)
g_free (proc_install->return_vals[i].description);
}
g_free (proc_install->params);
g_free (proc_install->return_vals);
g_free (proc_install);
}

View File

@ -184,6 +184,8 @@ gimp_tile_get (GTile *tile)
if (!gp_tile_ack_write (_writefd))
gimp_quit ();
wire_destroy (&msg);
}
static void
@ -240,6 +242,8 @@ gimp_tile_put (GTile *tile)
g_warning ("unexpected message: %d\n", msg.type);
gimp_quit ();
}
wire_destroy (&msg);
}
/* This function is nearly identical to the function 'tile_cache_insert'

View File

@ -334,7 +334,10 @@ wire_read_string (int fd,
{
data[i] = g_new (gchar, tmp);
if (!wire_read_int8 (fd, (guint8*) data[i], tmp))
return FALSE;
{
g_free (data[i]);
return FALSE;
}
}
else
{

View File

@ -504,7 +504,10 @@ _gp_proc_run_read (int fd, WireMessage *msg)
proc_run = g_new (GPProcRun, 1);
if (!wire_read_string (fd, &proc_run->name, 1))
return;
{
g_free (proc_run);
return;
}
_gp_params_read (fd, &proc_run->params, (guint*) &proc_run->nparams);
msg->data = proc_run;
@ -529,6 +532,7 @@ _gp_proc_run_destroy (WireMessage *msg)
proc_run = msg->data;
_gp_params_destroy (proc_run->params, proc_run->nparams);
g_free (proc_run->name);
g_free (proc_run);
}
@ -743,6 +747,8 @@ _gp_proc_install_destroy (WireMessage *msg)
g_free (proc_install->return_vals[i].description);
}
g_free (proc_install->params);
g_free (proc_install->return_vals);
g_free (proc_install);
}

View File

@ -334,7 +334,10 @@ wire_read_string (int fd,
{
data[i] = g_new (gchar, tmp);
if (!wire_read_int8 (fd, (guint8*) data[i], tmp))
return FALSE;
{
g_free (data[i]);
return FALSE;
}
}
else
{

View File

@ -1103,7 +1103,7 @@ design_op_menu_create(GtkWidget *window)
GtkAcceleratorTable *accelerator_table;
ifsDesign->op_menu = gtk_menu_new();
gtk_object_ref (ifsDesign->op_menu);
gtk_object_ref (GTK_OBJECT (ifsDesign->op_menu));
gtk_object_sink (GTK_OBJECT (ifsDesign->op_menu));
accelerator_table = gtk_accelerator_table_new();
@ -1572,7 +1572,7 @@ design_area_configure(GtkWidget *widget, GdkEventConfigure *event)
ifsDesign->pixmap = gdk_pixmap_new(widget->window,
widget->allocation.width,
widget->allocation.height,
-1);
gtk_preview_get_visual()->depth);
return FALSE;
}