renamed enum GimpCloneAlignMode to GimpSourceAlignMode.

2006-09-03  Michael Natterer  <mitch@gimp.org>

	* app/paint/paint-enums.[ch]: renamed enum GimpCloneAlignMode to
	GimpSourceAlignMode.

	* app/paint/Makefile.am
	* app/paint/gimpsourcecore.[ch]
	* app/paint/gimpsourceoptions.[ch]: new classes which contain the
	source selection functionality factored out of the clone core and
	options.

	* app/paint/gimpclone.[ch]
	* app/paint/gimpcloneoptions.[ch]: remove that functionality here
	and derive from the new classes.

	* app/tools/gimpclonetool.c: changed accordingly.
This commit is contained in:
Michael Natterer 2006-09-02 22:39:26 +00:00 committed by Michael Natterer
parent db52679583
commit 47b50d9123
14 changed files with 397 additions and 901 deletions

View File

@ -1,3 +1,20 @@
2006-09-03 Michael Natterer <mitch@gimp.org>
* app/paint/paint-enums.[ch]: renamed enum GimpCloneAlignMode to
GimpSourceAlignMode.
* app/paint/Makefile.am
* app/paint/gimpsourcecore.[ch]
* app/paint/gimpsourceoptions.[ch]: new classes which contain the
source selection functionality factored out of the clone core and
options.
* app/paint/gimpclone.[ch]
* app/paint/gimpcloneoptions.[ch]: remove that functionality here
and derive from the new classes.
* app/tools/gimpclonetool.c: changed accordingly.
2006-09-02 Michael Natterer <mitch@gimp.org>
Merged the "soc-2006-healing-brush" branch. That branch is now

View File

@ -71,7 +71,11 @@ libapppaint_a_sources = \
gimpsmudge.c \
gimpsmudge.h \
gimpsmudgeoptions.c \
gimpsmudgeoptions.h
gimpsmudgeoptions.h \
gimpsourcecore.c \
gimpsourcecore.h \
gimpsourceoptions.c \
gimpsourceoptions.h
libapppaint_a_built_sources = paint-enums.c

View File

