1997-11-24 22:05:25 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "appenv.h"
|
1998-07-09 05:31:06 +00:00
|
|
|
#include "gimpbrushlist.h"
|
1999-08-13 20:50:30 +00:00
|
|
|
#include "gimpbrushpixmap.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
#include "drawable.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "gdisplay.h"
|
|
|
|
#include "paint_funcs.h"
|
|
|
|
#include "paint_core.h"
|
1999-04-22 14:34:00 +00:00
|
|
|
#include "paint_options.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
#include "palette.h"
|
1999-08-13 20:50:30 +00:00
|
|
|
/* for color_area_with_pixmap */
|
|
|
|
#include "pixmapbrush.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
#include "airbrush.h"
|
|
|
|
#include "selection.h"
|
1999-04-12 17:55:06 +00:00
|
|
|
#include "tool_options_ui.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
#include "tools.h"
|
1998-06-29 00:24:44 +00:00
|
|
|
#include "gimage.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 23:23:52 +00:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
/* The maximum amount of pressure that can be exerted */
|
1999-06-26 11:16:47 +00:00
|
|
|
#define MAX_PRESSURE 0.075
|
1999-04-08 22:25:54 +00:00
|
|
|
|
1999-07-19 22:42:49 +00:00
|
|
|
/* Default pressure setting */
|
1999-08-19 19:53:30 +00:00
|
|
|
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
|
1999-08-13 20:50:30 +00:00
|
|
|
#define AIRBRUSH_INCREMENTAL_DEFAULT FALSE
|
1999-07-19 22:42:49 +00:00
|
|
|
|
1999-06-26 11:16:47 +00:00
|
|
|
#define OFF 0
|
|
|
|
#define ON 1
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
/* the airbrush structures */
|
|
|
|
|
|
|
|
typedef struct _AirbrushTimeout AirbrushTimeout;
|
1997-11-24 22:05:25 +00:00
|
|
|
struct _AirbrushTimeout
|
|
|
|
{
|
1999-08-19 19:53:30 +00:00
|
|
|
PaintCore *paint_core;
|
1998-01-22 07:02:57 +00:00
|
|
|
GimpDrawable *drawable;
|
1997-11-24 22:05:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _AirbrushOptions AirbrushOptions;
|
|
|
|
struct _AirbrushOptions
|
|
|
|
{
|
1999-04-22 14:34:00 +00:00
|
|
|
PaintOptions paint_options;
|
1999-04-08 22:25:54 +00:00
|
|
|
|
1999-04-12 17:55:06 +00:00
|
|
|
double rate;
|
|
|
|
double rate_d;
|
|
|
|
GtkObject *rate_w;
|
|
|
|
|
|
|
|
double pressure;
|
|
|
|
double pressure_d;
|
|
|
|
GtkObject *pressure_w;
|
1997-11-24 22:05:25 +00:00
|
|
|
};
|
|
|
|
|
1999-04-12 17:55:06 +00:00
|
|
|
|
|
|
|
/* the airbrush tool options */
|
1999-08-13 20:50:30 +00:00
|
|
|
static AirbrushOptions *airbrush_options = NULL;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* local variables */
|
1999-04-08 22:25:54 +00:00
|
|
|
static gint timer; /* timer for successive paint applications */
|
|
|
|
static int timer_state = OFF; /* state of airbrush tool */
|
1997-11-24 22:05:25 +00:00
|
|
|
static AirbrushTimeout airbrush_timeout;
|
1999-04-08 22:25:54 +00:00
|
|
|
|
|
|
|
static double non_gui_pressure;
|
1999-08-13 20:50:30 +00:00
|
|
|
static gboolean non_gui_incremental;
|
1999-04-08 22:25:54 +00:00
|
|
|
|
|
|
|
/* forward function declarations */
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-18 23:41:39 +00:00
|
|
|
static void airbrush_motion (PaintCore *, GimpDrawable *, double, PaintApplicationMode);
|
1999-04-08 22:25:54 +00:00
|
|
|
static gint airbrush_time_out (gpointer);
|
|
|
|
|
|
|
|
|
|
|
|
/* functions */
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
static void
|
1999-04-12 17:55:06 +00:00
|
|
|
airbrush_options_reset (void)
|
1999-04-08 22:25:54 +00:00
|
|
|
{
|
|
|
|
AirbrushOptions *options = airbrush_options;
|
|
|
|
|
1999-04-22 14:34:00 +00:00
|
|
|
paint_options_reset ((PaintOptions *) options);
|
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->rate_w),
|
|
|
|
options->rate_d);
|
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->pressure_w),
|
|
|
|
options->pressure_d);
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static AirbrushOptions *
|
1999-04-12 17:55:06 +00:00
|
|
|
airbrush_options_new (void)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
|
|
|
AirbrushOptions *options;
|
|
|
|
|
1999-04-12 17:55:06 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scale;
|
|
|
|
|
|
|
|
/* the new airbrush tool options structure */
|
1997-11-24 22:05:25 +00:00
|
|
|
options = (AirbrushOptions *) g_malloc (sizeof (AirbrushOptions));
|
1999-04-22 14:34:00 +00:00
|
|
|
paint_options_init ((PaintOptions *) options,
|
|
|
|
AIRBRUSH,
|
|
|
|
airbrush_options_reset);
|
1999-04-08 22:25:54 +00:00
|
|
|
options->rate = options->rate_d = 80.0;
|
1999-07-19 22:42:49 +00:00
|
|
|
options->pressure = options->pressure_d = AIRBRUSH_PRESSURE_DEFAULT;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* the main vbox */
|
1999-04-22 14:34:00 +00:00
|
|
|
vbox = ((ToolOptions *) options)->main_vbox;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* the rate scale */
|
1999-04-08 22:25:54 +00:00
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
1999-04-22 14:34:00 +00:00
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
1999-04-08 22:25:54 +00:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Rate:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-24 22:05:25 +00:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
options->rate_w =
|
|
|
|
gtk_adjustment_new (options->rate_d, 0.0, 150.0, 1.0, 1.0, 0.0);
|
|
|
|
scale = gtk_hscale_new (GTK_ADJUSTMENT (options->rate_w));
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), scale, 1, 2, 0, 1);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed",
|
1999-04-12 17:55:06 +00:00
|
|
|
(GtkSignalFunc) tool_options_double_adjustment_update,
|
|
|
|
&options->rate);
|
1999-04-08 22:25:54 +00:00
|
|
|
gtk_widget_show (scale);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* the pressure scale */
|
1999-04-08 22:25:54 +00:00
|
|
|
label = gtk_label_new (_("Pressure:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-24 22:05:25 +00:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
options->pressure_w =
|
|
|
|
gtk_adjustment_new (options->pressure_d, 0.0, 100.0, 1.0, 1.0, 0.0);
|
|
|
|
scale = gtk_hscale_new (GTK_ADJUSTMENT (options->pressure_w));
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), scale, 1, 2, 1, 2);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (options->pressure_w), "value_changed",
|
1999-04-12 17:55:06 +00:00
|
|
|
(GtkSignalFunc) tool_options_double_adjustment_update,
|
|
|
|
&options->pressure);
|
1999-04-08 22:25:54 +00:00
|
|
|
gtk_widget_show (scale);
|
|
|
|
|
|
|
|
gtk_widget_show (table);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
1999-04-12 17:55:06 +00:00
|
|
|
Tool *
|
|
|
|
tools_new_airbrush ()
|
|
|
|
{
|
|
|
|
Tool * tool;
|
|
|
|
PaintCore * private;
|
|
|
|
|
|
|
|
/* The tool options */
|
|
|
|
if (! airbrush_options)
|
|
|
|
{
|
|
|
|
airbrush_options = airbrush_options_new ();
|
|
|
|
tools_register (AIRBRUSH, (ToolOptions *) airbrush_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
tool = paint_core_new (AIRBRUSH);
|
|
|
|
|
|
|
|
private = (PaintCore *) tool->private;
|
|
|
|
private->paint_func = airbrush_paint_func;
|
1999-05-13 11:12:32 +00:00
|
|
|
private->pick_colors = TRUE;
|
1999-04-12 17:55:06 +00:00
|
|
|
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
void *
|
1999-08-19 19:53:30 +00:00
|
|
|
airbrush_paint_func (PaintCore *paint_core,
|
1998-01-22 07:02:57 +00:00
|
|
|
GimpDrawable *drawable,
|
1999-08-19 19:53:30 +00:00
|
|
|
int state)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
1998-07-09 05:31:06 +00:00
|
|
|
GimpBrushP brush;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1998-01-22 07:02:57 +00:00
|
|
|
if (!drawable)
|
|
|
|
return NULL;
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
brush = get_active_brush ();
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case INIT_PAINT :
|
1998-08-20 00:35:40 +00:00
|
|
|
/* timer_state = OFF; */
|
1998-08-15 22:03:32 +00:00
|
|
|
if (timer_state == ON)
|
1999-05-13 11:12:32 +00:00
|
|
|
{
|
|
|
|
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
|
|
|
gtk_timeout_remove (timer);
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
timer_state = OFF;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOTION_PAINT :
|
|
|
|
if (timer_state == ON)
|
|
|
|
gtk_timeout_remove (timer);
|
|
|
|
timer_state = OFF;
|
|
|
|
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-18 23:41:39 +00:00
|
|
|
airbrush_motion (paint_core, drawable, airbrush_options->pressure,
|
1999-08-19 19:53:30 +00:00
|
|
|
airbrush_options->paint_options.incremental ?
|
|
|
|
INCREMENTAL : CONSTANT);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
if (airbrush_options->rate != 0.0)
|
1999-08-19 19:53:30 +00:00
|
|
|
{
|
|
|
|
airbrush_timeout.paint_core = paint_core;
|
|
|
|
airbrush_timeout.drawable = drawable;
|
|
|
|
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
|
|
|
airbrush_time_out, NULL);
|
|
|
|
timer_state = ON;
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FINISH_PAINT :
|
|
|
|
if (timer_state == ON)
|
|
|
|
gtk_timeout_remove (timer);
|
|
|
|
timer_state = OFF;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_free_airbrush (Tool *tool)
|
|
|
|
{
|
|
|
|
if (timer_state == ON)
|
|
|
|
gtk_timeout_remove (timer);
|
|
|
|
timer_state = OFF;
|
1998-08-15 22:03:32 +00:00
|
|
|
|
|
|
|
paint_core_free (tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
airbrush_time_out (gpointer client_data)
|
|
|
|
{
|
|
|
|
/* service the timer */
|
|
|
|
airbrush_motion (airbrush_timeout.paint_core,
|
1998-01-22 07:02:57 +00:00
|
|
|
airbrush_timeout.drawable,
|
1999-08-13 20:50:30 +00:00
|
|
|
airbrush_options->pressure,
|
1999-08-19 19:53:30 +00:00
|
|
|
airbrush_options->paint_options.incremental ?
|
|
|
|
INCREMENTAL : CONSTANT);
|
1997-11-24 22:05:25 +00:00
|
|
|
gdisplays_flush ();
|
|
|
|
|
|
|
|
/* restart the timer */
|
|
|
|
if (airbrush_options->rate != 0.0)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-18 23:41:39 +00:00
|
|
|
airbrush_motion (PaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
double pressure,
|
|
|
|
PaintApplicationMode mode)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
1998-06-09 02:06:33 +00:00
|
|
|
gint opacity;
|
1997-11-24 22:05:25 +00:00
|
|
|
GImage *gimage;
|
|
|
|
TempBuf * area;
|
|
|
|
unsigned char col[MAX_CHANNELS];
|
|
|
|
|
1998-01-22 07:02:57 +00:00
|
|
|
if (!drawable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! (gimage = drawable_gimage (drawable)))
|
1997-11-24 22:05:25 +00:00
|
|
|
return;
|
|
|
|
|
1998-01-22 07:02:57 +00:00
|
|
|
gimage_get_foreground (gimage, drawable, col);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1998-01-22 07:02:57 +00:00
|
|
|
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
|
1997-11-24 22:05:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* color the pixels */
|
1998-01-25 01:24:46 +00:00
|
|
|
col[area->bytes - 1] = OPAQUE_OPACITY;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-08-13 20:50:30 +00:00
|
|
|
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-18 23:41:39 +00:00
|
|
|
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
|
1999-08-13 20:50:30 +00:00
|
|
|
{
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-18 23:41:39 +00:00
|
|
|
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
|
1999-08-13 20:50:30 +00:00
|
|
|
mode = INCREMENTAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* color the pixels */
|
|
|
|
color_pixels (temp_buf_data (area), col,
|
|
|
|
area->width * area->height, area->bytes);
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1998-06-09 02:06:33 +00:00
|
|
|
opacity = pressure * (paint_core->curpressure / 0.5);
|
|
|
|
if (opacity > 255)
|
|
|
|
opacity = 255;
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* paste the newly painted area to the image */
|
1998-01-22 07:02:57 +00:00
|
|
|
paint_core_paste_canvas (paint_core, drawable,
|
1998-06-09 02:06:33 +00:00
|
|
|
opacity,
|
1999-07-06 15:18:25 +00:00
|
|
|
(gint) (gimp_context_get_opacity (NULL) * 255),
|
|
|
|
gimp_context_get_paint_mode (NULL),
|
1999-08-13 20:50:30 +00:00
|
|
|
SOFT, mode);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
1999-07-06 15:18:25 +00:00
|
|
|
airbrush_non_gui_paint_func (PaintCore *paint_core,
|
1998-01-22 07:02:57 +00:00
|
|
|
GimpDrawable *drawable,
|
1999-07-06 15:18:25 +00:00
|
|
|
int state)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
1999-08-13 20:50:30 +00:00
|
|
|
airbrush_motion (paint_core, drawable, non_gui_pressure, non_gui_incremental);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-07-19 22:42:49 +00:00
|
|
|
gboolean
|
|
|
|
airbrush_non_gui_default (GimpDrawable *drawable,
|
|
|
|
int num_strokes,
|
|
|
|
double *stroke_array)
|
|
|
|
{
|
|
|
|
AirbrushOptions *options = airbrush_options;
|
|
|
|
gdouble pressure = AIRBRUSH_PRESSURE_DEFAULT;
|
|
|
|
|
|
|
|
if(options)
|
|
|
|
pressure = options->pressure;
|
|
|
|
|
|
|
|
return airbrush_non_gui(drawable,pressure,num_strokes,stroke_array);
|
|
|
|
}
|
|
|
|
|
1999-04-18 21:22:41 +00:00
|
|
|
gboolean
|
|
|
|
airbrush_non_gui (GimpDrawable *drawable,
|
|
|
|
double pressure,
|
|
|
|
int num_strokes,
|
|
|
|
double *stroke_array)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1999-04-18 21:22:41 +00:00
|
|
|
if (paint_core_init (&non_gui_paint_core, drawable,
|
|
|
|
stroke_array[0], stroke_array[1]))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
1999-04-18 21:22:41 +00:00
|
|
|
/* Set the paint core's paint func */
|
1997-11-24 22:05:25 +00:00
|
|
|
non_gui_paint_core.paint_func = airbrush_non_gui_paint_func;
|
|
|
|
|
1999-07-19 22:42:49 +00:00
|
|
|
non_gui_pressure = pressure;
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
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];
|
|
|
|
|
1999-07-22 23:11:46 +00:00
|
|
|
airbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
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];
|
|
|
|
|
1998-01-22 07:02:57 +00:00
|
|
|
paint_core_interpolate (&non_gui_paint_core, drawable);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
|
|
|
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
|
|
|
}
|
|
|
|
|
1999-04-18 21:22:41 +00:00
|
|
|
/* Finish the painting */
|
1998-01-22 07:02:57 +00:00
|
|
|
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-04-18 21:22:41 +00:00
|
|
|
/* Cleanup */
|
1997-11-24 22:05:25 +00:00
|
|
|
paint_core_cleanup ();
|
1999-04-18 21:22:41 +00:00
|
|
|
return TRUE;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
1999-04-18 21:22:41 +00:00
|
|
|
else
|
|
|
|
return FALSE;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|