app/tools/Makefile.am removed.

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

	* 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.
This commit is contained in:
Michael Natterer
2001-03-09 17:39:18 +00:00
committed by Michael Natterer
parent 6fa118a0fd
commit 80b55c7e52
19 changed files with 808 additions and 761 deletions

View File

@ -1,3 +1,21 @@
2001-03-09 Michael Natterer <mitch@gimp.org>
* 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 <rock@gimp.org> 2001-03-09 Nathan Summers <rock@gimp.org>
* app/tools/gimptransformtool.[ch]: More work on the transform tool. * app/tools/gimptransformtool.[ch]: More work on the transform tool.

View File

@ -79,6 +79,7 @@ typedef struct _GimpToolInfo GimpToolInfo;
typedef struct _GimpTool GimpTool; typedef struct _GimpTool GimpTool;
typedef struct _GimpPaintTool GimpPaintTool; typedef struct _GimpPaintTool GimpPaintTool;
typedef struct _GimpDrawTool GimpDrawTool; typedef struct _GimpDrawTool GimpDrawTool;
typedef struct _GimpTransformTool GimpTransformTool;
/* undo objects */ /* undo objects */
@ -177,8 +178,6 @@ typedef struct _Selection Selection;
typedef struct _SelectionOptions SelectionOptions; typedef struct _SelectionOptions SelectionOptions;
typedef struct _GimpTransformTool GimpTransformTool;
/* some undo stuff */ /* some undo stuff */

View File

