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-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "apptypes.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "channel.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "draw_core.h"
|
|
|
|
#include "errors.h"
|
2000-07-30 00:12:40 +08:00
|
|
|
#include "floating_sel.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gimage_mask.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "gimpimage.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gdisplay.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "scan_convert.h"
|
|
|
|
|
|
|
|
#include "edit_selection.h"
|
|
|
|
#include "free_select.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "rect_select.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-01-25 06:36:18 +08:00
|
|
|
#include "tools.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-07-30 00:12:40 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
#define DEFAULT_MAX_INC 1024
|
|
|
|
#define SUPERSAMPLE 3
|
|
|
|
#define SUPERSAMPLE2 9
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
/* the free selection structures */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
typedef struct _FreeSelect FreeSelect;
|
2000-12-31 12:07:42 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
struct _FreeSelect
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-03-29 07:39:32 +08:00
|
|
|
DrawCore *core; /* Core select object */
|
1999-05-05 17:10:35 +08:00
|
|
|
|
2000-03-29 07:39:32 +08:00
|
|
|
SelectOps op; /* selection operation (ADD, SUB, etc) */
|
2000-03-02 07:22:43 +08:00
|
|
|
|
|
|
|
gint current_x; /* these values are updated on every motion event */
|
|
|
|
gint current_y; /* (enables immediate cursor updating on modifier
|
|
|
|
* key events). */
|
|
|
|
|
|
|
|
gint num_pts; /* Number of points in the polygon */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
|
|
|
|
/* the free selection tool options */
|
1999-04-09 06:25:54 +08:00
|
|
|
static SelectionOptions * free_options = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The global array of XPoints for drawing the polygon... */
|
2000-03-29 07:39:32 +08:00
|
|
|
static GdkPoint *global_pts = NULL;
|
|
|
|
static gint max_segs = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
/* functions */
|
|
|
|
|
2000-03-29 07:39:32 +08:00
|
|
|
static gint
|
|
|
|
add_point (gint num_pts,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
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)
|
1999-11-25 19:35:48 +08:00
|
|
|
gimp_fatal_error ("add_point(): Unable to reallocate points array in free_select.");
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
global_pts[num_pts].x = x;
|
|
|
|
global_pts[num_pts].y = y;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-29 10:45:02 +08:00
|
|
|
static GimpChannel *
|
2000-03-29 07:39:32 +08:00
|
|
|
scan_convert (GimpImage *gimage,
|
|
|
|
gint num_pts,
|
1999-10-04 13:51:40 +08:00
|
|
|
ScanConvertPoint *pts,
|
2000-03-29 07:39:32 +08:00
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gboolean antialias)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 10:45:02 +08:00
|
|
|
GimpChannel *mask;
|
1999-10-04 13:51:40 +08:00
|
|
|
ScanConverter *sc;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-29 07:39:32 +08:00
|
|
|
sc = scan_converter_new (width, height, antialias ? SUPERSAMPLE : 1);
|
1999-10-04 13:51:40 +08:00
|
|
|
scan_converter_add_points (sc, num_pts, pts);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-04 13:51:40 +08:00
|
|
|
mask = scan_converter_to_channel (sc, gimage);
|
|
|
|
scan_converter_free (sc);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************/
|
1999-05-07 07:10:29 +08:00
|
|
|
/* Polygonal selection apparatus */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
void
|
2000-03-29 07:39:32 +08:00
|
|
|
free_select (GImage *gimage,
|
|
|
|
gint num_pts,
|
1999-10-04 13:51:40 +08:00
|
|
|
ScanConvertPoint *pts,
|
2000-03-29 07:39:32 +08:00
|
|
|
SelectOps op,
|
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 10:45:02 +08:00
|
|
|
GimpChannel *mask;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* if applicable, replace the current selection */
|
|
|
|
/* or insure that a floating selection is anchored down... */
|
2000-03-29 07:39:32 +08:00
|
|
|
if (op == SELECTION_REPLACE)
|
1997-11-25 06:05:25 +08:00
|
|
|
gimage_mask_clear (gimage);
|
|
|
|
else
|
|
|
|
gimage_mask_undo (gimage);
|
|
|
|
|
2000-03-29 07:39:32 +08:00
|
|
|
mask = scan_convert (gimage, num_pts, pts,
|
|
|
|
gimage->width, gimage->height, antialias);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
if (feather)
|
2001-01-29 10:45:02 +08:00
|
|
|
gimp_channel_feather (mask, gimp_image_get_mask (gimage),
|
|
|
|
feather_radius,
|
|
|
|
feather_radius,
|
|
|
|
op, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-01-29 10:45:02 +08:00
|
|
|
gimp_channel_combine_mask (gimp_image_get_mask (gimage),
|
|
|
|
mask, op, 0, 0);
|
2001-01-29 08:46:04 +08:00
|
|
|
|
|
|
|
gtk_object_unref (GTK_OBJECT (mask));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
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
|
|
|
free_select_button_press (Tool *tool,
|
|
|
|
GdkEventButton *bevent,
|
2000-12-31 12:07:42 +08:00
|
|
|
GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
FreeSelect *free_sel;
|
|
|
|
|
|
|
|
free_sel = (FreeSelect *) tool->private;
|
|
|
|
|
|
|
|
gdk_pointer_grab (gdisp->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
|
|
|
|
1999-05-05 17:10:35 +08:00
|
|
|
switch (free_sel->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
|
|
|
|
|
|
|
add_point (0, bevent->x, bevent->y);
|
|
|
|
free_sel->num_pts = 1;
|
|
|
|
|
|
|
|
draw_core_start (free_sel->core,
|
|
|
|
gdisp->canvas->window,
|
|
|
|
tool);
|
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
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
|
|
|
free_select_button_release (Tool *tool,
|
|
|
|
GdkEventButton *bevent,
|
2000-12-31 12:07:42 +08:00
|
|
|
GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-03-29 07:39:32 +08:00
|
|
|
FreeSelect *free_sel;
|
1999-10-04 13:51:40 +08:00
|
|
|
ScanConvertPoint *pts;
|
2000-03-29 07:39:32 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
free_sel = (FreeSelect *) tool->private;
|
|
|
|
|
|
|
|
gdk_pointer_ungrab (bevent->time);
|
|
|
|
gdk_flush ();
|
|
|
|
|
|
|
|
draw_core_stop (free_sel->core, tool);
|
|
|
|
|
|
|
|
tool->state = INACTIVE;
|
|
|
|
|
|
|
|
/* First take care of the case where the user "cancels" the action */
|
|
|
|
if (! (bevent->state & GDK_BUTTON3_MASK))
|
|
|
|
{
|
2000-07-30 00:12:40 +08:00
|
|
|
if (free_sel->op == SELECTION_ANCHOR)
|
|
|
|
{
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
gdisplays_flush ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-03-29 07:39:32 +08:00
|
|
|
pts = g_new (ScanConvertPoint, free_sel->num_pts);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 0; i < free_sel->num_pts; i++)
|
|
|
|
{
|
|
|
|
gdisplay_untransform_coords_f (gdisp, global_pts[i].x, global_pts[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_options->feather_radius);
|
|
|
|
|
|
|
|
g_free (pts);
|
|
|
|
|
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
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
|
|
|
free_select_motion (Tool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
2000-12-31 12:07:42 +08:00
|
|
|
GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
FreeSelect *free_sel;
|
|
|
|
|
|
|
|
free_sel = (FreeSelect *) tool->private;
|
|
|
|
|
2000-03-02 07:22:43 +08:00
|
|
|
/* needed for immediate cursor update on modifier event */
|
|
|
|
free_sel->current_x = mevent->x;
|
|
|
|
free_sel->current_y = mevent->y;
|
|
|
|
|
|
|
|
if (tool->state != ACTIVE)
|
|
|
|
return;
|
|
|
|
|
2000-07-30 00:12:40 +08:00
|
|
|
if (free_sel->op == SELECTION_ANCHOR)
|
|
|
|
{
|
|
|
|
free_sel->op = SELECTION_REPLACE;
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
rect_select_cursor_update (tool, mevent, gdisp);
|
2000-07-30 00:12:40 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
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);
|
1999-05-02 05:37:34 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
free_sel->num_pts ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-06-22 06:12:07 +08:00
|
|
|
free_select_control (Tool *tool,
|
|
|
|
ToolAction action,
|
2000-12-31 12:07:42 +08:00
|
|
|
GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-03-29 07:39:32 +08:00
|
|
|
FreeSelect *free_sel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
free_sel = (FreeSelect *) tool->private;
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
2000-03-29 07:39:32 +08:00
|
|
|
case PAUSE:
|
1997-11-25 06:05:25 +08:00
|
|
|
draw_core_pause (free_sel->core, tool);
|
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2000-03-29 07:39:32 +08:00
|
|
|
case RESUME:
|
1997-11-25 06:05:25 +08:00
|
|
|
draw_core_resume (free_sel->core, tool);
|
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2000-03-29 07:39:32 +08:00
|
|
|
case HALT:
|
1997-11-25 06:05:25 +08:00
|
|
|
draw_core_stop (free_sel->core, tool);
|
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
free_select_draw (Tool *tool)
|
|
|
|
{
|
2000-03-29 07:39:32 +08:00
|
|
|
FreeSelect *free_sel;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
static void
|
2000-03-29 07:39:32 +08:00
|
|
|
free_select_options_reset (void)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
1999-04-13 01:55:06 +08:00
|
|
|
selection_options_reset (free_options);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
Tool *
|
|
|
|
tools_new_free_select (void)
|
|
|
|
{
|
2000-03-29 07:39:32 +08:00
|
|
|
Tool *tool;
|
|
|
|
FreeSelect *private;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The tool options */
|
|
|
|
if (!free_options)
|
1999-04-13 01:55:06 +08:00
|
|
|
{
|
|
|
|
free_options =
|
|
|
|
selection_options_new (FREE_SELECT, free_select_options_reset);
|
|
|
|
tools_register (FREE_SELECT, (ToolOptions *) free_options);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool = tools_new_tool (FREE_SELECT);
|
2000-06-23 08:14:07 +08:00
|
|
|
private = g_new0 (FreeSelect, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-29 07:39:32 +08:00
|
|
|
private->core = draw_core_new (free_select_draw);
|
1997-11-25 06:05:25 +08:00
|
|
|
private->num_pts = 0;
|
2000-03-29 07:39:32 +08:00
|
|
|
private->op = SELECTION_REPLACE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->scroll_lock = TRUE; /* Do not allow scrolling */
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tool->private = (void *) private;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->button_press_func = free_select_button_press;
|
1997-11-25 06:05:25 +08:00
|
|
|
tool->button_release_func = free_select_button_release;
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->motion_func = free_select_motion;
|
2000-03-02 07:22:43 +08:00
|
|
|
tool->modifier_key_func = rect_select_modifier_update;
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->cursor_update_func = rect_select_cursor_update;
|
2000-01-20 03:06:13 +08:00
|
|
|
tool->oper_update_func = rect_select_oper_update;
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->control_func = free_select_control;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_free_free_select (Tool *tool)
|
|
|
|
{
|
2000-03-29 07:39:32 +08:00
|
|
|
FreeSelect *free_sel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
free_sel = (FreeSelect *) tool->private;
|
|
|
|
|
|
|
|
draw_core_free (free_sel->core);
|
|
|
|
g_free (free_sel);
|
|
|
|
}
|