Commit 2bca4b25 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

Bug 777911 - Cage Transform edits locked, invisible and group layers

Fix cage transform to refuse to work on locked, invisible and group
layers. Add GimpTool::initialize() implementation so the generic
"drawable has changed" mechanism triggers the right response.
parent 80f528a7
......@@ -19,6 +19,8 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
......@@ -33,6 +35,7 @@
#include "operations/gimpcageconfig.h"
#include "core/gimpdrawablefilter.h"
#include "core/gimperror.h"
#include "core/gimpimage.h"
#include "core/gimpitem.h"
#include "core/gimpprogress.h"
......@@ -68,6 +71,9 @@ enum
};
static gboolean gimp_cage_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static void gimp_cage_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
......@@ -162,6 +168,7 @@ gimp_cage_tool_class_init (GimpCageToolClass *klass)
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
tool_class->initialize = gimp_cage_tool_initialize;
tool_class->control = gimp_cage_tool_control;
tool_class->button_press = gimp_cage_tool_button_press;
tool_class->button_release = gimp_cage_tool_button_release;
......@@ -195,6 +202,43 @@ gimp_cage_tool_init (GimpCageTool *self)
self->tool_state = CAGE_STATE_INIT;
}
static gboolean
gimp_cage_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (! drawable)
return FALSE;
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("Cannot modify the pixels of layer groups."));
return FALSE;
}
if (gimp_item_is_content_locked (GIMP_ITEM (drawable)))
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer's pixels are locked."));
return FALSE;
}
if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer is not visible."));
return FALSE;
}
gimp_cage_tool_start (GIMP_CAGE_TOOL (tool), display);
return TRUE;
}
static void
gimp_cage_tool_control (GimpTool *tool,
GimpToolAction action,
......@@ -233,14 +277,6 @@ gimp_cage_tool_button_press (GimpTool *tool,
gint handle = -1;
gint edge = -1;
if (display != tool->display)
{
if (tool->display)
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, tool->display);
gimp_cage_tool_start (ct, display);
}
gimp_tool_control_activate (tool->control);
if (ct->config)
......@@ -644,6 +680,18 @@ gimp_cage_tool_cursor_update (GimpTool *tool,
modifier = GIMP_CURSOR_MODIFIER_BAD;
}
}
else
{
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
gimp_item_is_content_locked (GIMP_ITEM (drawable)) ||
! gimp_item_is_visible (GIMP_ITEM (drawable)))
{
modifier = GIMP_CURSOR_MODIFIER_BAD;
}
}
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment