Commit 9c510759 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Made the paint tool PDB wrappers work again (a bit at least...)

2002-02-21  Michael Natterer  <mitch@gimp.org>

	Made the paint tool PDB wrappers work again (a bit at least...)

	* app/Makefile.am: changed linking order. libtool sucks.

	* app/undo.c: check if active_tool is a GimpPaintTool before
	casting it.

	* app/paint/Makefile.am
	* app/paint/paint-types.h: added new files/types.

	* app/paint/gimppaintoptions.[ch]: new files cut out of
	tools/paint_options.h. Prefixed everything with "Gimp". There is
	still GtkWidget* cruft hanging around in the structs...

	* app/paint/gimppaintcore-stroke.[ch]: utility function
	which paints a stroke array. Needed for the PDB wrappers.

	* app/paint/gimpairbrush.[ch]
	* app/paint/gimpclone.[ch]
	* app/paint/gimpconvolve.[ch]
	* app/paint/gimpdodgeburn.[ch]
	* app/paint/gimperaser.[ch]
	* app/paint/gimppaintbrush.c
	* app/paint/gimppaintcore.[ch]
	* app/paint/gimppencil.c
	* app/paint/gimpsmudge.[ch]: added *_options_new() functions which
	create correctly initialized options structures without widgets.

	* app/tools/paint_options.[ch]: removed the options struct
	definitions and value initialisations.

	* app/tools/gimpairbrushtool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpconvolvetool.c
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimperasertool.c
	* app/tools/gimpinktool.c
	* app/tools/gimppaintbrushtool.c
	* app/tools/gimppainttool.c
	* app/tools/gimppenciltool.c
	* app/tools/gimpsmudgetool.c: changed all paint_options functions
	accordingly, s/PaintOptions/GimpPaintOptions/g etc., removed all
	#if 0'ed non_gui functions.

	* tools/pdbgen/pdb/paint_tools.pdb: use gimp_paint_core_stroke().
	We currently leak all paint_options structs created by the PDB
	wrappers, more stuff to come...

	* app/pdb/paint_tools_cmds.c: regenerated.
