2001-06-26 20:09:43 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
#include "core/gimp.h"
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
#include "core/gimpchannel.h"
|
2004-03-21 00:14:49 +08:00
|
|
|
#include "core/gimpchannel-select.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-09-05 04:18:08 +08:00
|
|
|
#include "core/gimpselection.h"
|
2004-10-18 19:29:58 +08:00
|
|
|
#include "core/gimpstrokeoptions.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2003-05-27 19:28:10 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2002-06-27 06:16:59 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-09-13 23:15:23 +08:00
|
|
|
#include "dialogs/dialogs.h"
|
|
|
|
#include "dialogs/stroke-dialog.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2003-05-27 19:28:10 +08:00
|
|
|
#include "select-commands.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
2004-05-03 22:46:29 +08:00
|
|
|
/* local function prototypes */
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
static void select_feather_callback (GtkWidget *widget,
|
|
|
|
gdouble size,
|
|
|
|
GimpUnit unit,
|
|
|
|
gpointer data);
|
|
|
|
static void select_border_callback (GtkWidget *widget,
|
|
|
|
gdouble size,
|
|
|
|
GimpUnit unit,
|
|
|
|
gpointer data);
|
|
|
|
static void select_grow_callback (GtkWidget *widget,
|
|
|
|
gdouble size,
|
|
|
|
GimpUnit unit,
|
|
|
|
gpointer data);
|
|
|
|
static void select_shrink_callback (GtkWidget *widget,
|
|
|
|
gdouble size,
|
|
|
|
GimpUnit unit,
|
|
|
|
gpointer data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* local variables */
|
|
|
|
|
|
|
|
static gdouble selection_feather_radius = 5.0;
|
|
|
|
static gint selection_border_radius = 5;
|
|
|
|
static gint selection_grow_pixels = 1;
|
|
|
|
static gint selection_shrink_pixels = 1;
|
|
|
|
static gboolean selection_shrink_edge_lock = FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_invert_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
gimp_channel_invert (gimp_image_get_mask (gimage), TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_all_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
gimp_channel_all (gimp_image_get_mask (gimage), TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_none_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_float_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-10-06 20:17:11 +08:00
|
|
|
gimp_selection_float (gimp_image_get_mask (gimage),
|
|
|
|
gimp_image_active_drawable (gimage),
|
2004-05-25 22:37:02 +08:00
|
|
|
action_data_get_context (data),
|
2003-10-06 20:17:11 +08:00
|
|
|
TRUE, 0, 0);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_feather_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2004-10-18 19:29:58 +08:00
|
|
|
GtkWidget *dialog;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
dialog = gimp_query_size_box (_("Feather Selection"),
|
|
|
|
gdisp->shell,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_SELECTION_FEATHER,
|
|
|
|
_("Feather selection by"),
|
|
|
|
selection_feather_radius, 0, 32767, 3,
|
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
|
|
|
|
MIN (gdisp->gimage->xresolution,
|
|
|
|
gdisp->gimage->yresolution),
|
|
|
|
FALSE,
|
|
|
|
G_OBJECT (gdisp->gimage), "disconnect",
|
|
|
|
select_feather_callback, gdisp->gimage);
|
|
|
|
gtk_widget_show (dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_sharpen_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
gimp_channel_sharpen (gimp_image_get_mask (gimage), TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_shrink_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp;
|
2004-10-18 19:29:58 +08:00
|
|
|
GtkWidget *dialog;
|
2002-01-14 04:59:56 +08:00
|
|
|
GtkWidget *edge_lock;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
dialog = gimp_query_size_box (_("Shrink Selection"),
|
|
|
|
gdisp->shell,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_SELECTION_SHRINK,
|
|
|
|
_("Shrink selection by"),
|
|
|
|
selection_shrink_pixels, 1, 32767, 0,
|
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
|
|
|
|
MIN (gdisp->gimage->xresolution,
|
|
|
|
gdisp->gimage->yresolution),
|
|
|
|
FALSE,
|
|
|
|
G_OBJECT (gdisp->gimage), "disconnect",
|
|
|
|
select_shrink_callback, gdisp->gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
edge_lock = gtk_check_button_new_with_label (_("Shrink from image border"));
|
2001-09-03 21:03:34 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (GIMP_QUERY_BOX_VBOX (dialog)), edge_lock,
|
2002-01-14 04:59:56 +08:00
|
|
|
FALSE, FALSE, 0);
|
2001-09-03 21:03:34 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
g_object_set_data (G_OBJECT (dialog), "edge_lock_toggle", edge_lock);
|
2001-06-26 20:09:43 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edge_lock),
|
2004-05-25 22:37:02 +08:00
|
|
|
! selection_shrink_edge_lock);
|
2001-06-26 20:09:43 +08:00
|
|
|
gtk_widget_show (edge_lock);
|
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
gtk_widget_show (dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_grow_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2004-10-18 19:29:58 +08:00
|
|
|
GtkWidget *dialog;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
dialog = gimp_query_size_box (_("Grow Selection"),
|
|
|
|
gdisp->shell,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_SELECTION_GROW,
|
|
|
|
_("Grow selection by"),
|
|
|
|
selection_grow_pixels, 1, 32767, 0,
|
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
|
|
|
|
MIN (gdisp->gimage->xresolution,
|
|
|
|
gdisp->gimage->yresolution),
|
|
|
|
FALSE,
|
|
|
|
G_OBJECT (gdisp->gimage), "disconnect",
|
|
|
|
select_grow_callback, gdisp->gimage);
|
|
|
|
gtk_widget_show (dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_border_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2004-10-18 19:29:58 +08:00
|
|
|
GtkWidget *dialog;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
dialog = gimp_query_size_box (_("Border Selection"),
|
|
|
|
gdisp->shell,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_SELECTION_BORDER,
|
|
|
|
_("Border selection by"),
|
|
|
|
selection_border_radius, 1, 32767, 0,
|
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
|
|
|
|
MIN (gdisp->gimage->xresolution,
|
|
|
|
gdisp->gimage->yresolution),
|
|
|
|
FALSE,
|
|
|
|
G_OBJECT (gdisp->gimage), "disconnect",
|
|
|
|
select_border_callback, gdisp->gimage);
|
|
|
|
gtk_widget_show (dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
select_save_cmd_callback (GtkAction *action,
|
2004-05-25 22:37:02 +08:00
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-05-03 22:46:29 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GtkWidget *widget;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
return_if_no_widget (widget, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-03 22:46:29 +08:00
|
|
|
gimp_selection_save (gimp_image_get_mask (gimage));
|
|
|
|
gimp_image_flush (gimage);
|
2003-05-27 19:28:10 +08:00
|
|
|
|
|
|
|
gimp_dialog_factory_dialog_raise (global_dock_factory,
|
2004-05-03 22:46:29 +08:00
|
|
|
gtk_widget_get_screen (widget),
|
2003-05-27 19:28:10 +08:00
|
|
|
"gimp-channel-list", -1);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
void
|
|
|
|
select_stroke_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2004-05-23 18:04:41 +08:00
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
return_if_no_widget (widget, data);
|
2004-05-13 02:36:33 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
drawable = gimp_image_active_drawable (gimage);
|
2004-05-13 02:36:33 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (! drawable)
|
2004-05-13 02:36:33 +08:00
|
|
|
{
|
|
|
|
g_message (_("There is no active layer or channel to stroke to."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
dialog = stroke_dialog_new (GIMP_ITEM (gimp_image_get_mask (gimage)),
|
|
|
|
GIMP_STOCK_SELECTION_STROKE,
|
2004-05-13 02:36:33 +08:00
|
|
|
GIMP_HELP_SELECTION_STROKE,
|
2004-05-23 18:04:41 +08:00
|
|
|
widget);
|
2004-05-13 02:36:33 +08:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
void
|
|
|
|
select_stroke_last_vals_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpContext *context;
|
|
|
|
GimpObject *options;
|
|
|
|
GimpItem *item;
|
|
|
|
gboolean libart_stroking;
|
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
|
|
|
drawable = gimp_image_active_drawable (image);
|
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
{
|
|
|
|
g_message (_("There is no active layer or channel to stroke to."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
context = gimp_get_user_context (image->gimp);
|
|
|
|
|
|
|
|
options = g_object_get_data (G_OBJECT (context), "saved-stroke-options");
|
|
|
|
|
|
|
|
if (options)
|
|
|
|
{
|
|
|
|
g_object_ref (options);
|
|
|
|
libart_stroking = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (options),
|
|
|
|
"libart-stroking"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
options = g_object_new (GIMP_TYPE_STROKE_OPTIONS,
|
|
|
|
"gimp", image->gimp,
|
|
|
|
NULL);
|
|
|
|
libart_stroking = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
item = GIMP_ITEM (gimp_image_get_mask (image));
|
|
|
|
|
|
|
|
if (libart_stroking)
|
|
|
|
{
|
|
|
|
gimp_item_stroke (item, drawable, context, options, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_item_stroke (item, drawable, context,
|
|
|
|
g_object_get_data (G_OBJECT (options),
|
|
|
|
"gimp-paint-info"), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
g_object_unref (options);
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2004-10-18 19:29:58 +08:00
|
|
|
select_feather_callback (GtkWidget *widget,
|
|
|
|
gdouble size,
|
|
|
|
GimpUnit unit,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE (data);
|
2001-06-26 20:09:43 +08:00
|
|
|
gdouble radius_x;
|
|
|
|
gdouble radius_y;
|
|
|
|
|
|
|
|
selection_feather_radius = size;
|
|
|
|
|
|
|
|
radius_x = radius_y = selection_feather_radius;
|
|
|
|
|
|
|
|
if (unit != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
|
|
|
gdouble factor;
|
|
|
|
|
|
|
|
factor = (MAX (gimage->xresolution, gimage->yresolution) /
|
2004-05-25 22:37:02 +08:00
|
|
|
MIN (gimage->xresolution, gimage->yresolution));
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
if (gimage->xresolution == MIN (gimage->xresolution, gimage->yresolution))
|
2004-05-25 22:37:02 +08:00
|
|
|
radius_y *= factor;
|
2001-06-26 20:09:43 +08:00
|
|
|
else
|
2004-05-25 22:37:02 +08:00
|
|
|
radius_x *= factor;
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
gimp_channel_feather (gimp_image_get_mask (gimage), radius_x, radius_y, TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-18 19:29:58 +08:00
|
|
|
select_border_callback (GtkWidget *widget,
|
|
|
|
gdouble size,
|
|
|
|
GimpUnit unit,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE (data);
|
2001-06-26 20:09:43 +08:00
|
|
|
gdouble radius_x;
|
|
|
|
gdouble radius_y;
|
|
|
|
|
|
|
|
selection_border_radius = ROUND (size);
|
|
|
|
|
|
|
|
radius_x = radius_y = selection_border_radius;
|
|
|
|
|
|
|
|
if (unit != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
|
|
|
gdouble factor;
|
|
|
|
|
|
|
|
factor = (MAX (gimage->xresolution, gimage->yresolution) /
|
2004-05-25 22:37:02 +08:00
|
|
|
MIN (gimage->xresolution, gimage->yresolution));
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
if (gimage->xresolution == MIN (gimage->xresolution, gimage->yresolution))
|
2004-05-25 22:37:02 +08:00
|
|
|
radius_y *= factor;
|
2001-06-26 20:09:43 +08:00
|
|
|
else
|
2004-05-25 22:37:02 +08:00
|
|
|
radius_x *= factor;
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
gimp_channel_border (gimp_image_get_mask (gimage), radius_x, radius_y, TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-18 19:29:58 +08:00
|
|
|
select_grow_callback (GtkWidget *widget,
|
|
|
|
gdouble size,
|
|
|
|
GimpUnit unit,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE (data);
|
2001-06-26 20:09:43 +08:00
|
|
|
gdouble radius_x;
|
|
|
|
gdouble radius_y;
|
|
|
|
|
|
|
|
selection_grow_pixels = ROUND (size);
|
|
|
|
|
|
|
|
radius_x = radius_y = selection_grow_pixels;
|
|
|
|
|
|
|
|
if (unit != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
|
|
|
gdouble factor;
|
|
|
|
|
|
|
|
factor = (MAX (gimage->xresolution, gimage->yresolution) /
|
2004-05-25 22:37:02 +08:00
|
|
|
MIN (gimage->xresolution, gimage->yresolution));
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
if (gimage->xresolution == MIN (gimage->xresolution, gimage->yresolution))
|
2004-05-25 22:37:02 +08:00
|
|
|
radius_y *= factor;
|
2001-06-26 20:09:43 +08:00
|
|
|
else
|
2004-05-25 22:37:02 +08:00
|
|
|
radius_x *= factor;
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
gimp_channel_grow (gimp_image_get_mask (gimage), radius_x, radius_y, TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-18 19:29:58 +08:00
|
|
|
select_shrink_callback (GtkWidget *widget,
|
|
|
|
gdouble size,
|
|
|
|
GimpUnit unit,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE (data);
|
2001-06-26 20:09:43 +08:00
|
|
|
gint radius_x;
|
|
|
|
gint radius_y;
|
|
|
|
|
|
|
|
selection_shrink_pixels = ROUND (size);
|
|
|
|
|
|
|
|
radius_x = radius_y = selection_shrink_pixels;
|
|
|
|
|
|
|
|
selection_shrink_edge_lock =
|
2001-08-15 00:33:28 +08:00
|
|
|
! GTK_TOGGLE_BUTTON (g_object_get_data (G_OBJECT (widget),
|
2004-05-25 22:37:02 +08:00
|
|
|
"edge_lock_toggle"))->active;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
if (unit != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
|
|
|
gdouble factor;
|
|
|
|
|
|
|
|
factor = (MAX (gimage->xresolution, gimage->yresolution) /
|
2004-05-25 22:37:02 +08:00
|
|
|
MIN (gimage->xresolution, gimage->yresolution));
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
if (gimage->xresolution == MIN (gimage->xresolution, gimage->yresolution))
|
2004-05-25 22:37:02 +08:00
|
|
|
radius_y *= factor;
|
2001-06-26 20:09:43 +08:00
|
|
|
else
|
2004-05-25 22:37:02 +08:00
|
|
|
radius_x *= factor;
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
removed the feather(), sharpen(), all(), invert(), border(), grow() and
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask.[ch]: removed the feather(), sharpen(),
all(), invert(), border(), grow() and shrink() wrappers.
* app/core/gimpselection.[ch]: changed gimp_selection_invalidate()
and gimp_selection_push_undo() to take GimpChannel parameters, not
GimpSelection ones. They will be made virtual GimpChannel
functions anyway.
* app/core/gimpedit.c
* app/gui/select-commands.c
* app/widgets/gimpselectioneditor.c
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/selection_cmds.c: regenerated.
2003-09-03 21:37:49 +08:00
|
|
|
gimp_channel_shrink (gimp_image_get_mask (gimage), radius_x, radius_y,
|
|
|
|
selection_shrink_edge_lock, TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|