@ -28,6 +28,7 @@
#include "apptypes.h" #include "apptypes.h"
#include "tools/gimpbucketfilltool.h" #include "tools/gimpbucketfilltool.h"
#include "tools/gimpfuzzyselecttool.h"
#include "tools/gimpmovetool.h" #include "tools/gimpmovetool.h"
#include "tools/tool_manager.h" #include "tools/tool_manager.h"
@ -386,7 +387,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
* *
* ugly: fuzzy_select sets busy cursors while ACTIVE. * 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)) active_tool->state == ACTIVE))
return TRUE; return TRUE;
@ -405,7 +406,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
gtk_grab_remove (canvas); gtk_grab_remove (canvas);
gdk_pointer_ungrab (bevent->time); /* fixes pointer grab bug */ 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))) ! gimp_image_is_empty (gdisp->gimage)))
{ {
if (active_tool->state == ACTIVE) if (active_tool->state == ACTIVE)
@ -459,13 +460,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
* *
* ugly: fuzzy_select sets busy cursors while ACTIVE. * 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)) active_tool->state == ACTIVE))
return TRUE; 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) if (mevent->is_hint)
{ {
gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty, gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty,

View File

@ -28,6 +28,7 @@
#include "apptypes.h" #include "apptypes.h"
#include "tools/gimpbucketfilltool.h" #include "tools/gimpbucketfilltool.h"
#include "tools/gimpfuzzyselecttool.h"
#include "tools/gimpmovetool.h" #include "tools/gimpmovetool.h"
#include "tools/tool_manager.h" #include "tools/tool_manager.h"
@ -386,7 +387,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
* *
* ugly: fuzzy_select sets busy cursors while ACTIVE. * 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)) active_tool->state == ACTIVE))
return TRUE; return TRUE;
@ -405,7 +406,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
gtk_grab_remove (canvas); gtk_grab_remove (canvas);
gdk_pointer_ungrab (bevent->time); /* fixes pointer grab bug */ 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))) ! gimp_image_is_empty (gdisp->gimage)))
{ {
if (active_tool->state == ACTIVE) if (active_tool->state == ACTIVE)
@ -459,13 +460,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
* *
* ugly: fuzzy_select sets busy cursors while ACTIVE. * 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)) active_tool->state == ACTIVE))
return TRUE; 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) if (mevent->is_hint)
{ {
gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty, gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty,

View File

@ -28,6 +28,7 @@
#include "apptypes.h" #include "apptypes.h"
#include "tools/gimpbucketfilltool.h" #include "tools/gimpbucketfilltool.h"
#include "tools/gimpfuzzyselecttool.h"
#include "tools/gimpmovetool.h" #include "tools/gimpmovetool.h"
#include "tools/tool_manager.h" #include "tools/tool_manager.h"
@ -386,7 +387,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
* *
* ugly: fuzzy_select sets busy cursors while ACTIVE. * 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)) active_tool->state == ACTIVE))
return TRUE; return TRUE;
@ -405,7 +406,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
gtk_grab_remove (canvas); gtk_grab_remove (canvas);
gdk_pointer_ungrab (bevent->time); /* fixes pointer grab bug */ 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))) ! gimp_image_is_empty (gdisp->gimage)))
{ {
if (active_tool->state == ACTIVE) if (active_tool->state == ACTIVE)
@ -459,13 +460,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
* *
* ugly: fuzzy_select sets busy cursors while ACTIVE. * 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)) active_tool->state == ACTIVE))
return TRUE; 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) if (mevent->is_hint)
{ {
gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty, gdk_input_window_get_pointer (canvas->window, current_device, &tx, &ty,

View File

@ -7,40 +7,40 @@ libapptools_la_SOURCES = \
## gimpairbrushtool.h \ ## gimpairbrushtool.h \
## gimpblendtool.c \ ## gimpblendtool.c \
## gimpblendtool.h \ ## gimpblendtool.h \
gimpbucketfilltool.c \
gimpbucketfilltool.h \
## gimpbycolorselecttool.c \ ## gimpbycolorselecttool.c \
## gimpbycolorselecttool.h \ ## gimpbycolorselecttool.h \
## gimpclonetool.c \ ## gimpclonetool.c \
## gimpclonetool.h \ ## gimpclonetool.h \
gimpcolorpickertool.c \
gimpcolorpickertool.h \
## gimpconvolvetool.c \ ## gimpconvolvetool.c \
## gimpconvolvetool.h \ ## gimpconvolvetool.h \
gimpcroptool.c \
gimpcroptool.h \
## gimpdodgeburntool.c \ ## gimpdodgeburntool.c \
## gimpdodgeburntool.h \ ## gimpdodgeburntool.h \
gimpdrawtool.c \
gimpdrawtool.h \
gimpeditselectiontool.c \
gimpeditselectiontool.h \
gimpellipseselecttool.c \ gimpellipseselecttool.c \
gimpellipseselecttool.h \ gimpellipseselecttool.h \
## gimperasertool.c \ ## gimperasertool.c \
## gimperasertool.h \ ## gimperasertool.h \
## gimpfliptool.c \ ## gimpfliptool.c \
## gimpfliptool.h \ ## gimpfliptool.h \
## gimpfreeselecttool.c \ gimpfreeselecttool.c \
## gimpfreeselecttool.h \ gimpfreeselecttool.h \
gimpfuzzyselecttool.c \
gimpfuzzyselecttool.h \
gimpinktool.c \ gimpinktool.c \
gimpinktool.h \ gimpinktool.h \
gimpinktool-blob.c \ gimpinktool-blob.c \
gimpinktool-blob.h \ gimpinktool-blob.h \
## gimpiscissorstool.c \ ## gimpiscissorstool.c \
## gimpiscissorstool.h \ ## 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.c \
gimpmagnifytool.h \ gimpmagnifytool.h \
gimpmeasuretool.c \ gimpmeasuretool.c \
@ -58,7 +58,6 @@ libapptools_la_SOURCES = \
## gimpperspectivetool.h \ ## gimpperspectivetool.h \
gimprectselecttool.c \ gimprectselecttool.c \
gimprectselecttool.h \ gimprectselecttool.h \
## rect_selectP.h \
## gimprotatetool.c \ ## gimprotatetool.c \
## gimprotatetool.h \ ## gimprotatetool.h \
## gimpscaletool.c \ ## gimpscaletool.c \

View File

@ -27,7 +27,6 @@
#include "apptypes.h" #include "apptypes.h"
#include "draw_core.h"
#include "errors.h" #include "errors.h"
#include "floating_sel.h" #include "floating_sel.h"
#include "gdisplay.h" #include "gdisplay.h"
@ -36,107 +35,98 @@
#include "gimpimage.h" #include "gimpimage.h"
#include "scan_convert.h" #include "scan_convert.h"
#include "edit_selection.h" #include "gimpeditselectiontool.h"
#include "free_select.h" #include "gimpfreeselecttool.h"
#include "rect_select.h"
#include "selection_options.h" #include "selection_options.h"
#include "tool_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 DEFAULT_MAX_INC 1024
#define SUPERSAMPLE 3 #define SUPERSAMPLE 3
#define SUPERSAMPLE2 9 #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 static void gimp_free_select_tool_button_press (GimpTool *tool,
{ GdkEventButton *bevent,
DrawCore *core; /* Core select object */ 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 */ static void gimp_free_select_tool_options_reset (void);
gint current_y; /* (enables immediate cursor updating on modifier
* key events). */
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; static SelectionOptions * free_options = NULL;
/* The global array of XPoints for drawing the polygon... */
static GdkPoint *global_pts = NULL;
static gint max_segs = 0;
/* public functions */
/* 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 */
void 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, gint num_pts,
ScanConvertPoint *pts, ScanConvertPoint *pts,
SelectOps op, 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_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_POINTER_MOTION_HINT_MASK |
@ -189,7 +243,7 @@ free_select_button_press (Tool *tool,
tool->state = ACTIVE; tool->state = ACTIVE;
tool->gdisp = gdisp; tool->gdisp = gdisp;
switch (free_sel->op) switch (GIMP_SELECTION_TOOL (tool)->op)
{ {
case SELECTION_MOVE_MASK: case SELECTION_MOVE_MASK:
init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE);
@ -201,36 +255,36 @@ free_select_button_press (Tool *tool,
break; break;
} }
add_point (0, bevent->x, bevent->y); free_sel->num_points = 0;
free_sel->num_pts = 1;
draw_core_start (free_sel->core, gimp_free_select_tool_add_point (free_sel, bevent->x, bevent->y);
gdisp->canvas->window,
tool); gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
gdisp->canvas->window);
} }
static void static void
free_select_button_release (Tool *tool, gimp_free_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
GDisplay *gdisp) GDisplay *gdisp)
{ {
FreeSelect *free_sel; GimpFreeSelectTool *free_sel;
ScanConvertPoint *pts; ScanConvertPoint *pts;
gint i; gint i;
free_sel = (FreeSelect *) tool->private; free_sel = GIMP_FREE_SELECT_TOOL (tool);
gdk_pointer_ungrab (bevent->time); gdk_pointer_ungrab (bevent->time);
gdk_flush (); gdk_flush ();
draw_core_stop (free_sel->core, tool); gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
tool->state = INACTIVE; tool->state = INACTIVE;
/* First take care of the case where the user "cancels" the action */ /* First take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK)) 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 there is a floating selection, anchor it */
if (gimp_image_floating_sel (gdisp->gimage)) if (gimp_image_floating_sel (gdisp->gimage))
@ -238,21 +292,28 @@ free_select_button_release (Tool *tool,
/* Otherwise, clear the selection mask */ /* Otherwise, clear the selection mask */
else else
gimage_mask_clear (gdisp->gimage); gimage_mask_clear (gdisp->gimage);
gdisplays_flush (); gdisplays_flush ();
return; 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, gdisplay_untransform_coords_f (gdisp,
&pts[i].x, &pts[i].y, FALSE); 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_select (gdisp->gimage,
free_options->antialias, free_options->feather, free_sel->num_points, pts,
GIMP_SELECTION_TOOL (tool)->op,
free_options->antialias,
free_options->feather,
free_options->feather_radius); free_options->feather_radius);
g_free (pts); g_free (pts);
@ -262,133 +323,107 @@ free_select_button_release (Tool *tool,
} }
static void static void
free_select_motion (Tool *tool, gimp_free_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
GDisplay *gdisp) 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 */ /* needed for immediate cursor update on modifier event */
free_sel->current_x = mevent->x; sel_tool->current_x = mevent->x;
free_sel->current_y = mevent->y; sel_tool->current_y = mevent->y;
if (tool->state != ACTIVE) if (tool->state != ACTIVE)
return; 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)) gimp_free_select_tool_add_point (free_sel, 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);
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 static void
free_select_control (Tool *tool, gimp_free_select_tool_options_reset (void)
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)
{ {
selection_options_reset (free_options); selection_options_reset (free_options);
} }
Tool * static void
tools_new_free_select (void) gimp_free_select_tool_add_point (GimpFreeSelectTool *free_sel,
gint x,
gint y)
{ {
Tool *tool; if (free_sel->num_points >= free_sel->max_segs)
FreeSelect *private;
/* The tool options */
if (!free_options)
{ {
free_options = free_sel->max_segs += DEFAULT_MAX_INC;
selection_options_new (FREE_SELECT, free_select_options_reset);
tools_register (FREE_SELECT, (ToolOptions *) free_options); 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); free_sel->points[free_sel->num_points].x = x;
private = g_new0 (FreeSelect, 1); free_sel->points[free_sel->num_points].y = y;
private->core = draw_core_new (free_select_draw); free_sel->num_points++;
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;
} }
void static GimpChannel *
tools_free_free_select (Tool *tool) 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); mask = scan_converter_to_channel (sc, gimage);
g_free (free_sel); scan_converter_free (sc);
return mask;
} }

