mirror of https://github.com/GNOME/gimp.git
add read-only "offset-x" and "offset-y" properties. Call
2008-11-11 Michael Natterer <mitch@gimp.org> * app/core/gimpitem.c: add read-only "offset-x" and "offset-y" properties. Call gimp_item_set_offset() from all places that set offset_x and offset_y in this file. Freeze and thaw GObject notification around all calls to virtual functions which might emit notify. Add missing notifications whenever width and height change. * app/core/gimpimage-rotate.c: use gimp_item_set_offset() instead of setting the values manually. svn path=/trunk/; revision=27623
This commit is contained in:
parent
cee9feca8f
commit
65b2a60455
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2008-11-11 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimpitem.c: add read-only "offset-x" and "offset-y"
|
||||||
|
properties. Call gimp_item_set_offset() from all places that set
|
||||||
|
offset_x and offset_y in this file. Freeze and thaw GObject
|
||||||
|
notification around all calls to virtual functions which might
|
||||||
|
emit notify. Add missing notifications whenever width and height
|
||||||
|
change.
|
||||||
|
|
||||||
|
* app/core/gimpimage-rotate.c: use gimp_item_set_offset() instead
|
||||||
|
of setting the values manually.
|
||||||
|
|
||||||
2008-11-11 Sven Neumann <sven@gimp.org>
|
2008-11-11 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
Bug 560300 – Document History did not clear when "Keep record of
|
Bug 560300 – Document History did not clear when "Keep record of
|
||||||
|
|
|
@ -122,8 +122,7 @@ gimp_image_rotate (GimpImage *image,
|
||||||
|
|
||||||
gimp_item_rotate (item, context, rotate_type, center_x, center_y, FALSE);
|
gimp_item_rotate (item, context, rotate_type, center_x, center_y, FALSE);
|
||||||
|
|
||||||
item->offset_x = 0;
|
gimp_item_set_offset (item, 0, 0);
|
||||||
item->offset_y = 0;
|
|
||||||
|
|
||||||
if (progress)
|
if (progress)
|
||||||
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
||||||
|
@ -140,8 +139,11 @@ gimp_image_rotate (GimpImage *image,
|
||||||
|
|
||||||
item->width = new_image_width;
|
item->width = new_image_width;
|
||||||
item->height = new_image_height;
|
item->height = new_image_height;
|
||||||
item->offset_x = 0;
|
|
||||||
item->offset_y = 0;
|
g_object_notify (G_OBJECT (item), "width");
|
||||||
|
g_object_notify (G_OBJECT (item), "height");
|
||||||
|
|
||||||
|
gimp_item_set_offset (item, 0, 0);
|
||||||
|
|
||||||
gimp_item_translate (item,
|
gimp_item_translate (item,
|
||||||
(new_image_width - gimp_image_get_width (image)) / 2,
|
(new_image_width - gimp_image_get_width (image)) / 2,
|
||||||
|
@ -159,8 +161,7 @@ gimp_image_rotate (GimpImage *image,
|
||||||
gimp_item_rotate (GIMP_ITEM (mask), context,
|
gimp_item_rotate (GIMP_ITEM (mask), context,
|
||||||
rotate_type, center_x, center_y, FALSE);
|
rotate_type, center_x, center_y, FALSE);
|
||||||
|
|
||||||
GIMP_ITEM (mask)->offset_x = 0;
|
gimp_item_set_offset (GIMP_ITEM (mask), 0, 0);
|
||||||
GIMP_ITEM (mask)->offset_y = 0;
|
|
||||||
|
|
||||||
if (progress)
|
if (progress)
|
||||||
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
gimp_progress_set_value (progress, progress_current++ / progress_max);
|
||||||
|
|
|
@ -58,7 +58,9 @@ enum
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ID,
|
PROP_ID,
|
||||||
PROP_WIDTH,
|
PROP_WIDTH,
|
||||||
PROP_HEIGHT
|
PROP_HEIGHT,
|
||||||
|
PROP_OFFSET_X,
|
||||||
|
PROP_OFFSET_Y
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,6 +201,18 @@ gimp_item_class_init (GimpItemClass *klass)
|
||||||
g_param_spec_int ("height", NULL, NULL,
|
g_param_spec_int ("height", NULL, NULL,
|
||||||
1, GIMP_MAX_IMAGE_SIZE, 1,
|
1, GIMP_MAX_IMAGE_SIZE, 1,
|
||||||
GIMP_PARAM_READABLE));
|
GIMP_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_OFFSET_X,
|
||||||
|
g_param_spec_int ("offset-x", NULL, NULL,
|
||||||
|
-GIMP_MAX_IMAGE_SIZE,
|
||||||
|
GIMP_MAX_IMAGE_SIZE, 0,
|
||||||
|
GIMP_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_OFFSET_Y,
|
||||||
|
g_param_spec_int ("offset-y", NULL, NULL,
|
||||||
|
-GIMP_MAX_IMAGE_SIZE,
|
||||||
|
GIMP_MAX_IMAGE_SIZE, 0,
|
||||||
|
GIMP_PARAM_READABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -254,6 +268,13 @@ gimp_item_get_property (GObject *object,
|
||||||
case PROP_HEIGHT:
|
case PROP_HEIGHT:
|
||||||
g_value_set_int (value, item->height);
|
g_value_set_int (value, item->height);
|
||||||
break;
|
break;
|
||||||
|
case PROP_OFFSET_X:
|
||||||
|
g_value_set_int (value, item->offset_x);
|
||||||
|
break;
|
||||||
|
case PROP_OFFSET_Y:
|
||||||
|
g_value_set_int (value, item->offset_y);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -408,10 +429,9 @@ gimp_item_real_translate (GimpItem *item,
|
||||||
gint offset_y,
|
gint offset_y,
|
||||||
gboolean push_undo)
|
gboolean push_undo)
|
||||||
{
|
{
|
||||||
item->offset_x += offset_x;
|
gimp_item_set_offset (item,
|
||||||
item->offset_y += offset_y;
|
item->offset_x + offset_x,
|
||||||
|
item->offset_y + offset_y);
|
||||||
gimp_item_sync_offset_node (item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -423,13 +443,19 @@ gimp_item_real_scale (GimpItem *item,
|
||||||
GimpInterpolationType interpolation,
|
GimpInterpolationType interpolation,
|
||||||
GimpProgress *progress)
|
GimpProgress *progress)
|
||||||
{
|
{
|
||||||
|
if (item->width != new_width)
|
||||||
|
{
|
||||||
item->width = new_width;
|
item->width = new_width;
|
||||||
item->height = new_height;
|
|
||||||
item->offset_x = new_offset_x;
|
|
||||||
item->offset_y = new_offset_y;
|
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (item), "width");
|
g_object_notify (G_OBJECT (item), "width");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item->height != new_height)
|
||||||
|
{
|
||||||
|
item->height = new_height;
|
||||||
g_object_notify (G_OBJECT (item), "height");
|
g_object_notify (G_OBJECT (item), "height");
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_item_set_offset (item, new_offset_x, new_offset_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -440,13 +466,21 @@ gimp_item_real_resize (GimpItem *item,
|
||||||
gint offset_x,
|
gint offset_x,
|
||||||
gint offset_y)
|
gint offset_y)
|
||||||
{
|
{
|
||||||
item->offset_x = item->offset_x - offset_x;
|
if (item->width != new_width)
|
||||||
item->offset_y = item->offset_y - offset_y;
|
{
|
||||||
item->width = new_width;
|
item->width = new_width;
|
||||||
item->height = new_height;
|
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (item), "width");
|
g_object_notify (G_OBJECT (item), "width");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item->height != new_height)
|
||||||
|
{
|
||||||
|
item->height = new_height;
|
||||||
g_object_notify (G_OBJECT (item), "height");
|
g_object_notify (G_OBJECT (item), "height");
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_item_set_offset (item,
|
||||||
|
item->offset_x - offset_x,
|
||||||
|
item->offset_y - offset_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GeglNode *
|
static GeglNode *
|
||||||
|
@ -548,13 +582,19 @@ gimp_item_configure (GimpItem *item,
|
||||||
g_object_notify (G_OBJECT (item), "id");
|
g_object_notify (G_OBJECT (item), "id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item->width != width)
|
||||||
|
{
|
||||||
item->width = width;
|
item->width = width;
|
||||||
item->height = height;
|
|
||||||
item->offset_x = offset_x;
|
|
||||||
item->offset_y = offset_y;
|
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (item), "width");
|
g_object_notify (G_OBJECT (item), "width");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item->height != height)
|
||||||
|
{
|
||||||
|
item->height = height;
|
||||||
g_object_notify (G_OBJECT (item), "height");
|
g_object_notify (G_OBJECT (item), "height");
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_item_set_offset (item, offset_x, offset_y);
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
gimp_object_set_name (GIMP_OBJECT (item), name);
|
gimp_object_set_name (GIMP_OBJECT (item), name);
|
||||||
|
@ -713,10 +753,23 @@ gimp_item_set_offset (GimpItem *item,
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_ITEM (item));
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
||||||
|
|
||||||
|
g_object_freeze_notify (G_OBJECT (item));
|
||||||
|
|
||||||
|
if (item->offset_x != offset_x)
|
||||||
|
{
|
||||||
item->offset_x = offset_x;
|
item->offset_x = offset_x;
|
||||||
|
g_object_notify (G_OBJECT (item), "offset-x");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item->offset_y != offset_y)
|
||||||
|
{
|
||||||
item->offset_y = offset_y;
|
item->offset_y = offset_y;
|
||||||
|
g_object_notify (G_OBJECT (item), "offset-y");
|
||||||
|
}
|
||||||
|
|
||||||
gimp_item_sync_offset_node (item);
|
gimp_item_sync_offset_node (item);
|
||||||
|
|
||||||
|
g_object_thaw_notify (G_OBJECT (item));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -817,9 +870,13 @@ gimp_item_scale (GimpItem *item,
|
||||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_SCALE,
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_SCALE,
|
||||||
item_class->scale_desc);
|
item_class->scale_desc);
|
||||||
|
|
||||||
|
g_object_freeze_notify (G_OBJECT (item));
|
||||||
|
|
||||||
item_class->scale (item, new_width, new_height, new_offset_x, new_offset_y,
|
item_class->scale (item, new_width, new_height, new_offset_x, new_offset_y,
|
||||||
interpolation, progress);
|
interpolation, progress);
|
||||||
|
|
||||||
|
g_object_thaw_notify (G_OBJECT (item));
|
||||||
|
|
||||||
if (gimp_item_is_attached (item))
|
if (gimp_item_is_attached (item))
|
||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
}
|
}
|
||||||
|
@ -984,8 +1041,12 @@ gimp_item_resize (GimpItem *item,
|
||||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
||||||
item_class->resize_desc);
|
item_class->resize_desc);
|
||||||
|
|
||||||
|
g_object_freeze_notify (G_OBJECT (item));
|
||||||
|
|
||||||
item_class->resize (item, context, new_width, new_height, offset_x, offset_y);
|
item_class->resize (item, context, new_width, new_height, offset_x, offset_y);
|
||||||
|
|
||||||
|
g_object_thaw_notify (G_OBJECT (item));
|
||||||
|
|
||||||
if (gimp_item_is_attached (item))
|
if (gimp_item_is_attached (item))
|
||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
}
|
}
|
||||||
|
@ -1010,8 +1071,12 @@ gimp_item_flip (GimpItem *item,
|
||||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
|
||||||
item_class->flip_desc);
|
item_class->flip_desc);
|
||||||
|
|
||||||
|
g_object_freeze_notify (G_OBJECT (item));
|
||||||
|
|
||||||
item_class->flip (item, context, flip_type, axis, clip_result);
|
item_class->flip (item, context, flip_type, axis, clip_result);
|
||||||
|
|
||||||
|
g_object_thaw_notify (G_OBJECT (item));
|
||||||
|
|
||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,9 +1101,13 @@ gimp_item_rotate (GimpItem *item,
|
||||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
|
||||||
item_class->rotate_desc);
|
item_class->rotate_desc);
|
||||||
|
|
||||||
|
g_object_freeze_notify (G_OBJECT (item));
|
||||||
|
|
||||||
item_class->rotate (item, context, rotate_type, center_x, center_y,
|
item_class->rotate (item, context, rotate_type, center_x, center_y,
|
||||||
clip_result);
|
clip_result);
|
||||||
|
|
||||||
|
g_object_thaw_notify (G_OBJECT (item));
|
||||||
|
|
||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1067,9 +1136,13 @@ gimp_item_transform (GimpItem *item,
|
||||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
|
||||||
item_class->transform_desc);
|
item_class->transform_desc);
|
||||||
|
|
||||||
|
g_object_freeze_notify (G_OBJECT (item));
|
||||||
|
|
||||||
item_class->transform (item, context, matrix, direction, interpolation,
|
item_class->transform (item, context, matrix, direction, interpolation,
|
||||||
recursion_level, clip_result, progress);
|
recursion_level, clip_result, progress);
|
||||||
|
|
||||||
|
g_object_thaw_notify (G_OBJECT (item));
|
||||||
|
|
||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,7 +1212,8 @@ gimp_item_get_offset_node (GimpItem *item)
|
||||||
{
|
{
|
||||||
GeglNode *node = gimp_item_get_node (item);
|
GeglNode *node = gimp_item_get_node (item);
|
||||||
|
|
||||||
item->offset_node = gegl_node_new_child (node,
|
item->offset_node =
|
||||||
|
gegl_node_new_child (node,
|
||||||
"operation", "gegl:shift",
|
"operation", "gegl:shift",
|
||||||
"x", (gdouble) item->offset_x,
|
"x", (gdouble) item->offset_x,
|
||||||
"y", (gdouble) item->offset_y,
|
"y", (gdouble) item->offset_y,
|
||||||
|
|
Loading…
Reference in New Issue