Commit 6c28319b authored by BST 1999 Andy Thomas's avatar BST 1999 Andy Thomas Committed by Andy Thomas
Browse files

app/indicator_area.c app/paths_dialog.c app/tools_cmds.c app/airbrush.c


Mon Jul 19 23:40:56 BST 1999 Andy Thomas <alt@gimp.org>

	* app/indicator_area.c
	* app/paths_dialog.c
	* app/tools_cmds.c
	* app/airbrush.c
	* app/airbrush.h
	* app/bezier_select.c
	* app/paintbrush.c
	* app/paintbrush.h
	* app/clone.c
	* app/clone.h
	* app/eraser.c
	* app/eraser.h
	* app/convolve.c
	* app/convolve.h
	* app/smudge.c
	* app/smudge.h
	* app/dodgeburn.c
	* app/dodgeburn.h
	* app/internal_procs.c
	* plug-ins/sel2path/sel2path.c
	* tools/pdbgen/pdb/tools.pdb
	* tools/pdbgen/enums.pl

	1) Fixed the brushpreview popup problem where it remained onscreen
           if the mouse button was released in another GTK window that accepted
	   mouse events.

	2) Selection to path now works on all types of images (it should have
	   anyway).

	3) Fixed PDB so you can once again use the PDB interfaces to the clone
	   and airbrush tools.

	4) PDB Function to add a path to an image now adds it correctly.

	5) airbrush/paintbrush/clone/eraser/convolve New PDB functions that
           use the options dialogs settings (or sane defaults if option dialog
           not present)

	6) Added PDB functions for Smudge & DodgeBurn tools.

	7) Path stroke command (from the LCP dialog) can now use any of the
	   painting tools (airbrush/paintbrush/clone/eraser/convolve/smudge/
           dodgeburn except ink). Just have the tool selected when you
	   press the stroke button.
