[gimp] Bug 795288 - Layer is moved by arrow keys even after all locks...
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 795288 - Layer is moved by arrow keys even after all locks...
- Date: Wed, 18 Apr 2018 18:45:10 +0000 (UTC)
commit ce8c4cb2a0a9ed6ffbe640fdda421700d1383225
Author: Michael Natterer <mitch gimp org>
Date: Wed Apr 18 20:41:54 2018 +0200
Bug 795288 - Layer is moved by arrow keys even after all locks...
...(Pixel, Position and Size, Alpha Channel) are enabled.
gimp_edit_selection_tool_translate(): add checks for locks and bail
out with a message if the item is NULL or locked.
gimp_move_tool_button_press(): refactor NULL and lock checks to look
more like the new code added above, and also check "lock-content" of
channels and masks: moving them changes their pixels.
app/tools/gimpeditselectiontool.c | 104 ++++++++++++++++++++++++------
app/tools/gimpmovetool.c | 129 ++++++++++++++++++-------------------
2 files changed, 147 insertions(+), 86 deletions(-)
---
diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c
index 115269c..dfc8d4e 100644
--- a/app/tools/gimpeditselectiontool.c
+++ b/app/tools/gimpeditselectiontool.c
@@ -1016,16 +1016,18 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
GimpTransformType translate_type,
GimpDisplay *display)
{
- gint inc_x = 0;
- gint inc_y = 0;
+ gint inc_x = 0;
+ gint inc_y = 0;
GimpUndo *undo;
- gboolean push_undo = TRUE;
- GimpImage *image = gimp_display_get_image (display);
- GimpItem *item = NULL;
- GimpTranslateMode edit_mode = GIMP_TRANSLATE_MODE_MASK;
- GimpUndoType undo_type = GIMP_UNDO_GROUP_MASK;
- const gchar *undo_desc = NULL;
- GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
+ gboolean push_undo = TRUE;
+ GimpImage *image = gimp_display_get_image (display);
+ GimpItem *item = NULL;
+ GimpTranslateMode edit_mode = GIMP_TRANSLATE_MODE_MASK;
+ GimpUndoType undo_type = GIMP_UNDO_GROUP_MASK;
+ const gchar *undo_desc = NULL;
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
+ const gchar *null_message = NULL;
+ const gchar *locked_message = NULL;
gint velocity;
/* bail out early if it is not an arrow key event */
@@ -1092,6 +1094,21 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
edit_mode = GIMP_TRANSLATE_MODE_MASK;
undo_type = GIMP_UNDO_GROUP_MASK;
+
+ if (! item)
+ {
+ /* cannot happen, don't translate this message */
+ null_message = "There is no selection to move.";
+ }
+ else if (gimp_item_is_position_locked (item))
+ {
+ /* cannot happen, don't translate this message */
+ locked_message = "The selection's position is locked.";
+ }
+ else if (gimp_channel_is_empty (GIMP_CHANNEL (item)))
+ {
+ locked_message = _("The selection is empty.");
+ }
break;
case GIMP_TRANSFORM_TYPE_PATH:
@@ -1099,38 +1116,85 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
edit_mode = GIMP_TRANSLATE_MODE_VECTORS;
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
+
+ if (! item)
+ {
+ null_message = _("There is no path to move.");
+ }
+ else if (gimp_item_is_position_locked (item))
+ {
+ locked_message = _("The active path's position is locked.");
+ }
break;
case GIMP_TRANSFORM_TYPE_LAYER:
item = GIMP_ITEM (gimp_image_get_active_drawable (image));
- if (item)
+ undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
+
+ if (! item)
+ {
+ null_message = _("There is no layer to move.");
+ }
+ else if (GIMP_IS_LAYER_MASK (item))
{
- if (GIMP_IS_LAYER_MASK (item))
+ edit_mode = GIMP_TRANSLATE_MODE_LAYER_MASK;
+
+ if (gimp_item_is_position_locked (item))
{
- edit_mode = GIMP_TRANSLATE_MODE_LAYER_MASK;
+ locked_message = _("The active layer's position is locked.");
}
- else if (GIMP_IS_CHANNEL (item))
+ else if (gimp_item_is_content_locked (item))
{
- edit_mode = GIMP_TRANSLATE_MODE_CHANNEL;
+ locked_message = _("The active layer's pixels are locked.");
}
- else if (gimp_layer_is_floating_sel (GIMP_LAYER (item)))
+ }
+ else if (GIMP_IS_CHANNEL (item))
+ {
+ edit_mode = GIMP_TRANSLATE_MODE_CHANNEL;
+
+ if (gimp_item_is_position_locked (item))
{
- edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
+ locked_message = _("The active channel's position is locked.");
}
- else
+ else if (gimp_item_is_content_locked (item))
{
- edit_mode = GIMP_TRANSLATE_MODE_LAYER;
+ locked_message = _("The active channel's pixels are locked.");
}
+ }
+ else if (gimp_layer_is_floating_sel (GIMP_LAYER (item)))
+ {
+ edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
- undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
+ if (gimp_item_is_position_locked (item))
+ {
+ locked_message = _("The active layer's position is locked.");
+ }
}
+ else
+ {
+ edit_mode = GIMP_TRANSLATE_MODE_LAYER;
+
+ if (gimp_item_is_position_locked (item))
+ {
+ locked_message = _("The active layer's position is locked.");
+ }
+ }
+
break;
}
}
if (! item)
- return TRUE;
+ {
+ gimp_tool_message_literal (tool, display, null_message);
+ return TRUE;
+ }
+ else if (locked_message)
+ {
+ gimp_tool_message_literal (tool, display, locked_message);
+ return TRUE;
+ }
switch (edit_mode)
{
diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c
index 0868067..b5524eb 100644
--- a/app/tools/gimpmovetool.c
+++ b/app/tools/gimpmovetool.c
@@ -160,13 +160,14 @@ gimp_move_tool_button_press (GimpTool *tool,
GimpButtonPressType press_type,
GimpDisplay *display)
{
- GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
- GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
- GimpDisplayShell *shell = gimp_display_get_shell (display);
- GimpImage *image = gimp_display_get_image (display);
- GimpItem *active_item = NULL;
- const gchar *null_message = NULL;
- const gchar *locked_message = NULL;
+ GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
+ GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
+ GimpDisplayShell *shell = gimp_display_get_shell (display);
+ GimpImage *image = gimp_display_get_image (display);
+ GimpItem *active_item = NULL;
+ GimpTranslateMode translate_mode = GIMP_TRANSLATE_MODE_MASK;
+ const gchar *null_message = NULL;
+ const gchar *locked_message = NULL;
tool->display = display;
@@ -252,87 +253,75 @@ gimp_move_tool_button_press (GimpTool *tool,
{
case GIMP_TRANSFORM_TYPE_PATH:
{
- active_item = GIMP_ITEM (gimp_image_get_active_vectors (image));
- null_message = _("There is no path to move.");
- locked_message = _("The active path's position is locked.");
+ active_item = GIMP_ITEM (gimp_image_get_active_vectors (image));
- if (active_item && ! gimp_item_is_position_locked (active_item))
+ translate_mode = GIMP_TRANSLATE_MODE_VECTORS;
+
+ if (! active_item)
+ {
+ null_message = _("There is no path to move.");
+ }
+ else if (gimp_item_is_position_locked (active_item))
{
- gimp_tool_control_activate (tool->control);
- gimp_edit_selection_tool_start (tool, display, coords,
- GIMP_TRANSLATE_MODE_VECTORS,
- TRUE);
- return;
+ locked_message = _("The active path's position is locked.");
}
}
break;
case GIMP_TRANSFORM_TYPE_SELECTION:
{
- active_item = GIMP_ITEM (gimp_image_get_mask (image));
- /* cannot happen, so don't translate these messages */
- null_message = "There is no selection to move.";
- locked_message = "The selection's position is locked.";
+ active_item = GIMP_ITEM (gimp_image_get_mask (image));
+
+ translate_mode = GIMP_TRANSLATE_MODE_MASK;
- if (active_item && ! gimp_item_is_position_locked (active_item))
+ if (! active_item)
+ {
+ /* cannot happen, don't translate this message */
+ null_message = "There is no selection to move.";
+ }
+ else if (gimp_item_is_position_locked (active_item))
+ {
+ locked_message = "The selection's position is locked.";
+ }
+ else if (gimp_channel_is_empty (GIMP_CHANNEL (active_item)))
{
- if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
- {
- gimp_tool_control_activate (tool->control);
- gimp_edit_selection_tool_start (tool, display, coords,
- GIMP_TRANSLATE_MODE_MASK,
- TRUE);
- return;
- }
- else
- locked_message = _("The selection is empty.");
+ locked_message = _("The selection is empty.");
}
}
break;
case GIMP_TRANSFORM_TYPE_LAYER:
{
- active_item = GIMP_ITEM (gimp_image_get_active_drawable (image));
- null_message = _("There is no layer to move.");
+ active_item = GIMP_ITEM (gimp_image_get_active_drawable (image));
- if (GIMP_IS_LAYER_MASK (active_item))
+ if (! active_item)
{
- locked_message = _("The active layer's position is locked.");
-
- if (! gimp_item_is_position_locked (active_item))
- {
- gimp_tool_control_activate (tool->control);
- gimp_edit_selection_tool_start (tool, display, coords,
- GIMP_TRANSLATE_MODE_LAYER_MASK,
- TRUE);
- return;
- }
+ null_message = _("There is no layer to move.");
+ }
+ else if (GIMP_IS_LAYER_MASK (active_item))
+ {
+ translate_mode = GIMP_TRANSLATE_MODE_LAYER_MASK;
+
+ if (gimp_item_is_position_locked (active_item))
+ locked_message = _("The active layer's position is locked.");
+ else if (gimp_item_is_content_locked (active_item))
+ locked_message = _("The active layer's pixels are locked.");
}
else if (GIMP_IS_CHANNEL (active_item))
{
- locked_message = _("The active channel's position is locked.");
-
- if (! gimp_item_is_position_locked (active_item))
- {
- gimp_tool_control_activate (tool->control);
- gimp_edit_selection_tool_start (tool, display, coords,
- GIMP_TRANSLATE_MODE_CHANNEL,
- TRUE);
- return;
- }
+ translate_mode = GIMP_TRANSLATE_MODE_CHANNEL;
+
+ if (gimp_item_is_position_locked (active_item))
+ locked_message = _("The active channel's position is locked.");
+ else if (gimp_item_is_content_locked (active_item))
+ locked_message = _("The active channel's pixels are locked.");
}
- else if (GIMP_IS_LAYER (active_item))
+ else
{
- locked_message = _("The active layer's position is locked.");
-
- if (! gimp_item_is_position_locked (active_item))
- {
- gimp_tool_control_activate (tool->control);
- gimp_edit_selection_tool_start (tool, display, coords,
- GIMP_TRANSLATE_MODE_LAYER,
- TRUE);
- return;
- }
+ translate_mode = GIMP_TRANSLATE_MODE_LAYER;
+
+ if (gimp_item_is_position_locked (active_item))
+ locked_message = _("The active layer's position is locked.");
}
}
break;
@@ -342,12 +331,20 @@ gimp_move_tool_button_press (GimpTool *tool,
{
gimp_tool_message_literal (tool, display, null_message);
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
+ return;
}
- else
+ else if (locked_message)
{
gimp_tool_message_literal (tool, display, locked_message);
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
+ return;
}
+
+ gimp_tool_control_activate (tool->control);
+
+ gimp_edit_selection_tool_start (tool, display, coords,
+ translate_mode,
+ TRUE);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]