1997-11-25 06:05:25 +08:00
|
|
|
/* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-07-30 00:12:40 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2000-03-29 07:39:32 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-08-06 00:08:19 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpchannel.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimpimage-mask.h"
|
2001-10-22 20:13:44 +08:00
|
|
|
#include "core/gimpimage-mask-select.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-10-13 20:52:30 +08:00
|
|
|
#include "display/gimpdisplay-foreach.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
#include "gimpeditselectiontool.h"
|
|
|
|
#include "gimpfreeselecttool.h"
|
1999-04-13 01:55:06 +08:00
|
|
|
#include "selection_options.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "tool_options.h"
|
2001-03-10 01:39:18 +08:00
|
|
|
#include "tool_manager.h"
|
|
|
|
|
2001-05-26 02:10:38 +08:00
|
|
|
#include "errors.h"
|
|
|
|
#include "floating_sel.h"
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-07-30 00:12:40 +08:00
|
|
|
|
2001-10-22 20:13:44 +08:00
|
|
|
#define DEFAULT_MAX_INC 1024
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
static void gimp_free_select_tool_class_init (GimpFreeSelectToolClass *klass);
|
|
|
|
static void gimp_free_select_tool_init (GimpFreeSelectTool *free_select);
|
2001-08-14 22:53:55 +08:00
|
|
|
static void gimp_free_select_tool_finalize (GObject *object);
|
1999-05-05 17:10:35 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
static void gimp_free_select_tool_button_press (GimpTool *tool,
|
|
|
|
GdkEventButton *bevent,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-03-10 01:39:18 +08:00
|
|
|
static void gimp_free_select_tool_button_release (GimpTool *tool,
|
|
|
|
GdkEventButton *bevent,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-03-10 01:39:18 +08:00
|
|
|
static void gimp_free_select_tool_motion (GimpTool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp);
|
2000-03-02 07:22:43 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
static void gimp_free_select_tool_draw (GimpDrawTool *draw_tool);
|
2000-03-02 07:22:43 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
static void gimp_free_select_tool_add_point (GimpFreeSelectTool *free_sel,
|
|
|
|
gint x,
|
|
|
|
gint y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
static GimpSelectionToolClass *parent_class = NULL;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
static SelectionOptions * free_options = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
/* public functions */
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
void
|
2001-07-07 20:17:23 +08:00
|
|
|
gimp_free_select_tool_register (Gimp *gimp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-07 20:17:23 +08:00
|
|
|
tool_manager_register_tool (gimp,
|
|
|
|
GIMP_TYPE_FREE_SELECT_TOOL,
|
|
|
|
FALSE,
|
2001-03-10 01:39:18 +08:00
|
|
|
"gimp:free_select_tool",
|
|
|
|
_("Free Select"),
|
|
|
|
_("Select hand-drawn regions"),
|
|
|
|
_("/Tools/Selection Tools/Free Select"), "F",
|
|
|
|
NULL, "tools/free_select.html",
|
2001-08-06 00:08:19 +08:00
|
|
|
GIMP_STOCK_TOOL_FREE_SELECT);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_free_select_tool_get_type (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
if (! tool_type)
|
2001-03-10 01:39:18 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-03-10 01:39:18 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpFreeSelectToolClass),
|
2001-08-14 22:53:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_free_select_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpFreeSelectTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_free_select_tool_init,
|
2001-03-10 01:39:18 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_SELECTION_TOOL,
|
|
|
|
"GimpFreeSelectTool",
|
|
|
|
&tool_info, 0);
|
2001-03-10 01:39:18 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
return tool_type;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_class_init (GimpFreeSelectToolClass *klass)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
GObjectClass *object_class;
|
2001-03-10 01:39:18 +08:00
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpDrawToolClass *draw_tool_class;
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
object_class->finalize = gimp_free_select_tool_finalize;
|
2001-03-10 01:39:18 +08:00
|
|
|
|
|
|
|
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,
|
2001-04-01 04:41:39 +08:00
|
|
|
selection_options_reset);
|
2001-03-10 01:39:18 +08:00
|
|
|
|
|
|
|
tool_manager_register_tool_options (GIMP_TYPE_FREE_SELECT_TOOL,
|
2001-07-18 04:50:01 +08:00
|
|
|
(GimpToolOptions *) free_options);
|
2001-03-10 01:39:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2001-08-14 22:53:55 +08:00
|
|
|
gimp_free_select_tool_finalize (GObject *object)
|
2001-03-10 01:39:18 +08:00
|
|
|
{
|
|
|
|
GimpFreeSelectTool *free_sel;
|
|
|
|
|
|
|
|
free_sel = GIMP_FREE_SELECT_TOOL (object);
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
if (free_sel->points)
|
|
|
|
{
|
|
|
|
g_free (free_sel->points);
|
|
|
|
free_sel->points = NULL;
|
|
|
|
}
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-03-10 01:39:18 +08:00
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_free_select_tool_button_press (GimpTool *tool,
|
|
|
|
GdkEventButton *bevent,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
GimpFreeSelectTool *free_sel;
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplayShell *shell;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel = GIMP_FREE_SELECT_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
|
|
|
gdk_pointer_grab (shell->canvas->window, FALSE,
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON1_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
1997-11-25 06:05:25 +08:00
|
|
|
NULL, NULL, bevent->time);
|
|
|
|
|
|
|
|
tool->state = ACTIVE;
|
2000-12-31 12:07:42 +08:00
|
|
|
tool->gdisp = gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
switch (GIMP_SELECTION_TOOL (tool)->op)
|
2000-03-29 07:39:32 +08:00
|
|
|
{
|
|
|
|
case SELECTION_MOVE_MASK:
|
2000-12-31 12:07:42 +08:00
|
|
|
init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE);
|
2000-03-29 07:39:32 +08:00
|
|
|
return;
|
|
|
|
case SELECTION_MOVE:
|
2000-12-31 12:07:42 +08:00
|
|
|
init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE);
|
2000-03-29 07:39:32 +08:00
|
|
|
return;
|
2000-04-07 02:59:48 +08:00
|
|
|
default:
|
2000-04-26 08:17:54 +08:00
|
|
|
break;
|
2000-03-29 07:39:32 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel->num_points = 0;
|
|
|
|
|
|
|
|
gimp_free_select_tool_add_point (free_sel, bevent->x, bevent->y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_free_select_tool_button_release (GimpTool *tool,
|
|
|
|
GdkEventButton *bevent,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
GimpFreeSelectTool *free_sel;
|
2001-05-26 02:10:38 +08:00
|
|
|
GimpVector2 *points;
|
2001-03-10 01:39:18 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel = GIMP_FREE_SELECT_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gdk_pointer_ungrab (bevent->time);
|
|
|
|
gdk_flush ();
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tool->state = INACTIVE;
|
|
|
|
|
|
|
|
/* First take care of the case where the user "cancels" the action */
|
|
|
|
if (! (bevent->state & GDK_BUTTON3_MASK))
|
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
if (free_sel->num_points == 1)
|
2000-07-30 00:12:40 +08:00
|
|
|
{
|
|
|
|
/* If there is a floating selection, anchor it */
|
2000-12-29 23:22:01 +08:00
|
|
|
if (gimp_image_floating_sel (gdisp->gimage))
|
|
|
|
floating_sel_anchor (gimp_image_floating_sel (gdisp->gimage));
|
2000-07-30 00:12:40 +08:00
|
|
|
/* Otherwise, clear the selection mask */
|
|
|
|
else
|
|
|
|
gimage_mask_clear (gdisp->gimage);
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2000-07-30 00:12:40 +08:00
|
|
|
gdisplays_flush ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-05-26 02:10:38 +08:00
|
|
|
points = g_new (GimpVector2, free_sel->num_points);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
for (i = 0; i < free_sel->num_points; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
gdisplay_untransform_coords_f (gdisp,
|
|
|
|
free_sel->points[i].x,
|
|
|
|
free_sel->points[i].y,
|
2001-05-26 02:10:38 +08:00
|
|
|
&points[i].x,
|
|
|
|
&points[i].y,
|
2001-03-10 01:39:18 +08:00
|
|
|
FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-10-22 20:13:44 +08:00
|
|
|
gimp_image_mask_select_polygon (gdisp->gimage,
|
|
|
|
free_sel->num_points, points,
|
|
|
|
GIMP_SELECTION_TOOL (tool)->op,
|
|
|
|
free_options->antialias,
|
|
|
|
free_options->feather,
|
|
|
|
free_options->feather_radius,
|
|
|
|
free_options->feather_radius);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-26 02:10:38 +08:00
|
|
|
g_free (points);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_free_select_tool_motion (GimpTool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
2001-10-22 20:13:44 +08:00
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
GimpFreeSelectTool *free_sel;
|
|
|
|
GimpSelectionTool *sel_tool;
|
|
|
|
GimpDrawTool *draw_tool;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel = GIMP_FREE_SELECT_TOOL (tool);
|
|
|
|
sel_tool = GIMP_SELECTION_TOOL (tool);
|
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-02 07:22:43 +08:00
|
|
|
/* needed for immediate cursor update on modifier event */
|
2001-03-10 01:39:18 +08:00
|
|
|
sel_tool->current_x = mevent->x;
|
|
|
|
sel_tool->current_y = mevent->y;
|
2000-03-02 07:22:43 +08:00
|
|
|
|
|
|
|
if (tool->state != ACTIVE)
|
|
|
|
return;
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
if (sel_tool->op == SELECTION_ANCHOR)
|
2000-07-30 00:12:40 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
sel_tool->op = SELECTION_REPLACE;
|
2000-07-30 00:12:40 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_tool_cursor_update (tool, mevent, gdisp);
|
2000-07-30 00:12:40 +08:00
|
|
|
}
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_free_select_tool_add_point (free_sel, mevent->x, mevent->y);
|
1999-05-02 05:37:34 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
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);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_free_select_tool_draw (GimpDrawTool *draw_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
GimpFreeSelectTool *free_sel;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel = GIMP_FREE_SELECT_TOOL (draw_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
for (i = 1; i < free_sel->num_points; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
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);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
static void
|
|
|
|
gimp_free_select_tool_add_point (GimpFreeSelectTool *free_sel,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
if (free_sel->num_points >= free_sel->max_segs)
|
1999-04-13 01:55:06 +08:00
|
|
|
{
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel->max_segs += DEFAULT_MAX_INC;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel->points = (GdkPoint *)
|
|
|
|
g_realloc ((void *) free_sel->points,
|
|
|
|
sizeof (GdkPoint) * free_sel->max_segs);
|
1999-07-03 01:40:10 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
if (! free_sel->points)
|
|
|
|
gimp_fatal_error ("%s(): Unable to reallocate points array",
|
|
|
|
G_GNUC_FUNCTION);
|
|
|
|
}
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel->points[free_sel->num_points].x = x;
|
|
|
|
free_sel->points[free_sel->num_points].y = y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
free_sel->num_points++;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|