? app/tools/colortool.patch Index: app/paint/Makefile.am =================================================================== RCS file: /cvs/gnome/gimp/app/paint/Makefile.am,v retrieving revision 1.30 diff -u -p -r1.30 Makefile.am --- app/paint/Makefile.am 2 Sep 2006 22:39:25 -0000 1.30 +++ app/paint/Makefile.am 4 Sep 2006 09:19:49 -0000 @@ -44,8 +44,6 @@ libapppaint_a_sources = \ gimperaseroptions.h \ gimpheal.c \ gimpheal.h \ - gimphealoptions.c \ - gimphealoptions.h \ gimpink.c \ gimpink.h \ gimpink-blob.c \ Index: app/paint/gimpheal.c =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpheal.c,v retrieving revision 1.3 diff -u -p -r1.3 gimpheal.c --- app/paint/gimpheal.c 2 Sep 2006 18:39:28 -0000 1.3 +++ app/paint/gimpheal.c 4 Sep 2006 09:19:49 -0000 @@ -18,7 +18,6 @@ #include "config.h" -#include #include #include @@ -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 (GimpPaintCore *paint_core, - GimpDrawable *drawable, - GimpPaintOptions *paint_options); -static void gimp_heal_set_src_drawable (GimpHeal *heal, - GimpDrawable *drawable); +static void gimp_heal_motion (GimpSourceCore *source_core, + GimpDrawable *drawable, + GimpPaintOptions *paint_options); + +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) -{ - 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) +gimp_heal_init (GimpHeal *heal) { - 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 *pai 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 *pai 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; @@ -703,47 +516,4 @@ gimp_heal_motion (GimpPaintCore *pai gimp_context_get_opacity (context), 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"); } Index: app/paint/gimpheal.h =================================================================== RCS file: /cvs/gnome/gimp/app/paint/gimpheal.h,v retrieving revision 1.3 diff -u -p -r1.3 gimpheal.h --- app/paint/gimpheal.h 2 Sep 2006 18:39:28 -0000 1.3 +++ app/paint/gimpheal.h 4 Sep 2006 09:19:49 -0000 @@ -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 GimpHealCl 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; }; Index: app/paint/paint-enums.c =================================================================== RCS file: /cvs/gnome/gimp/app/paint/paint-enums.c,v retrieving revision 1.14 diff -u -p -r1.14 paint-enums.c --- app/paint/paint-enums.c 2 Sep 2006 22:39:25 -0000 1.14 +++ app/paint/paint-enums.c 4 Sep 2006 09:19:49 -0000 @@ -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 */ Index: app/paint/paint-enums.h =================================================================== RCS file: /cvs/gnome/gimp/app/paint/paint-enums.h,v retrieving revision 1.15 diff -u -p -r1.15 paint-enums.h --- app/paint/paint-enums.h 2 Sep 2006 22:39:25 -0000 1.15 +++ app/paint/paint-enums.h 4 Sep 2006 09:19:49 -0000 @@ -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 */ Index: app/tools/gimphealtool.c =================================================================== RCS file: /cvs/gnome/gimp/app/tools/gimphealtool.c,v retrieving revision 1.3 diff -u -p -r1.3 gimphealtool.c --- app/tools/gimphealtool.c 2 Sep 2006 18:39:28 -0000 1.3 +++ app/tools/gimphealtool.c 4 Sep 2006 09:19:49 -0000 @@ -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 (GimpToolRegiste 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 (GimpToolRegiste 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) { - GimpTool *tool = GIMP_TOOL (heal); - GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); + GimpTool *tool = GIMP_TOOL (heal); + GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); + GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool); gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_HEAL); - paint_tool->status = _("Click to heal."); + paint_tool->status = _("Click to heal"); paint_tool->status_ctrl = _("%s to set a new heal source"); -} - -static gboolean -gimp_heal_tool_has_display (GimpTool *tool, - GimpDisplay *display) -{ - GimpHealTool *heal_tool = GIMP_HEAL_TOOL (tool); - - return (display == heal_tool->src_display || - GIMP_TOOL_CLASS (gimp_heal_tool_parent_class)->has_display (tool, - display)); -} - -static GimpDisplay * -gimp_heal_tool_has_image (GimpTool *tool, - GimpImage *image) -{ - GimpHealTool *heal_tool = GIMP_HEAL_TOOL (tool); - GimpDisplay *display; - - display = GIMP_TOOL_CLASS (gimp_heal_tool_parent_class)->has_image (tool, - image); - - if (! display && heal_tool->src_display) - { - if (image && heal_tool->src_display->image == image) - display = heal_tool->src_display; - - /* NULL image means any display */ - if (! image) - display = heal_tool->src_display; - } - - return display; -} - -static void -gimp_heal_tool_control (GimpTool *tool, - GimpToolAction action, - GimpDisplay *display) -{ - GimpHealTool *heal_tool = GIMP_HEAL_TOOL (tool); - switch (action) - { - case GIMP_TOOL_ACTION_PAUSE: - case GIMP_TOOL_ACTION_RESUME: - break; - - case GIMP_TOOL_ACTION_HALT: - heal_tool->src_display = NULL; - g_object_set (GIMP_PAINT_TOOL (tool)->core, - "src-drawable", NULL, - NULL); - break; - } - - GIMP_TOOL_CLASS (gimp_heal_tool_parent_class)->control (tool, action, display); + source_tool->status_paint = _("Click to heal"); + source_tool->status_set_source = _("Click to set a new heal source"); + source_tool->status_set_source_ctrl = _("%s to set a new heal source"); } -static void -gimp_heal_tool_button_press (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *display) -{ - GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); - GimpHealTool *heal_tool = GIMP_HEAL_TOOL (tool); - GimpHeal *heal = GIMP_HEAL (paint_tool->core); - GimpHealOptions *options; - - options = GIMP_HEAL_OPTIONS (tool->tool_info->tool_options); - - /* pause the tool before drawing */ - gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); - - /* use_saved_proj tells whether we keep the unmodified pixel projection - * around. in this case no. */ - paint_tool->core->use_saved_proj = FALSE; - - /* state holds a set of bit-flags to indicate the state of modifier keys and - * mouse buttons in various event types. Typical modifier keys are Shift, - * Control, Meta, Super, Hyper, Alt, Compose, Apple, CapsLock or ShiftLock. - * Part of gtk -> GdkModifierType */ - if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK) - /* we enter here only if CTRL is pressed */ - { - /* mark that the source display has been set. defined in gimpheal.h */ - heal->set_source = TRUE; - - /* if currently active display != the heal tools source display */ - if (display != heal_tool->src_display) - { - /* check if the heal tools src display has been previously set */ - if (heal_tool->src_display) - /* if so remove the pointer to the display */ - g_object_remove_weak_pointer (G_OBJECT (heal_tool->src_display), - (gpointer *) &heal_tool->src_display); - - /* set the heal tools source display to the currently active - * display */ - heal_tool->src_display = display; - - /* add a pointer to the display */ - g_object_add_weak_pointer (G_OBJECT (display), - (gpointer *) &heal_tool->src_display); - } - } - else - { - /* note that the source is not being set */ - heal->set_source = FALSE; - - if ((options->sample_merged) && (display == heal_tool->src_display)) - { - /* keep unmodified projection around */ - paint_tool->core->use_saved_proj = TRUE; - } - } - - /* chain up to call the parents functions */ - GIMP_TOOL_CLASS (gimp_heal_tool_parent_class)->button_press (tool, coords, - time, state, - display); - - /* set the tool display's source position to match the current heal - * implementation source position */ - heal_tool->src_x = heal->src_x; - heal_tool->src_y = heal->src_y; - - /* resume drawing */ - gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); -} - -static void -gimp_heal_tool_motion (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *display) -{ - GimpHealTool *heal_tool = GIMP_HEAL_TOOL (tool); - GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); - GimpHeal *heal = GIMP_HEAL (paint_tool->core); - - /* pause drawing */ - gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); - - /* check if CTRL is pressed */ - if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK) - /* if yes the source has been set */ - heal->set_source = TRUE; - else - /* if no the source has not been set */ - heal->set_source = FALSE; - - /* chain up to the parent classes motion function */ - GIMP_TOOL_CLASS (gimp_heal_tool_parent_class)->motion (tool, coords, time, - state, display); - - /* set the tool display's source to be the same as the heal implementation - * source */ - heal_tool->src_x = heal->src_x; - heal_tool->src_y = heal->src_y; - - /* resume drawing */ - gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); -} - -static void -gimp_heal_tool_cursor_update (GimpTool *tool, - GimpCoords *coords, - GdkModifierType state, - GimpDisplay *display) -{ - GimpHealOptions *options; - GimpCursorType cursor = GIMP_CURSOR_MOUSE; - GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE; - - options = GIMP_HEAL_OPTIONS (tool->tool_info->tool_options); - - /* if the cursor is in an active area */ - if (gimp_image_coords_in_active_pickable (display->image, coords, - FALSE, TRUE)) - { - /* set the cursor to the normal cursor */ - cursor = GIMP_CURSOR_MOUSE; - } - - /* if CTRL is pressed, change cursor to cross-hair */ - if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK) - { - cursor = GIMP_CURSOR_CROSSHAIR_SMALL; - } - /* otherwise, let the cursor now that we can't paint */ - else if (! GIMP_HEAL (GIMP_PAINT_TOOL (tool)->core)->src_drawable) - { - modifier = GIMP_CURSOR_MODIFIER_BAD; - } - - /* set the cursor and the modifier cursor */ - gimp_tool_control_set_cursor (tool->control, cursor); - gimp_tool_control_set_cursor_modifier (tool->control, modifier); - - /* chain up to the parent class */ - GIMP_TOOL_CLASS (gimp_heal_tool_parent_class)->cursor_update (tool, coords, - state, display); -} - -static void -gimp_heal_tool_oper_update (GimpTool *tool, - GimpCoords *coords, - GdkModifierType state, - gboolean proximity, - GimpDisplay *display) -{ - GimpHealTool *heal_tool = GIMP_HEAL_TOOL (tool); - GimpHealOptions *options; - - options = GIMP_HEAL_OPTIONS (tool->tool_info->tool_options); - - if (proximity) - { - GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); - - paint_tool->status_ctrl = _("%s to set a new heal source"); - } - - /* chain up to the parent class */ - GIMP_TOOL_CLASS (gimp_heal_tool_parent_class)->oper_update (tool, coords, - state, proximity, - display); - - if (proximity) - { - GimpHeal *heal = GIMP_HEAL (GIMP_PAINT_TOOL (tool)->core); - - if (heal->src_drawable == NULL) - { - if (state & GDK_CONTROL_MASK) - /* if we haven't set the source drawable yet, make a notice to do so */ - gimp_tool_replace_status (tool, display, - _("Ctrl-Click to set a heal source.")); - else - { - gchar *status; - status = g_strdup_printf (_("%s%sClick to set a heal source."), - gimp_get_mod_name_control (), - gimp_get_mod_separator ()); - gimp_tool_replace_status (tool, display, status); - g_free (status); - } - } - else - { - /* pause drawing */ - gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); - - /* set the tool source to match the implementation source */ - heal_tool->src_x = heal->src_x; - heal_tool->src_y = heal->src_y; - - if (! heal->first_stroke) - { - /* set the coordinates based on the alignment type */ - if (options->align_mode == GIMP_HEAL_ALIGN_YES) - { - heal_tool->src_x = coords->x + heal->offset_x; - heal_tool->src_y = coords->y + heal->offset_y; - } - } - - /* resume drawing */ - gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); - } - } -} - -static void -gimp_heal_tool_draw (GimpDrawTool *draw_tool) -{ - GimpTool *tool = GIMP_TOOL (draw_tool); - GimpHealTool *heal_tool = GIMP_HEAL_TOOL (draw_tool); - GimpHeal *heal = GIMP_HEAL (GIMP_PAINT_TOOL (tool)->core); - GimpHealOptions *options; - - options = GIMP_HEAL_OPTIONS (tool->tool_info->tool_options); - - /* If we have a source drawable and display we can do the drawing */ - if ((heal->src_drawable) && (heal_tool->src_display)) - { - /* make a temporary display and keep track of offsets */ - GimpDisplay *tmp_display; - gint off_x; - gint off_y; - - /* gimp_item_offsets reveals the X and Y offsets of the first parameter. - * this gets the location of the drawable. */ - gimp_item_offsets (GIMP_ITEM (heal->src_drawable), &off_x, &off_y); - - /* store the display for later */ - tmp_display = draw_tool->display; - - /* set the display */ - draw_tool->display = heal_tool->src_display; - - /* convenience function to simplify drawing */ - gimp_draw_tool_draw_handle (draw_tool, - GIMP_HANDLE_CROSS, - heal_tool->src_x + off_x, - heal_tool->src_y + off_y, - TARGET_WIDTH, TARGET_HEIGHT, - GTK_ANCHOR_CENTER, - FALSE); - - /* restore settings after drawing */ - draw_tool->display = tmp_display; - } - - /* chain up to the parent draw function */ - GIMP_DRAW_TOOL_CLASS (gimp_heal_tool_parent_class)->draw (draw_tool); -} +/* tool options stuff */ static GtkWidget * gimp_heal_options_gui (GimpToolOptions *tool_options) Index: app/tools/gimphealtool.h =================================================================== RCS file: /cvs/gnome/gimp/app/tools/gimphealtool.h,v retrieving revision 1.3 diff -u -p -r1.3 gimphealtool.h --- app/tools/gimphealtool.h 2 Sep 2006 18:39:28 -0000 1.3 +++ app/tools/gimphealtool.h 4 Sep 2006 09:19:49 -0000 @@ -20,7 +20,7 @@ #define __GIMP_HEAL_TOOL_H__ -#include "gimpbrushtool.h" +#include "gimpsourcetool.h" #define GIMP_TYPE_HEAL_TOOL (gimp_heal_tool_get_type ()) @@ -37,16 +37,12 @@ typedef struct _GimpHealToolClass GimpHe struct _GimpHealTool { - GimpBrushTool parent_instance; - - GimpDisplay *src_display; /* Detail about the source location to paint from */ - gint src_x; - gint src_y; + GimpSourceTool parent_instance; }; struct _GimpHealToolClass { - GimpBrushToolClass parent_class; + GimpSourceToolClass parent_class; };