View File

@ -16,23 +16,50 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __FREE_SELECT_H__ #ifndef __GIMP_FREE_SELECT_TOOL_H__
#define __FREE_SELECT_H__ #define __GIMP_FREE_SELECT_TOOL_H__
/* free select functions */ #include "gimpselectiontool.h"
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);
#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__ */

View File

@ -1,6 +1,3 @@
#warning (everything commented out)
#if 0
/* The GIMP -- an image manipulation program /* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
@ -18,7 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#endif
#include "config.h" #include "config.h"
#include <stdlib.h> #include <stdlib.h>
@ -50,48 +47,33 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#if 0 #include "pixmaps2.h"
/* 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 */
};
/* fuzzy select action functions */ static void gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass);
static void fuzzy_select_button_press (Tool *tool, static void gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select);
GdkEventButton *bevent, static void gimp_fuzzy_select_tool_destroy (GtkObject *object);
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 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, static void gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool);
GDisplay *gdisp,
gint *nsegs);
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 */ /* the fuzzy selection tool options */
static SelectionOptions *fuzzy_options = NULL; static SelectionOptions *fuzzy_options = NULL;
@ -102,8 +84,47 @@ static gint num_segs = 0;
GimpChannel * fuzzy_mask = NULL; 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 */ /* Fuzzy selection apparatus */
static gint static gint
@ -363,9 +384,9 @@ find_contiguous_region (GimpImage *gimage,
return mask; return mask;
} }
#if 0
void void
fuzzy_select (GImage *gimage, fuzzy_select (GimpImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
gint op, gint op,
gboolean feather, gboolean feather,
@ -400,19 +421,71 @@ fuzzy_select (GImage *gimage,
/* fuzzy select action functions */ /* fuzzy select action functions */
static void static void
fuzzy_select_button_press (Tool *tool, gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass)
GdkEventButton *bevent,
GDisplay *gdisp)
{ {
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; parent_class = gtk_type_class (GIMP_TYPE_SELECTION_TOOL);
fuzzy_sel->y = bevent->y;
fuzzy_sel->first_x = fuzzy_sel->x; object_class->destroy = gimp_fuzzy_select_tool_destroy;
fuzzy_sel->first_y = fuzzy_sel->y;
fuzzy_sel->first_threshold = fuzzy_options->threshold; 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_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_POINTER_MOTION_HINT_MASK |
@ -423,39 +496,45 @@ fuzzy_select_button_press (Tool *tool,
tool->state = ACTIVE; tool->state = ACTIVE;
tool->gdisp = gdisp; 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); init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE);
return; return;
} case SELECTION_MOVE:
else if (fuzzy_sel->op == SELECTION_MOVE)
{
init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE);
return; return;
default:
break;
} }
/* calculate the region boundary */ /* 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, gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
gdisp->canvas->window, gdisp->canvas->window);
tool);
} }
static void static void
fuzzy_select_button_release (Tool *tool, gimp_fuzzy_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
GDisplay *gdisp) GDisplay *gdisp)
{ {
FuzzySelect *fuzzy_sel; GimpFuzzySelectTool *fuzzy_sel;
GimpDrawable *drawable; GimpDrawable *drawable;
fuzzy_sel = (FuzzySelect *) tool->private; fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool);
gdk_pointer_ungrab (bevent->time); gdk_pointer_ungrab (bevent->time);
gdk_flush (); gdk_flush ();
draw_core_stop (fuzzy_sel->core, tool); gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
tool->state = INACTIVE; tool->state = INACTIVE;
/* First take care of the case where the user "cancels" the action */ /* 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 ? drawable = (fuzzy_options->sample_merged ?
NULL : gimp_image_active_drawable (gdisp->gimage)); NULL : gimp_image_active_drawable (gdisp->gimage));
fuzzy_select (gdisp->gimage, drawable, fuzzy_sel->op, fuzzy_select (gdisp->gimage,
fuzzy_options->feather, drawable,
GIMP_SELECTION_TOOL (tool)->op,
fuzzy_options->feather,
fuzzy_options->feather_radius); fuzzy_options->feather_radius);
gdisplays_flush (); gdisplays_flush ();
} }
@ -477,23 +559,25 @@ fuzzy_select_button_release (Tool *tool,
} }
static void static void
fuzzy_select_motion (Tool *tool, gimp_fuzzy_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
GDisplay *gdisp) GDisplay *gdisp)
{ {
FuzzySelect *fuzzy_sel; GimpFuzzySelectTool *fuzzy_sel;
GdkSegment *new_segs; GimpSelectionTool *sel_tool;
gint num_new_segs; GdkSegment *new_segs;
gint diff_x, diff_y; gint num_new_segs;
gdouble diff; gint diff_x, diff_y;
gdouble diff;
static guint last_time = 0; 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 */ /* needed for immediate cursor update on modifier event */
fuzzy_sel->current_x = mevent->x; sel_tool->current_x = mevent->x;
fuzzy_sel->current_y = mevent->y; sel_tool->current_y = mevent->y;
if (tool->state != ACTIVE) if (tool->state != ACTIVE)
return; 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 */ /* don't let the events come in too fast, ignore below a delay of 100 ms */
if (ABS (mevent->time - last_time) < 100) if (ABS (mevent->time - last_time) < 100)
return; return;
last_time = mevent->time; last_time = mevent->time;
diff_x = mevent->x - fuzzy_sel->first_x; 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), gtk_adjustment_set_value (GTK_ADJUSTMENT (fuzzy_options->threshold_w),
fuzzy_sel->first_threshold + diff); fuzzy_sel->first_threshold + diff);
/* calculate the new fuzzy boundary */ /* 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 */ /* 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 */ /* make sure the XSegment array is freed before we assign the new one */
if (segs) if (segs)
@ -525,17 +609,16 @@ fuzzy_select_motion (Tool *tool,
num_segs = num_new_segs; num_segs = num_new_segs;
/* start the new boundary */ /* start the new boundary */
draw_core_resume (fuzzy_sel->core, tool); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
} }
static GdkSegment * static GdkSegment *
fuzzy_select_calculate (Tool *tool, fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel,
GDisplay *gdisp, GDisplay *gdisp,
gint *nsegs) gint *nsegs)
{ {
PixelRegion maskPR; PixelRegion maskPR;
FuzzySelect *fuzzy_sel;
GimpChannel *new; GimpChannel *new;
GdkSegment *segs; GdkSegment *segs;
BoundSeg *bsegs; BoundSeg *bsegs;
@ -544,7 +627,6 @@ fuzzy_select_calculate (Tool *tool,
gint x, y; gint x, y;
gboolean use_offsets; gboolean use_offsets;
fuzzy_sel = (FuzzySelect *) tool->private;
drawable = gimp_image_active_drawable (gdisp->gimage); drawable = gimp_image_active_drawable (gdisp->gimage);
gimp_add_busy_cursors (); gimp_add_busy_cursors ();
@ -599,93 +681,20 @@ fuzzy_select_calculate (Tool *tool,
} }
static void 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) 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 static void
fuzzy_select_control (Tool *tool, gimp_fuzzy_select_tool_options_reset (void)
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)
{ {
selection_options_reset (fuzzy_options); 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

View File

@ -16,28 +16,59 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __FUZZY_SELECT_H__ #ifndef __GIMP_FUZZY_SELECT_TOOL_H__
#define __FUZZY_SELECT_H__ #define __GIMP_FUZZY_SELECT_TOOL_H__
GimpChannel * find_contiguous_region (GimpImage *gimage, #include "gimpselectiontool.h"
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);
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; extern GimpChannel *fuzzy_mask;
#endif /* __FUZZY_SELECT_H__ */ #endif /* __GIMP_FUZZY_SELECT_TOOL_H__ */

View File

@ -238,19 +238,11 @@ gimp_rect_select_tool_init (GimpRectSelectTool *rect_select)
rect_select->x = rect_select->y = 0; rect_select->x = rect_select->y = 0;
rect_select->w = rect_select->h = 0; rect_select->w = rect_select->h = 0;
} }
static void static void
gimp_rect_select_tool_destroy (GtkObject *object) 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) if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object); 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); gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), rect_sel->context_id);
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
tool->state = INACTIVE; tool->state = INACTIVE;
/* First take care of the case where the user "cancels" the action */ /* First take care of the case where the user "cancels" the action */