@ -45,56 +45,38 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_SRC_DRAWABLE,
PROP_SRC_X,
PROP_SRC_Y
};
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
static void gimp_clone_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static void gimp_clone_line_image (GimpImage *dest,
GimpImage *src,
GimpDrawable *d_drawable,
GimpPickable *s_pickable,
guchar *s,
guchar *d,
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_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);
G_DEFINE_TYPE (GimpClone, gimp_clone, GIMP_TYPE_SOURCE_CORE)
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
static void gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static void gimp_clone_line_image (GimpImage *dest,
GimpImage *src,
GimpDrawable *d_drawable,
GimpPickable *s_pickable,
guchar *s,
guchar *d,
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);
G_DEFINE_TYPE (GimpClone, gimp_clone, GIMP_TYPE_BRUSH_CORE)
#define parent_class gimp_clone_parent_class
void
@ -112,101 +94,17 @@ 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);
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
GimpSourceCoreClass *source_core_class = GIMP_SOURCE_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;
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));
source_core_class->motion = gimp_clone_motion;
}
static void
gimp_clone_init (GimpClone *clone)
{
clone->set_source = FALSE;
clone->src_drawable = NULL;
clone->src_x = 0.0;
clone->src_y = 0.0;
clone->orig_src_x = 0.0;
clone->orig_src_y = 0.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
@ -216,107 +114,37 @@ gimp_clone_paint (GimpPaintCore *paint_core,
GimpPaintState paint_state,
guint32 time)
{
GimpClone *clone = GIMP_CLONE (paint_core);
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
switch (paint_state)
{
case GIMP_PAINT_STATE_INIT:
if (clone->set_source)
{
gimp_clone_set_src_drawable (clone, drawable);
clone->src_x = paint_core->cur_coords.x;
clone->src_y = paint_core->cur_coords.y;
clone->first_stroke = TRUE;
}
else if (options->align_mode == GIMP_CLONE_ALIGN_NO)
{
clone->orig_src_x = clone->src_x;
clone->orig_src_y = clone->src_y;
clone->first_stroke = TRUE;
}
if (options->clone_type == GIMP_PATTERN_CLONE)
if (! gimp_context_get_pattern (context))
if (! gimp_context_get_pattern (GIMP_CONTEXT (options)))
g_message (_("No patterns available for this operation."));
break;
case GIMP_PAINT_STATE_MOTION:
if (clone->set_source)
{
/* If the control key is down, move the src target and return */
clone->src_x = paint_core->cur_coords.x;
clone->src_y = paint_core->cur_coords.y;
clone->first_stroke = TRUE;
}
else
{
/* otherwise, update the target */
gint dest_x;
gint dest_y;
dest_x = paint_core->cur_coords.x;
dest_y = paint_core->cur_coords.y;
if (options->align_mode == GIMP_CLONE_ALIGN_REGISTERED)
{
clone->offset_x = 0;
clone->offset_y = 0;
}
else if (options->align_mode == GIMP_CLONE_ALIGN_FIXED)
{
clone->offset_x = clone->src_x - dest_x;
clone->offset_y = clone->src_y - dest_y;
}
else if (clone->first_stroke)
{
clone->offset_x = clone->src_x - dest_x;
clone->offset_y = clone->src_y - dest_y;
clone->first_stroke = FALSE;
}
clone->src_x = dest_x + clone->offset_x;
clone->src_y = dest_y + clone->offset_y;
gimp_clone_motion (paint_core, drawable, paint_options);
}
break;
case GIMP_PAINT_STATE_FINISH:
if (options->align_mode == GIMP_CLONE_ALIGN_NO && ! clone->first_stroke)
{
clone->src_x = clone->orig_src_x;
clone->src_y = clone->orig_src_y;
}
break;
default:
break;
}
g_object_notify (G_OBJECT (clone), "src-x");
g_object_notify (G_OBJECT (clone), "src-y");
GIMP_PAINT_CORE_CLASS (parent_class)->paint (paint_core, drawable,
paint_options, paint_state,
time);
}
static void
gimp_clone_motion (GimpPaintCore *paint_core,
gimp_clone_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
GimpClone *clone = GIMP_CLONE (paint_core);
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
GimpSourceOptions *source_options = GIMP_SOURCE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpPressureOptions *pressure_options = paint_options->pressure_options;
GimpImage *image;
GimpImage *src_image = NULL;
GimpImage *src_image = NULL;
GimpPickable *src_pickable = NULL;
guchar *s;
guchar *d;
@ -339,25 +167,26 @@ gimp_clone_motion (GimpPaintCore *paint_core,
return;
/* make local copies because we change them */
offset_x = clone->offset_x;
offset_y = clone->offset_y;
offset_x = source_core->offset_x;
offset_y = source_core->offset_y;
/* Make sure we still have a source if we are doing image cloning */
if (options->clone_type == GIMP_IMAGE_CLONE)
{
if (! clone->src_drawable)
if (! source_core->src_drawable)
return;
src_pickable = GIMP_PICKABLE (clone->src_drawable);
src_pickable = GIMP_PICKABLE (source_core->src_drawable);
src_image = gimp_pickable_get_image (src_pickable);
if (options->sample_merged)
if (source_options->sample_merged)
{
gint off_x, off_y;
src_pickable = GIMP_PICKABLE (src_image->projection);
gimp_item_offsets (GIMP_ITEM (clone->src_drawable), &off_x, &off_y);
gimp_item_offsets (GIMP_ITEM (source_core->src_drawable),
&off_x, &off_y);
offset_x += off_x;
offset_y += off_y;
@ -396,8 +225,11 @@ gimp_clone_motion (GimpPaintCore *paint_core,
* Otherwise, we need a call to get_orig_image to make sure
* we get a copy of the unblemished (offset) image
*/
if (( options->sample_merged && (src_image != image)) ||
(! options->sample_merged && (clone->src_drawable != drawable)))
if ((source_options->sample_merged &&
(src_image != image)) ||
(! source_options->sample_merged &&
(source_core->src_drawable != drawable)))
{
pixel_region_init (&srcPR, src_tiles,
x1, y1, x2 - x1, y2 - y1, FALSE);
@ -407,7 +239,7 @@ gimp_clone_motion (GimpPaintCore *paint_core,
TempBuf *orig;
/* get the original image */
if (options->sample_merged)
if (source_options->sample_merged)
orig = gimp_paint_core_get_orig_proj (paint_core,
src_pickable,
x1, y1, x2, y2);
@ -489,7 +321,8 @@ gimp_clone_motion (GimpPaintCore *paint_core,
* Otherwise the stuff we paint is seamless
* and we don't need intermediate masking.
*/
options->align_mode == GIMP_CLONE_ALIGN_FIXED ?
source_options->align_mode ==
GIMP_SOURCE_ALIGN_FIXED ?
GIMP_PAINT_INCREMENTAL : GIMP_PAINT_CONSTANT);
}
@ -569,39 +402,3 @@ gimp_clone_line_pattern (GimpImage *dest,
d += bytes;
}
}
static void
gimp_clone_src_drawable_removed (GimpDrawable *drawable,
GimpClone *clone)
{
if (drawable == clone->src_drawable)
{
clone->src_drawable = NULL;
}
g_signal_handlers_disconnect_by_func (drawable,
gimp_clone_src_drawable_removed,
clone);
}
static void
gimp_clone_set_src_drawable (GimpClone *clone,
GimpDrawable *drawable)
{
if (clone->src_drawable == drawable)
return;
if (clone->src_drawable)
g_signal_handlers_disconnect_by_func (clone->src_drawable,
gimp_clone_src_drawable_removed,
clone);
clone->src_drawable = drawable;
if (clone->src_drawable)
g_signal_connect (clone->src_drawable, "removed",
G_CALLBACK (gimp_clone_src_drawable_removed),
clone);
g_object_notify (G_OBJECT (clone), "src-drawable");
}

View File

@ -20,7 +20,7 @@
#define __GIMP_CLONE_H__
#include "gimpbrushcore.h"
#include "gimpsourcecore.h"
#define GIMP_TYPE_CLONE (gimp_clone_get_type ())
@ -36,25 +36,12 @@ typedef struct _GimpCloneClass GimpCloneClass;
struct _GimpClone
{
GimpBrushCore parent_instance;
gboolean set_source;
GimpDrawable *src_drawable;
gdouble src_x;
gdouble src_y;
gdouble orig_src_x;
gdouble orig_src_y;
gdouble offset_x;
gdouble offset_y;
gboolean first_stroke;
GimpSourceCore parent_instance;
};
struct _GimpCloneClass
{
GimpBrushCoreClass parent_class;
GimpSourceCoreClass parent_class;
};

View File

@ -27,20 +27,13 @@
#include "gimpcloneoptions.h"
#define CLONE_DEFAULT_TYPE GIMP_IMAGE_CLONE
#define CLONE_DEFAULT_ALIGN_MODE GIMP_CLONE_ALIGN_NO
enum
{
PROP_0,
PROP_CLONE_TYPE,
PROP_ALIGN_MODE,
PROP_SAMPLE_MERGED
PROP_CLONE_TYPE
};
static void gimp_clone_options_set_property (GObject *object,
guint property_id,
const GValue *value,
@ -51,7 +44,7 @@ static void gimp_clone_options_get_property (GObject *object,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpCloneOptions, gimp_clone_options, GIMP_TYPE_PAINT_OPTIONS)
G_DEFINE_TYPE (GimpCloneOptions, gimp_clone_options, GIMP_TYPE_SOURCE_OPTIONS)
static void
@ -65,17 +58,8 @@ gimp_clone_options_class_init (GimpCloneOptionsClass *klass)
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CLONE_TYPE,
"clone-type", NULL,
GIMP_TYPE_CLONE_TYPE,
CLONE_DEFAULT_TYPE,
GIMP_IMAGE_CLONE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_ALIGN_MODE,
"align-mode", NULL,
GIMP_TYPE_CLONE_ALIGN_MODE,
CLONE_DEFAULT_ALIGN_MODE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
"sample-merged", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
@ -96,12 +80,6 @@ gimp_clone_options_set_property (GObject *object,
case PROP_CLONE_TYPE:
options->clone_type = g_value_get_enum (value);
break;
case PROP_ALIGN_MODE:
options->align_mode = g_value_get_enum (value);
break;
case PROP_SAMPLE_MERGED:
options->sample_merged = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -121,12 +99,6 @@ gimp_clone_options_get_property (GObject *object,
case PROP_CLONE_TYPE:
g_value_set_enum (value, options->clone_type);
break;
case PROP_ALIGN_MODE:
g_value_set_enum (value, options->align_mode);
break;
case PROP_SAMPLE_MERGED:
g_value_set_boolean (value, options->sample_merged);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;

View File

@ -20,7 +20,7 @@
#define __GIMP_CLONE_OPTIONS_H__
#include "gimppaintoptions.h"
#include "gimpsourceoptions.h"
#define GIMP_TYPE_CLONE_OPTIONS (gimp_clone_options_get_type ())
@ -32,15 +32,18 @@
typedef struct _GimpCloneOptions GimpCloneOptions;
typedef struct _GimpPaintOptionsClass GimpCloneOptionsClass;
typedef struct _GimpCloneOptionsClass GimpCloneOptionsClass;
struct _GimpCloneOptions
{
GimpPaintOptions paint_options;
GimpSourceOptions parent_instance;
GimpCloneType clone_type;
GimpCloneAlignMode align_mode;
gboolean sample_merged;
GimpCloneType clone_type;
};
struct _GimpCloneOptionsClass
{
GimpSourceOptionsClass parent_class;
};

View File

@ -18,29 +18,18 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "paint-types.h"
#include "base/pixel-region.h"
#include "base/temp-buf.h"
#include "base/tile-manager.h"
#include "paint-funcs/paint-funcs.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimppattern.h"
#include "core/gimppickable.h"
#include "gimpclone.h"
#include "gimpcloneoptions.h"
#include "gimpsourcecore.h"
#include "gimpsourceoptions.h"
#include "gimp-intl.h"
@ -54,75 +43,47 @@ enum
};
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_source_core_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_source_core_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
static void gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static void gimp_source_core_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
static void gimp_clone_line_image (GimpImage *dest,
GimpImage *src,
GimpDrawable *d_drawable,
GimpPickable *s_pickable,
guchar *s,
guchar *d,
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);
static void gimp_source_core_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static void gimp_source_core_set_src_drawable (GimpSourceCore *source_core,
GimpDrawable *drawable);
G_DEFINE_TYPE (GimpClone, gimp_clone, GIMP_TYPE_BRUSH_CORE)
G_DEFINE_TYPE (GimpSourceCore, gimp_source_core, GIMP_TYPE_BRUSH_CORE)
void
gimp_clone_register (Gimp *gimp,
GimpPaintRegisterCallback callback)
{
(* callback) (gimp,
GIMP_TYPE_CLONE,
GIMP_TYPE_CLONE_OPTIONS,
"gimp-clone",
_("Clone"),
"gimp-tool-clone");
}
static void
gimp_clone_class_init (GimpCloneClass *klass)
gimp_source_core_class_init (GimpSourceCoreClass *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;
object_class->set_property = gimp_source_core_set_property;
object_class->get_property = gimp_source_core_get_property;
paint_core_class->paint = gimp_clone_paint;
paint_core_class->paint = gimp_source_core_paint;
brush_core_class->handles_changing_brush = TRUE;
klass->motion = NULL;
g_object_class_install_property (object_class, PROP_SRC_DRAWABLE,
g_param_spec_object ("src-drawable",
NULL, NULL,
@ -143,40 +104,41 @@ gimp_clone_class_init (GimpCloneClass *klass)
}
static void
gimp_clone_init (GimpClone *clone)
gimp_source_core_init (GimpSourceCore *source_core)
{
clone->set_source = FALSE;
source_core->set_source = FALSE;
clone->src_drawable = NULL;
clone->src_x = 0.0;
clone->src_y = 0.0;
source_core->src_drawable = NULL;
source_core->src_x = 0.0;
source_core->src_y = 0.0;
clone->orig_src_x = 0.0;
clone->orig_src_y = 0.0;
source_core->orig_src_x = 0.0;
source_core->orig_src_y = 0.0;
clone->offset_x = 0.0;
clone->offset_y = 0.0;
clone->first_stroke = TRUE;
source_core->offset_x = 0.0;
source_core->offset_y = 0.0;
source_core->first_stroke = TRUE;
}
static void
gimp_clone_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
gimp_source_core_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpClone *clone = GIMP_CLONE (object);
GimpSourceCore *source_core = GIMP_SOURCE_CORE (object);
switch (property_id)
{
case PROP_SRC_DRAWABLE:
gimp_clone_set_src_drawable (clone, g_value_get_object (value));
gimp_source_core_set_src_drawable (source_core,
g_value_get_object (value));
break;
case PROP_SRC_X:
clone->src_x = g_value_get_double (value);
source_core->src_x = g_value_get_double (value);
break;
case PROP_SRC_Y:
clone->src_y = g_value_get_double (value);
source_core->src_y = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -185,23 +147,23 @@ gimp_clone_set_property (GObject *object,
}
static void
gimp_clone_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
gimp_source_core_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpClone *clone = GIMP_CLONE (object);
GimpSourceCore *source_core = GIMP_SOURCE_CORE (object);
switch (property_id)
{
case PROP_SRC_DRAWABLE:
g_value_set_object (value, clone->src_drawable);
g_value_set_object (value, source_core->src_drawable);
break;
case PROP_SRC_X:
g_value_set_int (value, clone->src_x);
g_value_set_int (value, source_core->src_x);
break;
case PROP_SRC_Y:
g_value_set_int (value, clone->src_y);
g_value_set_int (value, source_core->src_y);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -210,50 +172,45 @@ gimp_clone_get_property (GObject *object,
}
static void
gimp_clone_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time)
gimp_source_core_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time)
{
GimpClone *clone = GIMP_CLONE (paint_core);
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpSourceCore *source_core = GIMP_SOURCE_CORE (paint_core);
GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (paint_options);
switch (paint_state)
{
case GIMP_PAINT_STATE_INIT:
if (clone->set_source)
if (source_core->set_source)
{
gimp_clone_set_src_drawable (clone, drawable);
gimp_source_core_set_src_drawable (source_core, drawable);
clone->src_x = paint_core->cur_coords.x;
clone->src_y = paint_core->cur_coords.y;
source_core->src_x = paint_core->cur_coords.x;
source_core->src_y = paint_core->cur_coords.y;
clone->first_stroke = TRUE;
source_core->first_stroke = TRUE;
}
else if (options->align_mode == GIMP_CLONE_ALIGN_NO)
else if (options->align_mode == GIMP_SOURCE_ALIGN_NO)
{
clone->orig_src_x = clone->src_x;
clone->orig_src_y = clone->src_y;
source_core->orig_src_x = source_core->src_x;
source_core->orig_src_y = source_core->src_y;
clone->first_stroke = TRUE;
source_core->first_stroke = TRUE;
}
if (options->clone_type == GIMP_PATTERN_CLONE)
if (! gimp_context_get_pattern (context))
g_message (_("No patterns available for this operation."));
break;
case GIMP_PAINT_STATE_MOTION:
if (clone->set_source)
if (source_core->set_source)
{
/* If the control key is down, move the src target and return */
clone->src_x = paint_core->cur_coords.x;
clone->src_y = paint_core->cur_coords.y;
source_core->src_x = paint_core->cur_coords.x;
source_core->src_y = paint_core->cur_coords.y;
clone->first_stroke = TRUE;
source_core->first_stroke = TRUE;
}
else
{
@ -265,36 +222,37 @@ gimp_clone_paint (GimpPaintCore *paint_core,
dest_x = paint_core->cur_coords.x;
dest_y = paint_core->cur_coords.y;
if (options->align_mode == GIMP_CLONE_ALIGN_REGISTERED)
if (options->align_mode == GIMP_SOURCE_ALIGN_REGISTERED)
{
clone->offset_x = 0;
clone->offset_y = 0;
source_core->offset_x = 0;
source_core->offset_y = 0;
}
else if (options->align_mode == GIMP_CLONE_ALIGN_FIXED)
else if (options->align_mode == GIMP_SOURCE_ALIGN_FIXED)
{
clone->offset_x = clone->src_x - dest_x;
clone->offset_y = clone->src_y - dest_y;
source_core->offset_x = source_core->src_x - dest_x;
source_core->offset_y = source_core->src_y - dest_y;
}
else if (clone->first_stroke)
else if (source_core->first_stroke)
{
clone->offset_x = clone->src_x - dest_x;
clone->offset_y = clone->src_y - dest_y;
source_core->offset_x = source_core->src_x - dest_x;
source_core->offset_y = source_core->src_y - dest_y;
clone->first_stroke = FALSE;
source_core->first_stroke = FALSE;
}
clone->src_x = dest_x + clone->offset_x;
clone->src_y = dest_y + clone->offset_y;
source_core->src_x = dest_x + source_core->offset_x;
source_core->src_y = dest_y + source_core->offset_y;
gimp_clone_motion (paint_core, drawable, paint_options);
gimp_source_core_motion (source_core, drawable, paint_options);
}
break;
case GIMP_PAINT_STATE_FINISH:
if (options->align_mode == GIMP_CLONE_ALIGN_NO && ! clone->first_stroke)
if (options->align_mode == GIMP_SOURCE_ALIGN_NO &&
! source_core->first_stroke)
{
clone->src_x = clone->orig_src_x;
clone->src_y = clone->orig_src_y;
source_core->src_x = source_core->orig_src_x;
source_core->src_y = source_core->orig_src_y;
}
break;
@ -302,306 +260,52 @@ gimp_clone_paint (GimpPaintCore *paint_core,
break;
}
g_object_notify (G_OBJECT (clone), "src-x");
g_object_notify (G_OBJECT (clone), "src-y");
g_object_notify (G_OBJECT (source_core), "src-x");
g_object_notify (G_OBJECT (source_core), "src-y");
}
static void
gimp_clone_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
gimp_source_core_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
GimpClone *clone = GIMP_CLONE (paint_core);
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpPressureOptions *pressure_options = paint_options->pressure_options;
GimpImage *image;
GimpImage *src_image = NULL;
GimpPickable *src_pickable = NULL;
guchar *s;
guchar *d;
TempBuf *area;
gpointer pr = NULL;
gint y;
gint x1, y1, x2, y2;
TileManager *src_tiles;
PixelRegion srcPR, destPR;
GimpPattern *pattern = NULL;
gdouble opacity;
gint offset_x;
gint offset_y;
image = gimp_item_get_image (GIMP_ITEM (drawable));
opacity = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
if (opacity == 0.0)
return;
/* make local copies because we change them */
offset_x = clone->offset_x;
offset_y = clone->offset_y;
/* Make sure we still have a source if we are doing image cloning */
if (options->clone_type == GIMP_IMAGE_CLONE)
{
if (! clone->src_drawable)
return;
src_pickable = GIMP_PICKABLE (clone->src_drawable);
src_image = gimp_pickable_get_image (src_pickable);
if (options->sample_merged)
{
gint off_x, off_y;
src_pickable = GIMP_PICKABLE (src_image->projection);
gimp_item_offsets (GIMP_ITEM (clone->src_drawable), &off_x, &off_y);
offset_x += off_x;
offset_y += off_y;
}
gimp_pickable_flush (src_pickable);
}
area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options);
if (! area)
return;
switch (options->clone_type)
{
case GIMP_IMAGE_CLONE:
/* Set the paint area to transparent */
temp_buf_data_clear (area);
src_tiles = gimp_pickable_get_tiles (src_pickable);
x1 = CLAMP (area->x + offset_x,
0, tile_manager_width (src_tiles));
y1 = CLAMP (area->y + offset_y,
0, tile_manager_height (src_tiles));
x2 = CLAMP (area->x + offset_x + area->width,
0, tile_manager_width (src_tiles));
y2 = CLAMP (area->y + offset_y + area->height,
0, tile_manager_height (src_tiles));
if (!(x2 - x1) || !(y2 - y1))
return;
/* If the source image is different from the destination,
* then we should copy straight from the destination image
* to the canvas.
* Otherwise, we need a call to get_orig_image to make sure
* we get a copy of the unblemished (offset) image
*/
if (( options->sample_merged && (src_image != image)) ||
(! options->sample_merged && (clone->src_drawable != drawable)))
{
pixel_region_init (&srcPR, src_tiles,
x1, y1, x2 - x1, y2 - y1, FALSE);
}
else
{
TempBuf *orig;
/* get the original image */
if (options->sample_merged)
orig = gimp_paint_core_get_orig_proj (paint_core,
src_pickable,
x1, y1, x2, y2);
else
orig = gimp_paint_core_get_orig_image (paint_core,
GIMP_DRAWABLE (src_pickable),
x1, y1, x2, y2);
pixel_region_init_temp_buf (&srcPR, orig,
0, 0, x2 - x1, y2 - y1);
}
offset_x = x1 - (area->x + offset_x);
offset_y = y1 - (area->y + offset_y);
/* configure the destination */
pixel_region_init_temp_buf (&destPR, area,
offset_x, offset_y, srcPR.w, srcPR.h);
pr = pixel_regions_register (2, &srcPR, &destPR);
break;
case GIMP_PATTERN_CLONE:
pattern = gimp_context_get_pattern (context);
if (!pattern)
return;
/* configure the destination */
pixel_region_init_temp_buf (&destPR, area,
0, 0, area->width, area->height);
pr = pixel_regions_register (1, &destPR);
break;
}
for (; pr != NULL; pr = pixel_regions_process (pr))
{
s = srcPR.data;
d = destPR.data;
for (y = 0; y < destPR.h; y++)
{
switch (options->clone_type)
{
case GIMP_IMAGE_CLONE:
gimp_clone_line_image (image, src_image,
drawable, src_pickable,
s, d,
srcPR.bytes, destPR.bytes, destPR.w);
s += srcPR.rowstride;
break;
case GIMP_PATTERN_CLONE:
gimp_clone_line_pattern (image, drawable,
pattern, d,
area->x + offset_x,
area->y + y + offset_y,
destPR.bytes, destPR.w);
break;
}
d += destPR.rowstride;
}
}
if (pressure_options->opacity)
opacity *= PRESSURE_SCALE * paint_core->cur_coords.pressure;
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
MIN (opacity, GIMP_OPACITY_OPAQUE),
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context),
gimp_paint_options_get_brush_mode (paint_options),
/* In fixed mode, paint incremental so the
* individual brushes are properly applied
* on top of each other.
* Otherwise the stuff we paint is seamless
* and we don't need intermediate masking.
*/
options->align_mode == GIMP_CLONE_ALIGN_FIXED ?
GIMP_PAINT_INCREMENTAL : GIMP_PAINT_CONSTANT);
GIMP_SOURCE_CORE_GET_CLASS (source_core)->motion (source_core,
drawable,
paint_options);
}
static void
gimp_clone_line_image (GimpImage *dest,
GimpImage *src,
GimpDrawable *d_drawable,
GimpPickable *s_pickable,
guchar *s,
guchar *d,
gint src_bytes,
gint dest_bytes,
gint width)
gimp_source_core_src_drawable_removed (GimpDrawable *drawable,
GimpSourceCore *source_core)
{
guchar rgba[MAX_CHANNELS];
gint alpha;
alpha = dest_bytes - 1;
while (width--)
if (drawable == source_core->src_drawable)
{
gimp_image_get_color (src, gimp_pickable_get_image_type (s_pickable),
s, rgba);
gimp_image_transform_color (dest, d_drawable, d, GIMP_RGB, rgba);
d[alpha] = rgba[ALPHA_PIX];
s += src_bytes;
d += dest_bytes;
}
}
static void
gimp_clone_line_pattern (GimpImage *dest,
GimpDrawable *drawable,
GimpPattern *pattern,
guchar *d,
gint x,
gint y,
gint bytes,
gint width)
{
guchar *pat, *p;
GimpImageBaseType color_type;
gint alpha;
gint pat_bytes;
gint i;
pat_bytes = pattern->mask->bytes;
/* Make sure x, y are positive */
while (x < 0)
x += pattern->mask->width;
while (y < 0)
y += pattern->mask->height;
/* Get a pointer to the appropriate scanline of the pattern buffer */
pat = temp_buf_data (pattern->mask) +
(y % pattern->mask->height) * pattern->mask->width * pat_bytes;
color_type = (pat_bytes == 3 ||
pat_bytes == 4) ? GIMP_RGB : GIMP_GRAY;
alpha = bytes - 1;
for (i = 0; i < width; i++)
{
p = pat + ((i + x) % pattern->mask->width) * pat_bytes;
gimp_image_transform_color (dest, drawable, d, color_type, p);
if (pat_bytes == 2 || pat_bytes == 4)
d[alpha] = p[pat_bytes - 1];
else
d[alpha] = OPAQUE_OPACITY;
d += bytes;
}
}
static void
gimp_clone_src_drawable_removed (GimpDrawable *drawable,
GimpClone *clone)
{
if (drawable == clone->src_drawable)
{
clone->src_drawable = NULL;
source_core->src_drawable = NULL;
}
g_signal_handlers_disconnect_by_func (drawable,
gimp_clone_src_drawable_removed,
clone);
gimp_source_core_src_drawable_removed,
source_core);
}
static void
gimp_clone_set_src_drawable (GimpClone *clone,
GimpDrawable *drawable)
gimp_source_core_set_src_drawable (GimpSourceCore *source_core,
GimpDrawable *drawable)
{
if (clone->src_drawable == drawable)
if (source_core->src_drawable == drawable)
return;
if (clone->src_drawable)
g_signal_handlers_disconnect_by_func (clone->src_drawable,
gimp_clone_src_drawable_removed,
clone);
if (source_core->src_drawable)
g_signal_handlers_disconnect_by_func (source_core->src_drawable,
gimp_source_core_src_drawable_removed,
source_core);
clone->src_drawable = drawable;
source_core->src_drawable = drawable;
if (clone->src_drawable)
g_signal_connect (clone->src_drawable, "removed",
G_CALLBACK (gimp_clone_src_drawable_removed),
clone);
if (source_core->src_drawable)
g_signal_connect (source_core->src_drawable, "removed",
G_CALLBACK (gimp_source_core_src_drawable_removed),
source_core);
g_object_notify (G_OBJECT (clone), "src-drawable");
g_object_notify (G_OBJECT (source_core), "src-drawable");
}

View File

@ -16,52 +16,56 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CLONE_H__
#define __GIMP_CLONE_H__
#ifndef __GIMP_SOURCE_CORE_H__
#define __GIMP_SOURCE_CORE_H__
#include "gimpbrushcore.h"
#define GIMP_TYPE_CLONE (gimp_clone_get_type ())
#define GIMP_CLONE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CLONE, GimpClone))
#define GIMP_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CLONE, GimpCloneClass))
#define GIMP_IS_CLONE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CLONE))
#define GIMP_IS_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CLONE))
#define GIMP_CLONE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CLONE, GimpCloneClass))
#define GIMP_TYPE_SOURCE_CORE (gimp_source_core_get_type ())
#define GIMP_SOURCE_CORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SOURCE_CORE, GimpSourceCore))
#define GIMP_SOURCE_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SOURCE_CORE, GimpSourceCoreClass))
#define GIMP_IS_SOURCE_CORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SOURCE_CORE))
#define GIMP_IS_SOURCE_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SOURCE_CORE))
#define GIMP_SOURCE_CORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SOURCE_CORE, GimpSourceCoreClass))
typedef struct _GimpClone GimpClone;
typedef struct _GimpCloneClass GimpCloneClass;
typedef struct _GimpSourceCore GimpSourceCore;
typedef struct _GimpSourceCoreClass GimpSourceCoreClass;
struct _GimpClone
struct _GimpSourceCore
{
GimpBrushCore parent_instance;
GimpBrushCore parent_instance;
gboolean set_source;
gboolean set_source;
GimpDrawable *src_drawable;
gdouble src_x;
gdouble src_y;
GimpDrawable *src_drawable;
gdouble src_x;
gdouble src_y;
gdouble orig_src_x;
gdouble orig_src_y;
gdouble orig_src_x;
gdouble orig_src_y;
gdouble offset_x;
gdouble offset_y;
gboolean first_stroke;
gdouble offset_x;
gdouble offset_y;
gboolean first_stroke;
};
struct _GimpCloneClass
struct _GimpSourceCoreClass
{
GimpBrushCoreClass parent_class;
GimpBrushCoreClass parent_class;
void (* motion) (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
};
void gimp_clone_register (Gimp *gimp,
GimpPaintRegisterCallback callback);
void gimp_source_core_register (Gimp *gimp,
GimpPaintRegisterCallback callback);
GType gimp_clone_get_type (void) G_GNUC_CONST;
GType gimp_source_core_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_CLONE_H__ */
#endif /* __GIMP_SOURCE_CORE_H__ */

View File

@ -24,54 +24,44 @@
#include "paint-types.h"
#include "gimpcloneoptions.h"
#define CLONE_DEFAULT_TYPE GIMP_IMAGE_CLONE
#define CLONE_DEFAULT_ALIGN_MODE GIMP_CLONE_ALIGN_NO
#include "gimpsourceoptions.h"
enum
{
PROP_0,
PROP_CLONE_TYPE,
PROP_ALIGN_MODE,
PROP_SAMPLE_MERGED
};
static void gimp_clone_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_clone_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_source_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_source_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpCloneOptions, gimp_clone_options, GIMP_TYPE_PAINT_OPTIONS)
G_DEFINE_TYPE (GimpSourceOptions, gimp_source_options, GIMP_TYPE_PAINT_OPTIONS)
static void
gimp_clone_options_class_init (GimpCloneOptionsClass *klass)
gimp_source_options_class_init (GimpSourceOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_clone_options_set_property;
object_class->get_property = gimp_clone_options_get_property;
object_class->set_property = gimp_source_options_set_property;
object_class->get_property = gimp_source_options_get_property;
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CLONE_TYPE,
"clone-type", NULL,
GIMP_TYPE_CLONE_TYPE,
CLONE_DEFAULT_TYPE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_ALIGN_MODE,
"align-mode", NULL,
GIMP_TYPE_CLONE_ALIGN_MODE,
CLONE_DEFAULT_ALIGN_MODE,
GIMP_TYPE_SOURCE_ALIGN_MODE,
GIMP_SOURCE_ALIGN_NO,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
"sample-merged", NULL,
FALSE,
@ -79,23 +69,20 @@ gimp_clone_options_class_init (GimpCloneOptionsClass *klass)
}
static void
gimp_clone_options_init (GimpCloneOptions *options)
gimp_source_options_init (GimpSourceOptions *options)
{
}
static void
gimp_clone_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
gimp_source_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (object);
GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (object);
switch (property_id)
{
case PROP_CLONE_TYPE:
options->clone_type = g_value_get_enum (value);
break;
case PROP_ALIGN_MODE:
options->align_mode = g_value_get_enum (value);
break;
@ -109,18 +96,15 @@ gimp_clone_options_set_property (GObject *object,
}
static void
gimp_clone_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
gimp_source_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (object);
GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (object);
switch (property_id)
{
case PROP_CLONE_TYPE:
g_value_set_enum (value, options->clone_type);
break;
case PROP_ALIGN_MODE:
g_value_set_enum (value, options->align_mode);
break;

View File

@ -16,35 +16,39 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CLONE_OPTIONS_H__
#define __GIMP_CLONE_OPTIONS_H__
#ifndef __GIMP_SOURCE_OPTIONS_H__
#define __GIMP_SOURCE_OPTIONS_H__
#include "gimppaintoptions.h"
#define GIMP_TYPE_CLONE_OPTIONS (gimp_clone_options_get_type ())
#define GIMP_CLONE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CLONE_OPTIONS, GimpCloneOptions))
#define GIMP_CLONE_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CLONE_OPTIONS, GimpCloneOptionsClass))
#define GIMP_IS_CLONE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CLONE_OPTIONS))
#define GIMP_IS_CLONE_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CLONE_OPTIONS))
#define GIMP_CLONE_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CLONE_OPTIONS, GimpCloneOptionsClass))
#define GIMP_TYPE_SOURCE_OPTIONS (gimp_source_options_get_type ())
#define GIMP_SOURCE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SOURCE_OPTIONS, GimpSourceOptions))
#define GIMP_SOURCE_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SOURCE_OPTIONS, GimpSourceOptionsClass))
#define GIMP_IS_SOURCE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SOURCE_OPTIONS))
#define GIMP_IS_SOURCE_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SOURCE_OPTIONS))
#define GIMP_SOURCE_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SOURCE_OPTIONS, GimpSourceOptionsClass))
typedef struct _GimpCloneOptions GimpCloneOptions;
typedef struct _GimpPaintOptionsClass GimpCloneOptionsClass;
typedef struct _GimpSourceOptions GimpSourceOptions;
typedef struct _GimpSourceOptionsClass GimpSourceOptionsClass;
struct _GimpCloneOptions
struct _GimpSourceOptions
{
GimpPaintOptions paint_options;
GimpPaintOptions parent_instance;
GimpCloneType clone_type;
GimpCloneAlignMode align_mode;
GimpSourceAlignMode align_mode;
gboolean sample_merged;
};
GType gimp_clone_options_get_type (void) G_GNUC_CONST;
struct _GimpSourceOptionsClass
{
GimpPaintOptionsClass parent_class;
};
#endif /* __GIMP_CLONE_OPTIONS_H__ */
GType gimp_source_options_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_SOURCE_OPTIONS_H__ */

View File

@ -37,23 +37,23 @@ gimp_brush_application_mode_get_type (void)
}
GType
gimp_clone_align_mode_get_type (void)
gimp_source_align_mode_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_CLONE_ALIGN_NO, "GIMP_CLONE_ALIGN_NO", "no" },
{ GIMP_CLONE_ALIGN_YES, "GIMP_CLONE_ALIGN_YES", "yes" },
{ GIMP_CLONE_ALIGN_REGISTERED, "GIMP_CLONE_ALIGN_REGISTERED", "registered" },
{ GIMP_CLONE_ALIGN_FIXED, "GIMP_CLONE_ALIGN_FIXED", "fixed" },
{ GIMP_SOURCE_ALIGN_NO, "GIMP_SOURCE_ALIGN_NO", "no" },
{ GIMP_SOURCE_ALIGN_YES, "GIMP_SOURCE_ALIGN_YES", "yes" },
{ GIMP_SOURCE_ALIGN_REGISTERED, "GIMP_SOURCE_ALIGN_REGISTERED", "registered" },
{ GIMP_SOURCE_ALIGN_FIXED, "GIMP_SOURCE_ALIGN_FIXED", "fixed" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_CLONE_ALIGN_NO, N_("None"), NULL },
{ GIMP_CLONE_ALIGN_YES, N_("Aligned"), NULL },
{ GIMP_CLONE_ALIGN_REGISTERED, N_("Registered"), NULL },
{ GIMP_CLONE_ALIGN_FIXED, N_("Fixed"), NULL },
{ GIMP_SOURCE_ALIGN_NO, N_("None"), NULL },
{ GIMP_SOURCE_ALIGN_YES, N_("Aligned"), NULL },
{ GIMP_SOURCE_ALIGN_REGISTERED, N_("Registered"), NULL },
{ GIMP_SOURCE_ALIGN_FIXED, N_("Fixed"), NULL },
{ 0, NULL, NULL }
};
@ -61,7 +61,7 @@ gimp_clone_align_mode_get_type (void)
if (! type)
{
type = g_enum_register_static ("GimpCloneAlignMode", values);
type = g_enum_register_static ("GimpSourceAlignMode", values);
gimp_enum_set_value_descriptions (type, descs);
}

View File

@ -47,17 +47,17 @@ typedef enum
} GimpBrushApplicationMode;
#define GIMP_TYPE_CLONE_ALIGN_MODE (gimp_clone_align_mode_get_type ())
#define GIMP_TYPE_SOURCE_ALIGN_MODE (gimp_source_align_mode_get_type ())
GType gimp_clone_align_mode_get_type (void) G_GNUC_CONST;
GType gimp_source_align_mode_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_CLONE_ALIGN_NO, /*< desc="None" >*/
GIMP_CLONE_ALIGN_YES, /*< desc="Aligned" >*/
GIMP_CLONE_ALIGN_REGISTERED, /*< desc="Registered" >*/
GIMP_CLONE_ALIGN_FIXED /*< desc="Fixed" >*/
} GimpCloneAlignMode;
GIMP_SOURCE_ALIGN_NO, /*< desc="None" >*/
GIMP_SOURCE_ALIGN_YES, /*< desc="Aligned" >*/
GIMP_SOURCE_ALIGN_REGISTERED, /*< desc="Registered" >*/
GIMP_SOURCE_ALIGN_FIXED /*< desc="Fixed" >*/
} GimpSourceAlignMode;
#define GIMP_TYPE_CONVOLVE_TYPE (gimp_convolve_type_get_type ())

View File

@ -205,12 +205,14 @@ gimp_clone_tool_button_press (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpClone *clone = GIMP_CLONE (paint_tool->core);
GimpCloneOptions *options;
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
GimpCloneOptions *options;
GimpSourceOptions *source_options;
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
source_options = GIMP_SOURCE_OPTIONS (options);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
@ -218,16 +220,16 @@ gimp_clone_tool_button_press (GimpTool *tool,
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
{
clone->set_source = TRUE;
source->set_source = TRUE;
clone_tool->src_display = display;
}
else
{
clone->set_source = FALSE;
source->set_source = FALSE;
if (options->clone_type == GIMP_IMAGE_CLONE &&
options->sample_merged &&
source_options->sample_merged &&
display == clone_tool->src_display)
{
paint_tool->core->use_saved_proj = TRUE;
@ -237,8 +239,8 @@ gimp_clone_tool_button_press (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
display);
clone_tool->src_x = clone->src_x;
clone_tool->src_y = clone->src_y;
clone_tool->src_x = source->src_x;
clone_tool->src_y = source->src_y;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
@ -250,21 +252,21 @@ gimp_clone_tool_motion (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpClone *clone = GIMP_CLONE (paint_tool->core);
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
clone->set_source = TRUE;
source->set_source = TRUE;
else
clone->set_source = FALSE;
source->set_source = FALSE;
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display);
clone_tool->src_x = clone->src_x;
clone_tool->src_y = clone->src_y;
clone_tool->src_x = source->src_x;
clone_tool->src_y = source->src_y;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
@ -321,7 +323,7 @@ gimp_clone_tool_cursor_update (GimpTool *tool,
{
cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
}
else if (! GIMP_CLONE (GIMP_PAINT_TOOL (tool)->core)->src_drawable)
else if (! GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core)->src_drawable)
{
modifier = GIMP_CURSOR_MODIFIER_BAD;
}
@ -340,10 +342,12 @@ gimp_clone_tool_oper_update (GimpTool *tool,
gboolean proximity,
GimpDisplay *display)
{
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpCloneOptions *options;
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpCloneOptions *options;
GimpSourceOptions *source_options;
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
source_options = GIMP_SOURCE_OPTIONS (options);
if (proximity)
{
@ -360,9 +364,9 @@ gimp_clone_tool_oper_update (GimpTool *tool,
if (options->clone_type == GIMP_IMAGE_CLONE && proximity)
{
GimpClone *clone = GIMP_CLONE (GIMP_PAINT_TOOL (tool)->core);
GimpSourceCore *source = GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core);
if (clone->src_drawable == NULL)
if (source->src_drawable == NULL)
{
if (state & GDK_CONTROL_MASK)
gimp_tool_replace_status (tool, display,
@ -370,6 +374,7 @@ gimp_clone_tool_oper_update (GimpTool *tool,
else
{
gchar *status;
status = g_strdup_printf (_("%s%sClick to set a clone source."),
gimp_get_mod_name_control (),
gimp_get_mod_separator ());
@ -381,20 +386,25 @@ gimp_clone_tool_oper_update (GimpTool *tool,
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
clone_tool->src_x = clone->src_x;
clone_tool->src_y = clone->src_y;
clone_tool->src_x = source->src_x;
clone_tool->src_y = source->src_y;
if (! clone->first_stroke)
if (! source->first_stroke)
{
if (options->align_mode == GIMP_CLONE_ALIGN_YES)
{
clone_tool->src_x = coords->x + clone->offset_x;
clone_tool->src_y = coords->y + clone->offset_y;
}
else if (options->align_mode == GIMP_CLONE_ALIGN_REGISTERED)
switch (source_options->align_mode)
{
case GIMP_SOURCE_ALIGN_YES:
clone_tool->src_x = coords->x + source->offset_x;
clone_tool->src_y = coords->y + source->offset_y;
break;
case GIMP_SOURCE_ALIGN_REGISTERED:
clone_tool->src_x = coords->x;
clone_tool->src_y = coords->y;
break;
default:
break;
}
}
@ -408,19 +418,19 @@ gimp_clone_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (draw_tool);
GimpClone *clone = GIMP_CLONE (GIMP_PAINT_TOOL (tool)->core);
GimpSourceCore *source = GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core);
GimpCloneOptions *options;
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
if (options->clone_type == GIMP_IMAGE_CLONE &&
clone->src_drawable && clone_tool->src_display)
source->src_drawable && clone_tool->src_display)
{
GimpDisplay *tmp_display;
gint off_x;
gint off_y;
gimp_item_offsets (GIMP_ITEM (clone->src_drawable), &off_x, &off_y);
gimp_item_offsets (GIMP_ITEM (source->src_drawable), &off_x, &off_y);
tmp_display = draw_tool->display;
draw_tool->display = clone_tool->src_display;

View File

@ -205,12 +205,14 @@ gimp_clone_tool_button_press (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpClone *clone = GIMP_CLONE (paint_tool->core);
GimpCloneOptions *options;
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
GimpCloneOptions *options;
GimpSourceOptions *source_options;
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
source_options = GIMP_SOURCE_OPTIONS (options);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
@ -218,16 +220,16 @@ gimp_clone_tool_button_press (GimpTool *tool,
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
{
clone->set_source = TRUE;
source->set_source = TRUE;
clone_tool->src_display = display;
}
else
{
clone->set_source = FALSE;
source->set_source = FALSE;
if (options->clone_type == GIMP_IMAGE_CLONE &&
options->sample_merged &&
source_options->sample_merged &&
display == clone_tool->src_display)
{
paint_tool->core->use_saved_proj = TRUE;
@ -237,8 +239,8 @@ gimp_clone_tool_button_press (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
display);
clone_tool->src_x = clone->src_x;
clone_tool->src_y = clone->src_y;
clone_tool->src_x = source->src_x;
clone_tool->src_y = source->src_y;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
@ -250,21 +252,21 @@ gimp_clone_tool_motion (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpClone *clone = GIMP_CLONE (paint_tool->core);
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
clone->set_source = TRUE;
source->set_source = TRUE;
else
clone->set_source = FALSE;
source->set_source = FALSE;
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display);
clone_tool->src_x = clone->src_x;
clone_tool->src_y = clone->src_y;
clone_tool->src_x = source->src_x;
clone_tool->src_y = source->src_y;
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
@ -321,7 +323,7 @@ gimp_clone_tool_cursor_update (GimpTool *tool,
{
cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
}
else if (! GIMP_CLONE (GIMP_PAINT_TOOL (tool)->core)->src_drawable)
else if (! GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core)->src_drawable)
{
modifier = GIMP_CURSOR_MODIFIER_BAD;
}
@ -340,10 +342,12 @@ gimp_clone_tool_oper_update (GimpTool *tool,
gboolean proximity,
GimpDisplay *display)
{
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpCloneOptions *options;
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
GimpCloneOptions *options;
GimpSourceOptions *source_options;
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
source_options = GIMP_SOURCE_OPTIONS (options);
if (proximity)
{
@ -360,9 +364,9 @@ gimp_clone_tool_oper_update (GimpTool *tool,
if (options->clone_type == GIMP_IMAGE_CLONE && proximity)
{
GimpClone *clone = GIMP_CLONE (GIMP_PAINT_TOOL (tool)->core);
GimpSourceCore *source = GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core);
if (clone->src_drawable == NULL)
if (source->src_drawable == NULL)
{
if (state & GDK_CONTROL_MASK)
gimp_tool_replace_status (tool, display,
@ -370,6 +374,7 @@ gimp_clone_tool_oper_update (GimpTool *tool,
else
{
gchar *status;
status = g_strdup_printf (_("%s%sClick to set a clone source."),
gimp_get_mod_name_control (),
gimp_get_mod_separator ());
@ -381,20 +386,25 @@ gimp_clone_tool_oper_update (GimpTool *tool,
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
clone_tool->src_x = clone->src_x;
clone_tool->src_y = clone->src_y;
clone_tool->src_x = source->src_x;
clone_tool->src_y = source->src_y;
if (! clone->first_stroke)
if (! source->first_stroke)
{
if (options->align_mode == GIMP_CLONE_ALIGN_YES)
{
clone_tool->src_x = coords->x + clone->offset_x;
clone_tool->src_y = coords->y + clone->offset_y;
}
else if (options->align_mode == GIMP_CLONE_ALIGN_REGISTERED)
switch (source_options->align_mode)
{
case GIMP_SOURCE_ALIGN_YES:
clone_tool->src_x = coords->x + source->offset_x;
clone_tool->src_y = coords->y + source->offset_y;
break;
case GIMP_SOURCE_ALIGN_REGISTERED:
clone_tool->src_x = coords->x;
clone_tool->src_y = coords->y;
break;
default:
break;
}
}
@ -408,19 +418,19 @@ gimp_clone_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (draw_tool);
GimpClone *clone = GIMP_CLONE (GIMP_PAINT_TOOL (tool)->core);
GimpSourceCore *source = GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core);
GimpCloneOptions *options;
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
if (options->clone_type == GIMP_IMAGE_CLONE &&
clone->src_drawable && clone_tool->src_display)
source->src_drawable && clone_tool->src_display)
{
GimpDisplay *tmp_display;
gint off_x;
gint off_y;
gimp_item_offsets (GIMP_ITEM (clone->src_drawable), &off_x, &off_y);
gimp_item_offsets (GIMP_ITEM (source->src_drawable), &off_x, &off_y);
tmp_display = draw_tool->display;
draw_tool->display = clone_tool->src_display;