Make the size-changed-detailed signal also contain previous image size.
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. svn path=/trunk/; revision=26804
This commit is contained in:

committed by
Martin Nordholts

parent
2bffcadf11
commit
2975f815a8
22
ChangeLog
22
ChangeLog
@ -1,3 +1,25 @@
|
||||
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.
|
||||
|
||||
2008-08-28 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/config/gimpguiconfig.[ch]: allow to disable the Wilber image
|
||||
|
@ -87,10 +87,14 @@ gimp_image_crop (GimpImage *image,
|
||||
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 @@ gimp_image_crop (GimpImage *image,
|
||||
_("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_crop (GimpImage *image,
|
||||
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));
|
||||
}
|
||||
|
@ -97,7 +97,12 @@ gimp_image_resize_with_layers (GimpImage *image,
|
||||
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_resize_with_layers (GimpImage *image,
|
||||
|
||||
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));
|
||||
|
||||
|
@ -61,6 +61,8 @@ gimp_image_rotate (GimpImage *image,
|
||||
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_image_rotate (GimpImage *image,
|
||||
|
||||
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 @@ gimp_image_rotate (GimpImage *image,
|
||||
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_rotate (GimpImage *image,
|
||||
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));
|
||||
|
||||
|
@ -90,7 +90,12 @@ gimp_image_scale (GimpImage *image,
|
||||
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 @@ gimp_image_scale (GimpImage *image,
|
||||
|
||||
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));
|
||||
|
||||
|
@ -82,7 +82,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 previous_height)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
@ -91,6 +93,8 @@ gimp_image_undo_push_image_size (GimpImage *image,
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,9 @@ GimpUndo * gimp_image_undo_push_image_type (GimpImage *image,
|
||||
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,
|
||||
|
@ -383,7 +383,9 @@ gimp_image_undo_pop_stack (GimpImage *image,
|
||||
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);
|
||||
|
@ -151,7 +151,9 @@ static gchar * gimp_image_get_description (GimpViewable *viewable,
|
||||
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 @@ gimp_image_class_init (GimpImageClass *klass)
|
||||
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 @@ gimp_image_get_description (GimpViewable *viewable,
|
||||
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 @@ gimp_image_set_resolution (GimpImage *image,
|
||||
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 @@ gimp_image_sample_point_removed (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)
|
||||
{
|
||||
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
|
||||
|
@ -193,7 +193,9 @@ struct _GimpImageClass
|
||||
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_selection_control (GimpImage *image,
|
||||
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 */
|
||||
|
@ -43,6 +43,8 @@ enum
|
||||
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 @@ gimp_image_undo_class_init (GimpImageUndoClass *klass)
|
||||
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 @@ gimp_image_undo_set_property (GObject *object,
|
||||
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 @@ gimp_image_undo_get_property (GObject *object,
|
||||
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 @@ gimp_image_undo_pop (GimpUndo *undo,
|
||||
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 @@ gimp_image_undo_pop (GimpUndo *undo,
|
||||
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;
|
||||
|
@ -42,6 +42,8 @@ struct _GimpImageUndo
|
||||
gint height;
|
||||
gint previous_origin_x;
|
||||
gint previous_origin_y;
|
||||
gint previous_width;
|
||||
gint previous_height;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
GimpUnit resolution_unit;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -70,6 +70,8 @@ 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);
|
||||
static void gimp_display_shell_resolution_changed_handler (GimpImage *image,
|
||||
GimpDisplayShell *shell);
|
||||
@ -484,10 +486,27 @@ gimp_display_shell_update_sample_point_handler (GimpImage *image,
|
||||
gimp_display_shell_expose_sample_point (shell, sample_point);
|
||||
}
|
||||
|
||||
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 @@ gimp_display_shell_size_changed_detailed_handler (GimpImage *image,
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user