2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-03-02 23:24:12 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-03-02 23:24:12 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-03-02 23:24:12 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-03-02 23:24:12 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2001-03-02 23:24:12 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2001-03-02 23:24:12 +08:00
|
|
|
|
2003-09-03 23:13:19 +08:00
|
|
|
#include "core/gimpchannel.h"
|
2018-09-02 20:47:21 +08:00
|
|
|
#include "core/gimperror.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2017-06-22 14:16:43 +08:00
|
|
|
#include "core/gimpimage-pick-item.h"
|
2019-04-25 16:05:12 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2005-07-12 03:21:52 +08:00
|
|
|
#include "core/gimppickable.h"
|
2019-04-25 16:05:12 +08:00
|
|
|
#include "core/gimpundostack.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2019-04-25 16:05:12 +08:00
|
|
|
#include "display/gimpdisplayshell-appearance.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2006-08-03 17:06:36 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
2002-03-03 18:38:37 +08:00
|
|
|
#include "gimpeditselectiontool.h"
|
2001-03-02 23:24:12 +08:00
|
|
|
#include "gimpselectiontool.h"
|
2003-02-09 05:12:03 +08:00
|
|
|
#include "gimpselectionoptions.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2018-12-10 21:22:50 +08:00
|
|
|
#include "gimptools-utils.h"
|
2001-03-02 23:24:12 +08:00
|
|
|
|
2005-05-07 21:24:47 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2001-03-02 23:24:12 +08:00
|
|
|
|
2020-02-03 18:14:08 +08:00
|
|
|
static void gimp_selection_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_selection_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_selection_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_selection_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static gboolean gimp_selection_tool_real_have_selection (GimpSelectionTool *sel_tool,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static void gimp_selection_tool_commit (GimpSelectionTool *sel_tool);
|
|
|
|
static void gimp_selection_tool_halt (GimpSelectionTool *sel_tool,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static gboolean gimp_selection_tool_check (GimpSelectionTool *sel_tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
static gboolean gimp_selection_tool_have_selection (GimpSelectionTool *sel_tool,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
2001-03-02 23:24:12 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpSelectionTool, gimp_selection_tool, GIMP_TYPE_DRAW_TOOL)
|
2001-03-02 23:24:12 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_selection_tool_parent_class
|
2001-03-02 23:24:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_selection_tool_class_init (GimpSelectionToolClass *klass)
|
|
|
|
{
|
2004-03-10 20:45:11 +08:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
2001-03-02 23:24:12 +08:00
|
|
|
|
2019-04-25 16:05:12 +08:00
|
|
|
tool_class->control = gimp_selection_tool_control;
|
2001-11-21 11:54:09 +08:00
|
|
|
tool_class->modifier_key = gimp_selection_tool_modifier_key;
|
2004-06-13 02:41:52 +08:00
|
|
|
tool_class->key_press = gimp_edit_selection_tool_key_press;
|
2001-03-02 23:24:12 +08:00
|
|
|
tool_class->oper_update = gimp_selection_tool_oper_update;
|
2001-11-09 03:14:51 +08:00
|
|
|
tool_class->cursor_update = gimp_selection_tool_cursor_update;
|
2020-02-03 18:14:08 +08:00
|
|
|
|
|
|
|
klass->have_selection = gimp_selection_tool_real_have_selection;
|
2001-03-02 23:24:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_selection_tool_init (GimpSelectionTool *selection_tool)
|
|
|
|
{
|
2019-04-25 16:05:12 +08:00
|
|
|
selection_tool->function = SELECTION_SELECT;
|
|
|
|
selection_tool->saved_operation = GIMP_CHANNEL_OP_REPLACE;
|
|
|
|
|
|
|
|
selection_tool->saved_show_selection = FALSE;
|
|
|
|
selection_tool->undo = NULL;
|
|
|
|
selection_tool->redo = NULL;
|
|
|
|
selection_tool->idle_id = 0;
|
|
|
|
|
|
|
|
selection_tool->allow_move = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_selection_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpSelectionTool *selection_tool = GIMP_SELECTION_TOOL (tool);
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_ACTION_PAUSE:
|
|
|
|
case GIMP_TOOL_ACTION_RESUME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_HALT:
|
|
|
|
gimp_selection_tool_halt (selection_tool, display);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_COMMIT:
|
|
|
|
gimp_selection_tool_commit (selection_tool);
|
|
|
|
break;
|
|
|
|
}
|
2006-06-02 23:23:47 +08:00
|
|
|
|
2019-04-25 16:05:12 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
2001-11-21 11:54:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_selection_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2001-11-21 11:54:09 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
GimpSelectionTool *selection_tool = GIMP_SELECTION_TOOL (tool);
|
2011-10-07 03:59:07 +08:00
|
|
|
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
|
|
|
GdkModifierType extend_mask;
|
|
|
|
GdkModifierType modify_mask;
|
2001-11-21 11:54:09 +08:00
|
|
|
|
2011-10-07 03:59:07 +08:00
|
|
|
extend_mask = gimp_get_extend_selection_mask ();
|
|
|
|
modify_mask = gimp_get_modify_selection_mask ();
|
2001-11-21 11:54:09 +08:00
|
|
|
|
2011-10-07 03:59:07 +08:00
|
|
|
if (key == extend_mask ||
|
|
|
|
key == modify_mask ||
|
2006-08-26 06:07:26 +08:00
|
|
|
key == GDK_MOD1_MASK)
|
2001-11-21 11:54:09 +08:00
|
|
|
{
|
2011-10-12 22:00:58 +08:00
|
|
|
GimpChannelOps button_op = options->operation;
|
2003-09-17 19:16:55 +08:00
|
|
|
|
2020-05-05 23:12:31 +08:00
|
|
|
state &= extend_mask |
|
|
|
|
modify_mask |
|
|
|
|
GDK_MOD1_MASK;
|
|
|
|
|
2006-11-11 18:44:02 +08:00
|
|
|
if (press)
|
2001-11-21 11:54:09 +08:00
|
|
|
{
|
2020-05-05 23:12:31 +08:00
|
|
|
if (key == state ||
|
|
|
|
/* GimpPolygonSelectTool may mask-out part of the state, which
|
|
|
|
* can cause the wrong mode to be restored on release if we don't
|
|
|
|
* init saved_operation here.
|
|
|
|
*
|
|
|
|
* see issue #4992.
|
|
|
|
*/
|
|
|
|
! state)
|
2001-11-21 11:54:09 +08:00
|
|
|
{
|
2006-11-11 18:44:02 +08:00
|
|
|
/* first modifier pressed */
|
2002-03-15 06:42:50 +08:00
|
|
|
|
2006-11-11 18:44:02 +08:00
|
|
|
selection_tool->saved_operation = options->operation;
|
2001-11-21 11:54:09 +08:00
|
|
|
}
|
2006-11-11 18:44:02 +08:00
|
|
|
}
|
2011-10-12 22:00:58 +08:00
|
|
|
else
|
|
|
|
{
|
2020-05-05 23:12:31 +08:00
|
|
|
if (! state)
|
2011-10-12 22:00:58 +08:00
|
|
|
{
|
|
|
|
/* last modifier released */
|
|
|
|
|
|
|
|
button_op = selection_tool->saved_operation;
|
|
|
|
}
|
|
|
|
}
|
2006-08-26 06:07:26 +08:00
|
|
|
|
2006-11-11 18:44:02 +08:00
|
|
|
if (state & GDK_MOD1_MASK)
|
|
|
|
{
|
|
|
|
/* if alt is down, pretend that neither
|
|
|
|
* shift nor control are down
|
|
|
|
*/
|
|
|
|
button_op = selection_tool->saved_operation;
|
|
|
|
}
|
2012-05-18 05:31:48 +08:00
|
|
|
else if (state & (extend_mask |
|
|
|
|
modify_mask))
|
2006-11-11 18:44:02 +08:00
|
|
|
{
|
2012-05-18 05:31:48 +08:00
|
|
|
/* else get the operation from the modifier state, but only
|
|
|
|
* if there is actually a modifier pressed, so we don't
|
|
|
|
* override the "last modifier released" assignment above
|
|
|
|
*/
|
2011-10-07 03:59:07 +08:00
|
|
|
button_op = gimp_modifiers_to_channel_op (state);
|
2001-11-21 11:54:09 +08:00
|
|
|
}
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
if (button_op != options->operation)
|
2001-11-21 11:54:09 +08:00
|
|
|
{
|
2003-02-28 09:14:30 +08:00
|
|
|
g_object_set (options, "operation", button_op, NULL);
|
2001-11-21 11:54:09 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_selection_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
GimpSelectionTool *selection_tool = GIMP_SELECTION_TOOL (tool);
|
2011-10-07 03:59:07 +08:00
|
|
|
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *image;
|
2020-05-18 05:00:07 +08:00
|
|
|
GList *drawables;
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
GimpLayer *floating_sel;
|
2011-10-07 03:59:07 +08:00
|
|
|
GdkModifierType extend_mask;
|
|
|
|
GdkModifierType modify_mask;
|
2020-02-03 18:14:08 +08:00
|
|
|
gboolean have_selection;
|
2003-05-16 20:10:47 +08:00
|
|
|
gboolean move_layer = FALSE;
|
|
|
|
gboolean move_floating_sel = FALSE;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
image = gimp_display_get_image (display);
|
2020-05-18 05:00:07 +08:00
|
|
|
drawables = gimp_image_get_selected_drawables (image);
|
2018-12-16 06:34:07 +08:00
|
|
|
layer = gimp_image_pick_layer (image, coords->x, coords->y, NULL);
|
2009-10-07 01:20:44 +08:00
|
|
|
floating_sel = gimp_image_get_floating_selection (image);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2011-10-07 03:59:07 +08:00
|
|
|
extend_mask = gimp_get_extend_selection_mask ();
|
|
|
|
modify_mask = gimp_get_modify_selection_mask ();
|
|
|
|
|
2020-02-03 18:14:08 +08:00
|
|
|
have_selection = gimp_selection_tool_have_selection (selection_tool, display);
|
|
|
|
|
2020-05-18 05:00:07 +08:00
|
|
|
if (drawables)
|
2003-05-16 20:10:47 +08:00
|
|
|
{
|
|
|
|
if (floating_sel)
|
|
|
|
{
|
|
|
|
if (layer == floating_sel)
|
|
|
|
move_floating_sel = TRUE;
|
|
|
|
}
|
2020-05-18 05:00:07 +08:00
|
|
|
else if (have_selection)
|
2003-05-16 20:10:47 +08:00
|
|
|
{
|
2020-05-18 05:00:07 +08:00
|
|
|
GList *iter;
|
|
|
|
|
|
|
|
for (iter = drawables; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
if (gimp_item_mask_intersect (GIMP_ITEM (iter->data),
|
|
|
|
NULL, NULL, NULL, NULL))
|
|
|
|
{
|
|
|
|
move_layer = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-05-16 20:10:47 +08:00
|
|
|
}
|
2020-05-18 05:00:07 +08:00
|
|
|
|
|
|
|
g_list_free (drawables);
|
2003-05-16 20:10:47 +08:00
|
|
|
}
|
|
|
|
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
selection_tool->function = SELECTION_SELECT;
|
|
|
|
|
2006-06-02 23:23:47 +08:00
|
|
|
if (selection_tool->allow_move &&
|
2011-10-07 03:59:07 +08:00
|
|
|
(state & GDK_MOD1_MASK) && (state & modify_mask) && move_layer)
|
2003-05-16 20:10:47 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
/* move the selection */
|
|
|
|
selection_tool->function = SELECTION_MOVE;
|
2003-05-16 20:10:47 +08:00
|
|
|
}
|
2006-06-02 23:23:47 +08:00
|
|
|
else if (selection_tool->allow_move &&
|
2011-10-07 03:59:07 +08:00
|
|
|
(state & GDK_MOD1_MASK) && (state & extend_mask) && move_layer)
|
2006-06-02 23:23:47 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
/* move a copy of the selection */
|
|
|
|
selection_tool->function = SELECTION_MOVE_COPY;
|
2006-06-02 23:23:47 +08:00
|
|
|
}
|
|
|
|
else if (selection_tool->allow_move &&
|
2020-02-03 18:14:08 +08:00
|
|
|
(state & GDK_MOD1_MASK) && have_selection)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
/* move the selection mask */
|
|
|
|
selection_tool->function = SELECTION_MOVE_MASK;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
2006-06-02 23:23:47 +08:00
|
|
|
else if (selection_tool->allow_move &&
|
2011-10-07 03:59:07 +08:00
|
|
|
! (state & (extend_mask | modify_mask)) &&
|
2006-06-02 23:23:47 +08:00
|
|
|
move_floating_sel)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
/* move the selection */
|
|
|
|
selection_tool->function = SELECTION_MOVE;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
2011-10-07 03:59:07 +08:00
|
|
|
else if ((state & modify_mask) || (state & extend_mask))
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
/* select */
|
|
|
|
selection_tool->function = SELECTION_SELECT;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
else if (floating_sel)
|
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
/* anchor the selection */
|
|
|
|
selection_tool->function = SELECTION_ANCHOR;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
2005-05-07 21:24:47 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2006-03-25 21:51:13 +08:00
|
|
|
|
2006-03-25 22:23:09 +08:00
|
|
|
if (proximity)
|
2005-05-07 21:24:47 +08:00
|
|
|
{
|
2008-05-17 21:08:19 +08:00
|
|
|
const gchar *status = NULL;
|
2006-08-03 17:06:36 +08:00
|
|
|
gboolean free_status = FALSE;
|
2011-10-07 03:59:07 +08:00
|
|
|
GdkModifierType modifiers = (extend_mask | modify_mask);
|
2006-03-25 21:51:13 +08:00
|
|
|
|
2020-02-03 18:14:08 +08:00
|
|
|
if (have_selection)
|
2006-08-03 17:06:36 +08:00
|
|
|
modifiers |= GDK_MOD1_MASK;
|
2006-08-04 02:17:42 +08:00
|
|
|
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
switch (selection_tool->function)
|
2005-05-07 21:24:47 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
case SELECTION_SELECT:
|
|
|
|
switch (options->operation)
|
2006-08-03 17:06:36 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
case GIMP_CHANNEL_OP_REPLACE:
|
2020-02-03 18:14:08 +08:00
|
|
|
if (have_selection)
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
{
|
|
|
|
status = gimp_suggest_modifiers (_("Click-Drag to replace the "
|
|
|
|
"current selection"),
|
|
|
|
modifiers & ~state,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
free_status = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = _("Click-Drag to create a new selection");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_CHANNEL_OP_ADD:
|
|
|
|
status = gimp_suggest_modifiers (_("Click-Drag to add to the "
|
2006-09-12 14:37:54 +08:00
|
|
|
"current selection"),
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
modifiers
|
2011-10-07 03:59:07 +08:00
|
|
|
& ~(state | extend_mask),
|
2006-08-03 17:06:36 +08:00
|
|
|
NULL, NULL, NULL);
|
|
|
|
free_status = TRUE;
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
break;
|
2006-07-31 04:15:07 +08:00
|
|
|
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
case GIMP_CHANNEL_OP_SUBTRACT:
|
|
|
|
status = gimp_suggest_modifiers (_("Click-Drag to subtract from the "
|
|
|
|
"current selection"),
|
|
|
|
modifiers
|
2011-10-07 03:59:07 +08:00
|
|
|
& ~(state | modify_mask),
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
NULL, NULL, NULL);
|
|
|
|
free_status = TRUE;
|
|
|
|
break;
|
2006-07-31 04:15:07 +08:00
|
|
|
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
case GIMP_CHANNEL_OP_INTERSECT:
|
|
|
|
status = gimp_suggest_modifiers (_("Click-Drag to intersect with "
|
|
|
|
"the current selection"),
|
|
|
|
modifiers & ~state,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
free_status = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2006-07-31 04:15:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SELECTION_MOVE_MASK:
|
2006-08-03 17:06:36 +08:00
|
|
|
status = gimp_suggest_modifiers (_("Click-Drag to move the "
|
2006-09-12 14:37:54 +08:00
|
|
|
"selection mask"),
|
2006-08-03 17:06:36 +08:00
|
|
|
modifiers & ~state,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
free_status = TRUE;
|
2006-07-31 04:15:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SELECTION_MOVE:
|
2006-09-12 14:37:54 +08:00
|
|
|
status = _("Click-Drag to move the selected pixels");
|
2006-07-31 04:15:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SELECTION_MOVE_COPY:
|
2006-09-12 14:37:54 +08:00
|
|
|
status = _("Click-Drag to move a copy of the selected pixels");
|
2006-07-31 04:15:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SELECTION_ANCHOR:
|
2006-09-12 14:37:54 +08:00
|
|
|
status = _("Click to anchor the floating selection");
|
2006-07-31 04:15:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_return_if_reached ();
|
2005-05-07 21:24:47 +08:00
|
|
|
}
|
|
|
|
|
2006-03-25 21:51:13 +08:00
|
|
|
if (status)
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_tool_push_status (tool, display, "%s", status);
|
2006-08-03 17:06:36 +08:00
|
|
|
|
|
|
|
if (free_status)
|
2008-05-17 21:08:19 +08:00
|
|
|
g_free ((gchar *) status);
|
2006-03-25 21:51:13 +08:00
|
|
|
}
|
2001-03-02 23:24:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_selection_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
2001-03-02 23:24:12 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
GimpSelectionTool *selection_tool = GIMP_SELECTION_TOOL (tool);
|
|
|
|
GimpSelectionOptions *options;
|
|
|
|
GimpToolCursorType tool_cursor;
|
|
|
|
GimpCursorModifier modifier;
|
|
|
|
|
|
|
|
options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
2001-03-02 23:24:12 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
tool_cursor = gimp_tool_control_get_tool_cursor (tool->control);
|
2006-06-02 23:23:47 +08:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_NONE;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
switch (selection_tool->function)
|
2001-03-02 23:24:12 +08:00
|
|
|
{
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
case SELECTION_SELECT:
|
|
|
|
switch (options->operation)
|
|
|
|
{
|
|
|
|
case GIMP_CHANNEL_OP_REPLACE:
|
|
|
|
break;
|
|
|
|
case GIMP_CHANNEL_OP_ADD:
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_PLUS;
|
|
|
|
break;
|
|
|
|
case GIMP_CHANNEL_OP_SUBTRACT:
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_MINUS;
|
|
|
|
break;
|
|
|
|
case GIMP_CHANNEL_OP_INTERSECT:
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_INTERSECT;
|
|
|
|
break;
|
|
|
|
}
|
2001-03-02 23:24:12 +08:00
|
|
|
break;
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
|
2001-03-02 23:24:12 +08:00
|
|
|
case SELECTION_MOVE_MASK:
|
2006-06-02 23:23:47 +08:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_MOVE;
|
2001-03-02 23:24:12 +08:00
|
|
|
break;
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
|
2001-03-02 23:24:12 +08:00
|
|
|
case SELECTION_MOVE:
|
2003-05-16 20:10:47 +08:00
|
|
|
case SELECTION_MOVE_COPY:
|
2004-06-05 07:08:29 +08:00
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_MOVE;
|
2001-03-02 23:24:12 +08:00
|
|
|
break;
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
|
2001-03-02 23:24:12 +08:00
|
|
|
case SELECTION_ANCHOR:
|
2006-06-02 23:23:47 +08:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_ANCHOR;
|
2001-03-02 23:24:12 +08:00
|
|
|
break;
|
|
|
|
}
|
2002-04-21 15:31:12 +08:00
|
|
|
|
2018-09-02 20:47:21 +08:00
|
|
|
/* our subclass might have set a BAD modifier, in which case we leave it
|
|
|
|
* there, since it's more important than what we have to say.
|
2006-06-03 23:41:40 +08:00
|
|
|
*/
|
|
|
|
if (gimp_tool_control_get_cursor_modifier (tool->control) ==
|
2018-09-02 20:47:21 +08:00
|
|
|
GIMP_CURSOR_MODIFIER_BAD ||
|
|
|
|
! gimp_selection_tool_check (selection_tool, display, NULL))
|
2006-06-03 23:41:40 +08:00
|
|
|
{
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_BAD;
|
|
|
|
}
|
|
|
|
|
2006-06-02 23:23:47 +08:00
|
|
|
gimp_tool_set_cursor (tool, display,
|
|
|
|
gimp_tool_control_get_cursor (tool->control),
|
|
|
|
tool_cursor,
|
|
|
|
modifier);
|
2001-03-02 23:24:12 +08:00
|
|
|
}
|
2004-07-26 22:50:51 +08:00
|
|
|
|
2020-02-03 18:14:08 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_selection_tool_real_have_selection (GimpSelectionTool *sel_tool,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpChannel *selection = gimp_image_get_mask (image);
|
|
|
|
|
|
|
|
return ! gimp_channel_is_empty (selection);
|
|
|
|
}
|
|
|
|
|
2019-04-25 16:05:12 +08:00
|
|
|
static void
|
|
|
|
gimp_selection_tool_commit (GimpSelectionTool *sel_tool)
|
|
|
|
{
|
|
|
|
/* make sure gimp_selection_tool_halt() doesn't undo the change, if any */
|
2023-05-23 00:13:44 +08:00
|
|
|
g_clear_weak_pointer (&sel_tool->undo);
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_selection_tool_halt (GimpSelectionTool *sel_tool,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
g_warn_if_fail (sel_tool->change_count == 0);
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (sel_tool);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpUndoStack *undo_stack = gimp_image_get_undo_stack (image);
|
|
|
|
GimpUndo *undo = gimp_undo_stack_peek (undo_stack);
|
|
|
|
|
|
|
|
/* if we have an existing selection in the current display, then
|
|
|
|
* we have already "executed", and need to undo at this point,
|
|
|
|
* unless the user has done something in the meantime
|
|
|
|
*/
|
|
|
|
if (undo && sel_tool->undo == undo)
|
|
|
|
{
|
|
|
|
/* prevent this change from halting the tool */
|
|
|
|
gimp_tool_control_push_preserve (tool->control, TRUE);
|
|
|
|
|
|
|
|
gimp_image_undo (image);
|
|
|
|
gimp_image_flush (image);
|
|
|
|
|
|
|
|
gimp_tool_control_pop_preserve (tool->control);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset the automatic undo/redo mechanism */
|
2023-05-23 00:13:44 +08:00
|
|
|
g_clear_weak_pointer (&sel_tool->undo);
|
|
|
|
g_clear_weak_pointer (&sel_tool->redo);
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-02 20:47:21 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_selection_tool_check (GimpSelectionTool *sel_tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error)
|
|
|
|
{
|
2020-05-18 05:00:07 +08:00
|
|
|
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (sel_tool);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
2018-09-02 20:47:21 +08:00
|
|
|
|
|
|
|
switch (sel_tool->function)
|
|
|
|
{
|
|
|
|
case SELECTION_SELECT:
|
|
|
|
switch (options->operation)
|
|
|
|
{
|
|
|
|
case GIMP_CHANNEL_OP_ADD:
|
|
|
|
case GIMP_CHANNEL_OP_REPLACE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_CHANNEL_OP_SUBTRACT:
|
|
|
|
if (! gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
|
|
|
|
NULL, NULL, NULL, NULL))
|
|
|
|
{
|
|
|
|
g_set_error (error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
_("Cannot subtract from an empty selection."));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_CHANNEL_OP_INTERSECT:
|
|
|
|
if (! gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
|
|
|
|
NULL, NULL, NULL, NULL))
|
|
|
|
{
|
|
|
|
g_set_error (error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
_("Cannot intersect with an empty selection."));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SELECTION_MOVE:
|
|
|
|
case SELECTION_MOVE_COPY:
|
|
|
|
{
|
2022-02-15 22:42:44 +08:00
|
|
|
GList *drawables = gimp_image_get_selected_drawables (image);
|
|
|
|
GimpItem *locked_item = NULL;
|
|
|
|
GList *iter;
|
2018-09-02 20:47:21 +08:00
|
|
|
|
2020-05-18 05:00:07 +08:00
|
|
|
for (iter = drawables; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
if (gimp_viewable_get_children (iter->data))
|
|
|
|
{
|
|
|
|
g_set_error (error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
_("Cannot modify the pixels of layer groups."));
|
|
|
|
|
|
|
|
g_list_free (drawables);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2022-02-15 22:42:44 +08:00
|
|
|
else if (gimp_item_is_content_locked (iter->data, &locked_item))
|
2020-05-18 05:00:07 +08:00
|
|
|
{
|
|
|
|
g_set_error (error, GIMP_ERROR, GIMP_FAILED,
|
2022-02-15 22:42:44 +08:00
|
|
|
_("A selected item's pixels are locked."));
|
2020-05-18 05:00:07 +08:00
|
|
|
|
|
|
|
if (error)
|
2022-02-15 22:42:44 +08:00
|
|
|
gimp_tools_blink_lock_box (display->gimp, locked_item);
|
2018-09-02 20:47:21 +08:00
|
|
|
|
2020-05-18 05:00:07 +08:00
|
|
|
g_list_free (drawables);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2018-12-10 21:22:50 +08:00
|
|
|
|
2020-05-18 05:00:07 +08:00
|
|
|
g_list_free (drawables);
|
2018-09-02 20:47:21 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-02-03 18:14:08 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_selection_tool_have_selection (GimpSelectionTool *sel_tool,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
return GIMP_SELECTION_TOOL_GET_CLASS (sel_tool)->have_selection (sel_tool,
|
|
|
|
display);
|
|
|
|
}
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_selection_tool_start_edit (GimpSelectionTool *sel_tool,
|
2011-06-03 15:46:10 +08:00
|
|
|
GimpDisplay *display,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords)
|
2004-07-26 22:50:51 +08:00
|
|
|
{
|
2018-12-10 20:42:52 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpSelectionOptions *options;
|
|
|
|
GError *error = NULL;
|
2004-07-26 22:50:51 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_SELECTION_TOOL (sel_tool), FALSE);
|
2011-06-03 15:46:10 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), FALSE);
|
2004-07-26 22:50:51 +08:00
|
|
|
g_return_val_if_fail (coords != NULL, FALSE);
|
|
|
|
|
2018-12-10 20:42:52 +08:00
|
|
|
tool = GIMP_TOOL (sel_tool);
|
|
|
|
options = GIMP_SELECTION_TOOL_GET_OPTIONS (sel_tool);
|
2004-07-26 22:50:51 +08:00
|
|
|
|
2011-06-03 15:46:10 +08:00
|
|
|
g_return_val_if_fail (gimp_tool_control_is_active (tool->control) == FALSE,
|
|
|
|
FALSE);
|
2004-07-26 22:50:51 +08:00
|
|
|
|
2018-09-02 20:47:21 +08:00
|
|
|
if (! gimp_selection_tool_check (sel_tool, display, &error))
|
|
|
|
{
|
|
|
|
gimp_tool_message_literal (tool, display, error->message);
|
|
|
|
|
2022-07-27 16:09:43 +08:00
|
|
|
gimp_tools_show_tool_options (display->gimp);
|
2018-12-10 20:42:52 +08:00
|
|
|
gimp_widget_blink (options->mode_box);
|
|
|
|
|
2018-09-02 20:47:21 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
switch (sel_tool->function)
|
2004-07-26 22:50:51 +08:00
|
|
|
{
|
|
|
|
case SELECTION_MOVE_MASK:
|
2011-06-03 15:46:10 +08:00
|
|
|
gimp_edit_selection_tool_start (tool, display, coords,
|
2004-10-07 05:04:13 +08:00
|
|
|
GIMP_TRANSLATE_MODE_MASK, FALSE);
|
2004-07-26 22:50:51 +08:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case SELECTION_MOVE:
|
|
|
|
case SELECTION_MOVE_COPY:
|
2012-12-15 06:02:56 +08:00
|
|
|
{
|
2018-09-02 20:47:21 +08:00
|
|
|
GimpTranslateMode edit_mode;
|
2012-12-15 06:02:56 +08:00
|
|
|
|
2019-06-17 02:23:10 +08:00
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
|
|
|
|
|
2018-09-02 20:47:21 +08:00
|
|
|
if (sel_tool->function == SELECTION_MOVE)
|
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_MASK_TO_LAYER;
|
|
|
|
else
|
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_MASK_COPY_TO_LAYER;
|
2012-12-15 06:02:56 +08:00
|
|
|
|
2018-09-02 20:47:21 +08:00
|
|
|
gimp_edit_selection_tool_start (tool, display, coords,
|
|
|
|
edit_mode, FALSE);
|
2012-12-15 06:02:56 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-07-26 22:50:51 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-04-25 16:05:12 +08:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_selection_tool_idle (GimpSelectionTool *sel_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (sel_tool);
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
|
|
|
|
|
|
|
gimp_display_shell_set_show_selection (shell, FALSE);
|
|
|
|
|
|
|
|
sel_tool->idle_id = 0;
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_selection_tool_start_change (GimpSelectionTool *sel_tool,
|
|
|
|
gboolean create,
|
|
|
|
GimpChannelOps operation)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
GimpImage *image;
|
|
|
|
GimpUndoStack *undo_stack;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_SELECTION_TOOL (sel_tool));
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (sel_tool);
|
|
|
|
|
|
|
|
g_return_if_fail (tool->display != NULL);
|
|
|
|
|
|
|
|
if (sel_tool->change_count++ > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shell = gimp_display_get_shell (tool->display);
|
|
|
|
image = gimp_display_get_image (tool->display);
|
|
|
|
undo_stack = gimp_image_get_undo_stack (image);
|
|
|
|
|
|
|
|
sel_tool->saved_show_selection =
|
|
|
|
gimp_display_shell_get_show_selection (shell);
|
|
|
|
|
|
|
|
if (create)
|
|
|
|
{
|
2023-05-23 00:13:44 +08:00
|
|
|
g_clear_weak_pointer (&sel_tool->undo);
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpUndoStack *redo_stack = gimp_image_get_redo_stack (image);
|
|
|
|
GimpUndo *undo;
|
|
|
|
|
|
|
|
undo = gimp_undo_stack_peek (undo_stack);
|
|
|
|
|
|
|
|
if (undo && undo == sel_tool->undo)
|
|
|
|
{
|
|
|
|
/* prevent this change from halting the tool */
|
|
|
|
gimp_tool_control_push_preserve (tool->control, TRUE);
|
|
|
|
|
|
|
|
gimp_image_undo (image);
|
|
|
|
|
|
|
|
gimp_tool_control_pop_preserve (tool->control);
|
|
|
|
|
2023-05-23 00:13:44 +08:00
|
|
|
g_clear_weak_pointer (&sel_tool->undo);
|
2019-04-25 16:05:12 +08:00
|
|
|
|
|
|
|
/* we will need to redo if the user cancels or executes */
|
2023-05-23 00:13:44 +08:00
|
|
|
g_set_weak_pointer (&sel_tool->redo,
|
|
|
|
gimp_undo_stack_peek (redo_stack));
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if the operation is "Replace", turn off the marching ants,
|
|
|
|
* because they are confusing ...
|
|
|
|
*/
|
|
|
|
if (operation == GIMP_CHANNEL_OP_REPLACE)
|
|
|
|
{
|
|
|
|
/* ... however, do this in an idle function, to avoid unnecessarily
|
|
|
|
* restarting the selection if we don't visit the main loop between
|
|
|
|
* the start_change() and end_change() calls.
|
|
|
|
*/
|
2019-04-25 21:51:38 +08:00
|
|
|
sel_tool->idle_id = g_idle_add_full (
|
|
|
|
G_PRIORITY_HIGH_IDLE,
|
2019-04-25 16:05:12 +08:00
|
|
|
(GSourceFunc) gimp_selection_tool_idle,
|
2019-04-25 21:51:38 +08:00
|
|
|
sel_tool, NULL);
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-23 00:13:44 +08:00
|
|
|
g_set_weak_pointer (&sel_tool->undo,
|
|
|
|
gimp_undo_stack_peek (undo_stack));
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_selection_tool_end_change (GimpSelectionTool *sel_tool,
|
|
|
|
gboolean cancel)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
GimpImage *image;
|
|
|
|
GimpUndoStack *undo_stack;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_SELECTION_TOOL (sel_tool));
|
|
|
|
g_return_if_fail (sel_tool->change_count > 0);
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (sel_tool);
|
|
|
|
|
|
|
|
g_return_if_fail (tool->display != NULL);
|
|
|
|
|
|
|
|
if (--sel_tool->change_count > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shell = gimp_display_get_shell (tool->display);
|
|
|
|
image = gimp_display_get_image (tool->display);
|
|
|
|
undo_stack = gimp_image_get_undo_stack (image);
|
|
|
|
|
|
|
|
if (cancel)
|
|
|
|
{
|
|
|
|
GimpUndoStack *redo_stack = gimp_image_get_redo_stack (image);
|
|
|
|
GimpUndo *redo = gimp_undo_stack_peek (redo_stack);
|
|
|
|
|
|
|
|
if (redo && redo == sel_tool->redo)
|
|
|
|
{
|
|
|
|
/* prevent this from halting the tool */
|
|
|
|
gimp_tool_control_push_preserve (tool->control, TRUE);
|
|
|
|
|
|
|
|
gimp_image_redo (image);
|
|
|
|
|
|
|
|
gimp_tool_control_pop_preserve (tool->control);
|
|
|
|
|
2023-05-23 00:13:44 +08:00
|
|
|
g_set_weak_pointer (&sel_tool->undo,
|
|
|
|
gimp_undo_stack_peek (undo_stack));
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-05-23 00:13:44 +08:00
|
|
|
g_clear_weak_pointer (&sel_tool->undo);
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpUndo *undo = gimp_undo_stack_peek (undo_stack);
|
|
|
|
|
|
|
|
/* save the undo that we got when executing, but only if
|
|
|
|
* we actually selected something
|
|
|
|
*/
|
|
|
|
if (undo && undo != sel_tool->undo)
|
2023-05-23 00:13:44 +08:00
|
|
|
g_set_weak_pointer (&sel_tool->undo, undo);
|
2019-04-25 16:05:12 +08:00
|
|
|
else
|
2023-05-23 00:13:44 +08:00
|
|
|
g_clear_weak_pointer (&sel_tool->undo);
|
2019-04-25 16:05:12 +08:00
|
|
|
}
|
|
|
|
|
2023-05-23 00:13:44 +08:00
|
|
|
g_clear_weak_pointer (&sel_tool->redo);
|
2019-04-25 16:05:12 +08:00
|
|
|
|
|
|
|
if (sel_tool->idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (sel_tool->idle_id);
|
|
|
|
sel_tool->idle_id = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_display_shell_set_show_selection (shell,
|
|
|
|
sel_tool->saved_show_selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|