Commit fce4ad63 authored by Sven Neumann's avatar Sven Neumann
Browse files

a whole lotta guide fixes


--Sven
parent 08529ff5
Thu Oct 14 01:00:03 MEST 1999 Sven Neumann <sven@gimp.org>
* app/gdisplay.c
* app/gimage.c
* app/gimpimage.c
* app/guides_cmds.c
* app/move.c
* app/undo.c
* app/undo_types.h
* app/xcf.c
* tools/pdbgen/pdb/guides.pdb: a whole lotta guide fixes:
Guides are now freed on image close; undo should work in all
cases; resize and scale use undo_groups so all operations are
undoable in one step; some display probs fixed.
* plug-ins/common/rotate.c: when rotating an image, rotate
the guides too.
This should fix bug #2608.
Wed Oct 13 21:37:51 BST 1999 Andy Thomas <alt@gimp.org>
 
* app/crop.c
......
......@@ -1259,7 +1259,9 @@ image_scale_callback (GtkWidget *widget,
{
ImageResize * image_scale;
GImage * gimage;
gboolean flush = FALSE;
gboolean flush = FALSE; /* this is a bit ugly:
we hijack the flush variable to check if
an undo_group was already started */
image_scale = (ImageResize *) client_data;
......@@ -1268,6 +1270,8 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
......@@ -1276,8 +1280,13 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->unit != gimage->unit)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
......@@ -1286,6 +1295,9 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
......@@ -1300,7 +1312,10 @@ image_scale_callback (GtkWidget *widget,
}
if (flush)
gdisplays_flush ();
{
undo_push_group_end (gimage);
gdisplays_flush ();
}
}
resize_widget_free (image_scale->resize);
......
......@@ -1259,7 +1259,9 @@ image_scale_callback (GtkWidget *widget,
{
ImageResize * image_scale;
GImage * gimage;
gboolean flush = FALSE;
gboolean flush = FALSE; /* this is a bit ugly:
we hijack the flush variable to check if
an undo_group was already started */
image_scale = (ImageResize *) client_data;
......@@ -1268,6 +1270,8 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->resolution_x != gimage->xresolution ||
image_scale->resize->resolution_y != gimage->yresolution)
{
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_resolution (gimage,
image_scale->resize->resolution_x,
image_scale->resize->resolution_y);
......@@ -1276,8 +1280,13 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->unit != gimage->unit)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_set_unit (gimage, image_scale->resize->unit);
gdisplays_resize_cursor_label (gimage);
flush = TRUE;
}
if (image_scale->resize->width != gimage->width ||
......@@ -1286,6 +1295,9 @@ image_scale_callback (GtkWidget *widget,
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)
{
if (!flush)
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
gimage_scale (gimage,
image_scale->resize->width,
image_scale->resize->height);
......@@ -1300,7 +1312,10 @@ image_scale_callback (GtkWidget *widget,
}
if (flush)
gdisplays_flush ();
{
undo_push_group_end (gimage);
gdisplays_flush ();
}
}
resize_widget_free (image_scale->resize);
......
......@@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
......@@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
......@@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)
......
......@@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
......@@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
......@@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)
......
......@@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
......@@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
......@@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)
......
......@@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
......@@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
......@@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)
......
......@@ -423,7 +423,7 @@ gimp_image_resize (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_RESIZE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -458,11 +458,13 @@ gimp_image_resize (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position += offset_y;
if (guide->position < 0 || guide->position > new_height)
gimp_image_delete_guide (gimage, guide);
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position += offset_x;
if (guide->position < 0 || guide->position > new_width)
gimp_image_delete_guide (gimage, guide);
......@@ -529,7 +531,7 @@ gimp_image_scale (GimpImage *gimage,
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
undo_push_group_start (gimage, GIMAGE_MOD_UNDO);
undo_push_group_start (gimage, IMAGE_SCALE_UNDO);
/* Relax the floating selection */
if (floating_layer)
......@@ -581,9 +583,11 @@ gimp_image_scale (GimpImage *gimage,
switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_height) / old_height;
break;
case ORIENTATION_VERTICAL:
undo_push_guide (gimage, guide);
guide->position = (guide->position * new_width) / old_width;
break;
default:
......@@ -1064,10 +1068,16 @@ void
gimp_image_delete_guide (GimpImage *gimage,
Guide *guide)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
guide->position = -1;
if (guide->ref_count <= 0)
{
gimage->guides = g_list_remove (gimage->guides, guide);
g_free (guide);
}
}
Parasite *
gimp_image_find_parasite (const GimpImage *gimage,
const gchar *name)
......
......@@ -130,12 +130,12 @@ static void undo_free_cantundo (UndoState, UndoType, void *);
/* Sizing functions */
static int layer_size (Layer *);
static int channel_size (Channel *);
static int layer_size (Layer *);
static int channel_size (Channel *);
static const char *undo_type_to_name (UndoType);
static const char * undo_type_to_name (UndoType);
static Undo * undo_new (UndoType, long, gboolean);
static Undo * undo_new (UndoType, long, gboolean);
static int shrink_wrap = FALSE;
......@@ -170,7 +170,7 @@ channel_size (Channel *channel)
static void
undo_free_list (GImage *gimage,
UndoState state,
UndoState state,
GSList *list)
{
GSList * orig;
......@@ -248,7 +248,9 @@ remove_stack_bottom (GImage *gimage)
/* Allocate and initialise a new Undo. Leaves data and function
* pointers zeroed ready to be filled in by caller. */
static Undo *
undo_new (UndoType type, long size, gboolean dirties_image)
undo_new (UndoType type,
long size,
gboolean dirties_image)
{
Undo *new;
......@@ -283,7 +285,7 @@ undo_free_up_space (GImage *gimage)
static Undo *
undo_push (GImage *gimage,
long size,
UndoType type,
UndoType type,
gboolean dirties_image)
{
Undo * new;
......@@ -340,7 +342,7 @@ static int
pop_stack (GImage *gimage,
GSList **stack_ptr,
GSList **unstack_ptr,
UndoState state)
UndoState state)
{
Undo * object;
GSList *stack;
......@@ -520,7 +522,9 @@ undo_get_redo_name (GImage *gimage)
static void
undo_map_over_stack (GSList *stack, undo_map_fn fn, void *data)
undo_map_over_stack (GSList *stack,
undo_map_fn fn,
void *data)
{
int in_group = 0;
int count = 0;
......@@ -552,7 +556,9 @@ undo_map_over_stack (GSList *stack, undo_map_fn fn, void *data)
}
void
undo_map_over_undo_stack (GImage *gimage, undo_map_fn fn, void *data)
undo_map_over_undo_stack (GImage *gimage,
undo_map_fn fn,
void *data)
{
/* shouldn't have group open */
g_return_if_fail (gimage->pushing_undo_group == 0);
......@@ -560,7 +566,9 @@ undo_map_over_undo_stack (GImage *gimage, undo_map_fn fn, void *data)
}
void
undo_map_over_redo_stack (GImage *gimage, undo_map_fn fn, void *data)
undo_map_over_redo_stack (GImage *gimage,
undo_map_fn fn,
void *data)
{
/* shouldn't have group open */
g_return_if_fail (gimage->pushing_undo_group == 0);
......@@ -569,7 +577,6 @@ undo_map_over_redo_stack (GImage *gimage, undo_map_fn fn, void *data)
void
undo_free (GImage *gimage)
{
......@@ -601,7 +608,7 @@ undo_free (GImage *gimage)
int
undo_push_group_start (GImage *gimage,
UndoType type)
UndoType type)
{
Undo *boundary_marker;
......@@ -803,8 +810,8 @@ undo_push_image_mod (GImage *gimage,
static int
undo_pop_image (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *image_undo_ptr)
{
ImageUndo *image_undo;
......@@ -876,7 +883,7 @@ undo_pop_image (GImage *gimage,
static void
undo_free_image (UndoState state,
UndoType type,
void *image_undo_ptr)
void *image_undo_ptr)
{
ImageUndo *image_undo;
......@@ -924,8 +931,8 @@ undo_push_mask (GImage *gimage,
static int
undo_pop_mask (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *mask_ptr)
{
MaskUndo *mask_undo;
......@@ -1009,8 +1016,8 @@ undo_pop_mask (GImage *gimage,
static void
undo_free_mask (UndoState state,
UndoType type,
undo_free_mask (UndoState state,
UndoType type,
void *mask_ptr)
{
MaskUndo *mask_undo;
......@@ -1052,8 +1059,8 @@ undo_push_layer_displace (GImage *gimage,
static int
undo_pop_layer_displace (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *info_ptr)
{
Layer * layer;
......@@ -1100,8 +1107,8 @@ undo_pop_layer_displace (GImage *gimage,
static void
undo_free_layer_displace (UndoState state,
UndoType type,
undo_free_layer_displace (UndoState state,
UndoType type,
void *info_ptr)
{
g_free (info_ptr);
......@@ -1138,8 +1145,8 @@ undo_push_transform (GImage *gimage,
static int
undo_pop_transform (GImage *gimage,
UndoState state,
UndoType type,
UndoState state,
UndoType type,
void *tu_ptr)
{
TransformCore * tc;
......@@ -1187,8 +1194,8 @@ undo_pop_transform (GImage *gimage,
static void
undo_free_transform (UndoState state,
UndoType type,
undo_free_transform (UndoState state,
UndoType type,