Commit fca7fc02 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed enum GimpHealAlignMode, we use the GimpSourceAlignMode now and can

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

	* app/paint/paint-enums.[ch]: removed enum GimpHealAlignMode, we
	use the GimpSourceAlignMode now and can always disable REGISTERED
	in the GUI should it turn out to be really totally pointless.

	* app/paint/Makefile.am
	* app/paint/gimphealoptions.[ch]: removed. Its properties are
	completely covered by GimpSourceOptions.

	* app/paint/gimpheal.[ch]: derive from GimpSourceCore.

	* app/tools/gimphealtool.[ch]: derive from GimpSourceTool.
parent 38452827
2006-09-04 Michael Natterer <mitch@gimp.org>
* app/paint/paint-enums.[ch]: removed enum GimpHealAlignMode, we
use the GimpSourceAlignMode now and can always disable REGISTERED
in the GUI should it turn out to be really totally pointless.
* app/paint/Makefile.am
* app/paint/gimphealoptions.[ch]: removed. Its properties are
completely covered by GimpSourceOptions.
* app/paint/gimpheal.[ch]
* app/tools/gimphealtool.[ch]
2006-09-04 Sven Neumann <sven@gimp.org>
* menus/image-menu.xml.in: added the Heal tool to the Tools menu.
......
......@@ -44,8 +44,6 @@ libapppaint_a_sources = \
gimperaseroptions.h \
gimpheal.c \
gimpheal.h \
gimphealoptions.c \
gimphealoptions.h \
gimpink.c \
gimpink.h \
gimpink-blob.c \
......
......@@ -18,7 +18,6 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
......@@ -33,243 +32,56 @@
#include "base/temp-buf.h"
#include "base/tile-manager.h"
#include "core/gimpitem.h"
#include "core/gimppickable.h"
#include "core/gimpimage.h"
#include "core/gimpdrawable.h"
#include "core/gimppattern.h"
#include "gimpheal.h"
#include "gimphealoptions.h"
#include "gimpsourceoptions.h"
#include "gimp-intl.h"
/* NOTES:
*
* I had the code working for healing from a pattern, but the results look
* terrible and I can't see a use for it right now.
*
* The support for registered alignment has been removed because it doesn't make
* sense for healing.
*/
enum
{
PROP_0,
PROP_SRC_DRAWABLE,
PROP_SRC_X,
PROP_SRC_Y
};
static void gimp_heal_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_heal_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_heal_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
static void gimp_heal_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static void gimp_heal_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static void gimp_heal_set_src_drawable (GimpHeal *heal,
GimpDrawable *drawable);
G_DEFINE_TYPE (GimpHeal, gimp_heal, GIMP_TYPE_SOURCE_CORE)
G_DEFINE_TYPE (GimpHeal, gimp_heal, GIMP_TYPE_BRUSH_CORE)
#define parent_class gimp_heal_parent_class
void
gimp_heal_register (Gimp *gimp,
GimpPaintRegisterCallback callback)
{
(* callback) (gimp, /* gimp */
GIMP_TYPE_HEAL, /* paint type */
GIMP_TYPE_HEAL_OPTIONS, /* paint options type */
"gimp-heal", /* identifier */
_("Heal"), /* blurb */
"gimp-tool-heal"); /* stock id */
(* callback) (gimp,
GIMP_TYPE_HEAL,
GIMP_TYPE_SOURCE_OPTIONS,
"gimp-heal",
_("Heal"),
"gimp-tool-heal");
}
static void
gimp_heal_class_init (GimpHealClass *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_heal_set_property;
object_class->get_property = gimp_heal_get_property;
paint_core_class->paint = gimp_heal_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));
}
GimpSourceCoreClass *source_core_class = GIMP_SOURCE_CORE_CLASS (klass);
static void
gimp_heal_init (GimpHeal *heal)
{
heal->set_source = FALSE;
heal->src_drawable = NULL;
heal->src_x = 0.0;
heal->src_y = 0.0;
heal->offset_x = 0.0;
heal->offset_y = 0.0;
heal->first_stroke = TRUE;
source_core_class->motion = gimp_heal_motion;
}
static void
gimp_heal_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpHeal *heal = GIMP_HEAL (object);
switch (property_id)
{
case PROP_SRC_DRAWABLE:
gimp_heal_set_src_drawable (heal, g_value_get_object (value));
break;
case PROP_SRC_X:
heal->src_x = g_value_get_double (value);
break;
case PROP_SRC_Y:
heal->src_y = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_heal_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
gimp_heal_init (GimpHeal *heal)
{
GimpHeal *heal = GIMP_HEAL (object);
switch (property_id)
{
case PROP_SRC_DRAWABLE:
g_value_set_object (value, heal->src_drawable);
break;
case PROP_SRC_X:
g_value_set_int (value, heal->src_x);
break;
case PROP_SRC_Y:
g_value_set_int (value, heal->src_y);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_heal_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time)
{
GimpHeal *heal = GIMP_HEAL (paint_core);
/* gimp passes the current state of the painting system to the function */
switch (paint_state)
{
case GIMP_PAINT_STATE_INIT:
/* heal->set_source is set by gimphealtool when CTRL is pressed */
if (heal->set_source)
{
/* defined later in this file, sets heal to the current drawable
* and notifies heal that the drawable is ready */
gimp_heal_set_src_drawable (heal, drawable);
/* get the current source coordinates from the paint core */
heal->src_x = paint_core->cur_coords.x;
heal->src_y = paint_core->cur_coords.y;
/* set first stroke to be true */
heal->first_stroke = TRUE;
}
break;
case GIMP_PAINT_STATE_MOTION:
if (heal->set_source)
{
/* if the control key is down, move the src and return */
heal->src_x = paint_core->cur_coords.x;
heal->src_y = paint_core->cur_coords.y;
heal->first_stroke = TRUE;
}
else
{
/* otherwise, update the target */
/* get the current destination from the paint core */
gint dest_x = paint_core->cur_coords.x;
gint dest_y = paint_core->cur_coords.y;
/* if this is the first stroke, record the offset of the destination
* relative to the source */
if (heal->first_stroke)
{
heal->offset_x = heal->src_x - dest_x;
heal->offset_y = heal->src_y - dest_y;
heal->first_stroke = FALSE;
}
/* if this is not the first stroke, set the source as
* destination + offset */
heal->src_x = dest_x + heal->offset_x;
heal->src_y = dest_y + heal->offset_y;
/* defined later, does the actual cloning */
gimp_heal_motion (paint_core, drawable, paint_options);
}
break;
default:
break;
}
/* notify the brush that the src attributes have changed */
g_object_notify (G_OBJECT (heal), "src-x");
g_object_notify (G_OBJECT (heal), "src-y");
}
/*
......@@ -515,12 +327,12 @@ gimp_heal_region (PixelRegion *tempPR,
}
static void
gimp_heal_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
gimp_heal_motion (GimpSourceCore *source_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options)
{
GimpHeal *heal = GIMP_HEAL (paint_core);
GimpHealOptions *options = GIMP_HEAL_OPTIONS (paint_options);
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpSourceOptions *options = GIMP_SOURCE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options);
GimpPressureOptions *pressure_options = paint_options->pressure_options;
GimpImage *image;
......@@ -546,21 +358,22 @@ gimp_heal_motion (GimpPaintCore *paint_core,
return;
}
opacity = gimp_paint_options_get_fade (paint_options, image, paint_core->pixel_dist);
opacity = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist);
if (opacity == 0.0)
return;
if (! heal->src_drawable)
if (! source_core->src_drawable)
return;
/* prepare the regions to get data from */
src_pickable = GIMP_PICKABLE (heal->src_drawable);
src_pickable = GIMP_PICKABLE (source_core->src_drawable);
src_image = gimp_pickable_get_image (src_pickable);
/* make local copies */
offset_x = heal->offset_x;
offset_y = heal->offset_y;
offset_x = source_core->offset_x;
offset_y = source_core->offset_y;
/* adjust offsets and pickable if we are merging layers */
if (options->sample_merged)
......@@ -569,7 +382,7 @@ gimp_heal_motion (GimpPaintCore *paint_core,
src_pickable = GIMP_PICKABLE (src_image->projection);
gimp_item_offsets (GIMP_ITEM (heal->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;
......@@ -704,46 +517,3 @@ gimp_heal_motion (GimpPaintCore *paint_core,
gimp_paint_options_get_brush_mode (paint_options),
GIMP_PAINT_CONSTANT);
}
static void
gimp_heal_src_drawable_removed (GimpDrawable *drawable,
GimpHeal *heal)
{
/* set the drawable to NULL */
if (drawable == heal->src_drawable)
{
heal->src_drawable = NULL;
}
/* disconnect the signal handler for this function */
g_signal_handlers_disconnect_by_func (drawable,
gimp_heal_src_drawable_removed,
heal);
}
static void
gimp_heal_set_src_drawable (GimpHeal *heal,
GimpDrawable *drawable)
{
/* check if we already have a drawable */
if (heal->src_drawable == drawable)
return;
/* remove the current signal handler */
if (heal->src_drawable)
g_signal_handlers_disconnect_by_func (heal->src_drawable,
gimp_heal_src_drawable_removed,
heal);
/* set the drawable */
heal->src_drawable = drawable;
/* connect the signal handler that handles the "remove" signal */
if (heal->src_drawable)
g_signal_connect (heal->src_drawable, "removed",
G_CALLBACK (gimp_heal_src_drawable_removed),
heal);
/* notify heal that the source drawable is set */
g_object_notify (G_OBJECT (heal), "src-drawable");
}
......@@ -20,7 +20,7 @@
#define __GIMP_HEAL_H__
#include "gimpbrushcore.h"
#include "gimpsourcecore.h"
#define GIMP_TYPE_HEAL (gimp_heal_get_type ())
......@@ -36,25 +36,12 @@ typedef struct _GimpHealClass GimpHealClass;
struct _GimpHeal
{
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 _GimpHealClass
{
GimpBrushCoreClass parent_class;
GimpSourceCoreClass parent_class;
};
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "libgimpconfig/gimpconfig.h"
#include "paint-types.h"
#include "gimphealoptions.h"
enum
{
PROP_0,
PROP_ALIGN_MODE,
PROP_SAMPLE_MERGED
};
static void gimp_heal_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_heal_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpHealOptions, gimp_heal_options, GIMP_TYPE_PAINT_OPTIONS)
static void
gimp_heal_options_class_init (GimpHealOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_heal_options_set_property;
object_class->get_property = gimp_heal_options_get_property;
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_ALIGN_MODE,
"align-mode", NULL,
GIMP_TYPE_HEAL_ALIGN_MODE,
GIMP_HEAL_ALIGN_NO,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
"sample-merged", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_heal_options_init (GimpHealOptions *options)
{
}
static void
gimp_heal_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpHealOptions *options = GIMP_HEAL_OPTIONS (object);
switch (property_id)
{
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;
}
}
static void
gimp_heal_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpHealOptions *options = GIMP_HEAL_OPTIONS (object);
switch (property_id)
{
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;
}
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_HEAL_OPTIONS_H__
#define __GIMP_HEAL_OPTIONS_H__
#include "gimppaintoptions.h"
#define GIMP_TYPE_HEAL_OPTIONS (gimp_heal_options_get_type ())
#define GIMP_HEAL_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HEAL_OPTIONS, GimpHealOptions))
#define GIMP_HEAL_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_HEAL_OPTIONS, GimpHealOptionsClass))
#define GIMP_IS_HEAL_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_HEAL_OPTIONS))
#define GIMP_IS_HEAL_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_HEAL_OPTIONS))
#define GIMP_HEAL_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_HEAL_OPTIONS, GimpHealOptionsClass))
typedef struct _GimpHealOptions GimpHealOptions;
typedef struct _GimpPaintOptionsClass GimpHealOptionsClass;
struct _GimpHealOptions
{
GimpPaintOptions paint_options;
GimpHealAlignMode align_mode;
gboolean sample_merged;
};
GType gimp_heal_options_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_HEAL_OPTIONS_H__ */
......@@ -126,36 +126,6 @@ gimp_ink_blob_type_get_type (void)
return type;
}
GType
gimp_heal_align_mode_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_HEAL_ALIGN_NO, "GIMP_HEAL_ALIGN_NO", "no" },
{ GIMP_HEAL_ALIGN_YES, "GIMP_HEAL_ALIGN_YES", "yes" },
{ GIMP_HEAL_ALIGN_FIXED, "GIMP_HEAL_ALIGN_FIXED", "fixed" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_HEAL_ALIGN_NO, N_("None"), NULL },
{ GIMP_HEAL_ALIGN_YES, N_("Aligned"), NULL },
{ GIMP_HEAL_ALIGN_FIXED, N_("Fixed"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpHealAlignMode", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
/* Generated data ends here */
......@@ -84,18 +84,6 @@ typedef enum /*< pdb-skip >*/
} GimpInkBlobType;
#define GIMP_TYPE_HEAL_ALIGN_MODE (gimp_heal_align_mode_get_type ())
GType gimp_heal_align_mode_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_HEAL_ALIGN_NO, /*< desc="None" >*/
GIMP_HEAL_ALIGN_YES, /*< desc="Aligned" >*/
GIMP_HEAL_ALIGN_FIXED /*< desc="Fixed" >*/
} GimpHealAlignMode;
/*
* non-registered enums; register them if needed
*/
......
......@@ -24,16 +24,12 @@
#include "tools-types.h"
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "core/gimppickable.h"
#include "core/gimptoolinfo.h"
#include "paint/gimpheal.h"
#include "paint/gimphealoptions.h"
#include "paint/gimpsourceoptions.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpviewablebox.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
......@@ -45,48 +41,10 @@
#include "gimp-intl.h"
#define TARGET_WIDTH 15
#define TARGET_HEIGHT 15
static GtkWidget * gimp_heal_options_gui (GimpToolOptions *tool_options);
static gboolean gimp_heal_tool_has_display (GimpTool *tool,
GimpDisplay *display);
static GimpDisplay * gimp_heal_tool_has_image (GimpTool *tool,
GimpImage *image);
static void gimp_heal_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_heal_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_heal_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_heal_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_heal_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_heal_tool_draw (GimpDrawTool *draw_tool);
static GtkWidget * gimp_heal_options_gui (GimpToolOptions *tool_options);
G_DEFINE_TYPE (GimpHealTool, gimp_heal_tool, GIMP_TYPE_BRUSH_TOOL)
G_DEFINE_TYPE (GimpHealTool, gimp_heal_tool, GIMP_TYPE_SOURCE_TOOL)
void
......@@ -94,7 +52,7 @@ gimp_heal_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
(* callback) (GIMP_TYPE_HEAL_TOOL,
GIMP_TYPE_HEAL_OPTIONS,
GIMP_TYPE_SOURCE_OPTIONS,
gimp_heal_options_gui,
GIMP_PAINT_OPTIONS_CONTEXT_MASK,
"gimp-heal-tool",
......@@ -111,354 +69,27 @@ gimp_heal_tool_register (GimpToolRegisterCallback callback,
static void
gimp_heal_tool_class_init (GimpHealToolClass *klass)
{
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
tool_class->has_display = gimp_heal_tool_has_display;
tool_class->has_image = gimp_heal_tool_has_image;
tool_class->control = gimp_heal_tool_control;
tool_class->button_press = gimp_heal_tool_button_press;
tool_class->motion = gimp_heal_tool_motion;
tool_class->cursor_update = gimp_heal_tool_cursor_update;
tool_class->oper_update = gimp_heal_tool_oper_update;
draw_tool_class->draw = gimp_heal_tool_draw;
}
static void
gimp_heal_tool_init (GimpHealTool *heal)