Commit b101e7bc authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

enabled the (commented out) signal "invalidate_preview".

2000-05-12  Sven Neumann  <sven@gimp.org>

* gimpdrawable.c: enabled the (commented out) signal
  "invalidate_preview".

* app/layers_dialog.c: connect to the "invalidate_preview"
  signal to catch changes that need to be shown in the layer
  previews. Synthetize an expose event when a layer changes.

  Expose events are optimzed away by GTK+ if the widget is not
  visible. Therefore, previews not visible in the layers_dialog
  are not redrawn when they invalidate. Later the preview gets
  validated by the image_preview in lc_dialog but is never
  propagated to the layer_pixmap. We work around this by using an
  additional flag "layer_pixmap_valid" so that the pixmap gets
  updated once the preview scrolls into sight.

  Fixes bugs #10549, #10300 and #8787.

* app/channel.[ch]
* app/layer.[ch]: code review and indentation


--Sven
parent 5b98ce93
2000-05-12 Sven Neumann <sven@gimp.org>
* gimpdrawable.c: enabled the (commented out) signal
"invalidate_preview".
* app/layers_dialog.c: connect to the "invalidate_preview"
signal to catch changes that need to be shown in the layer
previews. Synthetize an expose event when a layer changes.
Expose events are optimzed away by GTK+ if the widget is not
visible. Therefore, previews not visible in the layers_dialog
are not redrawn when they invalidate. Later the preview gets
validated by the image_preview in lc_dialog but is never
propagated to the layer_pixmap. We work around this by using an
additional flag "layer_pixmap_valid" so that the pixmap gets
updated once the preview scrolls into sight.
We should probably do the same for all drawables (masks,
channels), but it is much more difficult to change one of these
when it's not visible.
In other words: This is an awful hack but otherwise I would have
had to rewrite it all....
Fixes bugs #10549, #10300 and #8787.
* app/channel.[ch]
* app/layer.[ch]: code review and indentation
2000-05-12 Michael Natterer <mitch@gimp.org> 2000-05-12 Michael Natterer <mitch@gimp.org>
* libgimp/gimp.c (gimp_plugin_io_error_handler): fixed a * libgimp/gimp.c (gimp_plugin_io_error_handler): fixed a
......
...@@ -238,7 +238,7 @@ channel_get_name (Channel *channel) ...@@ -238,7 +238,7 @@ channel_get_name (Channel *channel)
void void
channel_set_color (Channel *channel, channel_set_color (Channel *channel,
guchar *color) guchar *color)
{ {
gint i; gint i;
...@@ -315,7 +315,7 @@ gimp_channel_destroy (GtkObject *object) ...@@ -315,7 +315,7 @@ gimp_channel_destroy (GtkObject *object)
* particular layer. */ * particular layer. */
void void
channel_removed (Channel *channel, channel_removed (Channel *channel,
gpointer image) gpointer data)
{ {
g_return_if_fail (channel != NULL); g_return_if_fail (channel != NULL);
g_return_if_fail (GIMP_IS_CHANNEL (channel)); g_return_if_fail (GIMP_IS_CHANNEL (channel));
...@@ -592,9 +592,10 @@ channel_get_tattoo (const Channel *channel) ...@@ -592,9 +592,10 @@ channel_get_tattoo (const Channel *channel)
} }
void void
channel_set_tattoo (const Channel *channel, Tattoo val) channel_set_tattoo (const Channel *channel,
Tattoo value)
{ {
gimp_drawable_set_tattoo(GIMP_DRAWABLE (channel),val); gimp_drawable_set_tattoo (GIMP_DRAWABLE (channel), value);
} }
/******************************/ /******************************/
...@@ -602,7 +603,7 @@ channel_set_tattoo (const Channel *channel, Tattoo val) ...@@ -602,7 +603,7 @@ channel_set_tattoo (const Channel *channel, Tattoo val)
/******************************/ /******************************/
Channel * Channel *
channel_new_mask (GimpImage* gimage, channel_new_mask (GimpImage *gimage,
gint width, gint width,
gint height) gint height)
{ {
...@@ -731,9 +732,9 @@ channel_bounds (Channel *mask, ...@@ -731,9 +732,9 @@ channel_bounds (Channel *mask,
guchar *data, *data1; guchar *data, *data1;
gint x, y; gint x, y;
gint ex, ey; gint ex, ey;
void *pr;
gint tx1, tx2, ty1, ty2; gint tx1, tx2, ty1, ty2;
gint minx, maxx; gint minx, maxx;
gpointer pr;
/* if the mask's bounds have already been reliably calculated... */ /* if the mask's bounds have already been reliably calculated... */
if (mask->bounds_known) if (mask->bounds_known)
...@@ -840,7 +841,7 @@ channel_is_empty (Channel *mask) ...@@ -840,7 +841,7 @@ channel_is_empty (Channel *mask)
PixelRegion maskPR; PixelRegion maskPR;
guchar * data; guchar * data;
gint x, y; gint x, y;
void * pr; gpointer pr;
if (mask->bounds_known) if (mask->bounds_known)
return mask->empty; return mask->empty;
...@@ -896,7 +897,7 @@ channel_add_segment (Channel *mask, ...@@ -896,7 +897,7 @@ channel_add_segment (Channel *mask,
guchar *data; guchar *data;
gint val; gint val;
gint x2; gint x2;
void * pr; gpointer pr;
/* check horizontal extents... */ /* check horizontal extents... */
x2 = x + width; x2 = x + width;
...@@ -939,7 +940,7 @@ channel_sub_segment (Channel *mask, ...@@ -939,7 +940,7 @@ channel_sub_segment (Channel *mask,
guchar *data; guchar *data;
gint val; gint val;
gint x2; gint x2;
void * pr; gpointer pr;
/* check horizontal extents... */ /* check horizontal extents... */
x2 = x + width; x2 = x + width;
...@@ -1037,7 +1038,7 @@ channel_combine_ellipse (Channel *mask, ...@@ -1037,7 +1038,7 @@ channel_combine_ellipse (Channel *mask,
gint y, gint y,
gint w, gint w,
gint h, gint h,
gboolean aa /* antialias selection? */) gboolean antialias)
{ {
gint i, j; gint i, j;
gint x0, x1, x2; gint x0, x1, x2;
...@@ -1066,7 +1067,7 @@ channel_combine_ellipse (Channel *mask, ...@@ -1066,7 +1067,7 @@ channel_combine_ellipse (Channel *mask,
if (i >= 0 && i < GIMP_DRAWABLE (mask)->height) if (i >= 0 && i < GIMP_DRAWABLE (mask)->height)
{ {
/* Non-antialiased code */ /* Non-antialiased code */
if (!aa) if (!antialias)
{ {
y_sqr = (i + 0.5 - cy) * (i + 0.5 - cy); y_sqr = (i + 0.5 - cy) * (i + 0.5 - cy);
rad = sqrt (a_sqr - a_sqr * y_sqr / (double) b_sqr); rad = sqrt (a_sqr - a_sqr * y_sqr / (double) b_sqr);
...@@ -1754,3 +1755,4 @@ channel_invalidate_bounds (Channel *channel) ...@@ -1754,3 +1755,4 @@ channel_invalidate_bounds (Channel *channel)
{ {
channel->bounds_known = FALSE; channel->bounds_known = FALSE;
} }
...@@ -71,80 +71,138 @@ struct _MaskUndo ...@@ -71,80 +71,138 @@ struct _MaskUndo
/* function declarations */ /* function declarations */
Channel * channel_new (GimpImage*, Channel * channel_new (GimpImage *gimage,
gint, gint, gchar *, gint, guchar *); gint width,
Channel * channel_copy (Channel *); gint height,
Channel * channel_ref (Channel *); gchar *name,
void channel_unref (Channel *); gint opacity,
guchar *col);
gchar * channel_get_name (Channel *); Channel * channel_copy (Channel *channel);
void channel_set_name (Channel *, gchar *); Channel * channel_ref (Channel *channel);
void channel_unref (Channel *channel);
gint channel_get_opacity (Channel *);
void channel_set_opacity (Channel *, gint); gchar * channel_get_name (Channel *channel);
void channel_set_name (Channel *channel,
guchar * channel_get_color (Channel *); gchar *name);
void channel_set_color (Channel *, guchar *);
gint channel_get_opacity (Channel *channel);
Channel * channel_get_ID (gint); void channel_set_opacity (Channel *channel,
void channel_delete (Channel *); gint opacity);
void channel_removed (Channel *, gpointer);
void channel_scale (Channel *, gint, gint); guchar * channel_get_color (Channel *channel);
void channel_resize (Channel *, gint, gint, gint, gint); void channel_set_color (Channel *channel,
void channel_update (Channel *); guchar *color);
Channel * channel_get_ID (gint ID);
void channel_delete (Channel *channel);
void channel_removed (Channel *channel,
gpointer data);
void channel_scale (Channel *channel,
gint new_width,
gint new_height);
void channel_resize (Channel *channel,
gint new_width,
gint new_height,
gint offx,
gint offy);
void channel_update (Channel *channel);
/* access functions */ /* access functions */
gboolean channel_toggle_visibility (Channel *); gboolean channel_toggle_visibility (Channel *channel);
TempBuf * channel_preview (Channel *, gint, gint); TempBuf * channel_preview (Channel *channel,
gint width,
gint height);
void channel_invalidate_previews (GimpImage *gimage);
void channel_invalidate_previews (GimpImage*); Tattoo channel_get_tattoo (const Channel *channel);
Tattoo channel_get_tattoo (const Channel *); void channel_set_tattoo (const Channel *channel,
void channel_set_tattoo (const Channel *,Tattoo); Tattoo value);
/* selection mask functions */ /* selection mask functions */
Channel * channel_new_mask (GimpImage *, gint, gint); Channel * channel_new_mask (GimpImage *gimage,
gboolean channel_boundary (Channel *, BoundSeg **, BoundSeg **, gint width,
gint *, gint *, gint, gint, gint, gint); gint height);
gboolean channel_bounds (Channel *, gboolean channel_boundary (Channel *mask,
gint *, gint *, gint *, gint *); BoundSeg **segs_in,
gint channel_value (Channel *, gint, gint); BoundSeg **segs_out,
gboolean channel_is_empty (Channel *); gint *num_segs_in,
void channel_add_segment (Channel *, gint, gint, gint, gint); gint *num_segs_out,
void channel_sub_segment (Channel *, gint, gint, gint, gint); gint x1,
void channel_inter_segment (Channel *, gint, gint, gint, gint); gint y1,
void channel_combine_rect (Channel *, gint x2,
ChannelOps, gint, gint, gint, gint); gint y2);
void channel_combine_ellipse (Channel *, gboolean channel_bounds (Channel *mask,
ChannelOps, gint *x1,
gint, gint, gint, gint, gboolean); gint *y1,
void channel_combine_mask (Channel *, Channel *, gint *x2,
ChannelOps, gint, gint); gint *y2);
void channel_feather (Channel *, Channel *, gint channel_value (Channel *mask,
gdouble, gdouble, gint x,
ChannelOps, gint, gint); gint y);
void channel_push_undo (Channel *); gboolean channel_is_empty (Channel *mask);
void channel_clear (Channel *); void channel_add_segment (Channel *mask,
void channel_invert (Channel *); gint x,
void channel_sharpen (Channel *); gint y,
void channel_all (Channel *); gint width,
gint value);
void channel_border (Channel * channel, void channel_sub_segment (Channel *mask,
gint radius_x, gint x,
gint radius_y); gint y,
void channel_grow (Channel * channel, gint width,
gint radius_x, gint value);
gint radius_y); void channel_combine_rect (Channel *mask,
void channel_shrink (Channel * channel, ChannelOps op,
gint radius_x, gint x,
gint radius_y, gint y,
gboolean edge_lock); gint w,
gint h);
void channel_translate (Channel *, gint, gint); void channel_combine_ellipse (Channel *mask,
void channel_load (Channel *, Channel *); ChannelOps op,
gint x,
void channel_invalidate_bounds (Channel *); gint y,
gint w,
gint h,
gboolean antialias);
void channel_combine_mask (Channel *mask,
Channel *add_on,
ChannelOps op,
gint off_x,
gint off_y);
void channel_feather (Channel *input,
Channel *output,
gdouble radius_x,
gdouble radius_y,
ChannelOps op,
gint off_x,
gint off_y);
void channel_push_undo (Channel *mask);
void channel_clear (Channel *mask);
void channel_invert (Channel *mask);
void channel_sharpen (Channel *mask);
void channel_all (Channel *mask);
void channel_border (Channel *mask,
gint radius_x,
gint radius_y);
void channel_grow (Channel *mask,
gint radius_x,
gint radius_y);
void channel_shrink (Channel *mask,
gint radius_x,
gint radius_y,
gboolean edge_lock);
void channel_translate (Channel *mask,
gint off_x,
gint off_y);
void channel_load (Channel *mask,
Channel *channel);
void channel_invalidate_bounds (Channel *channel);
#define drawable_channel GIMP_IS_CHANNEL #define drawable_channel GIMP_IS_CHANNEL
......
...@@ -238,7 +238,7 @@ channel_get_name (Channel *channel) ...@@ -238,7 +238,7 @@ channel_get_name (Channel *channel)
void void
channel_set_color (Channel *channel, channel_set_color (Channel *channel,
guchar *color) guchar *color)
{ {
gint i; gint i;
...@@ -315,7 +315,7 @@ gimp_channel_destroy (GtkObject *object) ...@@ -315,7 +315,7 @@ gimp_channel_destroy (GtkObject *object)
* particular layer. */ * particular layer. */
void void
channel_removed (Channel *channel, channel_removed (Channel *channel,
gpointer image) gpointer data)
{ {
g_return_if_fail (channel != NULL); g_return_if_fail (channel != NULL);
g_return_if_fail (GIMP_IS_CHANNEL (channel)); g_return_if_fail (GIMP_IS_CHANNEL (channel));
...@@ -592,9 +592,10 @@ channel_get_tattoo (const Channel *channel) ...@@ -592,9 +592,10 @@ channel_get_tattoo (const Channel *channel)
} }
void void
channel_set_tattoo (const Channel *channel, Tattoo val) channel_set_tattoo (const Channel *channel,
Tattoo value)
{ {
gimp_drawable_set_tattoo(GIMP_DRAWABLE (channel),val); gimp_drawable_set_tattoo (GIMP_DRAWABLE (channel), value);
} }
/******************************/ /******************************/
...@@ -602,7 +603,7 @@ channel_set_tattoo (const Channel *channel, Tattoo val) ...@@ -602,7 +603,7 @@ channel_set_tattoo (const Channel *channel, Tattoo val)
/******************************/ /******************************/
Channel * Channel *
channel_new_mask (GimpImage* gimage, channel_new_mask (GimpImage *gimage,
gint width, gint width,
gint height) gint height)
{ {
...@@ -731,9 +732,9 @@ channel_bounds (Channel *mask, ...@@ -731,9 +732,9 @@ channel_bounds (Channel *mask,
guchar *data, *data1; guchar *data, *data1;
gint x, y; gint x, y;
gint ex, ey; gint ex, ey;
void *pr;
gint tx1, tx2, ty1, ty2; gint tx1, tx2, ty1, ty2;
gint minx, maxx; gint minx, maxx;
gpointer pr;
/* if the mask's bounds have already been reliably calculated... */ /* if the mask's bounds have already been reliably calculated... */
if (mask->bounds_known) if (mask->bounds_known)
...@@ -840,7 +841,7 @@ channel_is_empty (Channel *mask) ...@@ -840,7 +841,7 @@ channel_is_empty (Channel *mask)
PixelRegion maskPR; PixelRegion maskPR;
guchar * data; guchar * data;
gint x, y; gint x, y;
void * pr; gpointer pr;
if (mask->bounds_known) if (mask->bounds_known)
return mask->empty; return mask->empty;
...@@ -896,7 +897,7 @@ channel_add_segment (Channel *mask, ...@@ -896,7 +897,7 @@ channel_add_segment (Channel *mask,
guchar *data; guchar *data;
gint val; gint val;
gint x2; gint x2;
void * pr; gpointer pr;
/* check horizontal extents... */ /* check horizontal extents... */
x2 = x + width; x2 = x + width;
...@@ -939,7 +940,7 @@ channel_sub_segment (Channel *mask, ...@@ -939,7 +940,7 @@ channel_sub_segment (Channel *mask,
guchar *data; guchar *data;
gint val; gint val;
gint x2; gint x2;
void * pr; gpointer pr;
/* check horizontal extents... */ /* check horizontal extents... */
x2 = x + width; x2 = x + width;
...@@ -1037,7 +1038,7 @@ channel_combine_ellipse (Channel *mask, ...@@ -1037,7 +1038,7 @@ channel_combine_ellipse (Channel *mask,
gint y, gint y,
gint w, gint w,
gint h, gint h,
gboolean aa /* antialias selection? */) gboolean antialias)
{ {
gint i, j; gint i, j;
gint x0, x1, x2; gint x0, x1, x2;
...@@ -1066,7 +1067,7 @@ channel_combine_ellipse (Channel *mask, ...@@ -1066,7 +1067,7 @@ channel_combine_ellipse (Channel *mask,
if (i >= 0 && i < GIMP_DRAWABLE (mask)->height) if (i >= 0 && i < GIMP_DRAWABLE (mask)->height)
{ {
/* Non-antialiased code */ /* Non-antialiased code */
if (!aa) if (!antialias)
{ {
y_sqr = (i + 0.5 - cy) * (i + 0.5 - cy); y_sqr = (i + 0.5 - cy) * (i + 0.5 - cy);
rad = sqrt (a_sqr - a_sqr * y_sqr / (double) b_sqr); rad = sqrt (a_sqr - a_sqr * y_sqr / (double) b_sqr);
...@@ -1754,3 +1755,4 @@ channel_invalidate_bounds (Channel *channel) ...@@ -1754,3 +1755,4 @@ channel_invalidate_bounds (Channel *channel)
{ {
channel->bounds_known = FALSE; channel->bounds_known = FALSE;
} }
...@@ -71,80 +71,138 @@ struct _MaskUndo ...@@ -71,80 +71,138 @@ struct _MaskUndo
/* function declarations */ /* function declarations */
Channel * channel_new (GimpImage*, Channel * channel_new (GimpImage *gimage,
gint, gint, gchar *, gint, guchar *); gint width,
Channel * channel_copy (Channel *); gint height,
Channel * channel_ref (Channel *); gchar *name,
void channel_unref (Channel *); gint opacity,
guchar *col);
gchar * channel_get_name (Channel *); Channel * channel_copy (Channel *channel);
void channel_set_name (Channel *, gchar *); Channel * channel_ref (Channel *channel);
void channel_unref (Channel *channel);
gint channel_get_opacity (Channel *);
void channel_set_opacity (Channel *, gint); gchar * channel_get_name (Channel *channel);
void channel_set_name (Channel *channel,
guchar * channel_get_color (Channel *); gchar *name);
void channel_set_color (Channel *, guchar *);
gint channel_get_opacity (Channel *channel);
Channel * channel_get_ID (gint); void channel_set_opacity (Channel *channel,
void channel_delete (Channel *); gint opacity);
void channel_removed (Channel *, gpointer);
void channel_scale (Channel *, gint, gint); guchar * channel_get_color (Channel *channel);
void channel_resize (Channel *, gint, gint, gint, gint); void channel_set_color (Channel *channel,
void channel_update (Channel *); guchar *color);
Channel * channel_get_ID (gint ID);
void channel_delete (Channel *channel);
void channel_removed (Channel *channel,
gpointer data);
void channel_scale (Channel *channel,
gint new_width,
gint new_height);
void channel_resize (Channel *channel,
gint new_width,
gint new_height,
gint offx,
gint offy);
void channel_update (Channel *channel);
/* access functions */ /* access functions */
gboolean channel_toggle_visibility (Channel *); gboolean channel_toggle_visibility (Channel *channel);
TempBuf * channel_preview (Channel *, gint, gint); TempBuf * channel_preview (Channel *channel,
gint width,
gint height);
void channel_invalidate_previews (GimpImage *gimage);
void channel_invalidate_previews (GimpImage*); Tattoo channel_get_tattoo (const Channel *channel);
Tattoo channel_get_tattoo (const Channel *); void channel_set_tattoo (const Channel *channel,
void channel_set_tattoo (const Channel *,Tattoo); Tattoo value);
/* selection mask functions */ /* selection mask functions */
Channel * channel_new_mask (GimpImage *, gint, gint); Channel * channel_new_mask (GimpImage *gimage,
gboolean channel_boundary (Channel *, BoundSeg **, BoundSeg **, gint width,
gint *, gint *, gint, gint, gint, gint); gint height);
gboolean channel_bounds (Channel *, gboolean channel_boundary (Channel *mask,
gint *, gint *, gint *, gint *); BoundSeg **segs_in,
gint channel_value (Channel *, gint, gint); BoundSeg **segs_out,
gboolean channel_is_empty (Channel *); gint *num_segs_in,
void channel_add_segment (Channel *, gint, gint, gint, gint); gint *num_segs_out,
void channel_sub_segment (Channel *, gint, gint, gint, gint); gint x1,
void channel_inter_segment (Channel *, gint, gint, gint, gint); gint y1,
void channel_combine_rect (Channel *, gint x2,
ChannelOps, gint, gint, gint, gint); gint y2);
void channel_combine_ellipse (Channel *, gboolean channel_bounds (Channel *mask,
ChannelOps, gint *x1,
gint, gint, gint, gint, gboolean); gint *y1,
void channel_combine_mask (Channel *, Channel *, gint *x2,
ChannelOps, gint, gint); gint *y2);
void channel_feather (Channel *, Channel *, gint channel_value (Channel *mask,
gdouble, gdouble, gint x,
ChannelOps, gint, gint); gint y);
void channel_push_undo (Channel *); gboolean channel_is_empty (Channel *mask);
void channel_clear (Channel *); void channel_add_segment (Channel *mask,
void channel_invert (Channel *); gint x,
void channel_sharpen (Channel *); gint y,
void channel_all (Channel *); gint width,
gint value);
void channel_border (Channel * channel, void channel_sub_segment (Channel *mask,
gint radius_x, gint x,
gint radius_y); gint y,
void channel_grow (Channel * channel, gint width,
gint radius_x, gint value);
gint radius_y); void channel_combine_rect (Channel *mask,
void channel_shrink (Channel * channel, ChannelOps op,
gint radius_x, gint x,
gint radius_y, gint y,
gboolean edge_lock); gint w,
gint h);
void channel_translate (Channel *, gint, gint); void channel_combine_ellipse (Channel *mask,
void channel_load (Channel *, Channel *); ChannelOps op,
gint x,
void channel_invalidate_bounds (Channel *); gint y,
gint w,
gint h,
gboolean antialias);
void channel_combine_mask (Channel *mask,
Channel *add_on,
ChannelOps op,
gint off_x,
gint off_y);
void channel_feather (Channel *input,
Channel *output,
gdouble radius_x,
gdouble radius_y,
ChannelOps op,
gint off_x,
gint off_y);
void channel_push_undo (Channel *mask);
void channel_clear (Channel *mask);
void channel_invert (Channel *mask);
void channel_sharpen (Channel *mask);
void channel_all (Channel *mask);
void channel_border (Channel *mask,
gint radius_x,
gint radius_y);
void channel_grow (Channel *mask,
gint radius_x,
gint radius_y);
void channel_shrink (Channel *mask,
gint radius_x,
gint radius_y,
gboolean edge_lock);
void channel_translate (Channel *mask,
gint off_x,
gint off_y);
void channel_load (Channel *mask,
Channel *channel);
void channel_invalidate_bounds (Channel *channel);
#define drawable_channel GIMP_IS_CHANNEL #define drawable_channel GIMP_IS_CHANNEL
......