parent 9e2f55bc
2002-02-21 Michael Natterer <mitch@gimp.org>
Made the paint tool PDB wrappers work again (a bit at least...)
* app/Makefile.am: changed linking order. libtool sucks.
* app/undo.c: check if active_tool is a GimpPaintTool before
casting it.
* app/paint/Makefile.am
* app/paint/paint-types.h: added new files/types.
* app/paint/gimppaintoptions.[ch]: new files cut out of
tools/paint_options.h. Prefixed everything with "Gimp". There is
still GtkWidget* cruft hanging around in the structs...
* app/paint/gimppaintcore-stroke.[ch]: utility function
which paints a stroke array. Needed for the PDB wrappers.
* app/paint/gimpairbrush.[ch]
* app/paint/gimpclone.[ch]
* app/paint/gimpconvolve.[ch]
* app/paint/gimpdodgeburn.[ch]
* app/paint/gimperaser.[ch]
* app/paint/gimppaintbrush.c
* app/paint/gimppaintcore.[ch]
* app/paint/gimppencil.c
* app/paint/gimpsmudge.[ch]: added *_options_new() functions which
create correctly initialized options structures without widgets.
* app/tools/paint_options.[ch]: removed the options struct
definitions and value initialisations.
* app/tools/gimpairbrushtool.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpclonetool.c
* app/tools/gimpconvolvetool.c
* app/tools/gimpdodgeburntool.c
* app/tools/gimperasertool.c
* app/tools/gimpinktool.c
* app/tools/gimppaintbrushtool.c
* app/tools/gimppainttool.c
* app/tools/gimppenciltool.c
* app/tools/gimpsmudgetool.c: changed all paint_options functions
accordingly, s/PaintOptions/GimpPaintOptions/g etc., removed all
#if 0'ed non_gui functions.
* tools/pdbgen/pdb/paint_tools.pdb: use gimp_paint_core_stroke().
We currently leak all paint_options structs created by the PDB
wrappers, more stuff to come...
* app/pdb/paint_tools_cmds.c: regenerated.
2002-02-21 Sven Neumann <sven@gimp.org>
* plug-ins/common/glasstile.c: code cleanup based on a patch from
......
......@@ -134,12 +134,12 @@ gimp_1_3_LDADD = @STRIP_BEGIN@ \
tools/libapptools.a \
display/libappdisplay.a \
widgets/libappwidgets.a \
paint/libapppaint.a \
core/libappcore.a \
pdb/libapppdb.a \
paint/libapppaint.a \
xcf/libappxcf.a \
file/libappfile.a \
plug-in/libappplug-in.a \
pdb/libapppdb.a \
config/libappconfig.a \
paint-funcs/libapppaint-funcs.a \
base/libappbase.a \
......
......@@ -1368,7 +1368,7 @@ undo_pop_paint (GimpImage *gimage,
active_tool = tool_manager_get_active (gimage->gimp);
/* Can't have ANY tool selected - maybe a plugin running */
if (active_tool)
if (GIMP_IS_PAINT_TOOL (active_tool))
{
GimpPaintTool *pt;
GimpPaintCoreUndo *pu;
......
......@@ -15,6 +15,10 @@ libapppaint_a_SOURCES = @STRIP_BEGIN@ \
gimperaser.h \
gimppaintcore.c \
gimppaintcore.h \
gimppaintcore-stroke.c \
gimppaintcore-stroke.h \
gimppaintoptions.c \
gimppaintoptions.h \
gimppencil.c \
gimppencil.h \
gimppaintbrush.c \
......
......@@ -38,13 +38,17 @@
#include "gimpairbrush.h"
#define AIRBRUSH_DEFAULT_RATE 80.0
#define AIRBRUSH_DEFAULT_PRESSURE 10.0
typedef struct _AirbrushTimeout AirbrushTimeout;
struct _AirbrushTimeout
{
GimpPaintCore *paint_core;
GimpDrawable *drawable;
PaintOptions *paint_options;
GimpPaintCore *paint_core;
GimpDrawable *drawable;
GimpPaintOptions *paint_options;
};
......@@ -55,12 +59,12 @@ static void gimp_airbrush_finalize (GObject *object);
static void gimp_airbrush_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state);
static void gimp_airbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options);
GimpPaintOptions *paint_options);
static gboolean gimp_airbrush_timeout (gpointer data);
......@@ -139,12 +143,12 @@ gimp_airbrush_finalize (GObject *object)
static void
gimp_airbrush_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state)
{
AirbrushOptions *options;
GimpAirbrushOptions *options;
options = (AirbrushOptions *) paint_options;
options = (GimpAirbrushOptions *) paint_options;
switch (paint_state)
{
......@@ -213,7 +217,7 @@ gimp_airbrush_timeout (gpointer client_data)
#endif
gdisplays_flush ();
rate = ((AirbrushOptions *) airbrush_timeout.paint_options)->rate;
rate = ((GimpAirbrushOptions *) airbrush_timeout.paint_options)->rate;
/* restart the timer */
if (rate != 0.0)
......@@ -238,9 +242,9 @@ gimp_airbrush_timeout (gpointer client_data)
}
static void
gimp_airbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options)
gimp_airbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
GimpImage *gimage;
GimpContext *context;
......@@ -257,7 +261,7 @@ gimp_airbrush_motion (GimpPaintCore *paint_core,
paint_appl_mode = paint_options->incremental ? INCREMENTAL : CONSTANT;
pressure = ((AirbrushOptions *) paint_options)->pressure;
pressure = ((GimpAirbrushOptions *) paint_options)->pressure;
if (paint_options->pressure_options->size)
scale = paint_core->cur_coords.pressure;
......@@ -313,3 +317,21 @@ gimp_airbrush_motion (GimpPaintCore *paint_core,
gimp_context_get_paint_mode (context),
SOFT, scale, paint_appl_mode);
}
/* paint options stuff */
GimpAirbrushOptions *
gimp_airbrush_options_new (void)
{
GimpAirbrushOptions *options;
options = g_new0 (GimpAirbrushOptions, 1);
gimp_paint_options_init ((GimpPaintOptions *) options);
options->rate = options->rate_d = AIRBRUSH_DEFAULT_RATE;
options->pressure = options->pressure_d = AIRBRUSH_DEFAULT_PRESSURE;
return options;
}
......@@ -21,6 +21,7 @@
#include "gimppaintcore.h"
#include "gimppaintoptions.h"
#define GIMP_TYPE_AIRBRUSH (gimp_airbrush_get_type ())
......@@ -45,23 +46,25 @@ struct _GimpAirbrushClass
};
typedef struct _AirbrushOptions AirbrushOptions;
typedef struct _GimpAirbrushOptions GimpAirbrushOptions;
struct _AirbrushOptions
struct _GimpAirbrushOptions
{
PaintOptions paint_options;
GimpPaintOptions paint_options;
gdouble rate;
gdouble rate_d;
GtkObject *rate_w;
gdouble rate;
gdouble rate_d;
GtkObject *rate_w;
gdouble pressure;
gdouble pressure_d;
GtkObject *pressure_w;
gdouble pressure;
gdouble pressure_d;
GtkObject *pressure_w;
};
GType gimp_airbrush_get_type (void) G_GNUC_CONST;
GType gimp_airbrush_get_type (void) G_GNUC_CONST;
GimpAirbrushOptions * gimp_airbrush_options_new (void);
#endif /* __GIMP_AIRBRUSH_H__ */
......@@ -43,38 +43,38 @@
#include "libgimp/gimpintl.h"
static void gimp_clone_class_init (GimpCloneClass *klass);
static void gimp_clone_init (GimpClone *clone);
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options,
GimpPaintCoreState paint_state);
static void gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpDrawable *src_drawable,
PaintPressureOptions *pressure_options,
CloneType type,
gint offset_x,
gint offset_y);
static void gimp_clone_line_image (GimpImage *dest,
GimpImage *src,
GimpDrawable *d_drawable,
GimpDrawable *s_drawable,
guchar *s,
guchar *d,
gint has_alpha,
gint src_bytes,
gint dest_bytes,
gint width);
static void gimp_clone_line_pattern (GimpImage *dest,
GimpDrawable *drawable,
GimpPattern *pattern,
guchar *d,
gint x,
gint y,
gint bytes,
gint width);
static void gimp_clone_class_init (GimpCloneClass *klass);
static void gimp_clone_init (GimpClone *clone);
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state);
static void gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpDrawable *src_drawable,
GimpPressureOptions *pressure_options,
CloneType type,
gint offset_x,
gint offset_y);
static void gimp_clone_line_image (GimpImage *dest,
GimpImage *src,
GimpDrawable *d_drawable,
GimpDrawable *s_drawable,
guchar *s,
guchar *d,
gint has_alpha,
gint src_bytes,
gint dest_bytes,
gint width);
static void gimp_clone_line_pattern (GimpImage *dest,
GimpDrawable *drawable,
GimpPattern *pattern,
guchar *d,
gint x,
gint y,
gint bytes,
gint width);
static void gimp_clone_set_src_drawable (GimpClone *clone,
GimpDrawable *drawable);
......@@ -155,19 +155,19 @@ gimp_clone_init (GimpClone *clone)
static void
gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state)
{
static gint orig_src_x = 0;
static gint orig_src_y = 0;
GimpClone *clone;
CloneOptions *options;
GimpContext *context;
GimpClone *clone;
GimpCloneOptions *options;
GimpContext *context;
clone = GIMP_CLONE (paint_core);
options = (CloneOptions *) paint_options;
options = (GimpCloneOptions *) paint_options;
context = gimp_get_current_context (drawable->gimage->gimp);
......@@ -263,13 +263,13 @@ gimp_clone_paint (GimpPaintCore *paint_core,
}
static void
gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpDrawable *src_drawable,
PaintPressureOptions *pressure_options,
CloneType type,
gint offset_x,
gint offset_y)
gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpDrawable *src_drawable,
GimpPressureOptions *pressure_options,
CloneType type,
gint offset_x,
gint offset_y)
{
GimpImage *gimage;
GimpImage *src_gimage = NULL;
......@@ -544,3 +544,24 @@ gimp_clone_set_src_drawable (GimpClone *clone,
clone);
}
}
/* paint options stuff */
#define CLONE_DEFAULT_TYPE IMAGE_CLONE
#define CLONE_DEFAULT_ALIGNED ALIGN_NO
GimpCloneOptions *
gimp_clone_options_new (void)
{
GimpCloneOptions *options;
options = g_new0 (GimpCloneOptions, 1);
gimp_paint_options_init ((GimpPaintOptions *) options);
options->type = options->type_d = CLONE_DEFAULT_TYPE;
options->aligned = options->aligned_d = CLONE_DEFAULT_ALIGNED;
return options;
}
......@@ -21,6 +21,7 @@
#include "gimppaintcore.h"
#include "gimppaintoptions.h"
typedef enum /*< skip >*/ /*< pdb-skip >*/
......@@ -70,23 +71,25 @@ struct _GimpCloneClass
};
typedef struct _CloneOptions CloneOptions;
typedef struct _GimpCloneOptions GimpCloneOptions;
struct _CloneOptions
struct _GimpCloneOptions
{
PaintOptions paint_options;
GimpPaintOptions paint_options;
CloneType type;
CloneType type_d;
GtkWidget *type_w[2]; /* 2 radio buttons */
CloneType type;
CloneType type_d;
GtkWidget *type_w[2]; /* 2 radio buttons */
AlignType aligned;
AlignType aligned_d;
GtkWidget *aligned_w[3]; /* 3 radio buttons */
AlignType aligned;
AlignType aligned_d;
GtkWidget *aligned_w[3]; /* 3 radio buttons */
};
GType gimp_clone_get_type (void) G_GNUC_CONST;
GType gimp_clone_get_type (void) G_GNUC_CONST;
GimpCloneOptions * gimp_clone_options_new (void);
#endif /* __GIMP_CLONE_H__ */
......@@ -53,30 +53,30 @@ typedef enum
} ConvolveClipType;
static void gimp_convolve_class_init (GimpConvolveClass *klass);
static void gimp_convolve_init (GimpConvolve *convolve);
static void gimp_convolve_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options,
GimpPaintCoreState paint_state);
static void gimp_convolve_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintPressureOptions *pressure_options,
ConvolveType type,
gdouble rate);
static void gimp_convolve_calculate_matrix (ConvolveType type,
gdouble rate);
static void gimp_convolve_integer_matrix (gfloat *source,
gint *dest,
gint size);
static void gimp_convolve_copy_matrix (gfloat *src,
gfloat *dest,
gint size);
static gint gimp_convolve_sum_matrix (gint *matrix,
gint size);
static void gimp_convolve_class_init (GimpConvolveClass *klass);
static void gimp_convolve_init (GimpConvolve *convolve);
static void gimp_convolve_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state);
static void gimp_convolve_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPressureOptions *pressure_options,
ConvolveType type,
gdouble rate);
static void gimp_convolve_calculate_matrix (ConvolveType type,
gdouble rate);
static void gimp_convolve_integer_matrix (gfloat *source,
gint *dest,
gint size);
static void gimp_convolve_copy_matrix (gfloat *src,
gfloat *dest,
gint size);
static gint gimp_convolve_sum_matrix (gint *matrix,
gint size);
static gint matrix [25];
......@@ -161,12 +161,12 @@ gimp_convolve_init (GimpConvolve *convolve)
static void
gimp_convolve_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state)
{
ConvolveOptions *options;
GimpConvolveOptions *options;
options = (ConvolveOptions *) paint_options;
options = (GimpConvolveOptions *) paint_options;
switch (paint_state)
{
......@@ -184,11 +184,11 @@ gimp_convolve_paint (GimpPaintCore *paint_core,
}
static void
gimp_convolve_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintPressureOptions *pressure_options,
ConvolveType type,
gdouble rate)
gimp_convolve_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPressureOptions *pressure_options,
ConvolveType type,
gdouble rate)
{
TempBuf *area;
guchar *temp_data;
......@@ -487,3 +487,24 @@ gimp_convolve_sum_matrix (gint *matrix,
return sum;
}
/* paint options stuff */
#define DEFAULT_CONVOLVE_RATE 50.0
#define DEFAULT_CONVOLVE_TYPE BLUR_CONVOLVE
GimpConvolveOptions *
gimp_convolve_options_new (void)
{
GimpConvolveOptions *options;
options = g_new0 (GimpConvolveOptions, 1);
gimp_paint_options_init ((GimpPaintOptions *) options);
options->type = options->type_d = DEFAULT_CONVOLVE_TYPE;
options->rate = options->rate_d = DEFAULT_CONVOLVE_RATE;
return options;
}
......@@ -21,6 +21,7 @@
#include "gimppaintcore.h"
#include "gimppaintoptions.h"
#define GIMP_TYPE_CONVOLVE (gimp_convolve_get_type ())
......@@ -45,23 +46,25 @@ struct _GimpConvolveClass
};
typedef struct _ConvolveOptions ConvolveOptions;
typedef struct _GimpConvolveOptions GimpConvolveOptions;
struct _ConvolveOptions
struct _GimpConvolveOptions
{
PaintOptions paint_options;
GimpPaintOptions paint_options;
ConvolveType type;
ConvolveType type_d;
GtkWidget *type_w[2];
ConvolveType type;
ConvolveType type_d;
GtkWidget *type_w[2];
gdouble rate;
gdouble rate_d;
GtkObject *rate_w;
gdouble rate;
gdouble rate_d;
GtkObject *rate_w;
};
GType gimp_convolve_get_type (void) G_GNUC_CONST;
GType gimp_convolve_get_type (void) G_GNUC_CONST;
GimpConvolveOptions * gimp_convolve_options_new (void);
#endif /* __GIMP_CONVOLVE_H__ */
......@@ -50,12 +50,12 @@ static void gimp_dodgeburn_make_luts (GimpPaintCore *paint_core,
static void gimp_dodgeburn_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state);
static void gimp_dodgeburn_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options);
GimpPaintOptions *paint_options);
static gfloat gimp_dodgeburn_highlights_lut_func (gpointer user_data,
gint nchannels,
......@@ -166,12 +166,12 @@ gimp_dodgeburn_make_luts (GimpPaintCore *paint_core,
static void
gimp_dodgeburn_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options,
GimpPaintOptions *paint_options,
GimpPaintCoreState paint_state)
{
DodgeBurnOptions *options;
GimpDodgeBurnOptions *options;
options = (DodgeBurnOptions *) paint_options;
options = (GimpDodgeBurnOptions *) paint_options;
switch (paint_state)
{
......@@ -206,12 +206,12 @@ gimp_dodgeburn_paint (GimpPaintCore *paint_core,
}
static void
gimp_dodgeburn_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
PaintOptions *paint_options)
gimp_dodgeburn_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
DodgeBurnOptions *options;
PaintPressureOptions *pressure_options;
GimpDodgeBurnOptions *options;
GimpPressureOptions *pressure_options;
GimpImage *gimage;
TempBuf *area;
TempBuf *orig;
......@@ -228,7 +228,7 @@ gimp_dodgeburn_motion (GimpPaintCore *paint_core,
(gimp_drawable_type (drawable) == GIMP_INDEXEDA_IMAGE))
return;
options = (DodgeBurnOptions *) paint_options;
options = (GimpDodgeBurnOptions *) paint_options;
pressure_options = paint_options->pressure_options;
......@@ -383,3 +383,27 @@ gimp_dodgeburn_shadows_lut_func (gpointer user_data,
return new_value;