Commit de38a988 authored by Martin Nordholts's avatar Martin Nordholts

New offset getters for inline use.

* app/core/gimpitem.c
(gimp_item_get_offset_x)
(gimp_item_get_offset_y): New offset getters for inline use.

* app/core/gimpchannel.c
* app/core/gimpdrawable.c
* app/core/gimpimage-merge.c
* app/core/gimpimage-resize.c
* app/tools/gimptexttool.c: Don't access GimpItem offset members
directly, use gimp_item_set_offset() and
gimp_item_get_offset_[xy]() instead.

svn path=/trunk/; revision=27848
parent 28237630
2008-12-28 Martin Nordholts <martinn@svn.gnome.org>
* app/core/gimpitem.c
(gimp_item_get_offset_x)
(gimp_item_get_offset_y): New offset getters for inline use.
* app/core/gimpchannel.c
* app/core/gimpdrawable.c
* app/core/gimpimage-merge.c
* app/core/gimpimage-resize.c
* app/tools/gimptexttool.c: Don't access GimpItem offset members
directly, use gimp_item_set_offset() and
gimp_item_get_offset_[xy]() instead.
2008-12-28 Sven Neumann <sven@gimp.org>
Bug 563985 – jpg save dialog: "cancel" is treated like "commit"
......
......@@ -465,8 +465,8 @@ gimp_channel_convert (GimpItem *item,
gimp_drawable_set_tiles_full (drawable, FALSE, NULL,
new_tiles, GIMP_GRAY_IMAGE,
item->offset_x,
item->offset_y);
gimp_item_get_offset_x (item),
gimp_item_get_offset_y (item));
tile_manager_unref (new_tiles);
}
......
......@@ -468,16 +468,21 @@ gimp_drawable_resize (GimpItem *item,
offset_y == 0)
return;
new_offset_x = item->offset_x - offset_x;
new_offset_y = item->offset_y - offset_y;
new_offset_x = gimp_item_get_offset_x (item) - offset_x;
new_offset_y = gimp_item_get_offset_y (item) - offset_y;
gimp_rectangle_intersect (item->offset_x, item->offset_y,
gimp_item_get_width (item),
gimp_rectangle_intersect (gimp_item_get_offset_x (item),
gimp_item_get_offset_y (item),
gimp_item_get_width (item),
gimp_item_get_height (item),
new_offset_x, new_offset_y,
new_width, new_height,
&copy_x, &copy_y,
&copy_width, &copy_height);
new_offset_x,
new_offset_y,
new_width,
new_height,
&copy_x,
&copy_y,
&copy_width,
&copy_height);
new_tiles = tile_manager_new (new_width, new_height, drawable->bytes);
......@@ -502,9 +507,12 @@ gimp_drawable_resize (GimpItem *item,
/* Determine whether anything needs to be copied */
if (copy_width && copy_height)
{
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
copy_x - item->offset_x, copy_y - item->offset_y,
copy_width, copy_height,
pixel_region_init (&srcPR,
gimp_drawable_get_tiles (drawable),
copy_x - gimp_item_get_offset_x (item),
copy_y - gimp_item_get_offset_y (item),
copy_width,
copy_height,
FALSE);
pixel_region_init (&destPR, new_tiles,
......@@ -1192,10 +1200,10 @@ gimp_drawable_set_tiles_full (GimpDrawable *drawable,
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
push_undo = FALSE;
if (gimp_item_get_width (item) != tile_manager_width (tiles) ||
gimp_item_get_height (item) != tile_manager_height (tiles) ||
item->offset_x != offset_x ||
item->offset_y != offset_y)
if (gimp_item_get_width (item) != tile_manager_width (tiles) ||
gimp_item_get_height (item) != tile_manager_height (tiles) ||
gimp_item_get_offset_x (item) != offset_x ||
gimp_item_get_offset_y (item) != offset_y)
{
gimp_drawable_update (drawable,
0, 0,
......
......@@ -432,8 +432,7 @@ gimp_image_merge_layers (GimpImage *image,
return NULL;
}
GIMP_ITEM (merge_layer)->offset_x = x1;
GIMP_ITEM (merge_layer)->offset_y = y1;
gimp_item_set_offset (GIMP_ITEM (merge_layer), x1, y1);
/* get the background for compositing */
gimp_image_get_background (image, context,
......@@ -470,8 +469,7 @@ gimp_image_merge_layers (GimpImage *image,
return NULL;
}
GIMP_ITEM (merge_layer)->offset_x = x1;
GIMP_ITEM (merge_layer)->offset_y = y1;
gimp_item_set_offset (GIMP_ITEM (merge_layer), x1, y1);
/* clear the layer */
pixel_region_init (&src1PR,
......
......@@ -251,10 +251,10 @@ gimp_image_resize_to_layers (GimpImage *image,
/* figure out starting values */
item = list->data;
min_x = item->offset_x;
min_y = item->offset_y;
max_x = item->offset_x + gimp_item_get_width (item);
max_y = item->offset_y + gimp_item_get_height (item);
min_x = gimp_item_get_offset_x (item);
min_y = gimp_item_get_offset_y (item);
max_x = gimp_item_get_offset_x (item) + gimp_item_get_width (item);
max_y = gimp_item_get_offset_y (item) + gimp_item_get_height (item);
/* Respect all layers */
for (list = g_list_next (list);
......@@ -263,10 +263,10 @@ gimp_image_resize_to_layers (GimpImage *image,
{
item = list->data;
min_x = MIN (min_x, item->offset_x);
min_y = MIN (min_y, item->offset_y);
max_x = MAX (max_x, item->offset_x + gimp_item_get_width (item));
max_y = MAX (max_y, item->offset_y + gimp_item_get_height (item));
min_x = MIN (min_x, gimp_item_get_offset_x (item));
min_y = MIN (min_y, gimp_item_get_offset_y (item));
max_x = MAX (max_x, gimp_item_get_offset_x (item) + gimp_item_get_width (item));
max_y = MAX (max_y, gimp_item_get_offset_y (item) + gimp_item_get_height (item));
}
gimp_image_resize (image, context,
......
......@@ -790,6 +790,22 @@ gimp_item_set_offset (GimpItem *item,
g_object_thaw_notify (G_OBJECT (item));
}
gint
gimp_item_get_offset_x (GimpItem *item)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), 0);
return item->offset_x;
}
gint
gimp_item_get_offset_y (GimpItem *item)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), 0);
return item->offset_y;
}
/**
* gimp_item_translate:
* @item: The #GimpItem to move.
......
......@@ -166,6 +166,8 @@ void gimp_item_get_offset (const GimpItem *item,
void gimp_item_set_offset (GimpItem *item,
gint offset_x,
gint offset_y);
gint gimp_item_get_offset_x (GimpItem *item);
gint gimp_item_get_offset_y (GimpItem *item);
void gimp_item_translate (GimpItem *item,
gint offset_x,
......
......@@ -452,8 +452,8 @@ gimp_text_tool_button_press (GimpTool *tool,
GIMP_RECTANGLE_TOOL_CREATING)
{
GimpItem *item = GIMP_ITEM (text_tool->layer);
gdouble x = coords->x - item->offset_x;
gdouble y = coords->y - item->offset_y;
gdouble x = coords->x - gimp_item_get_offset_x (item);
gdouble y = coords->y - gimp_item_get_offset_y (item);
if (x < 0 || x > item->width ||
y < 0 || y > item->height)
......@@ -472,8 +472,8 @@ gimp_text_tool_button_press (GimpTool *tool,
if (GIMP_IS_LAYER (drawable))
{
GimpItem *item = GIMP_ITEM (drawable);
gdouble x = coords->x - item->offset_x;
gdouble y = coords->y - item->offset_y;
gdouble x = coords->x - gimp_item_get_offset_x (item);
gdouble y = coords->y - gimp_item_get_offset_y (item);
if (x > 0 && x < gimp_item_get_width (item) &&
y > 0 && y < gimp_item_get_height (item))
......@@ -600,8 +600,8 @@ gimp_text_tool_button_release (GimpTool *tool,
if (text_tool->layout && text_tool->text_cursor_changing)
{
GimpItem *item = GIMP_ITEM (text_tool->layer);
gdouble x = coords->x - item->offset_x;
gdouble y = coords->y - item->offset_y;
gdouble x = coords->x - gimp_item_get_offset_x (item);
gdouble y = coords->y - gimp_item_get_offset_y (item);
GtkTextIter cursor;
gint offset;
......@@ -656,8 +656,8 @@ gimp_text_tool_motion (GimpTool *tool,
if (text_tool->layout)
{
GimpItem *item = GIMP_ITEM (text_tool->layer);
gdouble x = coords->x - item->offset_x;
gdouble y = coords->y - item->offset_y;
gdouble x = coords->x - gimp_item_get_offset_x (item);
gdouble y = coords->y - gimp_item_get_offset_y (item);
GtkTextIter cursor;
GtkTextIter old_selection_bound;
GtkTextMark *selection_mark;
......@@ -1361,8 +1361,8 @@ gimp_text_tool_rectangle_change_complete (GimpRectangleTool *rect_tool)
_("Reshape Text Layer"));
gimp_item_translate (item,
x1 - item->offset_x,
y1 - item->offset_y,
x1 - gimp_item_get_offset_x (item),
y1 - gimp_item_get_offset_y (item),
TRUE);
gimp_text_tool_apply (text_tool);
......@@ -1767,8 +1767,7 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool,
"y2", &y2,
NULL);
GIMP_ITEM (layer)->offset_x = x1;
GIMP_ITEM (layer)->offset_y = y1;
gimp_item_set_offset (GIMP_ITEM (layer), x1, y1);
gimp_image_add_layer (image, layer, -1, TRUE);
......@@ -1782,8 +1781,8 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool,
"box-height", (gdouble) (y2 - y1),
NULL);
gimp_item_translate (item,
x1 - item->offset_x,
y1 - item->offset_y,
x1 - gimp_item_get_offset_x (item),
y1 - gimp_item_get_offset_y (item),
TRUE);
}
else
......
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