GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 67bc1a6a authored by GMT 1999 Andy Thomas's avatar GMT 1999 Andy Thomas Committed by Andy Thomas

app/undo.h app/undo.c app/undo_history.c pixmaps/question.xpm


Tue Nov  2 22:50:31 GMT 1999 Andy Thomas <alt@gimp.org>

	* app/undo.h
	* app/undo.c
	* app/undo_history.c
	* pixmaps/question.xpm

	Fixed undo history so it shows a dummy image if the preview
	image has not already been generated. The actual image
	could probably do with an artists hand ;-)
	Also mask operations are shown as such in the previews.

	* app/lc_dialog.c

	Fixed rounding error in preview when width << height.

	* plug-ins/common/jpeg.c

	Always freeze the undo stack for any of the image export types.
	Anyone know why this was not the case to start with?
parent ebc892e7
Tue Nov 2 22:50:31 GMT 1999 Andy Thomas <alt@gimp.org>
* app/undo.h
* app/undo.c
* app/undo_history.c
* pixmaps/question.xpm
Fixed undo history so it shows a dummy image if the preview
image has not already been generated. The actual image
could probably do with an artists hand ;-)
Also mask operations are shown as such in the previews.
* app/lc_dialog.c
Fixed rounding error in preview when width << height.
* plug-ins/common/jpeg.c
Always freeze the undo stack for any of the image export types.
Anyone know why this was not the case to start with?
Tue Nov 2 22:40:31 MET 1999 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/script-fu-scripts.c: Fonts aren't free'd after
......
......@@ -492,6 +492,25 @@ undo_get_topitem_name (GSList *stack)
return undo_type_to_name (object->type);
}
/* Return the type of the top undo action */
static UndoType
undo_get_topitem_type (GSList *stack)
{
Undo *object;
if (!stack)
return 0;
object = stack->data;
/* For group boundaries, the type of the boundary marker is the
* type of the whole group (but each individual action in the
* group retains its own type so layer/channel unrefs work
* correctly). */
return object->type;
}
const char *
undo_get_undo_name (GImage *gimage)
......@@ -505,6 +524,18 @@ undo_get_undo_name (GImage *gimage)
return undo_get_topitem_name (gimage->undo_stack);
}
UndoType
undo_get_undo_top_type (GImage *gimage)
{
g_return_val_if_fail (gimage != NULL, 0);
/* don't want to encourage undo while a group is open */
if (gimage->pushing_undo_group != 0)
return 0;
return undo_get_topitem_type (gimage->undo_stack);
}
const char *
undo_get_redo_name (GImage *gimage)
......
......@@ -67,6 +67,7 @@ const char *undo_get_redo_name (GImage *);
typedef int (*undo_map_fn) (const char *undoitemname, void *data);
void undo_map_over_undo_stack (GImage *, undo_map_fn, void *data);
void undo_map_over_redo_stack (GImage *, undo_map_fn, void *data);
UndoType undo_get_undo_top_type (GImage *);
/* Not really appropriate here, since undo_history_new is not defined
......
......@@ -428,10 +428,12 @@ lc_dialog_fill_preview_with_thumb (GtkWidget *widget,
if (dwidth > dheight)
{
height = (width * dheight) / dwidth;
width = (dwidth * height) / dheight;
}
else
{
width = (height * dwidth) / dheight;
height = (dheight * width) / dwidth;
}
buf = gimp_image_construct_composite_preview (gimage, width, height);
......
......@@ -492,6 +492,25 @@ undo_get_topitem_name (GSList *stack)
return undo_type_to_name (object->type);
}
/* Return the type of the top undo action */
static UndoType
undo_get_topitem_type (GSList *stack)
{
Undo *object;
if (!stack)
return 0;
object = stack->data;
/* For group boundaries, the type of the boundary marker is the
* type of the whole group (but each individual action in the
* group retains its own type so layer/channel unrefs work
* correctly). */
return object->type;
}
const char *
undo_get_undo_name (GImage *gimage)
......@@ -505,6 +524,18 @@ undo_get_undo_name (GImage *gimage)
return undo_get_topitem_name (gimage->undo_stack);
}
UndoType
undo_get_undo_top_type (GImage *gimage)
{
g_return_val_if_fail (gimage != NULL, 0);
/* don't want to encourage undo while a group is open */
if (gimage->pushing_undo_group != 0)
return 0;
return undo_get_topitem_type (gimage->undo_stack);
}
const char *
undo_get_redo_name (GImage *gimage)
......
......@@ -67,6 +67,7 @@ const char *undo_get_redo_name (GImage *);
typedef int (*undo_map_fn) (const char *undoitemname, void *data);
void undo_map_over_undo_stack (GImage *, undo_map_fn, void *data);
void undo_map_over_redo_stack (GImage *, undo_map_fn, void *data);
UndoType undo_get_undo_top_type (GImage *);
/* Not really appropriate here, since undo_history_new is not defined
......
......@@ -46,6 +46,7 @@
#include "gimpui.h"
#include "temp_buf.h"
#include "undo.h"
#include "gimage_mask.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -53,6 +54,7 @@
#include "pixmaps/raise.xpm"
#include "pixmaps/lower.xpm"
#include "pixmaps/yes.xpm"
#include "pixmaps/question.xpm"
typedef struct
{
......@@ -135,17 +137,115 @@ static GdkBitmap *redo_mask = NULL;
static GdkPixmap *clean_pixmap = NULL;
static GdkBitmap *clean_mask = NULL;
static GdkPixmap *clear_pixmap = NULL;
static GdkBitmap *clear_mask = NULL;
/**************************************************************/
/* Local functions */
static MaskBuf *
mask_render_preview (GImage *gimage,
gint *pwidth,
gint *pheight)
{
Channel * mask;
MaskBuf * scaled_buf = NULL;
PixelRegion srcPR, destPR;
int subsample;
int width, height;
int scale;
mask = gimage_get_mask (gimage);
if ((drawable_width (GIMP_DRAWABLE(mask)) > *pwidth) ||
(drawable_height (GIMP_DRAWABLE(mask)) > *pheight))
{
if (((float) drawable_width (GIMP_DRAWABLE (mask)) / (float) *pwidth) >
((float) drawable_height (GIMP_DRAWABLE (mask)) / (float) *pheight))
{
width = *pwidth;
height = (drawable_height (GIMP_DRAWABLE (mask)) * (*pwidth)) / drawable_width (GIMP_DRAWABLE (mask));
}
else
{
width = (drawable_width (GIMP_DRAWABLE (mask)) * (*pheight)) / drawable_height (GIMP_DRAWABLE (mask));
height = *pheight;
}
scale = TRUE;
}
else
{
width = drawable_width (GIMP_DRAWABLE (mask));
height = drawable_height (GIMP_DRAWABLE (mask));
scale = FALSE;
}
/* if the mask is empty, no need to scale and update again */
if (gimage_mask_is_empty (gimage))
return NULL;
if (scale)
{
/* calculate 'acceptable' subsample */
subsample = 1;
while ((width * (subsample + 1) * 2 < drawable_width (GIMP_DRAWABLE (mask))) &&
(height * (subsample + 1) * 2 < drawable_height (GIMP_DRAWABLE (mask))))
subsample = subsample + 1;
pixel_region_init (&srcPR, drawable_data (GIMP_DRAWABLE (mask)),
0, 0,
drawable_width (GIMP_DRAWABLE (mask)),
drawable_height (GIMP_DRAWABLE (mask)), FALSE);
scaled_buf = mask_buf_new (width, height);
destPR.bytes = 1;
destPR.x = 0;
destPR.y = 0;
destPR.w = width;
destPR.h = height;
destPR.rowstride = srcPR.bytes * width;
destPR.data = mask_buf_data (scaled_buf);
destPR.tiles = NULL;
subsample_region (&srcPR, &destPR, subsample);
}
else
{
pixel_region_init (&srcPR, drawable_data (GIMP_DRAWABLE (mask)),
0, 0,
drawable_width (GIMP_DRAWABLE (mask)),
drawable_height (GIMP_DRAWABLE (mask)), FALSE);
scaled_buf = mask_buf_new (width, height);
destPR.bytes = 1;
destPR.x = 0;
destPR.y = 0;
destPR.w = width;
destPR.h = height;
destPR.rowstride = srcPR.bytes * width;
destPR.data = mask_buf_data (scaled_buf);
destPR.tiles = NULL;
copy_region (&srcPR, &destPR);
}
*pheight = height;
*pwidth = width;
return scaled_buf;
}
static gint
undo_history_set_pixmap_idle (gpointer data)
{
idle_preview_args *idle = data;
static GdkGC *gc = NULL;
TempBuf *buf;
TempBuf *buf = NULL;
GdkPixmap *pixmap;
UndoType utype;
MaskBuf *mbuf = NULL;
guchar *src;
gdouble r, g, b, a;
gdouble c0, c1;
......@@ -163,16 +263,28 @@ undo_history_set_pixmap_idle (gpointer data)
if (width > height)
{
height = (idle->size * height) / width;
width = idle->size;
width = (width * height )/ idle->gimage->height;
}
else
{
width = (idle->size * width) / height;
height = idle->size;
height = (height * width ) / idle->gimage->width;
}
buf = gimp_image_construct_composite_preview (idle->gimage, width, height);
bpp = buf->bytes;
utype = undo_get_undo_top_type(idle->gimage);
if((utype != MASK_UNDO && utype != QMASK_UNDO) ||
(mbuf = mask_render_preview(idle->gimage,&width,&height)) == NULL)
{
buf = gimp_image_construct_composite_preview (idle->gimage, width, height);
bpp = buf->bytes;
src = temp_buf_data (buf);
}
else
{
src = mask_buf_data (mbuf);
bpp = 1; /* Always the case for masks */
}
pixmap = gdk_pixmap_new (GTK_WIDGET (idle->clist)->window, width+2, height+2, -1);
......@@ -182,11 +294,9 @@ undo_history_set_pixmap_idle (gpointer data)
0, 0,
width + 2, height + 2);
src = temp_buf_data (buf);
even = g_malloc (width * 3);
odd = g_malloc (width * 3);
for (y = 0; y < height; y++)
{
p0 = even;
......@@ -260,8 +370,13 @@ undo_history_set_pixmap_idle (gpointer data)
g_free (even);
g_free (odd);
temp_buf_free (buf);
if(buf)
temp_buf_free (buf);
if(mbuf)
mask_buf_free (mbuf);
gtk_clist_set_row_data (idle->clist, idle->row, (gpointer)2);
gtk_clist_set_pixmap (idle->clist, idle->row, 0, pixmap, NULL);
gdk_pixmap_unref (pixmap);
......@@ -276,10 +391,8 @@ undo_history_set_pixmap (GtkCList *clist,
GImage *gimage)
{
static idle_preview_args idle;
GdkPixmap *pixmap;
GdkPixmap *mask;
if (!size || gtk_clist_get_pixmap (clist, row, 0, &pixmap, &mask))
if (!size || ((gint)gtk_clist_get_row_data (clist, row)) == 2)
return;
idle.clist = clist;
......@@ -574,6 +687,8 @@ undo_history_init_undo (const char *undoitemname,
namelist[1] = NULL;
namelist[2] = (char *) undoitemname;
row = gtk_clist_prepend (GTK_CLIST (st->clist), namelist);
gtk_clist_set_pixmap (GTK_CLIST (st->clist), row, 0,
clear_pixmap, clear_mask);
return 0;
}
......@@ -590,6 +705,8 @@ undo_history_init_redo (const char *undoitemname,
namelist[0] = NULL; namelist[1] = NULL;
namelist[2] = (char *) undoitemname;
row = gtk_clist_append (GTK_CLIST (st->clist), namelist);
gtk_clist_set_pixmap (GTK_CLIST (st->clist), row, 0,
clear_pixmap, clear_mask);
return 0;
}
......@@ -692,6 +809,12 @@ undo_history_new (GImage *gimage)
&clean_mask,
&style->bg[GTK_STATE_NORMAL],
yes_xpm);
clear_pixmap =
gdk_pixmap_create_from_xpm_d (st->shell->window,
&clear_mask,
&style->bg[GTK_STATE_NORMAL],
question_xpm);
}
/* work out the initial contents */
......
......@@ -469,14 +469,12 @@ run (char *name,
}
#endif /* GIMP_HAVE_PARASITES */
if (!export)
{
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
}
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
/* prepare for the preview */
image_ID_global = image_ID;
orig_image_ID_global = orig_image_ID;
......@@ -485,12 +483,9 @@ run (char *name,
/* First acquire information with a dialog */
err = save_dialog ();
if (export != EXPORT_EXPORT)
{
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
}
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
if (!err)
return;
......
......@@ -469,14 +469,12 @@ run (char *name,
}
#endif /* GIMP_HAVE_PARASITES */
if (!export)
{
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
}
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
/* prepare for the preview */
image_ID_global = image_ID;
orig_image_ID_global = orig_image_ID;
......@@ -485,12 +483,9 @@ run (char *name,
/* First acquire information with a dialog */
err = save_dialog ();
if (export != EXPORT_EXPORT)
{
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
}
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
if (!err)
return;
......
......@@ -469,14 +469,12 @@ run (char *name,
}
#endif /* GIMP_HAVE_PARASITES */
if (!export)
{
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
}
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
/* prepare for the preview */
image_ID_global = image_ID;
orig_image_ID_global = orig_image_ID;
......@@ -485,12 +483,9 @@ run (char *name,
/* First acquire information with a dialog */
err = save_dialog ();
if (export != EXPORT_EXPORT)
{
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
}
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
if (!err)
return;
......
......@@ -469,14 +469,12 @@ run (char *name,
}
#endif /* GIMP_HAVE_PARASITES */
if (!export)
{
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
}
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
/* prepare for the preview */
image_ID_global = image_ID;
orig_image_ID_global = orig_image_ID;
......@@ -485,12 +483,9 @@ run (char *name,
/* First acquire information with a dialog */
err = save_dialog ();
if (export != EXPORT_EXPORT)
{
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
}
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
if (!err)
return;
......
......@@ -469,14 +469,12 @@ run (char *name,
}
#endif /* GIMP_HAVE_PARASITES */
if (!export)
{
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
}
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
/* prepare for the preview */
image_ID_global = image_ID;
orig_image_ID_global = orig_image_ID;
......@@ -485,12 +483,9 @@ run (char *name,
/* First acquire information with a dialog */
err = save_dialog ();
if (export != EXPORT_EXPORT)
{
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
}
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
if (!err)
return;
......
......@@ -469,14 +469,12 @@ run (char *name,
}
#endif /* GIMP_HAVE_PARASITES */
if (!export)
{
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
}
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
/* prepare for the preview */
image_ID_global = image_ID;
orig_image_ID_global = orig_image_ID;
......@@ -485,12 +483,9 @@ run (char *name,
/* First acquire information with a dialog */
err = save_dialog ();
if (export != EXPORT_EXPORT)
{
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
}
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
if (!err)
return;
......
......@@ -469,14 +469,12 @@ run (char *name,
}
#endif /* GIMP_HAVE_PARASITES */
if (!export)
{
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
}
/* we start an undo_group and immediately freeze undo saving
so that we can avoid sucking up tile cache with our unneeded
preview steps. */
gimp_undo_push_group_start (image_ID);
gimp_image_undo_freeze (image_ID);
/* prepare for the preview */
image_ID_global = image_ID;
orig_image_ID_global = orig_image_ID;
......@@ -485,12 +483,9 @@ run (char *name,
/* First acquire information with a dialog */
err = save_dialog ();
if (export != EXPORT_EXPORT)
{
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
}
/* thaw undo saving and end the undo_group. */
gimp_image_undo_thaw (image_ID);
gimp_undo_push_group_end (image_ID);
if (!err)
return;
......
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