Commit 1ef5fa93 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added "offset_x" and "offset_y" parameters to GimpDrawable::set_tiles().

2004-03-15  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpdrawable.[ch]: added "offset_x" and "offset_y"
	parameters to GimpDrawable::set_tiles().

	(gimp_drawable_set_tiles): removed the "GimpImageType" parameter.

	(gimp_drawable_set_tiles_full): new function adding type, offset_x
	and offset_y parameters.

	(gimp_drawable_real_set_tiles): set the drawable's offsets from
	the offset parameters and its size from the passed TileManager's
	size. Emit "size_changed" accordingly.

	* app/core/gimpchannel.c
	* app/core/gimpdrawable-offset.c
	* app/core/gimpdrawable-transform.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimage-undo-push.c
	* app/core/gimplayer.c
	* app/text/gimptextlayer.c
	* app/tools/gimptransformtool.c: changed accordingly: removed
	calls to gimp_viewable_size_changed() and all sorts of hackish
	assignments of the drawable's width/height/offset_x/offset_y
	properties.
parent 79776036
2004-03-15 Michael Natterer <mitch@gimp.org>
* app/core/gimpdrawable.[ch]: added "offset_x" and "offset_y"
parameters to GimpDrawable::set_tiles().
(gimp_drawable_set_tiles): removed the "GimpImageType" parameter.
(gimp_drawable_set_tiles_full): new function adding type, offset_x
and offset_y parameters.
(gimp_drawable_real_set_tiles): set the drawable's offsets from
the offset parameters and its size from the passed TileManager's
size. Emit "size_changed" accordingly.
* app/core/gimpchannel.c
* app/core/gimpdrawable-offset.c
* app/core/gimpdrawable-transform.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-undo-push.c
* app/core/gimplayer.c
* app/text/gimptextlayer.c
* app/tools/gimptransformtool.c: changed accordingly: removed
calls to gimp_viewable_size_changed() and all sorts of hackish
assignments of the drawable's width/height/offset_x/offset_y
properties.
2004-03-15 Michael Natterer <mitch@gimp.org>
* app/text/gimptextlayer.c (gimp_text_layer_render): don't call
......@@ -1071,6 +1071,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
else
{
const gchar *undo_desc;
gint offset_x, offset_y;
if (GIMP_IS_LAYER (drawable))
{
......@@ -1103,15 +1104,11 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
GIMP_ITEM (drawable)->width,
GIMP_ITEM (drawable)->height);
gimp_drawable_set_tiles (drawable,
TRUE, undo_desc,
tiles, drawable->type);
tile_manager_get_offsets (tiles, &offset_x, &offset_y);
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);
gimp_drawable_set_tiles_full (drawable, TRUE, undo_desc,
tiles, drawable->type,
offset_x, offset_y);
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);
......
......@@ -133,7 +133,9 @@ static void gimp_channel_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
GimpImageType type,
gint offset_x,
gint offset_y);
static void gimp_channel_swap_pixels (GimpDrawable *drawable,
TileManager *tiles,
gboolean sparse,
......@@ -769,7 +771,9 @@ gimp_channel_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
GimpImageType type,
gint offset_x,
gint offset_y)
{
if (push_undo)
gimp_image_undo_push_channel_mod (gimp_item_get_image (GIMP_ITEM (drawable)),
......@@ -778,7 +782,8 @@ gimp_channel_set_tiles (GimpDrawable *drawable,
GIMP_DRAWABLE_CLASS (parent_class)->set_tiles (drawable,
push_undo, undo_desc,
tiles, type);
tiles, type,
offset_x, offset_y);
GIMP_CHANNEL (drawable)->bounds_known = FALSE;
}
......
......@@ -322,8 +322,7 @@ gimp_drawable_offset (GimpDrawable *drawable,
FALSE);
/* set the tiles */
gimp_drawable_set_tiles (drawable, FALSE, NULL,
new_tiles, gimp_drawable_type (drawable));
gimp_drawable_set_tiles (drawable, FALSE, NULL, new_tiles);
tile_manager_unref (new_tiles);
/* update the drawable */
......
......@@ -1071,6 +1071,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
else
{
const gchar *undo_desc;
gint offset_x, offset_y;
if (GIMP_IS_LAYER (drawable))
{
......@@ -1103,15 +1104,11 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
GIMP_ITEM (drawable)->width,
GIMP_ITEM (drawable)->height);
gimp_drawable_set_tiles (drawable,
TRUE, undo_desc,
tiles, drawable->type);
tile_manager_get_offsets (tiles, &offset_x, &offset_y);
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);
gimp_drawable_set_tiles_full (drawable, TRUE, undo_desc,
tiles, drawable->type,
offset_x, offset_y);
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);
......
......@@ -112,7 +112,9 @@ static void gimp_drawable_real_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
GimpImageType type,
gint offset_x,
gint offset_y);
static void gimp_drawable_real_swap_pixels (GimpDrawable *drawable,
TileManager *tiles,
......@@ -382,19 +384,13 @@ gimp_drawable_scale (GimpItem *item,
GIMP_INTERPOLATION_NONE : interpolation_type,
progress_callback, progress_data);
gimp_drawable_set_tiles (drawable, FALSE, NULL,
new_tiles, gimp_drawable_type (drawable));
gimp_drawable_set_tiles_full (drawable, FALSE, NULL,
new_tiles, gimp_drawable_type (drawable),
new_offset_x, new_offset_y);
tile_manager_unref (new_tiles);
GIMP_ITEM_CLASS (parent_class)->scale (item, new_width, new_height,
new_offset_x, new_offset_y,
interpolation_type,
progress_callback, progress_data);
/* Update the new position */
gimp_drawable_update (drawable, 0, 0, item->width, item->height);
gimp_viewable_size_changed (GIMP_VIEWABLE (drawable));
}
static void
......@@ -464,17 +460,14 @@ gimp_drawable_resize (GimpItem *item,
copy_region (&srcPR, &destPR);
}
gimp_drawable_set_tiles (drawable, FALSE, NULL,
new_tiles, gimp_drawable_type (drawable));
gimp_drawable_set_tiles_full (drawable, FALSE, NULL,
new_tiles, gimp_drawable_type (drawable),
item->offset_x - offset_x,
item->offset_y - offset_y);
tile_manager_unref (new_tiles);
GIMP_ITEM_CLASS (parent_class)->resize (item, new_width, new_height,
offset_x, offset_y);
/* update the new area */
gimp_drawable_update (drawable, 0, 0, item->width, item->height);
gimp_viewable_size_changed (GIMP_VIEWABLE (drawable));
}
static void
......@@ -598,12 +591,17 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
GimpImageType type,
gint offset_x,
gint offset_y)
{
gboolean old_has_alpha;
GimpItem *item;
gboolean old_has_alpha;
g_return_if_fail (tile_manager_bpp (tiles) == GIMP_IMAGE_TYPE_BYTES (type));
item = GIMP_ITEM (drawable);
old_has_alpha = gimp_drawable_has_alpha (drawable);
gimp_drawable_invalidate_boundary (drawable);
......@@ -616,6 +614,18 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
drawable->bytes = tile_manager_bpp (tiles);
drawable->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (type);
item->offset_x = offset_x;
item->offset_y = offset_y;
if (item->width != tile_manager_width (tiles) ||
item->height != tile_manager_height (tiles))
{
item->width = tile_manager_width (tiles);
item->height = tile_manager_height (tiles);
gimp_viewable_size_changed (GIMP_VIEWABLE (drawable));
}
if (old_has_alpha != gimp_drawable_has_alpha (drawable))
gimp_drawable_alpha_changed (drawable);
}
......@@ -808,15 +818,36 @@ void
gimp_drawable_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
TileManager *tiles)
{
gint offset_x, offset_y;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (tiles != NULL);
gimp_item_offsets (GIMP_ITEM (drawable), &offset_x, &offset_y);
gimp_drawable_set_tiles_full (drawable, push_undo, undo_desc, tiles,
gimp_drawable_type (drawable),
offset_x, offset_y);
}
void
gimp_drawable_set_tiles_full (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type,
gint offset_x,
gint offset_y)
{
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);
tiles, type,
offset_x, offset_y);
}
void
......
......@@ -85,7 +85,9 @@ struct _GimpDrawableClass
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
GimpImageType type,
gint offset_x,
gint offset_y);
void (* swap_pixels) (GimpDrawable *drawable,
TileManager *tiles,
gboolean sparse,
......@@ -137,10 +139,16 @@ void gimp_drawable_replace_region (GimpDrawable *drawable,
gint y);
void gimp_drawable_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles);
void gimp_drawable_set_tiles_full (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
GimpImageType type,
gint offset_x,
gint offset_y);
void gimp_drawable_swap_pixels (GimpDrawable *drawable,
TileManager *tiles,
......
......@@ -941,10 +941,10 @@ gimp_image_convert (GimpImage *gimage,
break;
}
gimp_drawable_set_tiles (GIMP_DRAWABLE (layer),
TRUE, NULL,
new_tiles, new_layer_type);
gimp_drawable_set_tiles_full (GIMP_DRAWABLE (layer), TRUE, NULL,
new_tiles, new_layer_type,
GIMP_ITEM (layer)->offset_x,
GIMP_ITEM (layer)->offset_y);
tile_manager_unref (new_tiles);
}
......
......@@ -1407,27 +1407,10 @@ undo_pop_layer_mod (GimpUndo *undo,
lmu->offset_x = GIMP_ITEM (layer)->offset_x;
lmu->offset_y = GIMP_ITEM (layer)->offset_y;
GIMP_ITEM (layer)->width = tile_manager_width (tiles);
GIMP_ITEM (layer)->height = tile_manager_height (tiles);
GIMP_ITEM (layer)->offset_x = offset_x;
GIMP_ITEM (layer)->offset_y = offset_y;
gimp_drawable_set_tiles (GIMP_DRAWABLE (layer), FALSE, NULL,
tiles, layer_type);
gimp_drawable_set_tiles_full (GIMP_DRAWABLE (layer), FALSE, NULL,
tiles, layer_type, offset_x, offset_y);
tile_manager_unref (tiles);
if (layer->mask)
{
GIMP_ITEM (layer->mask)->offset_x = offset_x;
GIMP_ITEM (layer->mask)->offset_y = offset_y;
}
if (GIMP_ITEM (layer)->width != tile_manager_width (lmu->tiles) ||
GIMP_ITEM (layer)->height != tile_manager_height (lmu->tiles))
{
gimp_viewable_size_changed (GIMP_VIEWABLE (layer));
}
/* Issue the second update */
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
......@@ -2072,19 +2055,9 @@ undo_pop_channel_mod (GimpUndo *undo,
cmu->tiles = tile_manager_ref (GIMP_DRAWABLE (channel)->tiles);
GIMP_ITEM (channel)->width = tile_manager_width (tiles);
GIMP_ITEM (channel)->height = tile_manager_height (tiles);
gimp_drawable_set_tiles (GIMP_DRAWABLE (channel), FALSE, NULL,
tiles, gimp_drawable_type (GIMP_DRAWABLE (channel)));
gimp_drawable_set_tiles (GIMP_DRAWABLE (channel), FALSE, NULL, tiles);
tile_manager_unref (tiles);
if (GIMP_ITEM (channel)->width != tile_manager_width (cmu->tiles) ||
GIMP_ITEM (channel)->height != tile_manager_height (cmu->tiles))
{
gimp_viewable_size_changed (GIMP_VIEWABLE (channel));
}
/* Issue the second update */
gimp_drawable_update (GIMP_DRAWABLE (channel),
0, 0,
......
......@@ -126,7 +126,9 @@ static void gimp_layer_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
GimpImageType type,
gint offset_x,
gint offset_y);
static void gimp_layer_transform_color (GimpImage *gimage,
PixelRegion *layerPR,
......@@ -389,8 +391,12 @@ gimp_layer_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
GimpImageType type,
gint offset_x,
gint offset_y)
{
GimpLayer *layer = GIMP_LAYER (drawable);
if (push_undo)
gimp_image_undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (drawable)),
undo_desc,
......@@ -398,7 +404,14 @@ gimp_layer_set_tiles (GimpDrawable *drawable,
GIMP_DRAWABLE_CLASS (parent_class)->set_tiles (drawable,
push_undo, undo_desc,
tiles, type);
tiles, type,
offset_x, offset_y);
if (layer->mask)
{
GIMP_ITEM (layer->mask)->offset_x = offset_x;
GIMP_ITEM (layer->mask)->offset_y = offset_y;
}
}
static void
......@@ -540,7 +553,10 @@ gimp_layer_convert (GimpItem *item,
break;
}
gimp_drawable_set_tiles (new_drawable, FALSE, NULL, new_tiles, new_type);
gimp_drawable_set_tiles_full (new_drawable, FALSE, NULL,
new_tiles, new_type,
GIMP_ITEM (layer)->offset_x,
GIMP_ITEM (layer)->offset_y);
tile_manager_unref (new_tiles);
}
......@@ -1385,8 +1401,11 @@ gimp_layer_add_alpha (GimpLayer *layer)
add_alpha_region (&srcPR, &destPR);
/* Set the new tiles */
gimp_drawable_set_tiles (GIMP_DRAWABLE (layer), TRUE, _("Add Alpha Channel"),
new_tiles, new_type);
gimp_drawable_set_tiles_full (GIMP_DRAWABLE (layer),
TRUE, _("Add Alpha Channel"),
new_tiles, new_type,
GIMP_ITEM (layer)->offset_x,
GIMP_ITEM (layer)->offset_y);
tile_manager_unref (new_tiles);
GIMP_DRAWABLE (layer)->preview_valid = FALSE;
......
......@@ -89,7 +89,9 @@ static void gimp_text_layer_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type);
GimpImageType type,
gint offset_x,
gint offset_y);
static void gimp_text_layer_swap_pixels (GimpDrawable *drawable,
TileManager *tiles,
gboolean sparse,
......@@ -299,11 +301,14 @@ gimp_text_layer_set_tiles (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
TileManager *tiles,
GimpImageType type)
GimpImageType type,
gint offset_x,
gint offset_y)
{
GIMP_DRAWABLE_CLASS (parent_class)->set_tiles (drawable,
push_undo, undo_desc,
tiles, type);
tiles, type,
offset_x, offset_y);
GIMP_TEXT_LAYER (drawable)->modified = TRUE;
}
......@@ -491,10 +496,9 @@ gimp_text_layer_render (GimpTextLayer *layer)
GIMP_ITEM (drawable)->width = width;
GIMP_ITEM (drawable)->height = height;
new_tiles = tile_manager_new (width, height, drawable->bytes),
new_tiles = tile_manager_new (width, height, drawable->bytes);
gimp_drawable_set_tiles (drawable, FALSE, NULL,
new_tiles, gimp_drawable_type (drawable));
gimp_drawable_set_tiles (drawable, FALSE, NULL, new_tiles);
tile_manager_unref (new_tiles);
gimp_drawable_update (drawable,
......
......@@ -983,10 +983,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
gimp_channel_push_undo (gimp_image_get_mask (gdisp->gimage), NULL);
gimp_drawable_set_tiles (drawable,
FALSE, NULL,
new_tiles, drawable->type);
gimp_drawable_set_tiles (drawable, FALSE, NULL, new_tiles);
tile_manager_unref (new_tiles);
gimp_drawable_update (GIMP_DRAWABLE (active_item),
......
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