View File

@ -1,6 +1,3 @@
#warning (everything commented out)
#if 0
/* The GIMP -- an image manipulation program /* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
@ -18,7 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#endif
#include "config.h" #include "config.h"
#include <stdlib.h> #include <stdlib.h>
@ -50,48 +47,33 @@
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#if 0 #include "pixmaps2.h"
/* 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 */
};
/* fuzzy select action functions */ static void gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass);
static void fuzzy_select_button_press (Tool *tool, static void gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select);
GdkEventButton *bevent, static void gimp_fuzzy_select_tool_destroy (GtkObject *object);
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 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, static void gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool);
GDisplay *gdisp,
gint *nsegs);
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 */ /* the fuzzy selection tool options */
static SelectionOptions *fuzzy_options = NULL; static SelectionOptions *fuzzy_options = NULL;
@ -102,8 +84,47 @@ static gint num_segs = 0;
GimpChannel * fuzzy_mask = NULL; 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 */ /* Fuzzy selection apparatus */
static gint static gint
@ -363,9 +384,9 @@ find_contiguous_region (GimpImage *gimage,
return mask; return mask;
} }
#if 0
void void
fuzzy_select (GImage *gimage, fuzzy_select (GimpImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
gint op, gint op,
gboolean feather, gboolean feather,
@ -400,19 +421,71 @@ fuzzy_select (GImage *gimage,
/* fuzzy select action functions */ /* fuzzy select action functions */
static void static void
fuzzy_select_button_press (Tool *tool, gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass)
GdkEventButton *bevent,
GDisplay *gdisp)
{ {
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; parent_class = gtk_type_class (GIMP_TYPE_SELECTION_TOOL);
fuzzy_sel->y = bevent->y;
fuzzy_sel->first_x = fuzzy_sel->x; object_class->destroy = gimp_fuzzy_select_tool_destroy;
fuzzy_sel->first_y = fuzzy_sel->y;
fuzzy_sel->first_threshold = fuzzy_options->threshold; 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_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_POINTER_MOTION_HINT_MASK |
@ -423,39 +496,45 @@ fuzzy_select_button_press (Tool *tool,
tool->state = ACTIVE; tool->state = ACTIVE;
tool->gdisp = gdisp; 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); init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE);
return; return;
} case SELECTION_MOVE:
else if (fuzzy_sel->op == SELECTION_MOVE)
{
init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE);
return; return;
default:
break;
} }
/* calculate the region boundary */ /* 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, gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
gdisp->canvas->window, gdisp->canvas->window);
tool);
} }
static void static void
fuzzy_select_button_release (Tool *tool, gimp_fuzzy_select_tool_button_release (GimpTool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
GDisplay *gdisp) GDisplay *gdisp)
{ {
FuzzySelect *fuzzy_sel; GimpFuzzySelectTool *fuzzy_sel;
GimpDrawable *drawable; GimpDrawable *drawable;
fuzzy_sel = (FuzzySelect *) tool->private; fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool);
gdk_pointer_ungrab (bevent->time); gdk_pointer_ungrab (bevent->time);
gdk_flush (); gdk_flush ();
draw_core_stop (fuzzy_sel->core, tool); gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
tool->state = INACTIVE; tool->state = INACTIVE;
/* First take care of the case where the user "cancels" the action */ /* 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 ? drawable = (fuzzy_options->sample_merged ?
NULL : gimp_image_active_drawable (gdisp->gimage)); NULL : gimp_image_active_drawable (gdisp->gimage));
fuzzy_select (gdisp->gimage, drawable, fuzzy_sel->op, fuzzy_select (gdisp->gimage,
fuzzy_options->feather, drawable,
GIMP_SELECTION_TOOL (tool)->op,
fuzzy_options->feather,
fuzzy_options->feather_radius); fuzzy_options->feather_radius);
gdisplays_flush (); gdisplays_flush ();
} }
@ -477,23 +559,25 @@ fuzzy_select_button_release (Tool *tool,
} }
static void static void
fuzzy_select_motion (Tool *tool, gimp_fuzzy_select_tool_motion (GimpTool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
GDisplay *gdisp) GDisplay *gdisp)
{ {
FuzzySelect *fuzzy_sel; GimpFuzzySelectTool *fuzzy_sel;
GdkSegment *new_segs; GimpSelectionTool *sel_tool;
gint num_new_segs; GdkSegment *new_segs;
gint diff_x, diff_y; gint num_new_segs;
gdouble diff; gint diff_x, diff_y;
gdouble diff;
static guint last_time = 0; 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 */ /* needed for immediate cursor update on modifier event */
fuzzy_sel->current_x = mevent->x; sel_tool->current_x = mevent->x;
fuzzy_sel->current_y = mevent->y; sel_tool->current_y = mevent->y;
if (tool->state != ACTIVE) if (tool->state != ACTIVE)
return; 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 */ /* don't let the events come in too fast, ignore below a delay of 100 ms */
if (ABS (mevent->time - last_time) < 100) if (ABS (mevent->time - last_time) < 100)
return; return;
last_time = mevent->time; last_time = mevent->time;
diff_x = mevent->x - fuzzy_sel->first_x; 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), gtk_adjustment_set_value (GTK_ADJUSTMENT (fuzzy_options->threshold_w),
fuzzy_sel->first_threshold + diff); fuzzy_sel->first_threshold + diff);
/* calculate the new fuzzy boundary */ /* 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 */ /* 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 */ /* make sure the XSegment array is freed before we assign the new one */
if (segs) if (segs)
@ -525,17 +609,16 @@ fuzzy_select_motion (Tool *tool,
num_segs = num_new_segs; num_segs = num_new_segs;
/* start the new boundary */ /* start the new boundary */
draw_core_resume (fuzzy_sel->core, tool); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
} }
static GdkSegment * static GdkSegment *
fuzzy_select_calculate (Tool *tool, fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel,
GDisplay *gdisp, GDisplay *gdisp,
gint *nsegs) gint *nsegs)
{ {
PixelRegion maskPR; PixelRegion maskPR;
FuzzySelect *fuzzy_sel;
GimpChannel *new; GimpChannel *new;
GdkSegment *segs; GdkSegment *segs;
BoundSeg *bsegs; BoundSeg *bsegs;
@ -544,7 +627,6 @@ fuzzy_select_calculate (Tool *tool,
gint x, y; gint x, y;
gboolean use_offsets; gboolean use_offsets;
fuzzy_sel = (FuzzySelect *) tool->private;
drawable = gimp_image_active_drawable (gdisp->gimage); drawable = gimp_image_active_drawable (gdisp->gimage);
gimp_add_busy_cursors (); gimp_add_busy_cursors ();
@ -599,93 +681,20 @@ fuzzy_select_calculate (Tool *tool,
} }
static void 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) 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 static void
fuzzy_select_control (Tool *tool, gimp_fuzzy_select_tool_options_reset (void)
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)
{ {
selection_options_reset (fuzzy_options); 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

View File

@ -16,28 +16,59 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef __FUZZY_SELECT_H__ #ifndef __GIMP_FUZZY_SELECT_TOOL_H__
#define __FUZZY_SELECT_H__ #define __GIMP_FUZZY_SELECT_TOOL_H__
GimpChannel * find_contiguous_region (GimpImage *gimage, #include "gimpselectiontool.h"
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);
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; extern GimpChannel *fuzzy_mask;
#endif /* __FUZZY_SELECT_H__ */ #endif /* __GIMP_FUZZY_SELECT_TOOL_H__ */

View File

@ -27,6 +27,7 @@
#include "gimprc.h" #include "gimprc.h"
#include "gimpellipseselecttool.h" #include "gimpellipseselecttool.h"
#include "gimpfuzzyselecttool.h"
#include "gimprectselecttool.h" #include "gimprectselecttool.h"
#include "gimptool.h" #include "gimptool.h"
#include "gimptoolinfo.h" #include "gimptoolinfo.h"

View File

@ -531,7 +531,6 @@ STUB(paths_dialog_paste_path_callback)
STUB(paths_dialog_import_path_callback) STUB(paths_dialog_import_path_callback)
STUB(paths_dialog_export_path_callback) STUB(paths_dialog_export_path_callback)
STUB(paths_dialog_edit_path_attributes_callback) STUB(paths_dialog_edit_path_attributes_callback)
QUIET_STUB(GIMP_IS_FUZZY_SELECT)
STUB(dodgeburn_non_gui) STUB(dodgeburn_non_gui)
STUB(dodgeburn_non_gui_default) STUB(dodgeburn_non_gui_default)
STUB(eraser_non_gui) STUB(eraser_non_gui)
@ -539,9 +538,6 @@ STUB(eraser_non_gui_default)
STUB(transform_core_cut) STUB(transform_core_cut)
STUB(flip_tool_flip) STUB(flip_tool_flip)
STUB(transform_core_paste) STUB(transform_core_paste)
STUB(free_select)
STUB(fuzzy_mask)
STUB(fuzzy_select)
STUB(pencil_non_gui) STUB(pencil_non_gui)
STUB(perspective_find_transform) STUB(perspective_find_transform)
STUB(perspective_tool_perspective) STUB(perspective_tool_perspective)
@ -565,62 +561,6 @@ STUB(path_transform_xy)
#ifdef STONE_AGE #ifdef STONE_AGE
ToolInfo tool_info[] = 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, NULL,
N_("Bezier Select"), N_("Bezier Select"),

View File

@ -24,7 +24,6 @@
#define GIMP_TYPE_ISCISSORS_TOOL GTK_TYPE_NONE #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_BY_COLOR_SELECT_TOOL GTK_TYPE_NONE
#define GIMP_TYPE_BLEND_TOOL GTK_TYPE_NONE #define GIMP_TYPE_BLEND_TOOL GTK_TYPE_NONE
#define GIMP_TYPE_PENCIL_TOOL GTK_TYPE_NONE #define GIMP_TYPE_PENCIL_TOOL GTK_TYPE_NONE

View File

@ -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__ */

View File

@ -27,6 +27,7 @@
#include "gimprc.h" #include "gimprc.h"
#include "gimpellipseselecttool.h" #include "gimpellipseselecttool.h"
#include "gimpfuzzyselecttool.h"
#include "gimprectselecttool.h" #include "gimprectselecttool.h"
#include "gimptool.h" #include "gimptool.h"
#include "gimptoolinfo.h" #include "gimptoolinfo.h"

View File

@ -66,6 +66,8 @@ register_tools (void)
gimp_color_picker_tool_register (); gimp_color_picker_tool_register ();
gimp_text_tool_register (); gimp_text_tool_register ();
gimp_move_tool_register (); gimp_move_tool_register ();
gimp_fuzzy_select_tool_register ();
gimp_free_select_tool_register ();
gimp_ellipse_select_tool_register (); gimp_ellipse_select_tool_register ();
gimp_rect_select_tool_register (); gimp_rect_select_tool_register ();
@ -85,15 +87,12 @@ register_tools (void)
procedural_db_register (&crop_proc); procedural_db_register (&crop_proc);
procedural_db_register (&dodgeburn_proc); procedural_db_register (&dodgeburn_proc);
procedural_db_register (&dodgeburn_default_proc); procedural_db_register (&dodgeburn_default_proc);
procedural_db_register (&ellipse_select_proc);
procedural_db_register (&eraser_proc); procedural_db_register (&eraser_proc);
procedural_db_register (&eraser_default_proc); procedural_db_register (&eraser_default_proc);
procedural_db_register (&flip_proc); procedural_db_register (&flip_proc);
procedural_db_register (&free_select_proc);
procedural_db_register (&fuzzy_select_proc); procedural_db_register (&fuzzy_select_proc);
procedural_db_register (&pencil_proc); procedural_db_register (&pencil_proc);
procedural_db_register (&perspective_proc); procedural_db_register (&perspective_proc);
procedural_db_register (&rect_select_proc);
procedural_db_register (&rotate_proc); procedural_db_register (&rotate_proc);
procedural_db_register (&scale_proc); procedural_db_register (&scale_proc);
procedural_db_register (&shear_proc); procedural_db_register (&shear_proc);