Commit 0b12c776 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

use doubles for src coordinates. Added properties for "src-drawable",

2006-03-30  Sven Neumann  <sven@gimp.org>

	* app/paint/gimpclone.[ch]: use doubles for src coordinates. Added
	properties for "src-drawable", "src-x" and "src-y".

	* tools/pdbgen/pdb/paint_tools.pdb: resurrected cloning from
	drawables over the PDB. This used to be broken for quite a while.

	* app/pdb/paint_tools_cmds.c: regenerated.
parent 4b24ca37
2006-03-30 Sven Neumann <sven@gimp.org>
* app/paint/gimpclone.[ch]: use doubles for src coordinates. Added
properties for "src-drawable", "src-x" and "src-y".
* tools/pdbgen/pdb/paint_tools.pdb: resurrected cloning from
drawables over the PDB. This used to be broken for quite a while.
* app/pdb/paint_tools_cmds.c: regenerated.
2006-03-30 Michael Natterer <mitch@gimp.org>
 
* app/pdb/procedural_db.c (procedural_db_execute_proc): don't
......
......@@ -23,6 +23,8 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "paint-types.h"
#include "base/pixel-region.h"
......@@ -43,6 +45,24 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_SRC_DRAWABLE,
PROP_SRC_X,
PROP_SRC_Y
};
static void gimp_clone_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_clone_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
......@@ -92,12 +112,34 @@ gimp_clone_register (Gimp *gimp,
static void
gimp_clone_class_init (GimpCloneClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
GimpBrushCoreClass *brush_core_class = GIMP_BRUSH_CORE_CLASS (klass);
object_class->set_property = gimp_clone_set_property;
object_class->get_property = gimp_clone_get_property;
paint_core_class->paint = gimp_clone_paint;
brush_core_class->handles_changing_brush = TRUE;
g_object_class_install_property (object_class, PROP_SRC_DRAWABLE,
g_param_spec_object ("src-drawable",
NULL, NULL,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SRC_X,
g_param_spec_double ("src-x", NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE,
0.0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SRC_Y,
g_param_spec_double ("src-y", NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE,
0.0,
GIMP_PARAM_READWRITE));
}
static void
......@@ -109,14 +151,64 @@ gimp_clone_init (GimpClone *clone)
clone->src_x = 0.0;
clone->src_y = 0.0;
clone->orig_src_x = 0;
clone->orig_src_y = 0;
clone->orig_src_x = 0.0;
clone->orig_src_y = 0.0;
clone->offset_x = 0;
clone->offset_y = 0;
clone->offset_x = 0.0;
clone->offset_y = 0.0;
clone->first_stroke = TRUE;
}
static void
gimp_clone_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpClone *clone = GIMP_CLONE (object);
switch (property_id)
{
case PROP_SRC_DRAWABLE:
gimp_clone_set_src_drawable (clone, g_value_get_object (value));
break;
case PROP_SRC_X:
clone->src_x = g_value_get_double (value);
break;
case PROP_SRC_Y:
clone->src_y = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_clone_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpClone *clone = GIMP_CLONE (object);
switch (property_id)
{
case PROP_SRC_DRAWABLE:
g_value_set_object (value, clone->src_drawable);
break;
case PROP_SRC_X:
g_value_set_int (value, clone->src_x);
break;
case PROP_SRC_Y:
g_value_set_int (value, clone->src_y);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
......@@ -209,6 +301,9 @@ gimp_clone_paint (GimpPaintCore *paint_core,
default:
break;
}
g_object_notify (G_OBJECT (clone), "src-x");
g_object_notify (G_OBJECT (clone), "src-y");
}
static void
......@@ -507,4 +602,6 @@ gimp_clone_set_src_drawable (GimpClone *clone,
g_signal_connect (clone->src_drawable, "removed",
G_CALLBACK (gimp_clone_src_drawable_removed),
clone);
g_object_notify (G_OBJECT (clone), "src-drawable");
}
......@@ -41,14 +41,14 @@ struct _GimpClone
gboolean set_source;
GimpDrawable *src_drawable;
gint src_x;
gint src_y;
gdouble src_x;
gdouble src_y;
gint orig_src_x;
gint orig_src_y;
gdouble orig_src_x;
gdouble orig_src_y;
gint offset_x;
gint offset_y;
gdouble offset_x;
gdouble offset_y;
gboolean first_stroke;
};
......
......@@ -23,6 +23,8 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "paint-types.h"
#include "base/pixel-region.h"
......@@ -43,6 +45,24 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_SRC_DRAWABLE,
PROP_SRC_X,
PROP_SRC_Y
};
static void gimp_clone_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_clone_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
......@@ -92,12 +112,34 @@ gimp_clone_register (Gimp *gimp,
static void
gimp_clone_class_init (GimpCloneClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
GimpBrushCoreClass *brush_core_class = GIMP_BRUSH_CORE_CLASS (klass);
object_class->set_property = gimp_clone_set_property;
object_class->get_property = gimp_clone_get_property;
paint_core_class->paint = gimp_clone_paint;
brush_core_class->handles_changing_brush = TRUE;
g_object_class_install_property (object_class, PROP_SRC_DRAWABLE,
g_param_spec_object ("src-drawable",
NULL, NULL,
GIMP_TYPE_DRAWABLE,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SRC_X,
g_param_spec_double ("src-x", NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE,
0.0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SRC_Y,
g_param_spec_double ("src-y", NULL, NULL,
0, GIMP_MAX_IMAGE_SIZE,
0.0,
GIMP_PARAM_READWRITE));
}
static void
......@@ -109,14 +151,64 @@ gimp_clone_init (GimpClone *clone)
clone->src_x = 0.0;
clone->src_y = 0.0;
clone->orig_src_x = 0;
clone->orig_src_y = 0;
clone->orig_src_x = 0.0;
clone->orig_src_y = 0.0;
clone->offset_x = 0;
clone->offset_y = 0;
clone->offset_x = 0.0;
clone->offset_y = 0.0;
clone->first_stroke = TRUE;
}
static void
gimp_clone_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpClone *clone = GIMP_CLONE (object);
switch (property_id)
{
case PROP_SRC_DRAWABLE:
gimp_clone_set_src_drawable (clone, g_value_get_object (value));
break;
case PROP_SRC_X:
clone->src_x = g_value_get_double (value);
break;
case PROP_SRC_Y:
clone->src_y = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_clone_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpClone *clone = GIMP_CLONE (object);
switch (property_id)
{
case PROP_SRC_DRAWABLE:
g_value_set_object (value, clone->src_drawable);
break;
case PROP_SRC_X:
g_value_set_int (value, clone->src_x);
break;
case PROP_SRC_Y:
g_value_set_int (value, clone->src_y);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
......@@ -209,6 +301,9 @@ gimp_clone_paint (GimpPaintCore *paint_core,
default:
break;
}
g_object_notify (G_OBJECT (clone), "src-x");
g_object_notify (G_OBJECT (clone), "src-y");
}
static void
......@@ -507,4 +602,6 @@ gimp_clone_set_src_drawable (GimpClone *clone,
g_signal_connect (clone->src_drawable, "removed",
G_CALLBACK (gimp_clone_src_drawable_removed),
clone);
g_object_notify (G_OBJECT (clone), "src-drawable");
}
......@@ -41,14 +41,14 @@ struct _GimpClone
gboolean set_source;
GimpDrawable *src_drawable;
gint src_x;
gint src_y;
gdouble src_x;
gdouble src_y;
gint orig_src_x;
gint orig_src_y;
gdouble orig_src_x;
gdouble orig_src_y;
gint offset_x;
gint offset_y;
gdouble offset_x;
gdouble offset_y;
gboolean first_stroke;
};
......
......@@ -34,6 +34,7 @@
#include "core/gimpdrawable.h"
#include "core/gimppaintinfo.h"
#include "paint/gimppaintcore-stroke.h"
#include "paint/gimppaintcore.h"
#include "paint/gimppaintoptions.h"
static ProcRecord airbrush_proc;
......@@ -592,12 +593,15 @@ paint_tools_stroke (Gimp *gimp,
GimpPaintOptions *options,
GimpDrawable *drawable,
gint n_strokes,
gdouble *strokes)
gdouble *strokes,
const gchar *first_property_name,
...)
{
GimpPaintCore *core;
GimpCoords *coords;
gboolean retval;
gint i;
va_list args;
n_strokes /= 2; /* #doubles -> #points */
......@@ -609,7 +613,10 @@ paint_tools_stroke (Gimp *gimp,
FALSE);
gimp_context_set_parent (GIMP_CONTEXT (options), context);
core = g_object_new (options->paint_info->paint_type, NULL);
va_start (args, first_property_name);
core = GIMP_PAINT_CORE (g_object_new_valist (options->paint_info->paint_type,
first_property_name, args));
va_end (args);
coords = g_new (GimpCoords, n_strokes);
......@@ -665,7 +672,7 @@ airbrush_invoker (ProcRecord *proc_record,
NULL);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -715,7 +722,7 @@ airbrush_default_invoker (ProcRecord *proc_record,
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -776,19 +783,12 @@ clone_invoker (ProcRecord *proc_record,
"clone-type", clone_type,
NULL);
#ifdef __GNUC__
#warning FIXME: re-enable clone src_drawable
#endif
#if 0
FIXME
core->src_drawable = src_drawable;
core->src_x = srx_x;
core->src_y = src_y;
#endif
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes,
"src-drawable", src_drawable,
"src-x", src_x,
"src-y", src_y,
NULL);
}
}
......@@ -838,7 +838,7 @@ clone_default_invoker (ProcRecord *proc_record,
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -897,7 +897,7 @@ convolve_invoker (ProcRecord *proc_record,
NULL);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -947,7 +947,7 @@ convolve_default_invoker (ProcRecord *proc_record,
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1009,7 +1009,7 @@ dodgeburn_invoker (ProcRecord *proc_record,
NULL);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1059,7 +1059,7 @@ dodgeburn_default_invoker (ProcRecord *proc_record,
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1118,7 +1118,7 @@ eraser_invoker (ProcRecord *proc_record,
NULL);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1168,7 +1168,7 @@ eraser_default_invoker (ProcRecord *proc_record,
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1232,7 +1232,7 @@ paintbrush_invoker (ProcRecord *proc_record,
NULL);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1282,7 +1282,7 @@ paintbrush_default_invoker (ProcRecord *proc_record,
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1332,7 +1332,7 @@ pencil_invoker (ProcRecord *proc_record,
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1388,7 +1388,7 @@ smudge_invoker (ProcRecord *proc_record,
NULL);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......@@ -1438,7 +1438,7 @@ smudge_default_invoker (ProcRecord *proc_record,
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
......
......@@ -67,7 +67,7 @@ HELP
NULL);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
CODE
......@@ -81,8 +81,8 @@ time-dependent.
BLURB
$help = <<'HELP';
This tool simulates the use of an airbrush. It is similar to gimp_airbrush
except that the pressure is derived from the airbrush tools options box.
This tool simulates the use of an airbrush. It is similar to gimp_airbrush
except that the pressure is derived from the airbrush tools options box.
It the option has not been set the default for the option will be used.
HELP
......@@ -107,7 +107,7 @@ HELP
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
CODE
......@@ -121,8 +121,8 @@ Clone from the source to the dest drawable using the current brush
BLURB
$help = <<'HELP';
This tool clones (copies) from the source drawable starting at the specified
source coordinates to the dest drawable. If the "clone_type" argument is set
This tool clones (copies) from the source drawable starting at the specified
source coordinates to the dest drawable. If the "clone_type" argument is set
to PATTERN-CLONE, then the current pattern is used as the source and the
"src_drawable" argument is ignored. Pattern cloning assumes a tileable
pattern and mods the sum of the src coordinates and subsequent stroke offsets
......@@ -165,19 +165,12 @@ HELP
"clone-type", clone_type,
NULL);
#ifdef __GNUC__
#warning FIXME: re-enable clone src_drawable
#endif
#if 0
FIXME
core->src_drawable = src_drawable;
core->src_x = srx_x;
core->src_y = src_y;
#endif
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes,
"src-drawable", src_drawable,
"src-x", src_x,
"src-y", src_y,
NULL);
}
}
CODE
......@@ -190,9 +183,9 @@ Clone from the source to the dest drawable using the current brush
BLURB
$help = <<'HELP';
This tool clones (copies) from the source drawable starting at the specified
This tool clones (copies) from the source drawable starting at the specified
source coordinates to the dest drawable. This function performs exactly
the same as the gimp_clone function except that the tools arguments are
the same as the gimp_clone function except that the tools arguments are
obtained from the clones option dialog. It this dialog has not been activated
then the dialogs default values will be used.
HELP
......@@ -218,7 +211,7 @@ HELP
GimpPaintOptions *options = gimp_paint_options_new (info);
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes);
num_strokes, strokes, NULL);
}
}
CODE
......@@ -232,8 +225,8 @@ sub convolve_default {
$help = <<'HELP';
This tool convolves the specified drawable with either a sharpening or blurring
kernel. This function performs exactly the same as the gimp_convolve
function except that the tools arguments are obtained from the convolve
option dialog. It this dialog has not been activated then the dialogs
function except that the tools arguments are obtained from the convolve
option dialog. It this dialog has not been activated then the dialogs
default values will be used.
HELP
......@@ -258,7 +251,7 @@ HELP
GimpPaintOptions *options = gimp_paint_options_new (info);