gimp r26804 - in trunk: . app/core app/display
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26804 - in trunk: . app/core app/display
- Date: Thu, 28 Aug 2008 19:12:04 +0000 (UTC)
Author: martinn
Date: Thu Aug 28 19:12:03 2008
New Revision: 26804
URL: http://svn.gnome.org/viewvc/gimp?rev=26804&view=rev
Log:
2008-08-28 Martin Nordholts <martinn svn gnome org>
* app/core/gimpimage.[ch]: Make the size-changed-detailed signal
also contain previous image size.
* app/display/gimpdisplayshell-handlers.c
(gimp_display_shell_size_changed_detailed_handler): Take the
previous image size into account and center the image if it starts
to fit (axis indepentently) in the viewport due to the resize.
* app/core/gimpundo.h
* app/core/gimpimage-undo.c
* app/core/gimpimageundo.[ch]
* app/core/gimpimage-undo-push.[ch]: Manage the
previous-size-information.
* app/core/gimpimage-crop.c
* app/core/gimpimage-scale.c
* app/core/gimpimage-rotate.c
* app/core/gimpimage-resize.c: Propagate previous size to the
size-changed-detailed signal emission and the undo-system.
Modified:
trunk/ChangeLog
trunk/app/core/gimpimage-crop.c
trunk/app/core/gimpimage-resize.c
trunk/app/core/gimpimage-rotate.c
trunk/app/core/gimpimage-scale.c
trunk/app/core/gimpimage-undo-push.c
trunk/app/core/gimpimage-undo-push.h
trunk/app/core/gimpimage-undo.c
trunk/app/core/gimpimage.c
trunk/app/core/gimpimage.h
trunk/app/core/gimpimageundo.c
trunk/app/core/gimpimageundo.h
trunk/app/core/gimpundo.h
trunk/app/display/gimpdisplayshell-handlers.c
Modified: trunk/app/core/gimpimage-crop.c
==============================================================================
--- trunk/app/core/gimpimage-crop.c (original)
+++ trunk/app/core/gimpimage-crop.c Thu Aug 28 19:12:03 2008
@@ -87,10 +87,14 @@
gboolean crop_layers)
{
gint width, height;
+ gint previous_width, previous_height;
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (GIMP_IS_CONTEXT (context));
+ previous_width = gimp_image_get_width (image);
+ previous_height = gimp_image_get_height (image);
+
width = x2 - x1;
height = y2 - y1;
@@ -129,7 +133,12 @@
_("Resize Image"));
/* Push the image size to the stack */
- gimp_image_undo_push_image_size (image, NULL, x1, y1);
+ gimp_image_undo_push_image_size (image,
+ NULL,
+ x1,
+ y1,
+ width,
+ height);
/* Set the new width and height */
g_object_set (image,
@@ -267,7 +276,11 @@
gimp_image_get_width (image),
gimp_image_get_height (image));
- gimp_image_size_changed_detailed (image, -x1, -y1);
+ gimp_image_size_changed_detailed (image,
+ -x1,
+ -y1,
+ previous_width,
+ previous_height);
g_object_thaw_notify (G_OBJECT (image));
}
Modified: trunk/app/core/gimpimage-resize.c
==============================================================================
--- trunk/app/core/gimpimage-resize.c (original)
+++ trunk/app/core/gimpimage-resize.c Thu Aug 28 19:12:03 2008
@@ -97,7 +97,12 @@
old_height = gimp_image_get_height (image);
/* Push the image size to the stack */
- gimp_image_undo_push_image_size (image, NULL, -offset_x, -offset_y);
+ gimp_image_undo_push_image_size (image,
+ NULL,
+ -offset_x,
+ -offset_y,
+ new_width,
+ new_height);
/* Set the new width and height */
g_object_set (image,
@@ -220,7 +225,11 @@
gimp_image_undo_group_end (image);
- gimp_image_size_changed_detailed (image, offset_x, offset_y);
+ gimp_image_size_changed_detailed (image,
+ offset_x,
+ offset_y,
+ old_width,
+ old_height);
g_object_thaw_notify (G_OBJECT (image));
Modified: trunk/app/core/gimpimage-rotate.c
==============================================================================
--- trunk/app/core/gimpimage-rotate.c (original)
+++ trunk/app/core/gimpimage-rotate.c Thu Aug 28 19:12:03 2008
@@ -61,6 +61,8 @@
gdouble progress_current = 1.0;
gint new_image_width;
gint new_image_height;
+ gint previous_image_width;
+ gint previous_image_height;
gint offset_x;
gint offset_y;
gboolean size_changed;
@@ -71,8 +73,11 @@
gimp_set_busy (image->gimp);
- center_x = (gdouble) gimp_image_get_width (image) / 2.0;
- center_y = (gdouble) gimp_image_get_height (image) / 2.0;
+ previous_image_width = gimp_image_get_width (image);
+ previous_image_height = gimp_image_get_height (image);
+
+ center_x = previous_image_width / 2.0;
+ center_y = previous_image_height / 2.0;
progress_max = (image->channels->num_children +
image->layers->num_children +
@@ -192,7 +197,12 @@
gdouble xres;
gdouble yres;
- gimp_image_undo_push_image_size (image, NULL, offset_x, offset_y);
+ gimp_image_undo_push_image_size (image,
+ NULL,
+ offset_x,
+ offset_y,
+ new_image_width,
+ new_image_height);
g_object_set (image,
"width", new_image_width,
@@ -208,7 +218,11 @@
gimp_image_undo_group_end (image);
if (size_changed)
- gimp_image_size_changed_detailed (image, -offset_x, -offset_y);
+ gimp_image_size_changed_detailed (image,
+ -offset_x,
+ -offset_y,
+ previous_image_width,
+ previous_image_height);
g_object_thaw_notify (G_OBJECT (image));
Modified: trunk/app/core/gimpimage-scale.c
==============================================================================
--- trunk/app/core/gimpimage-scale.c (original)
+++ trunk/app/core/gimpimage-scale.c Thu Aug 28 19:12:03 2008
@@ -90,7 +90,12 @@
offset_y = (old_height - new_height) / 2;
/* Push the image size to the stack */
- gimp_image_undo_push_image_size (image, NULL, offset_x, offset_y);
+ gimp_image_undo_push_image_size (image,
+ NULL,
+ offset_x,
+ offset_y,
+ new_width,
+ new_height);
/* Set the new width and height */
g_object_set (image,
@@ -212,7 +217,11 @@
g_object_unref (sub_progress);
- gimp_image_size_changed_detailed (image, -offset_x, -offset_y);
+ gimp_image_size_changed_detailed (image,
+ -offset_x,
+ -offset_y,
+ old_width,
+ old_height);
g_object_thaw_notify (G_OBJECT (image));
Modified: trunk/app/core/gimpimage-undo-push.c
==============================================================================
--- trunk/app/core/gimpimage-undo-push.c (original)
+++ trunk/app/core/gimpimage-undo-push.c Thu Aug 28 19:12:03 2008
@@ -82,7 +82,9 @@
gimp_image_undo_push_image_size (GimpImage *image,
const gchar *undo_desc,
gint previous_origin_x,
- gint previous_origin_y)
+ gint previous_origin_y,
+ gint previous_width,
+ gint previous_height)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
@@ -91,6 +93,8 @@
GIMP_DIRTY_IMAGE | GIMP_DIRTY_IMAGE_SIZE,
"previous-origin-x", previous_origin_x,
"previous-origin-y", previous_origin_y,
+ "previous-width", previous_width,
+ "previous-height", previous_height,
NULL);
}
Modified: trunk/app/core/gimpimage-undo-push.h
==============================================================================
--- trunk/app/core/gimpimage-undo-push.h (original)
+++ trunk/app/core/gimpimage-undo-push.h Thu Aug 28 19:12:03 2008
@@ -27,7 +27,9 @@
GimpUndo * gimp_image_undo_push_image_size (GimpImage *image,
const gchar *undo_desc,
gint previous_origin_x,
- gint previous_origin_y);
+ gint previous_origin_y,
+ gint previous_width,
+ gint prevoius_height);
GimpUndo * gimp_image_undo_push_image_resolution (GimpImage *image,
const gchar *undo_desc);
GimpUndo * gimp_image_undo_push_image_grid (GimpImage *image,
Modified: trunk/app/core/gimpimage-undo.c
==============================================================================
--- trunk/app/core/gimpimage-undo.c (original)
+++ trunk/app/core/gimpimage-undo.c Thu Aug 28 19:12:03 2008
@@ -383,7 +383,9 @@
if (accum.size_changed)
gimp_image_size_changed_detailed (image,
accum.previous_origin_x,
- accum.previous_origin_y);
+ accum.previous_origin_y,
+ accum.previous_width,
+ accum.previous_height);
if (accum.resolution_changed)
gimp_image_resolution_changed (image);
Modified: trunk/app/core/gimpimage.c
==============================================================================
--- trunk/app/core/gimpimage.c (original)
+++ trunk/app/core/gimpimage.c Thu Aug 28 19:12:03 2008
@@ -151,7 +151,9 @@
static void gimp_image_real_size_changed_detailed
(GimpImage *image,
gint previous_origin_x,
- gint previous_origin_y);
+ gint previous_origin_y,
+ gint previous_width,
+ gint previous_height);
static void gimp_image_real_colormap_changed (GimpImage *image,
gint color_index);
static void gimp_image_real_flush (GimpImage *image,
@@ -325,8 +327,10 @@
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, size_changed_detailed),
NULL, NULL,
- gimp_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2,
+ gimp_marshal_VOID__INT_INT_INT_INT,
+ G_TYPE_NONE, 4,
+ G_TYPE_INT,
+ G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT);
@@ -1122,7 +1126,9 @@
static void
gimp_image_real_size_changed_detailed (GimpImage *image,
gint previous_origin_x,
- gint previous_origin_y)
+ gint previous_origin_y,
+ gint previous_width,
+ gint previous_height)
{
/* Whenever GimpImage::size-changed-detailed is emitted, so is
* GimpViewable::size-changed. Clients choose what signal to listen
@@ -1503,7 +1509,11 @@
image->yresolution = yresolution;
gimp_image_resolution_changed (image);
- gimp_image_size_changed_detailed (image, 0, 0);
+ gimp_image_size_changed_detailed (image,
+ 0,
+ 0,
+ gimp_image_get_width (image),
+ gimp_image_get_height (image));
}
}
@@ -1841,13 +1851,17 @@
void
gimp_image_size_changed_detailed (GimpImage *image,
gint previous_origin_x,
- gint previous_origin_y)
+ gint previous_origin_y,
+ gint previous_width,
+ gint previous_height)
{
g_return_if_fail (GIMP_IS_IMAGE (image));
g_signal_emit (image, gimp_image_signals[SIZE_CHANGED_DETAILED], 0,
previous_origin_x,
- previous_origin_y);
+ previous_origin_y,
+ previous_width,
+ previous_height);
}
void
Modified: trunk/app/core/gimpimage.h
==============================================================================
--- trunk/app/core/gimpimage.h (original)
+++ trunk/app/core/gimpimage.h Thu Aug 28 19:12:03 2008
@@ -193,7 +193,9 @@
void (* resolution_changed) (GimpImage *image);
void (* size_changed_detailed) (GimpImage *image,
gint previous_origin_x,
- gint previous_origin_y);
+ gint previous_origin_y,
+ gint previous_width,
+ gint previous_height);
void (* unit_changed) (GimpImage *image);
void (* quick_mask_changed) (GimpImage *image);
void (* selection_control) (GimpImage *image,
@@ -329,7 +331,9 @@
void gimp_image_quick_mask_changed (GimpImage *image);
void gimp_image_size_changed_detailed (GimpImage *image,
gint previous_origin_x,
- gint previous_origin_y);
+ gint previous_origin_y,
+ gint previous_width,
+ gint previous_height);
/* undo */
Modified: trunk/app/core/gimpimageundo.c
==============================================================================
--- trunk/app/core/gimpimageundo.c (original)
+++ trunk/app/core/gimpimageundo.c Thu Aug 28 19:12:03 2008
@@ -43,6 +43,8 @@
PROP_0,
PROP_PREVIOUS_ORIGIN_X,
PROP_PREVIOUS_ORIGIN_Y,
+ PROP_PREVIOUS_WIDTH,
+ PROP_PREVIOUS_HEIGHT,
PROP_GRID,
PROP_PARASITE_NAME
};
@@ -107,6 +109,22 @@
0,
GIMP_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_PREVIOUS_WIDTH,
+ g_param_spec_int ("previous-width",
+ NULL, NULL,
+ -GIMP_MAX_IMAGE_SIZE,
+ GIMP_MAX_IMAGE_SIZE,
+ 0,
+ GIMP_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class, PROP_PREVIOUS_HEIGHT,
+ g_param_spec_int ("previous-height",
+ NULL, NULL,
+ -GIMP_MAX_IMAGE_SIZE,
+ GIMP_MAX_IMAGE_SIZE,
+ 0,
+ GIMP_PARAM_READWRITE));
+
g_object_class_install_property (object_class, PROP_GRID,
g_param_spec_object ("grid", NULL, NULL,
GIMP_TYPE_GRID,
@@ -200,6 +218,12 @@
case PROP_PREVIOUS_ORIGIN_Y:
image_undo->previous_origin_y = g_value_get_int (value);
break;
+ case PROP_PREVIOUS_WIDTH:
+ image_undo->previous_width = g_value_get_int (value);
+ break;
+ case PROP_PREVIOUS_HEIGHT:
+ image_undo->previous_height = g_value_get_int (value);
+ break;
case PROP_GRID:
{
GimpGrid *grid = g_value_get_object (value);
@@ -234,6 +258,12 @@
case PROP_PREVIOUS_ORIGIN_Y:
g_value_set_int (value, image_undo->previous_origin_y);
break;
+ case PROP_PREVIOUS_WIDTH:
+ g_value_set_int (value, image_undo->previous_width);
+ break;
+ case PROP_PREVIOUS_HEIGHT:
+ g_value_set_int (value, image_undo->previous_height);
+ break;
case PROP_GRID:
g_value_set_object (value, image_undo->grid);
break;
@@ -299,17 +329,23 @@
gint height;
gint previous_origin_x;
gint previous_origin_y;
+ gint previous_width;
+ gint previous_height;
width = image_undo->width;
height = image_undo->height;
previous_origin_x = image_undo->previous_origin_x;
previous_origin_y = image_undo->previous_origin_y;
+ previous_width = image_undo->previous_width;
+ previous_height = image_undo->previous_height;
/* Transform to a redo */
image_undo->width = gimp_image_get_width (image);
image_undo->height = gimp_image_get_height (image);
image_undo->previous_origin_x = -previous_origin_x;
image_undo->previous_origin_y = -previous_origin_y;
+ image_undo->previous_width = width;
+ image_undo->previous_height = height;
g_object_set (image,
"width", width,
@@ -325,6 +361,8 @@
accum->size_changed = TRUE;
accum->previous_origin_x = previous_origin_x;
accum->previous_origin_y = previous_origin_y;
+ accum->previous_width = previous_width;
+ accum->previous_height = previous_height;
}
}
break;
Modified: trunk/app/core/gimpimageundo.h
==============================================================================
--- trunk/app/core/gimpimageundo.h (original)
+++ trunk/app/core/gimpimageundo.h Thu Aug 28 19:12:03 2008
@@ -42,6 +42,8 @@
gint height;
gint previous_origin_x;
gint previous_origin_y;
+ gint previous_width;
+ gint previous_height;
gdouble xresolution;
gdouble yresolution;
GimpUnit resolution_unit;
Modified: trunk/app/core/gimpundo.h
==============================================================================
--- trunk/app/core/gimpundo.h (original)
+++ trunk/app/core/gimpundo.h Thu Aug 28 19:12:03 2008
@@ -26,12 +26,19 @@
struct _GimpUndoAccumulator
{
gboolean mode_changed;
+
gboolean size_changed;
- gdouble previous_origin_x;
- gdouble previous_origin_y;
+ gint previous_origin_x;
+ gint previous_origin_y;
+ gint previous_width;
+ gint previous_height;
+
gboolean resolution_changed;
+
gboolean unit_changed;
+
gboolean quick_mask_changed;
+
gboolean alpha_changed;
};
Modified: trunk/app/display/gimpdisplayshell-handlers.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-handlers.c (original)
+++ trunk/app/display/gimpdisplayshell-handlers.c Thu Aug 28 19:12:03 2008
@@ -70,6 +70,8 @@
(GimpImage *image,
gint previous_origin_x,
gint previous_origin_y,
+ gint previous_width,
+ gint previous_height,
GimpDisplayShell *shell);
static void gimp_display_shell_resolution_changed_handler (GimpImage *image,
GimpDisplayShell *shell);
@@ -485,9 +487,26 @@
}
static void
+gimp_display_shell_image_size_starts_to_fit (GimpDisplayShell *shell,
+ gint previous_width,
+ gint previous_height,
+ gint new_width,
+ gint new_height,
+ gboolean *horizontally,
+ gboolean *vertically)
+{
+ *horizontally = SCALEX (shell, previous_width) > shell->disp_width &&
+ SCALEX (shell, new_width) <= shell->disp_width;
+ *vertically = SCALEY (shell, previous_height) > shell->disp_height &&
+ SCALEY (shell, new_height) <= shell->disp_height;
+}
+
+static void
gimp_display_shell_size_changed_detailed_handler (GimpImage *image,
gint previous_origin_x,
gint previous_origin_y,
+ gint previous_width,
+ gint previous_height,
GimpDisplayShell *shell)
{
if (shell->display->config->resize_windows_on_resize)
@@ -499,12 +518,26 @@
}
else
{
- gint scaled_previous_origin_x = SCALEX (shell, previous_origin_x);
- gint scaled_previous_origin_y = SCALEY (shell, previous_origin_y);
+ GimpImage *image;
+ gboolean horizontally, vertically;
+ gint scaled_previous_origin_x = SCALEX (shell, previous_origin_x);
+ gint scaled_previous_origin_y = SCALEY (shell, previous_origin_y);
+
+ image = GIMP_IMAGE (shell->display->image);
+
+ gimp_display_shell_image_size_starts_to_fit (shell,
+ previous_width,
+ previous_height,
+ gimp_image_get_width (image),
+ gimp_image_get_height (image),
+ &horizontally,
+ &vertically);
gimp_display_shell_scroll_set_offset (shell,
shell->offset_x + scaled_previous_origin_x,
shell->offset_y + scaled_previous_origin_y);
+
+ gimp_display_shell_scroll_center_image (shell, horizontally, vertically);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]