Commit 13a32c91 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

applied patch from Sven Neumann which removes code that prevents layers

2004-12-06  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimptransformtool.c: applied patch from Sven Neumann
	which removes code that prevents layers with mask from being
	transformed.

	* app/tools/gimptransformtool.[ch]: added "gboolean mask_empty"
	parameter to GimpTransformTool::transform(). Needed because the
	selection gets cleared by cutting from the drawable and we need
	the selection's state before that cutting.

	(gimp_transform_tool_doit): pass "mask_empty" to
	GimpTransformTool::transform():

	* app/tools/gimptransformtool.c (gimp_transform_tool_real_transform)
	* app/tools/gimpfliptool.c (gimp_flip_tool_transform): when
	transforming a layer with mask and there is no selection,
	transform the mask just as if it was a linked item.
	Fixes bug #143837 and bug #159697.
parent ecf17031
2004-12-06 Michael Natterer <mitch@gimp.org>
* app/tools/gimptransformtool.c: applied patch from Sven Neumann
which removes code that prevents layers with mask from being
transformed.
* app/tools/gimptransformtool.[ch]: added "gboolean mask_empty"
parameter to GimpTransformTool::transform(). Needed because the
selection gets cleared by cutting from the drawable and we need
the selection's state before that cutting.
(gimp_transform_tool_doit): pass "mask_empty" to
GimpTransformTool::transform():
* app/tools/gimptransformtool.c (gimp_transform_tool_real_transform)
* app/tools/gimpfliptool.c (gimp_flip_tool_transform): when
transforming a layer with mask and there is no selection,
transform the mask just as if it was a linked item.
Fixes bug #143837 and bug #159697.
2004-12-05 Sven Neumann <sven@gimp.org>
 
* app/core/gimp-transform-utils.c (gimp_transform_matrix_flip_free):
......
......@@ -18,10 +18,7 @@
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpwidgets/gimpwidgets.h"
......@@ -29,14 +26,14 @@
#include "base/tile-manager.h"
#include "core/gimpchannel.h"
#include "core/gimpdrawable-transform.h"
#include "core/gimpimage.h"
#include "core/gimpitem-linked.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
......@@ -55,16 +52,17 @@ static void gimp_flip_tool_init (GimpFlipTool *flip_tool)
static void gimp_flip_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp);
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_flip_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
GdkModifierType state,
GimpDisplay *gdisp);
static TileManager * gimp_flip_tool_transform (GimpTransformTool *tool,
GimpItem *item,
GimpDisplay *gdisp);
gboolean mask_empty,
GimpDisplay *gdisp);
static GimpTransformToolClass *parent_class = NULL;
......@@ -99,18 +97,18 @@ gimp_flip_tool_get_type (void)
static const GTypeInfo tool_info =
{
sizeof (GimpFlipToolClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_flip_tool_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpFlipTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_flip_tool_init,
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_flip_tool_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpFlipTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_flip_tool_init,
};
tool_type = g_type_register_static (GIMP_TYPE_TRANSFORM_TOOL,
"GimpFlipTool",
"GimpFlipTool",
&tool_info, 0);
}
......@@ -123,11 +121,8 @@ gimp_flip_tool_get_type (void)
static void
gimp_flip_tool_class_init (GimpFlipToolClass *klass)
{
GimpToolClass *tool_class;
GimpTransformToolClass *trans_class;
tool_class = GIMP_TOOL_CLASS (klass);
trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -140,11 +135,8 @@ gimp_flip_tool_class_init (GimpFlipToolClass *klass)
static void
gimp_flip_tool_init (GimpFlipTool *flip_tool)
{
GimpTool *tool;
GimpTransformTool *transform_tool;
tool = GIMP_TOOL (flip_tool);
transform_tool = GIMP_TRANSFORM_TOOL (flip_tool);
GimpTool *tool = GIMP_TOOL (flip_tool);
GimpTransformTool *transform_tool = GIMP_TRANSFORM_TOOL (flip_tool);
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_cursor (tool->control,
......@@ -163,12 +155,10 @@ static void
gimp_flip_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp)
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpFlipOptions *options;
options = GIMP_FLIP_OPTIONS (tool->tool_info->tool_options);
GimpFlipOptions *options = GIMP_FLIP_OPTIONS (tool->tool_info->tool_options);
if (key == GDK_CONTROL_MASK)
{
......@@ -188,15 +178,15 @@ gimp_flip_tool_modifier_key (GimpTool *tool,
default:
break;
}
}
}
}
static void
gimp_flip_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp)
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpFlipOptions *options;
gboolean bad_cursor = TRUE;
......@@ -235,7 +225,8 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
static TileManager *
gimp_flip_tool_transform (GimpTransformTool *trans_tool,
GimpItem *active_item,
GimpDisplay *gdisp)
gboolean mask_empty,
GimpDisplay *gdisp)
{
GimpTransformOptions *tr_options;
GimpFlipOptions *options;
......@@ -267,6 +258,16 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
gimp_item_linked_flip (active_item, context, options->flip_type, axis,
FALSE);
if (GIMP_IS_LAYER (active_item) &&
gimp_layer_get_mask (GIMP_LAYER (active_item)) &&
mask_empty)
{
GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (active_item));
gimp_item_flip (GIMP_ITEM (mask), context,
options->flip_type, axis, FALSE);
}
switch (tr_options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
......
......@@ -39,6 +39,7 @@
#include "core/gimpimage-undo-push.h"
#include "core/gimpitem-linked.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimpprogress.h"
#include "core/gimptoolinfo.h"
......@@ -122,6 +123,7 @@ static void gimp_transform_tool_draw (GimpDrawTool *draw_tool
static TileManager *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *item,
gboolean mask_empty,
GimpDisplay *gdisp);
static void gimp_transform_tool_halt (GimpTransformTool *tr_tool);
......@@ -348,20 +350,11 @@ gimp_transform_tool_initialize (GimpTool *tool,
if (gdisp != tool->gdisp)
{
GimpDrawable *drawable = gimp_image_active_drawable (gdisp->gimage);
gint i;
if (GIMP_IS_LAYER (drawable) &&
gimp_layer_get_mask (GIMP_LAYER (drawable)))
{
g_message (_("Transformations do not work on "
"layers that contain layer masks."));
return FALSE;
}
gint i;
/* Set the pointer to the active display */
tool->gdisp = gdisp;
tool->drawable = drawable;
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
/* Initialize the transform tool dialog */
if (! tr_tool->info_dialog)
......@@ -662,27 +655,14 @@ gimp_transform_tool_cursor_update (GimpTool *tool,
switch (options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
{
GimpDrawable *drawable = gimp_image_active_drawable (gdisp->gimage);
if (drawable)
{
if (GIMP_IS_LAYER (drawable) &&
gimp_layer_get_mask (GIMP_LAYER (drawable)))
{
cursor = GIMP_CURSOR_BAD;
}
else if (gimp_image_coords_in_active_drawable (gdisp->gimage,
coords))
{
if (gimp_channel_is_empty (selection) ||
gimp_channel_value (selection, coords->x, coords->y))
{
cursor = GIMP_CURSOR_MOUSE;
}
}
}
}
if (gimp_image_coords_in_active_drawable (gdisp->gimage, coords))
{
if (gimp_channel_is_empty (selection) ||
gimp_channel_value (selection, coords->x, coords->y))
{
cursor = GIMP_CURSOR_MOUSE;
}
}
break;
case GIMP_TRANSFORM_TYPE_SELECTION:
......@@ -866,6 +846,7 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
static TileManager *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *active_item,
gboolean mask_empty,
GimpDisplay *gdisp)
{
GimpTool *tool = GIMP_TOOL (tr_tool);
......@@ -893,6 +874,22 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
options->clip,
progress);
if (GIMP_IS_LAYER (active_item) &&
gimp_layer_get_mask (GIMP_LAYER (active_item)) &&
mask_empty)
{
GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (active_item));
gimp_item_transform (GIMP_ITEM (mask), context,
&tr_tool->transform,
options->direction,
options->interpolation,
options->supersample,
options->recursion_level,
options->clip,
progress);
}
switch (options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
......@@ -940,8 +937,8 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
}
static void
gimp_transform_tool_doit (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
gimp_transform_tool_doit (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
GimpTool *tool = GIMP_TOOL (tr_tool);
GimpTransformOptions *options;
......@@ -949,6 +946,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
GimpItem *active_item = NULL;
TileManager *new_tiles;
gboolean new_layer;
gboolean mask_empty;
options = GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options);
context = GIMP_CONTEXT (options);
......@@ -971,6 +969,8 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
if (! active_item)
return;
mask_empty = gimp_channel_is_empty (gimp_image_get_mask (gdisp->gimage));
if (gimp_display_shell_get_show_transform (GIMP_DISPLAY_SHELL (gdisp->shell)))
{
gimp_display_shell_set_show_transform (GIMP_DISPLAY_SHELL (gdisp->shell),
......@@ -1025,6 +1025,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
*/
new_tiles = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->transform (tr_tool,
active_item,
mask_empty,
gdisp);
gimp_transform_tool_prepare (tr_tool, gdisp);
......@@ -1039,7 +1040,6 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
/* paste the new transformed image to the gimage...also implement
* undo...
*/
/* FIXME: we should check if the drawable is still valid */
gimp_drawable_transform_paste (tool->drawable,
new_tiles,
new_layer);
......@@ -1050,11 +1050,10 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
case GIMP_TRANSFORM_TYPE_SELECTION:
if (new_tiles)
{
GimpDrawable *drawable = GIMP_DRAWABLE (active_item);
gimp_channel_push_undo (gimp_image_get_mask (gdisp->gimage), NULL);
gimp_channel_push_undo (GIMP_CHANNEL (active_item), NULL);
gimp_drawable_set_tiles (drawable, FALSE, NULL, new_tiles);
gimp_drawable_set_tiles (GIMP_DRAWABLE (active_item),
FALSE, NULL, new_tiles);
tile_manager_unref (new_tiles);
}
......
......@@ -114,6 +114,7 @@ struct _GimpTransformToolClass
GimpDisplay *gdisp);
TileManager * (* transform) (GimpTransformTool *tool,
GimpItem *item,
gboolean mask_empty,
GimpDisplay *gdisp);
};
......
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