Commit c179f9ac authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added new virtual function GimpDrawable::set_tiles().

2004-03-13  Sven Neumann  <sven@gimp.org>

	* app/core/gimpdrawable.[ch]: added new virtual function
	GimpDrawable::set_tiles().

	* app/core/gimpchannel.c
	* app/core/gimplayer.c: push an undo before chaining up in
	set_tiles().

	* app/core/gimpdrawable-transform.c
	* app/core/gimpimage-convert.c
	* app/tools/gimptransformtool.c: use gimp_drawable_set_tiles()
	instead of fiddling with the drawable's tile manager directly.
parent beaed82c
2004-03-13 Sven Neumann <sven@gimp.org>
* app/core/gimpdrawable.[ch]: added new virtual function
GimpDrawable::set_tiles().
* app/core/gimpchannel.c
* app/core/gimplayer.c: push an undo before chaining up in
set_tiles().
* app/core/gimpdrawable-transform.c
* app/core/gimpimage-convert.c
* app/tools/gimptransformtool.c: use gimp_drawable_set_tiles()
instead of fiddling with the drawable's tile manager directly.
2004-03-13 Sven Neumann <sven@gimp.org>
* app/tools/gimptransformoptions.c (gimp_transform_options_gui): for
......@@ -1033,8 +1033,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gboolean new_layer)
{
GimpImage *gimage;
GimpLayer *layer = NULL;
GimpChannel *channel = NULL;
GimpLayer *layer = NULL;
GimpLayer *floating_layer;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
......@@ -1073,12 +1072,21 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
}
else
{
const gchar *undo_desc;
if (GIMP_IS_LAYER (drawable))
layer = GIMP_LAYER (drawable);
{
layer = GIMP_LAYER (drawable);
undo_desc = _("Transform Layer");
}
else if (GIMP_IS_CHANNEL (drawable))
channel = GIMP_CHANNEL (drawable);
{
undo_desc = _("Transform Channel");
}
else
return FALSE;
{
return FALSE;
}
gimp_drawable_invalidate_boundary (drawable);
......@@ -1099,27 +1107,16 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
GIMP_ITEM (drawable)->width,
GIMP_ITEM (drawable)->height);
/* Push an undo */
if (layer)
gimp_image_undo_push_layer_mod (gimage, _("Transform Layer"),
layer);
else if (channel)
gimp_image_undo_push_channel_mod (gimage, _("Transform Channel"),
channel);
gimp_drawable_set_tiles (drawable,
TRUE, undo_desc,
tiles, drawable->type);
/* set the current layer's data */
tile_manager_unref (drawable->tiles);
drawable->tiles = tile_manager_ref (tiles);
/* Fill in the new layer's attributes */
GIMP_ITEM (drawable)->width = tile_manager_width (tiles);
GIMP_ITEM (drawable)->height = tile_manager_height (tiles);
tile_manager_get_offsets (tiles,
&GIMP_ITEM (drawable)->offset_x,
&GIMP_ITEM (drawable)->offset_y);
drawable->bytes = tile_manager_bpp (tiles);
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);
......
......@@ -110,7 +110,7 @@ static void gimp_channel_invalidate_boundary (GimpDrawable *drawable);
static void gimp_channel_get_active_components (const GimpDrawable *drawable,
gboolean *active);
static void gimp_channel_apply_region (GimpDrawable *drawable,
static void gimp_channel_apply_region (GimpDrawable *drawable,
PixelRegion *src2PR,
gboolean push_undo,
const gchar *undo_desc,
......@@ -127,6 +127,11 @@ static void gimp_channel_replace_region (GimpDrawable *drawable,
PixelRegion *maskPR,
gint x,
gint y);
static void gimp_channel_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
static gboolean gimp_channel_real_boundary (GimpChannel *channel,
const BoundSeg **segs_in,
......@@ -247,6 +252,7 @@ gimp_channel_class_init (GimpChannelClass *klass)
drawable_class->get_active_components = gimp_channel_get_active_components;
drawable_class->apply_region = gimp_channel_apply_region;
drawable_class->replace_region = gimp_channel_replace_region;
drawable_class->set_tiles = gimp_channel_set_tiles;
klass->boundary = gimp_channel_real_boundary;
klass->bounds = gimp_channel_real_bounds;
......@@ -744,6 +750,23 @@ gimp_channel_replace_region (GimpDrawable *drawable,
GIMP_CHANNEL (drawable)->bounds_known = FALSE;
}
static void
gimp_channel_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
{
if (push_undo)
gimp_image_undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (drawable)),
undo_desc,
GIMP_CHANNEL (drawable));
GIMP_DRAWABLE_CLASS (parent_class)->set_tiles (drawable,
push_undo, undo_desc,
tiles, type);
}
static gboolean
gimp_channel_real_boundary (GimpChannel *channel,
const BoundSeg **segs_in,
......
......@@ -1033,8 +1033,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gboolean new_layer)
{
GimpImage *gimage;
GimpLayer *layer = NULL;
GimpChannel *channel = NULL;
GimpLayer *layer = NULL;
GimpLayer *floating_layer;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
......@@ -1073,12 +1072,21 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
}
else
{
const gchar *undo_desc;
if (GIMP_IS_LAYER (drawable))
layer = GIMP_LAYER (drawable);
{
layer = GIMP_LAYER (drawable);
undo_desc = _("Transform Layer");
}
else if (GIMP_IS_CHANNEL (drawable))
channel = GIMP_CHANNEL (drawable);
{
undo_desc = _("Transform Channel");
}
else
return FALSE;
{
return FALSE;
}
gimp_drawable_invalidate_boundary (drawable);
......@@ -1099,27 +1107,16 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
GIMP_ITEM (drawable)->width,
GIMP_ITEM (drawable)->height);
/* Push an undo */
if (layer)
gimp_image_undo_push_layer_mod (gimage, _("Transform Layer"),
layer);
else if (channel)
gimp_image_undo_push_channel_mod (gimage, _("Transform Channel"),
channel);
gimp_drawable_set_tiles (drawable,
TRUE, undo_desc,
tiles, drawable->type);
/* set the current layer's data */
tile_manager_unref (drawable->tiles);
drawable->tiles = tile_manager_ref (tiles);
/* Fill in the new layer's attributes */
GIMP_ITEM (drawable)->width = tile_manager_width (tiles);
GIMP_ITEM (drawable)->height = tile_manager_height (tiles);
tile_manager_get_offsets (tiles,
&GIMP_ITEM (drawable)->offset_x,
&GIMP_ITEM (drawable)->offset_y);
drawable->bytes = tile_manager_bpp (tiles);
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);
......
......@@ -107,6 +107,12 @@ static void gimp_drawable_real_update (GimpDrawable *drawable,
gint width,
gint height);
static void gimp_drawable_real_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
/* private variables */
......@@ -200,6 +206,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
klass->get_active_components = NULL;
klass->apply_region = gimp_drawable_real_apply_region;
klass->replace_region = gimp_drawable_real_replace_region;
klass->set_tiles = gimp_drawable_real_set_tiles;
}
static void
......@@ -573,6 +580,24 @@ gimp_drawable_real_update (GimpDrawable *drawable,
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (drawable));
}
static void
gimp_drawable_real_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
{
g_return_if_fail (tile_manager_bpp (tiles) == GIMP_IMAGE_TYPE_BYTES (type));
if (drawable->tiles)
tile_manager_unref (drawable->tiles);
drawable->tiles = tile_manager_ref (tiles);
drawable->type = type;
drawable->bytes = tile_manager_bpp (tiles);
drawable->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (type);
}
void
gimp_drawable_configure (GimpDrawable *drawable,
GimpImage *gimage,
......@@ -693,6 +718,21 @@ gimp_drawable_replace_region (GimpDrawable *drawable,
x, y);
}
void
gimp_drawable_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (tiles != NULL);
GIMP_DRAWABLE_GET_CLASS (drawable)->set_tiles (drawable,
push_undo, undo_desc,
tiles, type);
}
void
gimp_drawable_push_undo (GimpDrawable *drawable,
const gchar *undo_desc,
......
......@@ -81,6 +81,11 @@ struct _GimpDrawableClass
PixelRegion *maskPR,
gint x,
gint y);
void (* set_tiles) (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
};
......@@ -124,6 +129,13 @@ void gimp_drawable_replace_region (GimpDrawable *drawable,
gint x,
gint y);
void gimp_drawable_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
void gimp_drawable_push_undo (GimpDrawable *drawable,
const gchar *undo_desc,
gint x1,
......
......@@ -941,15 +941,11 @@ gimp_image_convert (GimpImage *gimage,
break;
}
/* Push the layer onto the undo stack */
gimp_image_undo_push_layer_mod (gimage, NULL, layer);
gimp_drawable_set_tiles (GIMP_DRAWABLE (layer),
TRUE, NULL,
new_tiles, new_layer_type);
tile_manager_unref (GIMP_DRAWABLE (layer)->tiles);
GIMP_DRAWABLE (layer)->tiles = new_tiles;
GIMP_DRAWABLE (layer)->type = new_layer_type;
GIMP_DRAWABLE (layer)->bytes = GIMP_IMAGE_TYPE_BYTES (new_layer_type);
GIMP_DRAWABLE (layer)->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (new_layer_type);
tile_manager_unref (new_tiles);
}
switch (new_type)
......
......@@ -120,6 +120,11 @@ static void gimp_layer_transform (GimpItem *item,
static void gimp_layer_invalidate_boundary (GimpDrawable *drawable);
static void gimp_layer_get_active_components (const GimpDrawable *drawable,
gboolean *active);
static void gimp_layer_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
static void gimp_layer_transform_color (GimpImage *gimage,
PixelRegion *layerPR,
......@@ -246,6 +251,7 @@ gimp_layer_class_init (GimpLayerClass *klass)
drawable_class->invalidate_boundary = gimp_layer_invalidate_boundary;
drawable_class->get_active_components = gimp_layer_get_active_components;
drawable_class->set_tiles = gimp_layer_set_tiles;
klass->opacity_changed = NULL;
klass->mode_changed = NULL;
......@@ -376,6 +382,23 @@ gimp_layer_get_active_components (const GimpDrawable *drawable,
active[gimp_drawable_bytes (drawable) - 1] = FALSE;
}
static void
gimp_layer_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
{
if (push_undo)
gimp_image_undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (drawable)),
undo_desc,
GIMP_LAYER (drawable));
GIMP_DRAWABLE_CLASS (parent_class)->set_tiles (drawable,
push_undo, undo_desc,
tiles, type);
}
static void
gimp_layer_removed (GimpItem *item)
{
......
......@@ -974,10 +974,15 @@ 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);
tile_manager_unref (GIMP_DRAWABLE (active_item)->tiles);
GIMP_DRAWABLE (active_item)->tiles = new_tiles;
gimp_drawable_set_tiles (drawable,
FALSE, NULL,
new_tiles, drawable->type);
tile_manager_unref (new_tiles);
GIMP_CHANNEL (active_item)->bounds_known = FALSE;
......
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