2002-08-22 20:49:01 +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 "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-09-25 20:48:41 +08:00
|
|
|
#include "widgets-types.h"
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2003-04-04 00:13:12 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
2003-02-09 05:20:07 +08:00
|
|
|
#include "core/gimp.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpchannel-select.h"
|
2003-02-09 05:20:07 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2002-08-22 20:49:01 +08:00
|
|
|
#include "core/gimpimage.h"
|
2004-07-14 07:04:05 +08:00
|
|
|
#include "core/gimpimage-pick-color.h"
|
2003-09-05 04:18:08 +08:00
|
|
|
#include "core/gimpselection.h"
|
2002-08-22 20:49:01 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
|
2004-09-25 20:48:41 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning #include "tools/tools-types.h"
|
|
|
|
#endif
|
|
|
|
#include "tools/tools-types.h"
|
2003-02-09 05:20:07 +08:00
|
|
|
#include "tools/gimpselectionoptions.h"
|
2002-08-22 20:49:01 +08:00
|
|
|
|
|
|
|
#include "gimpselectioneditor.h"
|
|
|
|
#include "gimpdnd.h"
|
2006-08-30 05:44:51 +08:00
|
|
|
#include "gimpdocked.h"
|
2004-05-13 02:36:33 +08:00
|
|
|
#include "gimpmenufactory.h"
|
2004-08-25 01:16:46 +08:00
|
|
|
#include "gimpview.h"
|
2004-08-26 06:31:44 +08:00
|
|
|
#include "gimpviewrenderer.h"
|
2003-06-03 01:57:11 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-08-22 20:49:01 +08:00
|
|
|
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
static void gimp_selection_editor_docked_iface_init (GimpDockedInterface *iface);
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
static GObject * gimp_selection_editor_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
static void gimp_selection_editor_set_image (GimpImageEditor *editor,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
static void gimp_selection_editor_set_context (GimpDocked *docked,
|
|
|
|
GimpContext *context);
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
static gboolean gimp_selection_view_button_press (GtkWidget *widget,
|
2002-08-22 20:49:01 +08:00
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpSelectionEditor *editor);
|
|
|
|
static void gimp_selection_editor_drop_color (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2002-08-22 20:49:01 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
static void gimp_selection_editor_mask_changed (GimpImage *image,
|
2002-08-22 20:49:01 +08:00
|
|
|
GimpSelectionEditor *editor);
|
|
|
|
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpSelectionEditor, gimp_selection_editor,
|
|
|
|
GIMP_TYPE_IMAGE_EDITOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
|
|
|
|
gimp_selection_editor_docked_iface_init))
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
#define parent_class gimp_selection_editor_parent_class
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
static GimpDockedInterface *parent_docked_iface = NULL;
|
|
|
|
|
2002-08-22 20:49:01 +08:00
|
|
|
|
|
|
|
static void
|
2006-08-30 05:44:51 +08:00
|
|
|
gimp_selection_editor_class_init (GimpSelectionEditorClass *klass)
|
2002-08-22 20:49:01 +08:00
|
|
|
{
|
2004-05-13 02:36:33 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpImageEditorClass *image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
object_class->constructor = gimp_selection_editor_constructor;
|
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
image_editor_class->set_image = gimp_selection_editor_set_image;
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
static void
|
|
|
|
gimp_selection_editor_docked_iface_init (GimpDockedInterface *iface)
|
|
|
|
{
|
|
|
|
parent_docked_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
if (! parent_docked_iface)
|
|
|
|
parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
|
|
|
|
|
|
|
|
iface->set_context = gimp_selection_editor_set_context;
|
|
|
|
}
|
|
|
|
|
2002-08-22 20:49:01 +08:00
|
|
|
static void
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_selection_editor_init (GimpSelectionEditor *editor)
|
2002-08-22 20:49:01 +08:00
|
|
|
{
|
2003-03-10 22:07:22 +08:00
|
|
|
GtkWidget *frame;
|
2002-08-22 20:49:01 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2004-05-13 02:36:33 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0);
|
2002-08-22 20:49:01 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
editor->view = gimp_view_new_by_types (NULL,
|
|
|
|
GIMP_TYPE_VIEW,
|
2006-01-17 18:08:50 +08:00
|
|
|
GIMP_TYPE_SELECTION,
|
|
|
|
GIMP_VIEW_SIZE_HUGE,
|
|
|
|
0, TRUE);
|
|
|
|
gimp_view_renderer_set_background (GIMP_VIEW (editor->view)->renderer,
|
2004-08-26 06:31:44 +08:00
|
|
|
GIMP_STOCK_TEXTURE);
|
2006-01-17 18:08:50 +08:00
|
|
|
gtk_widget_set_size_request (editor->view,
|
2004-08-29 19:58:05 +08:00
|
|
|
GIMP_VIEW_SIZE_HUGE, GIMP_VIEW_SIZE_HUGE);
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_view_set_expand (GIMP_VIEW (editor->view), TRUE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), editor->view);
|
|
|
|
gtk_widget_show (editor->view);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
g_signal_connect (editor->view, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_selection_view_button_press),
|
2004-05-13 02:36:33 +08:00
|
|
|
editor);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_dnd_color_dest_add (editor->view,
|
2002-08-22 20:49:01 +08:00
|
|
|
gimp_selection_editor_drop_color,
|
2004-05-13 02:36:33 +08:00
|
|
|
editor);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gimp_selection_editor_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
GimpSelectionEditor *editor;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
editor = GIMP_SELECTION_EDITOR (object);
|
|
|
|
|
|
|
|
editor->all_button =
|
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (editor), "select",
|
|
|
|
"select-all", NULL);
|
|
|
|
|
|
|
|
editor->none_button =
|
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (editor), "select",
|
|
|
|
"select-none", NULL);
|
|
|
|
|
|
|
|
editor->invert_button =
|
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (editor), "select",
|
|
|
|
"select-invert", NULL);
|
|
|
|
|
|
|
|
editor->save_button =
|
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (editor), "select",
|
|
|
|
"select-save", NULL);
|
|
|
|
|
|
|
|
editor->path_button =
|
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (editor), "vectors",
|
|
|
|
"vectors-selection-to-vectors",
|
|
|
|
"vectors-selection-to-vectors-advanced",
|
|
|
|
GDK_SHIFT_MASK,
|
|
|
|
NULL);
|
2003-06-03 01:57:11 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
editor->stroke_button =
|
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (editor), "select",
|
2004-10-23 08:53:48 +08:00
|
|
|
"select-stroke",
|
|
|
|
"select-stroke-last-values",
|
|
|
|
GDK_SHIFT_MASK,
|
|
|
|
NULL);
|
2003-05-10 05:41:53 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
return object;
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-20 23:40:15 +08:00
|
|
|
gimp_selection_editor_set_image (GimpImageEditor *image_editor,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image)
|
2002-08-22 20:49:01 +08:00
|
|
|
{
|
2004-02-18 21:43:50 +08:00
|
|
|
GimpSelectionEditor *editor = GIMP_SELECTION_EDITOR (image_editor);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image_editor->image)
|
2003-02-20 23:40:15 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (image_editor->image,
|
2004-07-14 18:31:59 +08:00
|
|
|
gimp_selection_editor_mask_changed,
|
|
|
|
editor);
|
2003-02-20 23:40:15 +08:00
|
|
|
}
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, image);
|
2003-02-20 23:40:15 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image)
|
2003-02-20 23:40:15 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
g_signal_connect (image, "mask-changed",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_CALLBACK (gimp_selection_editor_mask_changed),
|
|
|
|
editor);
|
2003-02-20 23:40:15 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_view_set_viewable (GIMP_VIEW (editor->view),
|
2006-03-29 01:08:36 +08:00
|
|
|
GIMP_VIEWABLE (gimp_image_get_mask (image)));
|
2003-02-20 23:40:15 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL);
|
2003-02-20 23:40:15 +08:00
|
|
|
}
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
static void
|
|
|
|
gimp_selection_editor_set_context (GimpDocked *docked,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpSelectionEditor *editor = GIMP_SELECTION_EDITOR (docked);
|
|
|
|
|
|
|
|
parent_docked_iface->set_context (docked, context);
|
|
|
|
|
|
|
|
gimp_view_renderer_set_context (GIMP_VIEW (editor->view)->renderer,
|
|
|
|
context);
|
|
|
|
}
|
|
|
|
|
2002-08-22 20:49:01 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GtkWidget *
|
2004-09-25 20:48:41 +08:00
|
|
|
gimp_selection_editor_new (GimpMenuFactory *menu_factory)
|
2002-08-22 20:49:01 +08:00
|
|
|
{
|
2004-05-13 02:36:33 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2004-09-25 20:48:41 +08:00
|
|
|
return g_object_new (GIMP_TYPE_SELECTION_EDITOR,
|
|
|
|
"menu-factory", menu_factory,
|
|
|
|
"menu-identifier", "<SelectionEditor>",
|
|
|
|
"ui-path", "/selection-editor-popup",
|
|
|
|
NULL);
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_selection_view_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpSelectionEditor *editor)
|
2002-08-22 20:49:01 +08:00
|
|
|
{
|
2004-02-18 21:43:50 +08:00
|
|
|
GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
|
2004-08-26 06:31:44 +08:00
|
|
|
GimpViewRenderer *renderer;
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GimpSelectionOptions *options;
|
|
|
|
GimpDrawable *drawable;
|
2006-10-18 03:18:34 +08:00
|
|
|
GimpChannelOps operation = GIMP_CHANNEL_OP_REPLACE;
|
2003-02-05 22:39:40 +08:00
|
|
|
gint x, y;
|
|
|
|
GimpRGB color;
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! image_editor->image)
|
2002-08-22 20:49:01 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
renderer = GIMP_VIEW (editor->view)->renderer;
|
2003-03-10 22:07:22 +08:00
|
|
|
|
2006-09-08 21:42:00 +08:00
|
|
|
tool_info = gimp_get_tool_info (image_editor->image->gimp,
|
|
|
|
"gimp-by-color-select-tool");
|
2003-02-09 05:20:07 +08:00
|
|
|
|
|
|
|
if (! tool_info)
|
|
|
|
return TRUE;
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
drawable = gimp_image_active_drawable (image_editor->image);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (bevent->state & GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
if (bevent->state & GDK_CONTROL_MASK)
|
|
|
|
{
|
2006-10-18 03:18:34 +08:00
|
|
|
operation = GIMP_CHANNEL_OP_INTERSECT;
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-18 03:18:34 +08:00
|
|
|
operation = GIMP_CHANNEL_OP_ADD;
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bevent->state & GDK_CONTROL_MASK)
|
|
|
|
{
|
2006-10-18 03:18:34 +08:00
|
|
|
operation = GIMP_CHANNEL_OP_SUBTRACT;
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
x = image_editor->image->width * bevent->x / renderer->width;
|
|
|
|
y = image_editor->image->height * bevent->y / renderer->height;
|
2003-03-10 22:07:22 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (gimp_image_pick_color (image_editor->image, drawable, x, y,
|
2004-07-14 07:04:05 +08:00
|
|
|
options->sample_merged,
|
|
|
|
FALSE, 0.0,
|
|
|
|
NULL,
|
|
|
|
&color, NULL))
|
2002-08-22 20:49:01 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_channel_select_by_color (gimp_image_get_mask (image_editor->image),
|
2004-07-14 07:04:05 +08:00
|
|
|
drawable,
|
|
|
|
options->sample_merged,
|
|
|
|
&color,
|
|
|
|
options->threshold,
|
|
|
|
options->select_transparent,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
options->select_criterion,
|
2004-07-14 07:04:05 +08:00
|
|
|
operation,
|
|
|
|
options->antialias,
|
|
|
|
options->feather,
|
|
|
|
options->feather_radius,
|
|
|
|
options->feather_radius);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image_editor->image);
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_selection_editor_drop_color (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2002-08-22 20:49:01 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-02-18 21:43:50 +08:00
|
|
|
GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data);
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
GimpSelectionOptions *options;
|
|
|
|
GimpDrawable *drawable;
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! editor->image)
|
2002-08-22 20:49:01 +08:00
|
|
|
return;
|
|
|
|
|
2006-09-08 21:42:00 +08:00
|
|
|
tool_info = gimp_get_tool_info (editor->image->gimp,
|
|
|
|
"gimp-by-color-select-tool");
|
2003-02-09 05:20:07 +08:00
|
|
|
if (! tool_info)
|
|
|
|
return;
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
drawable = gimp_image_active_drawable (editor->image);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
return;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_channel_select_by_color (gimp_image_get_mask (editor->image),
|
2003-10-06 20:17:11 +08:00
|
|
|
drawable,
|
|
|
|
options->sample_merged,
|
|
|
|
color,
|
|
|
|
options->threshold,
|
|
|
|
options->select_transparent,
|
Applied (modified and enhanced) patch from Chris Moller which allows tools
2006-08-05 Michael Natterer <mitch@gimp.org>
Applied (modified and enhanced) patch from Chris Moller which allows
tools to distinguish similar colors not only by composite, but also
by R, G, B, H, S and V. Fixes bug #348291.
* app/core/core-enums.[ch]: added new enum GimpSelectCriterion
which can be one of { COMPOSITE, R, G, B, H, S, V }.
* app/core/gimpimage-contiguous-region.[ch]: added
select_criterion params and create the region based on difference
by the selected criterion.
* app/core/gimpchannel-select.[ch]
* app/core/gimpdrawable-bucket-fill.[ch]: take criterion params and
pass them through to the contiguous region functions.
* app/tools/gimpbucketfilloptions.[ch]
* app/tools/gimpselectionoptions.[ch]: added criterion properties
and GUI to select it.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c: pass the selected criterion to
the resp. core functions.
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/display/gimpdisplayshell-dnd.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly
(simply pass GIMP_SELECT_CRITERION_COMPOSITE in most cases).
* app/pdb/edit_cmds.c
* app/pdb/selection_tools_cmds.c: regenerated.
2006-08-05 21:02:47 +08:00
|
|
|
options->select_criterion,
|
2003-10-06 20:17:11 +08:00
|
|
|
options->operation,
|
|
|
|
options->antialias,
|
|
|
|
options->feather,
|
|
|
|
options->feather_radius,
|
|
|
|
options->feather_radius);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (editor->image);
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_selection_editor_mask_changed (GimpImage *image,
|
2002-08-22 20:49:01 +08:00
|
|
|
GimpSelectionEditor *editor)
|
|
|
|
{
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_view_renderer_invalidate (GIMP_VIEW (editor->view)->renderer);
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|