diff --git a/ChangeLog b/ChangeLog index b22c919439..9e30878089 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2001-03-09 Michael Natterer + + * app/tools/Makefile.am + * app/tools/rect_selectP.h: removed. + + * app/tools/gimpfreeselecttool.[ch] + * app/tools/gimpfuzzyselecttool.[ch]: reactivated. + + * app/tools/gimptool.[ch]: removed STUB()s and old crap. + + * app/tools/tools.c: register the new tools. + + * app/disp_callbacks.c + * app/tools/selection_options.c: changed accordingly. + + * app/apptypes.h + * app/tools/gimprectselecttool.c: cleanup. + 2001-03-09 Nathan Summers * app/tools/gimptransformtool.[ch]: More work on the transform tool. diff --git a/app/apptypes.h b/app/apptypes.h index 1a2b8e0c88..554c55b6f9 100644 --- a/app/apptypes.h +++ b/app/apptypes.h @@ -79,6 +79,7 @@ typedef struct _GimpToolInfo GimpToolInfo; typedef struct _GimpTool GimpTool; typedef struct _GimpPaintTool GimpPaintTool; typedef struct _GimpDrawTool GimpDrawTool; +typedef struct _GimpTransformTool GimpTransformTool; /* undo objects */ @@ -177,8 +178,6 @@ typedef struct _Selection Selection; typedef struct _SelectionOptions SelectionOptions; -typedef struct _GimpTransformTool GimpTransformTool; - /* some undo stuff */ diff --git a/app/disp_callbacks.c b/app/disp_callbacks.c index 2d74953077..ef7497ef65 100644 --- a/app/disp_callbacks.c +++ b/app/disp_callbacks.c @@ -28,6 +28,7 @@ #include "apptypes.h" #include "tools/gimpbucketfilltool.h" +#include "tools/gimpfuzzyselecttool.h" #include "tools/gimpmovetool.h" #include "tools/tool_manager.h" @@ -386,7 +387,7 @@ gdisplay_canvas_events (GtkWidget *canvas, * * ugly: fuzzy_select sets busy cursors while ACTIVE. */ - if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT(active_tool) && + if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT_TOOL (active_tool) && active_tool->state == ACTIVE)) return TRUE; @@ -405,7 +406,7 @@ gdisplay_canvas_events (GtkWidget *canvas, gtk_grab_remove (canvas); gdk_pointer_ungrab (bevent->time); /* fixes pointer grab bug */ - if (active_tool && (GIMP_IS_MOVE_TOOL(active_tool) || + if (active_tool && (GIMP_IS_MOVE_TOOL (active_tool) || ! gimp_image_is_empty (gdisp->gimage))) { if (active_tool->state == ACTIVE) @@ -459,13 +460,13 @@ gdisplay_canvas_events (GtkWidget *canvas, * * ugly: fuzzy_select sets busy cursors while ACTIVE. */ - if (gimp_busy && !(GIMP_IS_FUZZY_SELECT(active_tool) && - active_tool->state == ACTIVE)) + if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT_TOOL (active_tool) && + active_tool->state == ACTIVE)) return TRUE; - /* Ask for the pointer position, but ignore it except for cursor - * handling, so motion events sync with the button press/release events - */ + /* Ask for the pointer position, but ignore it except for cursor + * handling, so motion events sync with the button press/release events + */ if (mevent->is_hint) { gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty, diff --git a/app/display/gimpdisplay-callbacks.c b/app/display/gimpdisplay-callbacks.c index 2d74953077..ef7497ef65 100644 --- a/app/display/gimpdisplay-callbacks.c +++ b/app/display/gimpdisplay-callbacks.c @@ -28,6 +28,7 @@ #include "apptypes.h" #include "tools/gimpbucketfilltool.h" +#include "tools/gimpfuzzyselecttool.h" #include "tools/gimpmovetool.h" #include "tools/tool_manager.h" @@ -386,7 +387,7 @@ gdisplay_canvas_events (GtkWidget *canvas, * * ugly: fuzzy_select sets busy cursors while ACTIVE. */ - if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT(active_tool) && + if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT_TOOL (active_tool) && active_tool->state == ACTIVE)) return TRUE; @@ -405,7 +406,7 @@ gdisplay_canvas_events (GtkWidget *canvas, gtk_grab_remove (canvas); gdk_pointer_ungrab (bevent->time); /* fixes pointer grab bug */ - if (active_tool && (GIMP_IS_MOVE_TOOL(active_tool) || + if (active_tool && (GIMP_IS_MOVE_TOOL (active_tool) || ! gimp_image_is_empty (gdisp->gimage))) { if (active_tool->state == ACTIVE) @@ -459,13 +460,13 @@ gdisplay_canvas_events (GtkWidget *canvas, * * ugly: fuzzy_select sets busy cursors while ACTIVE. */ - if (gimp_busy && !(GIMP_IS_FUZZY_SELECT(active_tool) && - active_tool->state == ACTIVE)) + if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT_TOOL (active_tool) && + active_tool->state == ACTIVE)) return TRUE; - /* Ask for the pointer position, but ignore it except for cursor - * handling, so motion events sync with the button press/release events - */ + /* Ask for the pointer position, but ignore it except for cursor + * handling, so motion events sync with the button press/release events + */ if (mevent->is_hint) { gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty, diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 2d74953077..ef7497ef65 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -28,6 +28,7 @@ #include "apptypes.h" #include "tools/gimpbucketfilltool.h" +#include "tools/gimpfuzzyselecttool.h" #include "tools/gimpmovetool.h" #include "tools/tool_manager.h" @@ -386,7 +387,7 @@ gdisplay_canvas_events (GtkWidget *canvas, * * ugly: fuzzy_select sets busy cursors while ACTIVE. */ - if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT(active_tool) && + if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT_TOOL (active_tool) && active_tool->state == ACTIVE)) return TRUE; @@ -405,7 +406,7 @@ gdisplay_canvas_events (GtkWidget *canvas, gtk_grab_remove (canvas); gdk_pointer_ungrab (bevent->time); /* fixes pointer grab bug */ - if (active_tool && (GIMP_IS_MOVE_TOOL(active_tool) || + if (active_tool && (GIMP_IS_MOVE_TOOL (active_tool) || ! gimp_image_is_empty (gdisp->gimage))) { if (active_tool->state == ACTIVE) @@ -459,13 +460,13 @@ gdisplay_canvas_events (GtkWidget *canvas, * * ugly: fuzzy_select sets busy cursors while ACTIVE. */ - if (gimp_busy && !(GIMP_IS_FUZZY_SELECT(active_tool) && - active_tool->state == ACTIVE)) + if (gimp_busy && ! (GIMP_IS_FUZZY_SELECT_TOOL (active_tool) && + active_tool->state == ACTIVE)) return TRUE; - /* Ask for the pointer position, but ignore it except for cursor - * handling, so motion events sync with the button press/release events - */ + /* Ask for the pointer position, but ignore it except for cursor + * handling, so motion events sync with the button press/release events + */ if (mevent->is_hint) { gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty, diff --git a/app/tools/Makefile.am b/app/tools/Makefile.am index 2dd1eefa05..a45ade63d9 100644 --- a/app/tools/Makefile.am +++ b/app/tools/Makefile.am @@ -7,40 +7,40 @@ libapptools_la_SOURCES = \ ## gimpairbrushtool.h \ ## gimpblendtool.c \ ## gimpblendtool.h \ + gimpbucketfilltool.c \ + gimpbucketfilltool.h \ ## gimpbycolorselecttool.c \ ## gimpbycolorselecttool.h \ ## gimpclonetool.c \ ## gimpclonetool.h \ + gimpcolorpickertool.c \ + gimpcolorpickertool.h \ ## gimpconvolvetool.c \ ## gimpconvolvetool.h \ + gimpcroptool.c \ + gimpcroptool.h \ ## gimpdodgeburntool.c \ ## gimpdodgeburntool.h \ + gimpdrawtool.c \ + gimpdrawtool.h \ + gimpeditselectiontool.c \ + gimpeditselectiontool.h \ gimpellipseselecttool.c \ gimpellipseselecttool.h \ ## gimperasertool.c \ ## gimperasertool.h \ ## gimpfliptool.c \ ## gimpfliptool.h \ -## gimpfreeselecttool.c \ -## gimpfreeselecttool.h \ + gimpfreeselecttool.c \ + gimpfreeselecttool.h \ + gimpfuzzyselecttool.c \ + gimpfuzzyselecttool.h \ gimpinktool.c \ gimpinktool.h \ gimpinktool-blob.c \ gimpinktool-blob.h \ ## gimpiscissorstool.c \ ## gimpiscissorstool.h \ - gimpbucketfilltool.c \ - gimpbucketfilltool.h \ - gimpcolorpickertool.c \ - gimpcolorpickertool.h \ - gimpcroptool.c \ - gimpcroptool.h \ - gimpdrawtool.c \ - gimpdrawtool.h \ - gimpeditselectiontool.c \ - gimpeditselectiontool.h \ - gimpfuzzyselecttool.c \ - gimpfuzzyselecttool.h \ gimpmagnifytool.c \ gimpmagnifytool.h \ gimpmeasuretool.c \ @@ -58,7 +58,6 @@ libapptools_la_SOURCES = \ ## gimpperspectivetool.h \ gimprectselecttool.c \ gimprectselecttool.h \ -## rect_selectP.h \ ## gimprotatetool.c \ ## gimprotatetool.h \ ## gimpscaletool.c \ diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c index ebc2ea9346..11c69be32c 100644 --- a/app/tools/gimpfreeselecttool.c +++ b/app/tools/gimpfreeselecttool.c @@ -27,7 +27,6 @@ #include "apptypes.h" -#include "draw_core.h" #include "errors.h" #include "floating_sel.h" #include "gdisplay.h" @@ -36,107 +35,98 @@ #include "gimpimage.h" #include "scan_convert.h" -#include "edit_selection.h" -#include "free_select.h" -#include "rect_select.h" +#include "gimpeditselectiontool.h" +#include "gimpfreeselecttool.h" #include "selection_options.h" #include "tool_options.h" -#include "tools.h" +#include "tool_manager.h" + +#include "libgimp/gimpintl.h" + +#include "pixmaps2.h" #define DEFAULT_MAX_INC 1024 #define SUPERSAMPLE 3 #define SUPERSAMPLE2 9 -/* the free selection structures */ -typedef struct _FreeSelect FreeSelect; +static void gimp_free_select_tool_class_init (GimpFreeSelectToolClass *klass); +static void gimp_free_select_tool_init (GimpFreeSelectTool *free_select); +static void gimp_free_select_tool_destroy (GtkObject *object); -struct _FreeSelect -{ - DrawCore *core; /* Core select object */ +static void gimp_free_select_tool_button_press (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void gimp_free_select_tool_button_release (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void gimp_free_select_tool_motion (GimpTool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); - SelectOps op; /* selection operation (ADD, SUB, etc) */ +static void gimp_free_select_tool_draw (GimpDrawTool *draw_tool); - gint current_x; /* these values are updated on every motion event */ - gint current_y; /* (enables immediate cursor updating on modifier - * key events). */ +static void gimp_free_select_tool_options_reset (void); - gint num_pts; /* Number of points in the polygon */ -}; +static void gimp_free_select_tool_add_point (GimpFreeSelectTool *free_sel, + gint x, + gint y); + +static GimpChannel * scan_convert (GimpImage *gimage, + gint num_pts, + ScanConvertPoint *pts, + gint width, + gint height, + gboolean antialias); -/* local function prototypes */ +static GimpSelectionToolClass *parent_class = NULL; -static void free_select_button_press (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp); -static void free_select_button_release (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp); -static void free_select_motion (Tool *tool, - GdkEventMotion *mevent, - GDisplay *gdisp); - - -/* the free selection tool options */ static SelectionOptions * free_options = NULL; -/* The global array of XPoints for drawing the polygon... */ -static GdkPoint *global_pts = NULL; -static gint max_segs = 0; - -/* functions */ - -static gint -add_point (gint num_pts, - gint x, - gint y) -{ - if (num_pts >= max_segs) - { - max_segs += DEFAULT_MAX_INC; - - global_pts = (GdkPoint *) g_realloc ((void *) global_pts, sizeof (GdkPoint) * max_segs); - - if (!global_pts) - gimp_fatal_error ("add_point(): Unable to reallocate points array in free_select."); - } - - global_pts[num_pts].x = x; - global_pts[num_pts].y = y; - - return 1; -} - - -static GimpChannel * -scan_convert (GimpImage *gimage, - gint num_pts, - ScanConvertPoint *pts, - gint width, - gint height, - gboolean antialias) -{ - GimpChannel *mask; - ScanConverter *sc; - - sc = scan_converter_new (width, height, antialias ? SUPERSAMPLE : 1); - scan_converter_add_points (sc, num_pts, pts); - - mask = scan_converter_to_channel (sc, gimage); - scan_converter_free (sc); - - return mask; -} - - -/*************************************/ -/* Polygonal selection apparatus */ +/* public functions */ void -free_select (GImage *gimage, +gimp_free_select_tool_register (void) +{ + tool_manager_register_tool (GIMP_TYPE_FREE_SELECT_TOOL, FALSE, + "gimp:free_select_tool", + _("Free Select"), + _("Select hand-drawn regions"), + _("/Tools/Selection Tools/Free Select"), "F", + NULL, "tools/free_select.html", + (const gchar **) free_bits); +} + +GtkType +gimp_free_select_tool_get_type (void) +{ + static GtkType free_select_type = 0; + + if (! free_select_type) + { + GtkTypeInfo free_select_info = + { + "GimpFreeSelectTool", + sizeof (GimpFreeSelectTool), + sizeof (GimpFreeSelectToolClass), + (GtkClassInitFunc) gimp_free_select_tool_class_init, + (GtkObjectInitFunc) gimp_free_select_tool_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL + }; + + free_select_type = gtk_type_unique (GIMP_TYPE_SELECTION_TOOL, + &free_select_info); + } + + return free_select_type; +} + +void +free_select (GimpImage *gimage, gint num_pts, ScanConvertPoint *pts, SelectOps op, @@ -171,14 +161,78 @@ free_select (GImage *gimage, } } -static void -free_select_button_press (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp) -{ - FreeSelect *free_sel; - free_sel = (FreeSelect *) tool->private; +/* private functions */ + +static void +gimp_free_select_tool_class_init (GimpFreeSelectToolClass *klass) +{ + GtkObjectClass *object_class; + GimpToolClass *tool_class; + GimpDrawToolClass *draw_tool_class; + + object_class = (GtkObjectClass *) klass; + tool_class = (GimpToolClass *) klass; + draw_tool_class = (GimpDrawToolClass *) klass; + + parent_class = gtk_type_class (GIMP_TYPE_SELECTION_TOOL); + + object_class->destroy = gimp_free_select_tool_destroy; + + tool_class->button_press = gimp_free_select_tool_button_press; + tool_class->button_release = gimp_free_select_tool_button_release; + tool_class->motion = gimp_free_select_tool_motion; + + draw_tool_class->draw = gimp_free_select_tool_draw; +} + +static void +gimp_free_select_tool_init (GimpFreeSelectTool *free_select) +{ + GimpTool *tool; + GimpSelectionTool *select_tool; + + tool = GIMP_TOOL (free_select); + select_tool = GIMP_SELECTION_TOOL (free_select); + + if (! free_options) + { + free_options = selection_options_new (GIMP_TYPE_FREE_SELECT_TOOL, + gimp_free_select_tool_options_reset); + + tool_manager_register_tool_options (GIMP_TYPE_FREE_SELECT_TOOL, + (ToolOptions *) free_options); + } + + tool->tool_cursor = GIMP_FREE_SELECT_TOOL_CURSOR; + tool->scroll_lock = TRUE; /* Do not allow scrolling */ + + free_select->points = NULL; + free_select->num_points = 0; + free_select->max_segs = 0; +} + +static void +gimp_free_select_tool_destroy (GtkObject *object) +{ + GimpFreeSelectTool *free_sel; + + free_sel = GIMP_FREE_SELECT_TOOL (object); + + g_free (free_sel->points); + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + GTK_OBJECT_CLASS (parent_class)->destroy (object); +} + +static void +gimp_free_select_tool_button_press (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp) +{ + GimpFreeSelectTool *free_sel; + + free_sel = GIMP_FREE_SELECT_TOOL (tool); gdk_pointer_grab (gdisp->canvas->window, FALSE, GDK_POINTER_MOTION_HINT_MASK | @@ -189,7 +243,7 @@ free_select_button_press (Tool *tool, tool->state = ACTIVE; tool->gdisp = gdisp; - switch (free_sel->op) + switch (GIMP_SELECTION_TOOL (tool)->op) { case SELECTION_MOVE_MASK: init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); @@ -201,36 +255,36 @@ free_select_button_press (Tool *tool, break; } - add_point (0, bevent->x, bevent->y); - free_sel->num_pts = 1; + free_sel->num_points = 0; - draw_core_start (free_sel->core, - gdisp->canvas->window, - tool); + gimp_free_select_tool_add_point (free_sel, bevent->x, bevent->y); + + gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), + gdisp->canvas->window); } static void -free_select_button_release (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp) +gimp_free_select_tool_button_release (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp) { - FreeSelect *free_sel; - ScanConvertPoint *pts; - gint i; + GimpFreeSelectTool *free_sel; + ScanConvertPoint *pts; + gint i; - free_sel = (FreeSelect *) tool->private; + free_sel = GIMP_FREE_SELECT_TOOL (tool); gdk_pointer_ungrab (bevent->time); gdk_flush (); - draw_core_stop (free_sel->core, tool); + gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); tool->state = INACTIVE; /* First take care of the case where the user "cancels" the action */ if (! (bevent->state & GDK_BUTTON3_MASK)) { - if (free_sel->op == SELECTION_ANCHOR) + if (free_sel->num_points == 1) { /* If there is a floating selection, anchor it */ if (gimp_image_floating_sel (gdisp->gimage)) @@ -238,21 +292,28 @@ free_select_button_release (Tool *tool, /* Otherwise, clear the selection mask */ else gimage_mask_clear (gdisp->gimage); - + gdisplays_flush (); return; } - pts = g_new (ScanConvertPoint, free_sel->num_pts); + pts = g_new (ScanConvertPoint, free_sel->num_points); - for (i = 0; i < free_sel->num_pts; i++) + for (i = 0; i < free_sel->num_points; i++) { - gdisplay_untransform_coords_f (gdisp, global_pts[i].x, global_pts[i].y, - &pts[i].x, &pts[i].y, FALSE); + gdisplay_untransform_coords_f (gdisp, + free_sel->points[i].x, + free_sel->points[i].y, + &pts[i].x, + &pts[i].y, + FALSE); } - free_select (gdisp->gimage, free_sel->num_pts, pts, free_sel->op, - free_options->antialias, free_options->feather, + free_select (gdisp->gimage, + free_sel->num_points, pts, + GIMP_SELECTION_TOOL (tool)->op, + free_options->antialias, + free_options->feather, free_options->feather_radius); g_free (pts); @@ -262,133 +323,107 @@ free_select_button_release (Tool *tool, } static void -free_select_motion (Tool *tool, - GdkEventMotion *mevent, - GDisplay *gdisp) +gimp_free_select_tool_motion (GimpTool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp) { - FreeSelect *free_sel; + GimpFreeSelectTool *free_sel; + GimpSelectionTool *sel_tool; + GimpDrawTool *draw_tool; - free_sel = (FreeSelect *) tool->private; + free_sel = GIMP_FREE_SELECT_TOOL (tool); + sel_tool = GIMP_SELECTION_TOOL (tool); + draw_tool = GIMP_DRAW_TOOL (tool); /* needed for immediate cursor update on modifier event */ - free_sel->current_x = mevent->x; - free_sel->current_y = mevent->y; + sel_tool->current_x = mevent->x; + sel_tool->current_y = mevent->y; if (tool->state != ACTIVE) return; - if (free_sel->op == SELECTION_ANCHOR) + if (sel_tool->op == SELECTION_ANCHOR) { - free_sel->op = SELECTION_REPLACE; + sel_tool->op = SELECTION_REPLACE; - rect_select_cursor_update (tool, mevent, gdisp); + gimp_tool_cursor_update (tool, mevent, gdisp); } - if (add_point (free_sel->num_pts, mevent->x, mevent->y)) - { - gdk_draw_line (free_sel->core->win, free_sel->core->gc, - global_pts[free_sel->num_pts - 1].x, - global_pts[free_sel->num_pts - 1].y, - global_pts[free_sel->num_pts].x, - global_pts[free_sel->num_pts].y); + gimp_free_select_tool_add_point (free_sel, mevent->x, mevent->y); - free_sel->num_pts ++; + gdk_draw_line (draw_tool->win, + draw_tool->gc, + free_sel->points[free_sel->num_points - 2].x, + free_sel->points[free_sel->num_points - 2].y, + free_sel->points[free_sel->num_points - 1].x, + free_sel->points[free_sel->num_points - 1].y); +} + +static void +gimp_free_select_tool_draw (GimpDrawTool *draw_tool) +{ + GimpFreeSelectTool *free_sel; + gint i; + + free_sel = GIMP_FREE_SELECT_TOOL (draw_tool); + + for (i = 1; i < free_sel->num_points; i++) + { + gdk_draw_line (draw_tool->win, + draw_tool->gc, + free_sel->points[i - 1].x, + free_sel->points[i - 1].y, + free_sel->points[i].x, + free_sel->points[i].y); } } static void -free_select_control (Tool *tool, - ToolAction action, - GDisplay *gdisp) -{ - FreeSelect *free_sel; - - free_sel = (FreeSelect *) tool->private; - - switch (action) - { - case PAUSE: - draw_core_pause (free_sel->core, tool); - break; - - case RESUME: - draw_core_resume (free_sel->core, tool); - break; - - case HALT: - draw_core_stop (free_sel->core, tool); - break; - - default: - break; - } -} - -void -free_select_draw (Tool *tool) -{ - FreeSelect *free_sel; - gint i; - - free_sel = (FreeSelect *) tool->private; - - for (i = 1; i < free_sel->num_pts; i++) - gdk_draw_line (free_sel->core->win, free_sel->core->gc, - global_pts[i - 1].x, global_pts[i - 1].y, - global_pts[i].x, global_pts[i].y); -} - -static void -free_select_options_reset (void) +gimp_free_select_tool_options_reset (void) { selection_options_reset (free_options); } -Tool * -tools_new_free_select (void) +static void +gimp_free_select_tool_add_point (GimpFreeSelectTool *free_sel, + gint x, + gint y) { - Tool *tool; - FreeSelect *private; - - /* The tool options */ - if (!free_options) + if (free_sel->num_points >= free_sel->max_segs) { - free_options = - selection_options_new (FREE_SELECT, free_select_options_reset); - tools_register (FREE_SELECT, (ToolOptions *) free_options); + free_sel->max_segs += DEFAULT_MAX_INC; + + free_sel->points = (GdkPoint *) + g_realloc ((void *) free_sel->points, + sizeof (GdkPoint) * free_sel->max_segs); + + if (! free_sel->points) + gimp_fatal_error ("%s(): Unable to reallocate points array", + G_GNUC_FUNCTION); } - tool = tools_new_tool (FREE_SELECT); - private = g_new0 (FreeSelect, 1); + free_sel->points[free_sel->num_points].x = x; + free_sel->points[free_sel->num_points].y = y; - private->core = draw_core_new (free_select_draw); - private->num_pts = 0; - private->op = SELECTION_REPLACE; - - tool->scroll_lock = TRUE; /* Do not allow scrolling */ - - tool->private = (void *) private; - - tool->tool_cursor = GIMP_FREE_SELECT_TOOL_CURSOR; - - tool->button_press_func = free_select_button_press; - tool->button_release_func = free_select_button_release; - tool->motion_func = free_select_motion; - tool->modifier_key_func = rect_select_modifier_update; - tool->cursor_update_func = rect_select_cursor_update; - tool->oper_update_func = rect_select_oper_update; - tool->control_func = free_select_control; - - return tool; + free_sel->num_points++; } -void -tools_free_free_select (Tool *tool) +static GimpChannel * +scan_convert (GimpImage *gimage, + gint num_pts, + ScanConvertPoint *pts, + gint width, + gint height, + gboolean antialias) { - FreeSelect *free_sel; + GimpChannel *mask; + ScanConverter *sc; - free_sel = (FreeSelect *) tool->private; + sc = scan_converter_new (width, height, antialias ? SUPERSAMPLE : 1); + scan_converter_add_points (sc, num_pts, pts); - draw_core_free (free_sel->core); - g_free (free_sel); + mask = scan_converter_to_channel (sc, gimage); + scan_converter_free (sc); + + return mask; } diff --git a/app/tools/gimpfreeselecttool.h b/app/tools/gimpfreeselecttool.h index 11b148c231..33b98a82f8 100644 --- a/app/tools/gimpfreeselecttool.h +++ b/app/tools/gimpfreeselecttool.h @@ -16,23 +16,50 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __FREE_SELECT_H__ -#define __FREE_SELECT_H__ +#ifndef __GIMP_FREE_SELECT_TOOL_H__ +#define __GIMP_FREE_SELECT_TOOL_H__ -/* free select functions */ - -void free_select (GimpImage *gimage, - gint num_pts, - ScanConvertPoint *pts, - SelectOps op, - gboolean antialias, - gboolean feather, - gdouble feather_radius); -void free_select_draw (Tool *tool); - -Tool * tools_new_free_select (void); -void tools_free_free_select (Tool *tool); +#include "gimpselectiontool.h" -#endif /* __FREE_SELECT_H__ */ +#define GIMP_TYPE_FREE_SELECT_TOOL (gimp_free_select_tool_get_type ()) +#define GIMP_FREE_SELECT_TOOL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_FREE_SELECT_TOOL, GimpFreeSelectTool)) +#define GIMP_IS_FREE_SELECT_TOOL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_FREE_SELECT_TOOL)) +#define GIMP_FREE_SELECT_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FREE_SELECT_TOOL, GimpFreeSelectToolClass)) +#define GIMP_IS_FREE_SELECT_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FREE_SELECT_TOOL)) + + +typedef struct _GimpFreeSelectTool GimpFreeSelectTool; +typedef struct _GimpFreeSelectToolClass GimpFreeSelectToolClass; + +struct _GimpFreeSelectTool +{ + GimpSelectionTool parent_instance; + + GdkPoint *points; + gint num_points; + gint max_segs; +}; + +struct _GimpFreeSelectToolClass +{ + GimpSelectionToolClass parent_class; +}; + + +void gimp_free_select_tool_register (void); + +GtkType gimp_free_select_tool_get_type (void); + + +void free_select (GimpImage *gimage, + gint num_pts, + ScanConvertPoint *pts, + SelectOps op, + gboolean antialias, + gboolean feather, + gdouble feather_radius); + + +#endif /* __GIMP_FREE_SELECT_TOOL_H__ */ diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c index b9de1bb02b..c6d66728b7 100644 --- a/app/tools/gimpfuzzyselecttool.c +++ b/app/tools/gimpfuzzyselecttool.c @@ -1,6 +1,3 @@ -#warning (everything commented out) -#if 0 - /* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * @@ -18,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#endif + #include "config.h" #include @@ -50,48 +47,33 @@ #include "libgimp/gimpintl.h" -#if 0 -/* the fuzzy selection structures */ - -typedef struct _FuzzySelect FuzzySelect; - -struct _FuzzySelect -{ - DrawCore *core; /* Core select object */ - - gint op; /* selection operation (ADD, SUB, etc) */ - - gint current_x; /* these values are updated on every motion event */ - gint current_y; /* (enables immediate cursor updating on modifier - * key events). */ - - gint x, y; /* Point from which to execute seed fill */ - gint first_x; /* */ - gint first_y; /* variables to keep track of sensitivity */ - gdouble first_threshold; /* initial value of threshold slider */ -}; +#include "pixmaps2.h" -/* fuzzy select action functions */ -static void fuzzy_select_button_press (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp); -static void fuzzy_select_button_release (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp); -static void fuzzy_select_motion (Tool *tool, - GdkEventMotion *mevent, - GDisplay *gdisp); -static void fuzzy_select_control (Tool *tool, - ToolAction tool_action, - GDisplay *gdisp); +static void gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass); +static void gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select); +static void gimp_fuzzy_select_tool_destroy (GtkObject *object); -static void fuzzy_select_draw (Tool *tool); +static void gimp_fuzzy_select_tool_button_press (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void gimp_fuzzy_select_tool_button_release (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void gimp_fuzzy_select_tool_motion (GimpTool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); -static GdkSegment * fuzzy_select_calculate (Tool *tool, - GDisplay *gdisp, - gint *nsegs); +static void gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool); +static void gimp_fuzzy_select_tool_options_reset (void); + +static GdkSegment * fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, + GDisplay *gdisp, + gint *nsegs); + + +static GimpSelectionToolClass *parent_class = NULL; /* the fuzzy selection tool options */ static SelectionOptions *fuzzy_options = NULL; @@ -102,8 +84,47 @@ static gint num_segs = 0; GimpChannel * fuzzy_mask = NULL; -#endif -/*************************************/ + +/* public functions */ + +void +gimp_fuzzy_select_tool_register (void) +{ + tool_manager_register_tool (GIMP_TYPE_FUZZY_SELECT_TOOL, FALSE, + "gimp:fuzzy_select_tool", + _("Fuzzy Select"), + _("Select contiguous regions"), + _("/Tools/Selection Tools/Fuzzy Select"), "Z", + NULL, "tools/fuzzy_select.html", + (const gchar **) fuzzy_bits); +} + +GtkType +gimp_fuzzy_select_tool_get_type (void) +{ + static GtkType fuzzy_select_type = 0; + + if (! fuzzy_select_type) + { + GtkTypeInfo fuzzy_select_info = + { + "GimpFuzzySelectTool", + sizeof (GimpFuzzySelectTool), + sizeof (GimpFuzzySelectToolClass), + (GtkClassInitFunc) gimp_fuzzy_select_tool_class_init, + (GtkObjectInitFunc) gimp_fuzzy_select_tool_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL + }; + + fuzzy_select_type = gtk_type_unique (GIMP_TYPE_SELECTION_TOOL, + &fuzzy_select_info); + } + + return fuzzy_select_type; +} + +/*******************************/ /* Fuzzy selection apparatus */ static gint @@ -363,9 +384,9 @@ find_contiguous_region (GimpImage *gimage, return mask; } -#if 0 + void -fuzzy_select (GImage *gimage, +fuzzy_select (GimpImage *gimage, GimpDrawable *drawable, gint op, gboolean feather, @@ -400,19 +421,71 @@ fuzzy_select (GImage *gimage, /* fuzzy select action functions */ static void -fuzzy_select_button_press (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp) +gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass) { - FuzzySelect *fuzzy_sel; + GtkObjectClass *object_class; + GimpToolClass *tool_class; + GimpDrawToolClass *draw_tool_class; - fuzzy_sel = (FuzzySelect *) tool->private; + object_class = (GtkObjectClass *) klass; + tool_class = (GimpToolClass *) klass; + draw_tool_class = (GimpDrawToolClass *) klass; - fuzzy_sel->x = bevent->x; - fuzzy_sel->y = bevent->y; - fuzzy_sel->first_x = fuzzy_sel->x; - fuzzy_sel->first_y = fuzzy_sel->y; - fuzzy_sel->first_threshold = fuzzy_options->threshold; + parent_class = gtk_type_class (GIMP_TYPE_SELECTION_TOOL); + + object_class->destroy = gimp_fuzzy_select_tool_destroy; + + tool_class->button_press = gimp_fuzzy_select_tool_button_press; + tool_class->button_release = gimp_fuzzy_select_tool_button_release; + tool_class->motion = gimp_fuzzy_select_tool_motion; + + draw_tool_class->draw = gimp_fuzzy_select_tool_draw; +} + +static void +gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select) +{ + GimpTool *tool; + GimpSelectionTool *select_tool; + + tool = GIMP_TOOL (fuzzy_select); + select_tool = GIMP_SELECTION_TOOL (fuzzy_select); + + if (! fuzzy_options) + { + fuzzy_options = + selection_options_new (GIMP_TYPE_FUZZY_SELECT_TOOL, + gimp_fuzzy_select_tool_options_reset); + + tool_manager_register_tool_options (GIMP_TYPE_FUZZY_SELECT_TOOL, + (ToolOptions *) fuzzy_options); + } + + tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR; + tool->scroll_lock = TRUE; /* Do not allow scrolling */ + + fuzzy_select->x = 0; + fuzzy_select->y = 0; + fuzzy_select->first_x = 0; + fuzzy_select->first_y = 0; + fuzzy_select->first_threshold = 0.0; +} + +static void +gimp_fuzzy_select_tool_destroy (GtkObject *object) +{ + if (GTK_OBJECT_CLASS (parent_class)->destroy) + GTK_OBJECT_CLASS (parent_class)->destroy (object); +} + +static void +gimp_fuzzy_select_tool_button_press (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp) +{ + GimpFuzzySelectTool *fuzzy_sel; + + fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); gdk_pointer_grab (gdisp->canvas->window, FALSE, GDK_POINTER_MOTION_HINT_MASK | @@ -423,39 +496,45 @@ fuzzy_select_button_press (Tool *tool, tool->state = ACTIVE; tool->gdisp = gdisp; - if (fuzzy_sel->op == SELECTION_MOVE_MASK) + fuzzy_sel->x = bevent->x; + fuzzy_sel->y = bevent->y; + fuzzy_sel->first_x = fuzzy_sel->x; + fuzzy_sel->first_y = fuzzy_sel->y; + fuzzy_sel->first_threshold = fuzzy_options->threshold; + + switch (GIMP_SELECTION_TOOL (tool)->op) { + case SELECTION_MOVE_MASK: init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; - } - else if (fuzzy_sel->op == SELECTION_MOVE) - { + case SELECTION_MOVE: init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; + default: + break; } /* calculate the region boundary */ - segs = fuzzy_select_calculate (tool, gdisp, &num_segs); + segs = fuzzy_select_calculate (fuzzy_sel, gdisp, &num_segs); - draw_core_start (fuzzy_sel->core, - gdisp->canvas->window, - tool); + gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), + gdisp->canvas->window); } static void -fuzzy_select_button_release (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp) +gimp_fuzzy_select_tool_button_release (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp) { - FuzzySelect *fuzzy_sel; - GimpDrawable *drawable; + GimpFuzzySelectTool *fuzzy_sel; + GimpDrawable *drawable; - fuzzy_sel = (FuzzySelect *) tool->private; + fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); gdk_pointer_ungrab (bevent->time); gdk_flush (); - draw_core_stop (fuzzy_sel->core, tool); + gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); tool->state = INACTIVE; /* First take care of the case where the user "cancels" the action */ @@ -464,9 +543,12 @@ fuzzy_select_button_release (Tool *tool, drawable = (fuzzy_options->sample_merged ? NULL : gimp_image_active_drawable (gdisp->gimage)); - fuzzy_select (gdisp->gimage, drawable, fuzzy_sel->op, - fuzzy_options->feather, + fuzzy_select (gdisp->gimage, + drawable, + GIMP_SELECTION_TOOL (tool)->op, + fuzzy_options->feather, fuzzy_options->feather_radius); + gdisplays_flush (); } @@ -477,23 +559,25 @@ fuzzy_select_button_release (Tool *tool, } static void -fuzzy_select_motion (Tool *tool, - GdkEventMotion *mevent, - GDisplay *gdisp) +gimp_fuzzy_select_tool_motion (GimpTool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp) { - FuzzySelect *fuzzy_sel; - GdkSegment *new_segs; - gint num_new_segs; - gint diff_x, diff_y; - gdouble diff; + GimpFuzzySelectTool *fuzzy_sel; + GimpSelectionTool *sel_tool; + GdkSegment *new_segs; + gint num_new_segs; + gint diff_x, diff_y; + gdouble diff; static guint last_time = 0; - fuzzy_sel = (FuzzySelect *) tool->private; + fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); + sel_tool = GIMP_SELECTION_TOOL (tool); /* needed for immediate cursor update on modifier event */ - fuzzy_sel->current_x = mevent->x; - fuzzy_sel->current_y = mevent->y; + sel_tool->current_x = mevent->x; + sel_tool->current_y = mevent->y; if (tool->state != ACTIVE) return; @@ -501,7 +585,7 @@ fuzzy_select_motion (Tool *tool, /* don't let the events come in too fast, ignore below a delay of 100 ms */ if (ABS (mevent->time - last_time) < 100) return; - + last_time = mevent->time; diff_x = mevent->x - fuzzy_sel->first_x; @@ -511,12 +595,12 @@ fuzzy_select_motion (Tool *tool, gtk_adjustment_set_value (GTK_ADJUSTMENT (fuzzy_options->threshold_w), fuzzy_sel->first_threshold + diff); - + /* calculate the new fuzzy boundary */ - new_segs = fuzzy_select_calculate (tool, gdisp, &num_new_segs); + new_segs = fuzzy_select_calculate (fuzzy_sel, gdisp, &num_new_segs); /* stop the current boundary */ - draw_core_pause (fuzzy_sel->core, tool); + gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); /* make sure the XSegment array is freed before we assign the new one */ if (segs) @@ -525,17 +609,16 @@ fuzzy_select_motion (Tool *tool, num_segs = num_new_segs; /* start the new boundary */ - draw_core_resume (fuzzy_sel->core, tool); + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } static GdkSegment * -fuzzy_select_calculate (Tool *tool, - GDisplay *gdisp, - gint *nsegs) +fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, + GDisplay *gdisp, + gint *nsegs) { PixelRegion maskPR; - FuzzySelect *fuzzy_sel; GimpChannel *new; GdkSegment *segs; BoundSeg *bsegs; @@ -544,7 +627,6 @@ fuzzy_select_calculate (Tool *tool, gint x, y; gboolean use_offsets; - fuzzy_sel = (FuzzySelect *) tool->private; drawable = gimp_image_active_drawable (gdisp->gimage); gimp_add_busy_cursors (); @@ -599,93 +681,20 @@ fuzzy_select_calculate (Tool *tool, } static void -fuzzy_select_draw (Tool *tool) +gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool) { - FuzzySelect *fuzzy_sel; + GimpFuzzySelectTool *fuzzy_sel; - fuzzy_sel = (FuzzySelect *) tool->private; + fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (draw_tool); if (segs) - gdk_draw_segments (fuzzy_sel->core->win, fuzzy_sel->core->gc, segs, num_segs); + gdk_draw_segments (draw_tool->win, + draw_tool->gc, + segs, num_segs); } static void -fuzzy_select_control (Tool *tool, - ToolAction action, - GDisplay *gdisp) -{ - FuzzySelect *fuzzy_sel; - - fuzzy_sel = (FuzzySelect *) tool->private; - - switch (action) - { - case PAUSE : - draw_core_pause (fuzzy_sel->core, tool); - break; - - case RESUME : - draw_core_resume (fuzzy_sel->core, tool); - break; - - case HALT : - draw_core_stop (fuzzy_sel->core, tool); - break; - - default: - break; - } -} - -static void -fuzzy_select_options_reset (void) +gimp_fuzzy_select_tool_options_reset (void) { selection_options_reset (fuzzy_options); } - -Tool * -tools_new_fuzzy_select (void) -{ - Tool *tool; - FuzzySelect *private; - - /* The tool options */ - if (! fuzzy_options) - { - fuzzy_options = selection_options_new (FUZZY_SELECT, - fuzzy_select_options_reset); - tools_register (FUZZY_SELECT, (ToolOptions *) fuzzy_options); - } - - tool = tools_new_tool (FUZZY_SELECT); - private = g_new0 (FuzzySelect, 1); - - private->core = draw_core_new (fuzzy_select_draw); - - tool->scroll_lock = TRUE; /* Disallow scrolling */ - - tool->private = (void *) private; - - tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR; - - tool->button_press_func = fuzzy_select_button_press; - tool->button_release_func = fuzzy_select_button_release; - tool->motion_func = fuzzy_select_motion; - tool->modifier_key_func = rect_select_modifier_update; - tool->cursor_update_func = rect_select_cursor_update; - tool->oper_update_func = rect_select_oper_update; - tool->control_func = fuzzy_select_control; - - return tool; -} - -void -tools_free_fuzzy_select (Tool *tool) -{ - FuzzySelect *fuzzy_sel; - - fuzzy_sel = (FuzzySelect *) tool->private; - draw_core_free (fuzzy_sel->core); - g_free (fuzzy_sel); -} -#endif diff --git a/app/tools/gimpfuzzyselecttool.h b/app/tools/gimpfuzzyselecttool.h index 049dba3205..2f6e1bd4b7 100644 --- a/app/tools/gimpfuzzyselecttool.h +++ b/app/tools/gimpfuzzyselecttool.h @@ -16,28 +16,59 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __FUZZY_SELECT_H__ -#define __FUZZY_SELECT_H__ +#ifndef __GIMP_FUZZY_SELECT_TOOL_H__ +#define __GIMP_FUZZY_SELECT_TOOL_H__ -GimpChannel * find_contiguous_region (GimpImage *gimage, - GimpDrawable *drawable, - gboolean antialias, - gint threshold, - gint x, - gint y, - gboolean sample_merged); -void fuzzy_select (GimpImage *gimage, - GimpDrawable *drawable, - gint op, - gboolean feather, - gdouble feather_radius); +#include "gimpselectiontool.h" -Tool * tools_new_fuzzy_select (void); -void tools_free_fuzzy_select (Tool *tool); + +#define GIMP_TYPE_FUZZY_SELECT_TOOL (gimp_fuzzy_select_tool_get_type ()) +#define GIMP_FUZZY_SELECT_TOOL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_FUZZY_SELECT_TOOL, GimpFuzzySelectTool)) +#define GIMP_IS_FUZZY_SELECT_TOOL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_FUZZY_SELECT_TOOL)) +#define GIMP_FUZZY_SELECT_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FUZZY_SELECT_TOOL, GimpFuzzySelectToolClass)) +#define GIMP_IS_FUZZY_SELECT_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FUZZY_SELECT_TOOL)) + + +typedef struct _GimpFuzzySelectTool GimpFuzzySelectTool; +typedef struct _GimpFuzzySelectToolClass GimpFuzzySelectToolClass; + +struct _GimpFuzzySelectTool +{ + GimpSelectionTool parent_instance; + + gint x, y; /* Point from which to execute seed fill */ + gint first_x; /* */ + gint first_y; /* variables to keep track of sensitivity */ + gdouble first_threshold; /* initial value of threshold slider */ +}; + +struct _GimpFuzzySelectToolClass +{ + GimpSelectionToolClass parent_class; +}; + + +void gimp_fuzzy_select_tool_register (void); + +GtkType gimp_fuzzy_select_tool_get_type (void); + + +GimpChannel * find_contiguous_region (GimpImage *gimage, + GimpDrawable *drawable, + gboolean antialias, + gint threshold, + gint x, + gint y, + gboolean sample_merged); +void fuzzy_select (GimpImage *gimage, + GimpDrawable *drawable, + gint op, + gboolean feather, + gdouble feather_radius); extern GimpChannel *fuzzy_mask; -#endif /* __FUZZY_SELECT_H__ */ +#endif /* __GIMP_FUZZY_SELECT_TOOL_H__ */ diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index ca65881923..3473a2429a 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -238,19 +238,11 @@ gimp_rect_select_tool_init (GimpRectSelectTool *rect_select) rect_select->x = rect_select->y = 0; rect_select->w = rect_select->h = 0; - } static void gimp_rect_select_tool_destroy (GtkObject *object) { - GimpTool *tool; - - tool = GIMP_TOOL (object); - - if (tool->state == ACTIVE) - gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); - if (GTK_OBJECT_CLASS (parent_class)->destroy) GTK_OBJECT_CLASS (parent_class)->destroy (object); } @@ -381,6 +373,7 @@ gimp_rect_select_tool_button_release (GimpTool *tool, gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id); gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); + tool->state = INACTIVE; /* First take care of the case where the user "cancels" the action */ diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c index b9de1bb02b..c6d66728b7 100644 --- a/app/tools/gimpregionselecttool.c +++ b/app/tools/gimpregionselecttool.c @@ -1,6 +1,3 @@ -#warning (everything commented out) -#if 0 - /* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * @@ -18,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#endif + #include "config.h" #include @@ -50,48 +47,33 @@ #include "libgimp/gimpintl.h" -#if 0 -/* the fuzzy selection structures */ - -typedef struct _FuzzySelect FuzzySelect; - -struct _FuzzySelect -{ - DrawCore *core; /* Core select object */ - - gint op; /* selection operation (ADD, SUB, etc) */ - - gint current_x; /* these values are updated on every motion event */ - gint current_y; /* (enables immediate cursor updating on modifier - * key events). */ - - gint x, y; /* Point from which to execute seed fill */ - gint first_x; /* */ - gint first_y; /* variables to keep track of sensitivity */ - gdouble first_threshold; /* initial value of threshold slider */ -}; +#include "pixmaps2.h" -/* fuzzy select action functions */ -static void fuzzy_select_button_press (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp); -static void fuzzy_select_button_release (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp); -static void fuzzy_select_motion (Tool *tool, - GdkEventMotion *mevent, - GDisplay *gdisp); -static void fuzzy_select_control (Tool *tool, - ToolAction tool_action, - GDisplay *gdisp); +static void gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass); +static void gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select); +static void gimp_fuzzy_select_tool_destroy (GtkObject *object); -static void fuzzy_select_draw (Tool *tool); +static void gimp_fuzzy_select_tool_button_press (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void gimp_fuzzy_select_tool_button_release (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void gimp_fuzzy_select_tool_motion (GimpTool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); -static GdkSegment * fuzzy_select_calculate (Tool *tool, - GDisplay *gdisp, - gint *nsegs); +static void gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool); +static void gimp_fuzzy_select_tool_options_reset (void); + +static GdkSegment * fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, + GDisplay *gdisp, + gint *nsegs); + + +static GimpSelectionToolClass *parent_class = NULL; /* the fuzzy selection tool options */ static SelectionOptions *fuzzy_options = NULL; @@ -102,8 +84,47 @@ static gint num_segs = 0; GimpChannel * fuzzy_mask = NULL; -#endif -/*************************************/ + +/* public functions */ + +void +gimp_fuzzy_select_tool_register (void) +{ + tool_manager_register_tool (GIMP_TYPE_FUZZY_SELECT_TOOL, FALSE, + "gimp:fuzzy_select_tool", + _("Fuzzy Select"), + _("Select contiguous regions"), + _("/Tools/Selection Tools/Fuzzy Select"), "Z", + NULL, "tools/fuzzy_select.html", + (const gchar **) fuzzy_bits); +} + +GtkType +gimp_fuzzy_select_tool_get_type (void) +{ + static GtkType fuzzy_select_type = 0; + + if (! fuzzy_select_type) + { + GtkTypeInfo fuzzy_select_info = + { + "GimpFuzzySelectTool", + sizeof (GimpFuzzySelectTool), + sizeof (GimpFuzzySelectToolClass), + (GtkClassInitFunc) gimp_fuzzy_select_tool_class_init, + (GtkObjectInitFunc) gimp_fuzzy_select_tool_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL + }; + + fuzzy_select_type = gtk_type_unique (GIMP_TYPE_SELECTION_TOOL, + &fuzzy_select_info); + } + + return fuzzy_select_type; +} + +/*******************************/ /* Fuzzy selection apparatus */ static gint @@ -363,9 +384,9 @@ find_contiguous_region (GimpImage *gimage, return mask; } -#if 0 + void -fuzzy_select (GImage *gimage, +fuzzy_select (GimpImage *gimage, GimpDrawable *drawable, gint op, gboolean feather, @@ -400,19 +421,71 @@ fuzzy_select (GImage *gimage, /* fuzzy select action functions */ static void -fuzzy_select_button_press (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp) +gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass) { - FuzzySelect *fuzzy_sel; + GtkObjectClass *object_class; + GimpToolClass *tool_class; + GimpDrawToolClass *draw_tool_class; - fuzzy_sel = (FuzzySelect *) tool->private; + object_class = (GtkObjectClass *) klass; + tool_class = (GimpToolClass *) klass; + draw_tool_class = (GimpDrawToolClass *) klass; - fuzzy_sel->x = bevent->x; - fuzzy_sel->y = bevent->y; - fuzzy_sel->first_x = fuzzy_sel->x; - fuzzy_sel->first_y = fuzzy_sel->y; - fuzzy_sel->first_threshold = fuzzy_options->threshold; + parent_class = gtk_type_class (GIMP_TYPE_SELECTION_TOOL); + + object_class->destroy = gimp_fuzzy_select_tool_destroy; + + tool_class->button_press = gimp_fuzzy_select_tool_button_press; + tool_class->button_release = gimp_fuzzy_select_tool_button_release; + tool_class->motion = gimp_fuzzy_select_tool_motion; + + draw_tool_class->draw = gimp_fuzzy_select_tool_draw; +} + +static void +gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select) +{ + GimpTool *tool; + GimpSelectionTool *select_tool; + + tool = GIMP_TOOL (fuzzy_select); + select_tool = GIMP_SELECTION_TOOL (fuzzy_select); + + if (! fuzzy_options) + { + fuzzy_options = + selection_options_new (GIMP_TYPE_FUZZY_SELECT_TOOL, + gimp_fuzzy_select_tool_options_reset); + + tool_manager_register_tool_options (GIMP_TYPE_FUZZY_SELECT_TOOL, + (ToolOptions *) fuzzy_options); + } + + tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR; + tool->scroll_lock = TRUE; /* Do not allow scrolling */ + + fuzzy_select->x = 0; + fuzzy_select->y = 0; + fuzzy_select->first_x = 0; + fuzzy_select->first_y = 0; + fuzzy_select->first_threshold = 0.0; +} + +static void +gimp_fuzzy_select_tool_destroy (GtkObject *object) +{ + if (GTK_OBJECT_CLASS (parent_class)->destroy) + GTK_OBJECT_CLASS (parent_class)->destroy (object); +} + +static void +gimp_fuzzy_select_tool_button_press (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp) +{ + GimpFuzzySelectTool *fuzzy_sel; + + fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); gdk_pointer_grab (gdisp->canvas->window, FALSE, GDK_POINTER_MOTION_HINT_MASK | @@ -423,39 +496,45 @@ fuzzy_select_button_press (Tool *tool, tool->state = ACTIVE; tool->gdisp = gdisp; - if (fuzzy_sel->op == SELECTION_MOVE_MASK) + fuzzy_sel->x = bevent->x; + fuzzy_sel->y = bevent->y; + fuzzy_sel->first_x = fuzzy_sel->x; + fuzzy_sel->first_y = fuzzy_sel->y; + fuzzy_sel->first_threshold = fuzzy_options->threshold; + + switch (GIMP_SELECTION_TOOL (tool)->op) { + case SELECTION_MOVE_MASK: init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; - } - else if (fuzzy_sel->op == SELECTION_MOVE) - { + case SELECTION_MOVE: init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; + default: + break; } /* calculate the region boundary */ - segs = fuzzy_select_calculate (tool, gdisp, &num_segs); + segs = fuzzy_select_calculate (fuzzy_sel, gdisp, &num_segs); - draw_core_start (fuzzy_sel->core, - gdisp->canvas->window, - tool); + gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), + gdisp->canvas->window); } static void -fuzzy_select_button_release (Tool *tool, - GdkEventButton *bevent, - GDisplay *gdisp) +gimp_fuzzy_select_tool_button_release (GimpTool *tool, + GdkEventButton *bevent, + GDisplay *gdisp) { - FuzzySelect *fuzzy_sel; - GimpDrawable *drawable; + GimpFuzzySelectTool *fuzzy_sel; + GimpDrawable *drawable; - fuzzy_sel = (FuzzySelect *) tool->private; + fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); gdk_pointer_ungrab (bevent->time); gdk_flush (); - draw_core_stop (fuzzy_sel->core, tool); + gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); tool->state = INACTIVE; /* First take care of the case where the user "cancels" the action */ @@ -464,9 +543,12 @@ fuzzy_select_button_release (Tool *tool, drawable = (fuzzy_options->sample_merged ? NULL : gimp_image_active_drawable (gdisp->gimage)); - fuzzy_select (gdisp->gimage, drawable, fuzzy_sel->op, - fuzzy_options->feather, + fuzzy_select (gdisp->gimage, + drawable, + GIMP_SELECTION_TOOL (tool)->op, + fuzzy_options->feather, fuzzy_options->feather_radius); + gdisplays_flush (); } @@ -477,23 +559,25 @@ fuzzy_select_button_release (Tool *tool, } static void -fuzzy_select_motion (Tool *tool, - GdkEventMotion *mevent, - GDisplay *gdisp) +gimp_fuzzy_select_tool_motion (GimpTool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp) { - FuzzySelect *fuzzy_sel; - GdkSegment *new_segs; - gint num_new_segs; - gint diff_x, diff_y; - gdouble diff; + GimpFuzzySelectTool *fuzzy_sel; + GimpSelectionTool *sel_tool; + GdkSegment *new_segs; + gint num_new_segs; + gint diff_x, diff_y; + gdouble diff; static guint last_time = 0; - fuzzy_sel = (FuzzySelect *) tool->private; + fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); + sel_tool = GIMP_SELECTION_TOOL (tool); /* needed for immediate cursor update on modifier event */ - fuzzy_sel->current_x = mevent->x; - fuzzy_sel->current_y = mevent->y; + sel_tool->current_x = mevent->x; + sel_tool->current_y = mevent->y; if (tool->state != ACTIVE) return; @@ -501,7 +585,7 @@ fuzzy_select_motion (Tool *tool, /* don't let the events come in too fast, ignore below a delay of 100 ms */ if (ABS (mevent->time - last_time) < 100) return; - + last_time = mevent->time; diff_x = mevent->x - fuzzy_sel->first_x; @@ -511,12 +595,12 @@ fuzzy_select_motion (Tool *tool, gtk_adjustment_set_value (GTK_ADJUSTMENT (fuzzy_options->threshold_w), fuzzy_sel->first_threshold + diff); - + /* calculate the new fuzzy boundary */ - new_segs = fuzzy_select_calculate (tool, gdisp, &num_new_segs); + new_segs = fuzzy_select_calculate (fuzzy_sel, gdisp, &num_new_segs); /* stop the current boundary */ - draw_core_pause (fuzzy_sel->core, tool); + gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); /* make sure the XSegment array is freed before we assign the new one */ if (segs) @@ -525,17 +609,16 @@ fuzzy_select_motion (Tool *tool, num_segs = num_new_segs; /* start the new boundary */ - draw_core_resume (fuzzy_sel->core, tool); + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } static GdkSegment * -fuzzy_select_calculate (Tool *tool, - GDisplay *gdisp, - gint *nsegs) +fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, + GDisplay *gdisp, + gint *nsegs) { PixelRegion maskPR; - FuzzySelect *fuzzy_sel; GimpChannel *new; GdkSegment *segs; BoundSeg *bsegs; @@ -544,7 +627,6 @@ fuzzy_select_calculate (Tool *tool, gint x, y; gboolean use_offsets; - fuzzy_sel = (FuzzySelect *) tool->private; drawable = gimp_image_active_drawable (gdisp->gimage); gimp_add_busy_cursors (); @@ -599,93 +681,20 @@ fuzzy_select_calculate (Tool *tool, } static void -fuzzy_select_draw (Tool *tool) +gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool) { - FuzzySelect *fuzzy_sel; + GimpFuzzySelectTool *fuzzy_sel; - fuzzy_sel = (FuzzySelect *) tool->private; + fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (draw_tool); if (segs) - gdk_draw_segments (fuzzy_sel->core->win, fuzzy_sel->core->gc, segs, num_segs); + gdk_draw_segments (draw_tool->win, + draw_tool->gc, + segs, num_segs); } static void -fuzzy_select_control (Tool *tool, - ToolAction action, - GDisplay *gdisp) -{ - FuzzySelect *fuzzy_sel; - - fuzzy_sel = (FuzzySelect *) tool->private; - - switch (action) - { - case PAUSE : - draw_core_pause (fuzzy_sel->core, tool); - break; - - case RESUME : - draw_core_resume (fuzzy_sel->core, tool); - break; - - case HALT : - draw_core_stop (fuzzy_sel->core, tool); - break; - - default: - break; - } -} - -static void -fuzzy_select_options_reset (void) +gimp_fuzzy_select_tool_options_reset (void) { selection_options_reset (fuzzy_options); } - -Tool * -tools_new_fuzzy_select (void) -{ - Tool *tool; - FuzzySelect *private; - - /* The tool options */ - if (! fuzzy_options) - { - fuzzy_options = selection_options_new (FUZZY_SELECT, - fuzzy_select_options_reset); - tools_register (FUZZY_SELECT, (ToolOptions *) fuzzy_options); - } - - tool = tools_new_tool (FUZZY_SELECT); - private = g_new0 (FuzzySelect, 1); - - private->core = draw_core_new (fuzzy_select_draw); - - tool->scroll_lock = TRUE; /* Disallow scrolling */ - - tool->private = (void *) private; - - tool->tool_cursor = GIMP_FUZZY_SELECT_TOOL_CURSOR; - - tool->button_press_func = fuzzy_select_button_press; - tool->button_release_func = fuzzy_select_button_release; - tool->motion_func = fuzzy_select_motion; - tool->modifier_key_func = rect_select_modifier_update; - tool->cursor_update_func = rect_select_cursor_update; - tool->oper_update_func = rect_select_oper_update; - tool->control_func = fuzzy_select_control; - - return tool; -} - -void -tools_free_fuzzy_select (Tool *tool) -{ - FuzzySelect *fuzzy_sel; - - fuzzy_sel = (FuzzySelect *) tool->private; - draw_core_free (fuzzy_sel->core); - g_free (fuzzy_sel); -} -#endif diff --git a/app/tools/gimpregionselecttool.h b/app/tools/gimpregionselecttool.h index 049dba3205..2f6e1bd4b7 100644 --- a/app/tools/gimpregionselecttool.h +++ b/app/tools/gimpregionselecttool.h @@ -16,28 +16,59 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __FUZZY_SELECT_H__ -#define __FUZZY_SELECT_H__ +#ifndef __GIMP_FUZZY_SELECT_TOOL_H__ +#define __GIMP_FUZZY_SELECT_TOOL_H__ -GimpChannel * find_contiguous_region (GimpImage *gimage, - GimpDrawable *drawable, - gboolean antialias, - gint threshold, - gint x, - gint y, - gboolean sample_merged); -void fuzzy_select (GimpImage *gimage, - GimpDrawable *drawable, - gint op, - gboolean feather, - gdouble feather_radius); +#include "gimpselectiontool.h" -Tool * tools_new_fuzzy_select (void); -void tools_free_fuzzy_select (Tool *tool); + +#define GIMP_TYPE_FUZZY_SELECT_TOOL (gimp_fuzzy_select_tool_get_type ()) +#define GIMP_FUZZY_SELECT_TOOL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_FUZZY_SELECT_TOOL, GimpFuzzySelectTool)) +#define GIMP_IS_FUZZY_SELECT_TOOL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_FUZZY_SELECT_TOOL)) +#define GIMP_FUZZY_SELECT_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FUZZY_SELECT_TOOL, GimpFuzzySelectToolClass)) +#define GIMP_IS_FUZZY_SELECT_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FUZZY_SELECT_TOOL)) + + +typedef struct _GimpFuzzySelectTool GimpFuzzySelectTool; +typedef struct _GimpFuzzySelectToolClass GimpFuzzySelectToolClass; + +struct _GimpFuzzySelectTool +{ + GimpSelectionTool parent_instance; + + gint x, y; /* Point from which to execute seed fill */ + gint first_x; /* */ + gint first_y; /* variables to keep track of sensitivity */ + gdouble first_threshold; /* initial value of threshold slider */ +}; + +struct _GimpFuzzySelectToolClass +{ + GimpSelectionToolClass parent_class; +}; + + +void gimp_fuzzy_select_tool_register (void); + +GtkType gimp_fuzzy_select_tool_get_type (void); + + +GimpChannel * find_contiguous_region (GimpImage *gimage, + GimpDrawable *drawable, + gboolean antialias, + gint threshold, + gint x, + gint y, + gboolean sample_merged); +void fuzzy_select (GimpImage *gimage, + GimpDrawable *drawable, + gint op, + gboolean feather, + gdouble feather_radius); extern GimpChannel *fuzzy_mask; -#endif /* __FUZZY_SELECT_H__ */ +#endif /* __GIMP_FUZZY_SELECT_TOOL_H__ */ diff --git a/app/tools/gimpselectionoptions.c b/app/tools/gimpselectionoptions.c index 13faeb9680..d4fc2a7160 100644 --- a/app/tools/gimpselectionoptions.c +++ b/app/tools/gimpselectionoptions.c @@ -27,6 +27,7 @@ #include "gimprc.h" #include "gimpellipseselecttool.h" +#include "gimpfuzzyselecttool.h" #include "gimprectselecttool.h" #include "gimptool.h" #include "gimptoolinfo.h" diff --git a/app/tools/gimptool.c b/app/tools/gimptool.c index 7bab75a38c..bc7f0286a7 100644 --- a/app/tools/gimptool.c +++ b/app/tools/gimptool.c @@ -531,7 +531,6 @@ STUB(paths_dialog_paste_path_callback) STUB(paths_dialog_import_path_callback) STUB(paths_dialog_export_path_callback) STUB(paths_dialog_edit_path_attributes_callback) -QUIET_STUB(GIMP_IS_FUZZY_SELECT) STUB(dodgeburn_non_gui) STUB(dodgeburn_non_gui_default) STUB(eraser_non_gui) @@ -539,9 +538,6 @@ STUB(eraser_non_gui_default) STUB(transform_core_cut) STUB(flip_tool_flip) STUB(transform_core_paste) -STUB(free_select) -STUB(fuzzy_mask) -STUB(fuzzy_select) STUB(pencil_non_gui) STUB(perspective_find_transform) STUB(perspective_tool_perspective) @@ -565,62 +561,6 @@ STUB(path_transform_xy) #ifdef STONE_AGE ToolInfo tool_info[] = { - { - NULL, - N_("Free Select"), - N_("/Tools/Select Tools/Free Select"), - "F", - (char **) free_bits, - NULL, - NULL, - N_("Select hand-drawn regions"), - "tools/free_select.html", - FREE_SELECT, - tools_new_free_select, - tools_free_free_select, - NULL, - NULL, - NULL, - { - free_select_small_bits, free_select_small_mask_bits, - free_select_small_width, free_select_small_height, - 0, 0, NULL, NULL, NULL - }, - { - NULL, NULL, - 0, 0, - 0, 0, NULL, NULL, NULL - } - }, - - { - NULL, - N_("Fuzzy Select"), - N_("/Tools/Select Tools/Fuzzy Select"), - "Z", - (char **) fuzzy_bits, - NULL, - NULL, - N_("Select contiguous regions"), - "tools/fuzzy_select.html", - FUZZY_SELECT, - tools_new_fuzzy_select, - tools_free_fuzzy_select, - NULL, - NULL, - NULL, - { - fuzzy_select_small_bits, fuzzy_select_small_mask_bits, - fuzzy_select_small_width, fuzzy_select_small_height, - 0, 0, NULL, NULL, NULL - }, - { - NULL, NULL, - 0, 0, - 0, 0, NULL, NULL, NULL - } - }, - { NULL, N_("Bezier Select"), diff --git a/app/tools/gimptool.h b/app/tools/gimptool.h index 894020fd1d..7e9db0e09a 100644 --- a/app/tools/gimptool.h +++ b/app/tools/gimptool.h @@ -24,7 +24,6 @@ #define GIMP_TYPE_ISCISSORS_TOOL GTK_TYPE_NONE -#define GIMP_TYPE_FUZZY_SELECT_TOOL GTK_TYPE_NONE #define GIMP_TYPE_BY_COLOR_SELECT_TOOL GTK_TYPE_NONE #define GIMP_TYPE_BLEND_TOOL GTK_TYPE_NONE #define GIMP_TYPE_PENCIL_TOOL GTK_TYPE_NONE diff --git a/app/tools/rect_selectP.h b/app/tools/rect_selectP.h deleted file mode 100644 index cce1e57051..0000000000 --- a/app/tools/rect_selectP.h +++ /dev/null @@ -1,47 +0,0 @@ -/* 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 __RECT_SELECTP_H__ -#define __RECT_SELECTP_H__ - - -typedef struct _RectSelect RectSelect, EllipseSelect; - -struct _RectSelect -{ - DrawCore *core; /* Core select object */ - - SelectOps op; /* selection operation (SELECTION_ADD etc.) */ - - gint current_x; /* these values are updated on every motion event */ - gint current_y; /* (enables immediate cursor updating on modifier - * key events). */ - - gint x, y; /* upper left hand coordinate */ - gint w, h; /* width and height */ - gint center; /* is the selection being created from the - * center out? */ - - gint fixed_size; - gdouble fixed_width; - gdouble fixed_height; - guint context_id; /* for the statusbar */ -}; - - -#endif /* __RECT_SELECTP_H__ */ diff --git a/app/tools/selection_options.c b/app/tools/selection_options.c index 13faeb9680..d4fc2a7160 100644 --- a/app/tools/selection_options.c +++ b/app/tools/selection_options.c @@ -27,6 +27,7 @@ #include "gimprc.h" #include "gimpellipseselecttool.h" +#include "gimpfuzzyselecttool.h" #include "gimprectselecttool.h" #include "gimptool.h" #include "gimptoolinfo.h" diff --git a/app/tools/tools.c b/app/tools/tools.c index c0cf07eb4f..9b3d3916c1 100644 --- a/app/tools/tools.c +++ b/app/tools/tools.c @@ -66,6 +66,8 @@ register_tools (void) gimp_color_picker_tool_register (); gimp_text_tool_register (); gimp_move_tool_register (); + gimp_fuzzy_select_tool_register (); + gimp_free_select_tool_register (); gimp_ellipse_select_tool_register (); gimp_rect_select_tool_register (); @@ -85,15 +87,12 @@ register_tools (void) procedural_db_register (&crop_proc); procedural_db_register (&dodgeburn_proc); procedural_db_register (&dodgeburn_default_proc); - procedural_db_register (&ellipse_select_proc); procedural_db_register (&eraser_proc); procedural_db_register (&eraser_default_proc); procedural_db_register (&flip_proc); - procedural_db_register (&free_select_proc); procedural_db_register (&fuzzy_select_proc); procedural_db_register (&pencil_proc); procedural_db_register (&perspective_proc); - procedural_db_register (&rect_select_proc); procedural_db_register (&rotate_proc); procedural_db_register (&scale_proc); procedural_db_register (&shear_proc);