parent 645f8535
Mon Jul 19 21:33:56 BST 1999 Andy Thomas <alt@gimp.org>
* app/indicator_area.c
* app/paths_dialog.c
* app/tools_cmds.c
* app/airbrush.c
* app/airbrush.h
* app/bezier_select.c
* app/paintbrush.c
* app/paintbrush.h
* app/clone.c
* app/clone.h
* app/eraser.c
* app/eraser.h
* app/convolve.c
* app/convolve.h
* app/smudge.c
* app/smudge.h
* app/dodgeburn.c
* app/dodgeburn.h
* app/internal_procs.c
* plug-ins/sel2path/sel2path.c
* tools/pdbgen/pdb/tools.pdb
* tools/pdbgen/enums.pl
1) Fixed the brushpreview popup problem where it remained onscreen
if the mouse button was released in another GTK window that accepted
mouse events.
2) Selection to path now works on all types of images (it should have
anyway).
3) Fixed PDB so you can once again use the PDB interfaces to the clone
and airbrush tools.
4) PDB Function to add a path to an image now adds it correctly.
5) airbrush/paintbrush/clone/eraser/convolve New PDB functions that
use the options dialogs settings (or sane defaults if option dialog
not present)
6) Added PDB functions for Smudge & DodgeBurn tools.
7) Path stroke command (from the LCP dialog) can now use any of the
painting tools (airbrush/paintbrush/clone/eraser/convolve/smudge/
dodgeburn except ink). Just have the tool selected when you
press the stroke button.
Mon Jul 19 21:40:48 MEST 1999 Sven Neumann <sven@gimp.org>
* app/brush_select.c: update the brush title when editing a brush
......
......@@ -36,6 +36,9 @@
/* The maximum amount of pressure that can be exerted */
#define MAX_PRESSURE 0.075
/* Default pressure setting */
#define AIRBRUSH_PRESSURE_DEFAULT 10.0
#define OFF 0
#define ON 1
......@@ -110,7 +113,7 @@ airbrush_options_new (void)
AIRBRUSH,
airbrush_options_reset);
options->rate = options->rate_d = 80.0;
options->pressure = options->pressure_d = 10.0;
options->pressure = options->pressure_d = AIRBRUSH_PRESSURE_DEFAULT;
/* the main vbox */
vbox = ((ToolOptions *) options)->main_vbox;
......@@ -316,6 +319,20 @@ airbrush_non_gui_paint_func (PaintCore *paint_core,
return NULL;
}
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);
}
gboolean
airbrush_non_gui (GimpDrawable *drawable,
double pressure,
......@@ -330,6 +347,8 @@ airbrush_non_gui (GimpDrawable *drawable,
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = airbrush_non_gui_paint_func;
non_gui_pressure = pressure;
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];
......
......@@ -21,10 +21,11 @@
#include "tools.h"
#include "paint_core.h"
void * airbrush_paint_func (PaintCore *, GimpDrawable *, int);
gboolean airbrush_non_gui (GimpDrawable *, double, int, double *);
Tool * tools_new_airbrush (void);
void tools_free_airbrush (Tool *);
void * airbrush_paint_func (PaintCore *, GimpDrawable *, int);
gboolean airbrush_non_gui (GimpDrawable *, double, int, double *);
gboolean airbrush_non_gui_default (GimpDrawable *, int, double *);
Tool * tools_new_airbrush (void);
void tools_free_airbrush (Tool *);
#endif /* __AIRBRUSH_H__ */
......@@ -3027,6 +3027,7 @@ bezier_stack_points (BezierSelect *bezier_sel,
}
/* allow one pixel fluctuation */
error = 2.0 / MAX(maxx - minx, maxy - miny);
error = 0.0; /* ALT */
/* add the start point */
bezier_stack_points_aux (points, 0, 0, 0, rpnts);
......@@ -3046,6 +3047,7 @@ bezier_gen_points(BezierSelect *bezier_sel,
BezierPoint * start_pt;
BezierPoint * next_curve;
BezierRenderPnts *next_rpnts = rpnts;
gint point_counts = 0;
/* stack points */
points = bezier_sel->points;
......@@ -3054,6 +3056,9 @@ bezier_gen_points(BezierSelect *bezier_sel,
if(bezier_sel->num_points >= 4)
{
do {
point_counts = count_points_on_curve(points);
if(point_counts < 4)
return(TRUE);
do {
bezier_draw_segment (bezier_sel, points,
SUBDIVIDE, IMAGE_COORDS,
......@@ -3075,6 +3080,48 @@ bezier_gen_points(BezierSelect *bezier_sel,
return (TRUE);
}
static guchar *
active_tool_PDB_string()
{
guchar *toolStr = "gimp_paintbrush_default";
/* Return the correct PDB function for the active tool */
/* The default is paintbrush if the tool is not recognised */
if(!active_tool)
return toolStr;
switch(active_tool->type)
{
case PENCIL:
toolStr = "gimp_pencil";
break;
case PAINTBRUSH:
toolStr = "gimp_paintbrush_default";
break;
case ERASER:
toolStr = "gimp_eraser_default";
break;
case AIRBRUSH:
toolStr = "gimp_airbrush_default";
break;
case CLONE:
toolStr = "gimp_clone_default";
break;
case CONVOLVE:
toolStr = "gimp_convolve_default";
break;
case SMUDGE:
toolStr = "gimp_smudge_default";
break;
case DODGEBURN:
toolStr = "gimp_dodgeburn_default";
break;
default:
toolStr = "gimp_paintbrush_default";
}
return toolStr;
}
void
bezier_stroke (BezierSelect *bezier_sel,
GDisplay *gdisp,
......@@ -3110,14 +3157,12 @@ bezier_stroke (BezierSelect *bezier_sel,
}
}
return_vals = procedural_db_run_proc ("gimp_paintbrush",
/* Stroke with the correct tool */
return_vals = procedural_db_run_proc (active_tool_PDB_string(),
&nreturn_vals,
PDB_DRAWABLE, drawable_ID (drawable),
PDB_FLOAT, (gdouble) 0,
PDB_INT32, (gint32) rpnts->num_stroke_points * 2,
PDB_FLOATARRAY, rpnts->stroke_points,
PDB_INT32, 0 /* continuous */,
PDB_FLOAT, (gdouble) 0 /*no grad*/,
PDB_END);
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
......@@ -3327,3 +3372,5 @@ bezier_distance_along(BezierSelect *bezier_sel,
g_free(bdist);
return (ret);
}
......@@ -36,6 +36,10 @@
#define TARGET_HEIGHT 15
#define TARGET_WIDTH 15
/* default types */
#define CLONE_DEFAULT_TYPE IMAGE_CLONE
#define CLONE_DEFAULT_ALIGNED AlignNo
/* the clone structures */
typedef enum
......@@ -152,8 +156,8 @@ clone_options_new (void)
paint_options_init ((PaintOptions *) options,
CLONE,
clone_options_reset);
options->type = options->type_d = IMAGE_CLONE;
options->aligned = options->aligned_d = AlignNo;
options->type = options->type_d = CLONE_DEFAULT_TYPE;
options->aligned = options->aligned_d = CLONE_DEFAULT_ALIGNED;
/* the main vbox */
vbox = ((ToolOptions *) options)->main_vbox;
......@@ -687,6 +691,32 @@ clone_non_gui_paint_func (PaintCore *paint_core,
return NULL;
}
gboolean
clone_non_gui_default (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
{
GimpDrawable *src_drawable = NULL;
CloneType clone_type = CLONE_DEFAULT_TYPE;
double local_src_x = 0.0;
double local_src_y = 0.0;
CloneOptions *options = clone_options;
if(options)
{
clone_type = options->type;
src_drawable = src_drawable_;
local_src_x = src_x;
local_src_y = src_y;
}
return clone_non_gui(drawable,
src_drawable,
clone_type,
local_src_x,local_src_y,
num_strokes,stroke_array);
}
gboolean
clone_non_gui (GimpDrawable *drawable,
GimpDrawable *src_drawable,
......@@ -703,6 +733,8 @@ clone_non_gui (GimpDrawable *drawable,
{
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = clone_non_gui_paint_func;
non_gui_type = clone_type;
non_gui_src_drawable = src_drawable;
......
......@@ -30,6 +30,7 @@ typedef enum
void * clone_paint_func (PaintCore *, GimpDrawable *, int);
gboolean clone_non_gui (GimpDrawable *, GimpDrawable *, CloneType,
double, double, int, double *);
gboolean clone_non_gui_default (GimpDrawable *, int, double *);
Tool * tools_new_clone (void);
void tools_free_clone (Tool *);
......
......@@ -39,6 +39,10 @@
#define MIN_SHARPEN -512
#define MAX_SHARPEN -64
/* defaults */
#define DEFAULT_CONVOLVE_PRESSURE 50.0
#define DEFAULT_CONVOLVE_TYPE BLUR_CONVOLVE
/* the convolve structures */
typedef struct _ConvolveOptions ConvolveOptions;
......@@ -64,6 +68,9 @@ static int matrix [25];
static int matrix_size;
static int matrix_divisor;
static ConvolveType non_gui_type;
static double non_gui_pressure;
static float custom_matrix [25] =
{
0, 0, 0, 0, 0,
......@@ -98,8 +105,7 @@ static void integer_matrix (float *, int *, int);
static void copy_matrix (float *, float *, int);
static int sum_matrix (int *, int);
static void convolve_motion (PaintCore *, GimpDrawable *);
static void convolve_motion (PaintCore *, GimpDrawable *, ConvolveType, double);
/* functions */
......@@ -134,8 +140,8 @@ convolve_options_new (void)
paint_options_init ((PaintOptions *) options,
CONVOLVE,
convolve_options_reset);
options->type = options->type_d = BLUR_CONVOLVE;
options->pressure = options->pressure_d = 50.0;
options->type = options->type_d = DEFAULT_CONVOLVE_TYPE;
options->pressure = options->pressure_d = DEFAULT_CONVOLVE_PRESSURE;
/* the main vbox */
vbox = ((ToolOptions *) options)->main_vbox;
......@@ -182,7 +188,7 @@ convolve_paint_func (PaintCore *paint_core,
switch (state)
{
case MOTION_PAINT:
convolve_motion (paint_core, drawable);
convolve_motion (paint_core, drawable,convolve_options->type, convolve_options->pressure);
break;
}
......@@ -248,8 +254,10 @@ tools_free_convolve (Tool *tool)
}
static void
convolve_motion (PaintCore *paint_core,
GimpDrawable *drawable)
convolve_motion (PaintCore *paint_core,
GimpDrawable *drawable,
ConvolveType type,
double pressure)
{
GImage *gimage;
TempBuf * area;
......@@ -278,7 +286,7 @@ convolve_motion (PaintCore *paint_core,
destPR.rowstride = area->width * destPR.bytes;
destPR.data = temp_buf_data (area);
calculate_matrix (convolve_options->type, convolve_options->pressure,
calculate_matrix (type, pressure,
paint_core->curpressure);
/* convolve the source image with the convolve mask */
......@@ -433,14 +441,33 @@ convolve_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
convolve_motion (paint_core, drawable);
convolve_motion (paint_core, drawable,non_gui_type,non_gui_pressure);
return NULL;
}
gboolean
convolve_non_gui_default (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
{
double pressure = DEFAULT_CONVOLVE_PRESSURE;
ConvolveType type = DEFAULT_CONVOLVE_TYPE;
ConvolveOptions *options = convolve_options;
if(options)
{
pressure = options->pressure;
type = options->type;
}
return convolve_non_gui(drawable,pressure,type,num_strokes,stroke_array);
}
gboolean
convolve_non_gui (GimpDrawable *drawable,
double pressure,
ConvolveType type,
int num_strokes,
double *stroke_array)
{
......@@ -451,6 +478,9 @@ convolve_non_gui (GimpDrawable *drawable,
{
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = convolve_non_gui_paint_func;
non_gui_type = type;
non_gui_pressure = pressure;
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];
......
......@@ -29,7 +29,8 @@ typedef enum /*< chop=_CONVOLVE >*/
} ConvolveType;
void * convolve_paint_func (PaintCore *, GimpDrawable *, int);
gboolean convolve_non_gui (GimpDrawable *, double, int, double *);
gboolean convolve_non_gui (GimpDrawable *, double, ConvolveType, int, double *);
gboolean convolve_non_gui_default (GimpDrawable *, int, double *);
Tool * tools_new_convolve (void);
void tools_free_convolve (Tool *);
......
......@@ -58,7 +58,8 @@ struct _DodgeBurnOptions
GimpLut *lut;
};
static void dodgeburn_make_luts ( PaintCore *, GimpDrawable *);
static void
dodgeburn_make_luts ( PaintCore *, double, DodgeBurnType, DodgeBurnMode, GimpLut *, GimpDrawable *);
static gfloat dodgeburn_highlights_lut_func(void *, int, int, gfloat);
static gfloat dodgeburn_midtones_lut_func(void *, int, int, gfloat);
......@@ -72,7 +73,16 @@ gfloat dodgeburn_shadows(void *, int, int, gfloat);
/* the dodgeburn tool options */
static DodgeBurnOptions * dodgeburn_options = NULL;
static void dodgeburn_motion (PaintCore *, GimpDrawable *);
/* Non gui function */
static double non_gui_exposure;
static GimpLut *non_gui_lut;
/* Default values */
#define DODGEBURN_DEFAULT_TYPE DODGE
#define DODGEBURN_DEFAULT_EXPOSURE 50.0
#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS
static void dodgeburn_motion (PaintCore *, double, GimpLut *, GimpDrawable *);
static void dodgeburn_init (PaintCore *, GimpDrawable *);
static void dodgeburn_finish (PaintCore *, GimpDrawable *);
......@@ -121,9 +131,9 @@ dodgeburn_options_new (void)
DODGEBURN,
dodgeburn_options_reset);
options->type = options->type_d = DODGE;
options->exposure = options->exposure_d = 50.0;
options->mode = options->mode_d = DODGEBURN_HIGHLIGHTS;
options->type = options->type_d = DODGEBURN_DEFAULT_TYPE;
options->exposure = options->exposure_d = DODGEBURN_DEFAULT_EXPOSURE;
options->mode = options->mode_d = DODGEBURN_DEFAULT_MODE;
/* the main vbox */
vbox = ((ToolOptions *) options)->main_vbox;
......@@ -187,7 +197,7 @@ dodgeburn_paint_func (PaintCore *paint_core,
dodgeburn_init (paint_core, drawable);
break;
case MOTION_PAINT:
dodgeburn_motion (paint_core, drawable);
dodgeburn_motion (paint_core, dodgeburn_options->exposure, dodgeburn_options->lut, drawable);
break;
case FINISH_PAINT:
dodgeburn_finish (paint_core, drawable);
......@@ -199,7 +209,7 @@ dodgeburn_paint_func (PaintCore *paint_core,
static void
dodgeburn_finish ( PaintCore *paint_core,
GimpDrawable * drawable)
GimpDrawable * drawable)
{
/* Here we destroy the luts to do the painting with.*/
if (dodgeburn_options->lut)
......@@ -214,24 +224,34 @@ dodgeburn_init ( PaintCore *paint_core,
GimpDrawable * drawable)
{
/* Here we create the luts to do the painting with.*/
dodgeburn_make_luts (paint_core, drawable);
dodgeburn_options->lut = gimp_lut_new();
dodgeburn_make_luts (paint_core,
dodgeburn_options->exposure,
dodgeburn_options->type,
dodgeburn_options->mode,
dodgeburn_options->lut,
drawable);
}
static void
dodgeburn_make_luts ( PaintCore *paint_core,
GimpDrawable * drawable)
dodgeburn_make_luts ( PaintCore *paint_core,
double db_exposure,
DodgeBurnType type,
DodgeBurnMode mode,
GimpLut *lut,
GimpDrawable *drawable)
{
GimpLutFunc lut_func;
int nchannels = gimp_drawable_bytes (drawable);
gfloat exposure = (dodgeburn_options->exposure)/100.0;
static gfloat exposure;
exposure = (db_exposure)/100.0;
/* make the exposure negative if burn for luts*/
if (dodgeburn_options->type == BURN)
if (type == BURN)
exposure = -exposure;
dodgeburn_options->lut = gimp_lut_new();
switch (dodgeburn_options->mode)
switch (mode)
{
case DODGEBURN_HIGHLIGHTS:
lut_func = dodgeburn_highlights_lut_func;
......@@ -247,7 +267,7 @@ dodgeburn_make_luts ( PaintCore *paint_core,
break;
}
gimp_lut_setup_exact (dodgeburn_options->lut,
gimp_lut_setup_exact (lut,
lut_func, (void *)&exposure,
nchannels);
......@@ -314,8 +334,10 @@ tools_free_dodgeburn (Tool *tool)
}
static void
dodgeburn_motion (PaintCore *paint_core,
GimpDrawable *drawable)
dodgeburn_motion (PaintCore *paint_core,
double dodgeburn_exposure,
GimpLut *lut,
GimpDrawable *drawable)
{
GImage *gimage;
TempBuf * area;
......@@ -374,10 +396,10 @@ dodgeburn_motion (PaintCore *paint_core,
brush_opacity = gimp_context_get_opacity (NULL);
/* Enable pressure sensitive exposure */
exposure = ((dodgeburn_options->exposure)/100.0 * (paint_core->curpressure)/0.5);
exposure = ((dodgeburn_exposure)/100.0 * (paint_core->curpressure)/0.5);
/* DodgeBurn the region */
gimp_lut_process (dodgeburn_options->lut, &srcPR, &tempPR);
gimp_lut_process (lut, &srcPR, &tempPR);
/* The dest is the paint area we got above (= canvas_buf) */
destPR.bytes = area->bytes;
......@@ -407,16 +429,38 @@ dodgeburn_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
dodgeburn_motion (paint_core, drawable);
dodgeburn_motion (paint_core, non_gui_exposure, non_gui_lut, drawable);
return NULL;
}
gboolean
dodgeburn_non_gui_default (GimpDrawable *drawable,
int num_strokes,
double *stroke_array)
{
double exposure = DODGEBURN_DEFAULT_TYPE;
DodgeBurnType type = DODGEBURN_DEFAULT_TYPE;
DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE;
DodgeBurnOptions *options = dodgeburn_options;
if(options)
{
exposure = dodgeburn_options->exposure;
type = dodgeburn_options->type;
mode = dodgeburn_options->mode;
}
return dodgeburn_non_gui(drawable,exposure,type,mode,num_strokes,stroke_array);
}
gboolean
dodgeburn_non_gui (GimpDrawable *drawable,
double pressure,
int num_strokes,
double *stroke_array)
double exposure,
DodgeBurnType type,
DodgeBurnMode mode,
int num_strokes,
double *stroke_array)
{
int i;
......@@ -426,6 +470,15 @@ dodgeburn_non_gui (GimpDrawable *drawable,
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = dodgeburn_non_gui_paint_func;
non_gui_exposure = exposure;
non_gui_lut = gimp_lut_new();
dodgeburn_make_luts (&non_gui_paint_core,
exposure,
type,
mode,
non_gui_lut,
drawable);
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];
......@@ -448,6 +501,9 @@ dodgeburn_non_gui (GimpDrawable *drawable,
/* Cleanup */
paint_core_cleanup ();
gimp_lut_free (non_gui_lut);
return TRUE;
}
else
......