Commit 420d17d2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

made all functions which push an undo step virtual and added them all as

2003-09-03  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpchannel.[ch]: made all functions which push an
	undo step virtual and added them all as default implementations.

	* app/core/Makefile.am
	* app/core/core-types.h
	* app/core/gimpselection.[ch]: new object which is a GimpChannel
	subclass and implements all of its virtual functions, pushes
	an image_mask undo and chains up with "push_undo = FALSE".

	* app/core/gimpimage-mask.[ch]: made most functions simple
	wrappers like gimp_channel_invert(gimp_image_get_mask(gimage));
	so the API stays the same for now.

	* app/core/gimpimage.[ch]: create a GimpSelection object
	as gimage->selection_mask. Removed "gboolean mask_stroking"
	since it is in GimpSelection now.

	* app/xcf/xcf-load.c (xcf_load_channel_props): added an evil hack
	which turns a GimpChannel into a GimpSelection once we figured the
	loaded channel is the selection.

	* app/core/gimplayer.c (gimp_layer_create_mask):
	gimp_channel_clear() takes an additional "const gchar *undo_desc"
	parameter now.

	* app/core/gimpscanconvert.c (gimp_scan_convert_to_channel): set
	mask->bounds_known to FALSE before returning the new channel

	* app/tools/gimpiscissorstool.c (iscissors_convert): no need to
	call gimp_channel_invalidate_boundary() on the channel returned by
	the above function.

	* app/core/gimpchannel.[ch]: removed
	gimp_channel_invalidate_boundary() since it is no longer needed.
parent 443a5f3f
2003-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.[ch]: made all functions which push an
undo step virtual and added them all as default implementations.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpselection.[ch]: new object which is a GimpChannel
subclass and implements all of its virtual functions, pushes
an image_mask undo and chains up with "push_undo = FALSE".
* app/core/gimpimage-mask.[ch]: made most functions simple
wrappers like gimp_channel_invert(gimp_image_get_mask(gimage));
so the API stays the same for now.
* app/core/gimpimage.[ch]: create a GimpSelection object
as gimage->selection_mask. Removed "gboolean mask_stroking"
since it is in GimpSelection now.
* app/xcf/xcf-load.c (xcf_load_channel_props): added an evil hack
which turns a GimpChannel into a GimpSelection once we figured the
loaded channel is the selection.
* app/core/gimplayer.c (gimp_layer_create_mask):
gimp_channel_clear() takes an additional "const gchar *undo_desc"
parameter now.
* app/core/gimpscanconvert.c (gimp_scan_convert_to_channel): set
mask->bounds_known to FALSE before returning the new channel
* app/tools/gimpiscissorstool.c (iscissors_convert): no need to
call gimp_channel_invalidate_boundary() on the channel returned by
the above function.
* app/core/gimpchannel.[ch]: removed
gimp_channel_invalidate_boundary() since it is no longer needed.
2003-09-03 Sven Neumann <sven@gimp.org>
* libgimpcolor/gimpcolorspace.[ch] (gimp_rgb_to_cmyk_int): made
......@@ -172,6 +172,8 @@ libappcore_a_sources = \
gimppreviewcache.h \
gimpscanconvert.c \
gimpscanconvert.h \
gimpselection.c \
gimpselection.h \
gimptemplate.c \
gimptemplate.h \
gimptoolinfo.c \
......
......@@ -80,6 +80,7 @@ typedef struct _GimpGrid GimpGrid;
typedef struct _GimpDrawable GimpDrawable;
typedef struct _GimpChannel GimpChannel;
typedef struct _GimpSelection GimpSelection;
typedef struct _GimpLayer GimpLayer;
typedef struct _GimpLayerMask GimpLayerMask;
......
This diff is collapsed.
......@@ -59,131 +59,175 @@ struct _GimpChannel
struct _GimpChannelClass
{
GimpDrawableClass parent_class;
gboolean (* boundary) (GimpChannel *channel,
const BoundSeg **segs_in,
const BoundSeg **segs_out,
gint *num_segs_in,
gint *num_segs_out,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean (* bounds) (GimpChannel *channel,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gint (* value) (GimpChannel *channel,
gint x,
gint y);
gboolean (* is_empty) (GimpChannel *channel);
void (* feather) (GimpChannel *channel,
gdouble radius_x,
gdouble radius_y,
gboolean push_undo);
void (* sharpen) (GimpChannel *channel,
gboolean push_undo);
void (* clear) (GimpChannel *channel,
const gchar *undo_desc,
gboolean push_undo);
void (* all) (GimpChannel *channel,
gboolean push_undo);
void (* invert) (GimpChannel *channel,
gboolean push_undo);
void (* border) (GimpChannel *channel,
gint radius_x,
gint radius_y,
gboolean push_undo);
void (* grow) (GimpChannel *channel,
gint radius_x,
gint radius_y,
gboolean push_undo);
void (* shrink) (GimpChannel *channel,
gint radius_x,
gint radius_y,
gboolean edge_lock,
gboolean push_undo);
};
/* function declarations */
GType gimp_channel_get_type (void) G_GNUC_CONST;
GType gimp_channel_get_type (void) G_GNUC_CONST;
GimpChannel * gimp_channel_new (GimpImage *gimage,
gint width,
gint height,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new (GimpImage *gimage,
gint width,
gint height,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_alpha (GimpImage *gimage,
GimpLayer *layer,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
GimpChannelType type,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_alpha (GimpImage *gimage,
GimpLayer *layer,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
GimpChannelType type,
const gchar *name,
const GimpRGB *color);
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity,
gboolean push_undo);
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity,
gboolean push_undo);
void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
void gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color,
gboolean push_undo);
void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
void gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color,
gboolean push_undo);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
void gimp_channel_set_show_masked (GimpChannel *channel,
gboolean show_masked);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
void gimp_channel_set_show_masked (GimpChannel *channel,
gboolean show_masked);
/* selection mask functions */
GimpChannel * gimp_channel_new_mask (GimpImage *gimage,
gint width,
gint height);
gboolean gimp_channel_boundary (GimpChannel *mask,
const BoundSeg **segs_in,
const BoundSeg **segs_out,
gint *num_segs_in,
gint *num_segs_out,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean gimp_channel_bounds (GimpChannel *mask,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gint gimp_channel_value (GimpChannel *mask,
gint x,
gint y);
gboolean gimp_channel_is_empty (GimpChannel *mask);
void gimp_channel_add_segment (GimpChannel *mask,
gint x,
gint y,
gint width,
gint value);
void gimp_channel_sub_segment (GimpChannel *mask,
gint x,
gint y,
gint width,
gint value);
void gimp_channel_combine_rect (GimpChannel *mask,
GimpChannelOps op,
gint x,
gint y,
gint w,
gint h);
void gimp_channel_combine_ellipse (GimpChannel *mask,
GimpChannelOps op,
gint x,
gint y,
gint w,
gint h,
gboolean antialias);
void gimp_channel_combine_mask (GimpChannel *mask,
GimpChannel *add_on,
GimpChannelOps op,
gint off_x,
gint off_y);
void gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
gboolean push_undo);
void gimp_channel_sharpen (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_clear (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_all (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_invert (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_border (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean push_undo);
void gimp_channel_grow (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean push_undo);
void gimp_channel_shrink (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean edge_lock,
gboolean push_undo);
void gimp_channel_load (GimpChannel *mask,
GimpChannel *channel,
gboolean push_undo);
void gimp_channel_invalidate_bounds (GimpChannel *channel);
GimpChannel * gimp_channel_new_mask (GimpImage *gimage,
gint width,
gint height);
gboolean gimp_channel_boundary (GimpChannel *mask,
const BoundSeg **segs_in,
const BoundSeg **segs_out,
gint *num_segs_in,
gint *num_segs_out,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean gimp_channel_bounds (GimpChannel *mask,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gint gimp_channel_value (GimpChannel *mask,
gint x,
gint y);
gboolean gimp_channel_is_empty (GimpChannel *mask);
void gimp_channel_add_segment (GimpChannel *mask,
gint x,
gint y,
gint width,
gint value);
void gimp_channel_sub_segment (GimpChannel *mask,
gint x,
gint y,
gint width,
gint value);
void gimp_channel_combine_rect (GimpChannel *mask,
GimpChannelOps op,
gint x,
gint y,
gint w,
gint h);
void gimp_channel_combine_ellipse (GimpChannel *mask,
GimpChannelOps op,
gint x,
gint y,
gint w,
gint h,
gboolean antialias);
void gimp_channel_combine_mask (GimpChannel *mask,
GimpChannel *add_on,
GimpChannelOps op,
gint off_x,
gint off_y);
void gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
gboolean push_undo);
void gimp_channel_sharpen (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_clear (GimpChannel *mask,
const gchar *undo_desc,
gboolean push_undo);
void gimp_channel_all (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_invert (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_border (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean push_undo);
void gimp_channel_grow (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean push_undo);
void gimp_channel_shrink (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean edge_lock,
gboolean push_undo);
void gimp_channel_load (GimpChannel *mask,
GimpChannel *channel,
gboolean push_undo);
#endif /* __GIMP_CHANNEL_H__ */
This diff is collapsed.
......@@ -59,131 +59,175 @@ struct _GimpChannel
struct _GimpChannelClass
{
GimpDrawableClass parent_class;
gboolean (* boundary) (GimpChannel *channel,
const BoundSeg **segs_in,
const BoundSeg **segs_out,
gint *num_segs_in,
gint *num_segs_out,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean (* bounds) (GimpChannel *channel,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gint (* value) (GimpChannel *channel,
gint x,
gint y);
gboolean (* is_empty) (GimpChannel *channel);
void (* feather) (GimpChannel *channel,
gdouble radius_x,
gdouble radius_y,
gboolean push_undo);
void (* sharpen) (GimpChannel *channel,
gboolean push_undo);
void (* clear) (GimpChannel *channel,
const gchar *undo_desc,
gboolean push_undo);
void (* all) (GimpChannel *channel,
gboolean push_undo);
void (* invert) (GimpChannel *channel,
gboolean push_undo);
void (* border) (GimpChannel *channel,
gint radius_x,
gint radius_y,
gboolean push_undo);
void (* grow) (GimpChannel *channel,
gint radius_x,
gint radius_y,
gboolean push_undo);
void (* shrink) (GimpChannel *channel,
gint radius_x,
gint radius_y,
gboolean edge_lock,
gboolean push_undo);
};
/* function declarations */
GType gimp_channel_get_type (void) G_GNUC_CONST;
GType gimp_channel_get_type (void) G_GNUC_CONST;
GimpChannel * gimp_channel_new (GimpImage *gimage,
gint width,
gint height,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new (GimpImage *gimage,
gint width,
gint height,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_alpha (GimpImage *gimage,
GimpLayer *layer,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
GimpChannelType type,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_alpha (GimpImage *gimage,
GimpLayer *layer,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_new_from_component (GimpImage *gimage,
GimpChannelType type,
const gchar *name,
const GimpRGB *color);
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity,
gboolean push_undo);
gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity,
gboolean push_undo);
void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
void gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color,
gboolean push_undo);
void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
void gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color,
gboolean push_undo);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
void gimp_channel_set_show_masked (GimpChannel *channel,
gboolean show_masked);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
void gimp_channel_set_show_masked (GimpChannel *channel,
gboolean show_masked);
/* selection mask functions */
GimpChannel * gimp_channel_new_mask (GimpImage *gimage,
gint width,
gint height);
gboolean gimp_channel_boundary (GimpChannel *mask,
const BoundSeg **segs_in,
const BoundSeg **segs_out,
gint *num_segs_in,
gint *num_segs_out,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean gimp_channel_bounds (GimpChannel *mask,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gint gimp_channel_value (GimpChannel *mask,
gint x,
gint y);
gboolean gimp_channel_is_empty (GimpChannel *mask);
void gimp_channel_add_segment (GimpChannel *mask,
gint x,
gint y,
gint width,
gint value);
void gimp_channel_sub_segment (GimpChannel *mask,
gint x,
gint y,
gint width,
gint value);
void gimp_channel_combine_rect (GimpChannel *mask,
GimpChannelOps op,
gint x,
gint y,
gint w,
gint h);
void gimp_channel_combine_ellipse (GimpChannel *mask,
GimpChannelOps op,
gint x,
gint y,
gint w,
gint h,
gboolean antialias);
void gimp_channel_combine_mask (GimpChannel *mask,
GimpChannel *add_on,
GimpChannelOps op,
gint off_x,
gint off_y);
void gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
gboolean push_undo);
void gimp_channel_sharpen (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_clear (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_all (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_invert (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_border (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean push_undo);
void gimp_channel_grow (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean push_undo);
void gimp_channel_shrink (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean edge_lock,
gboolean push_undo);
void gimp_channel_load (GimpChannel *mask,
GimpChannel *channel,
gboolean push_undo);
void gimp_channel_invalidate_bounds (GimpChannel *channel);
GimpChannel * gimp_channel_new_mask (GimpImage *gimage,
gint width,
gint height);
gboolean gimp_channel_boundary (GimpChannel *mask,
const BoundSeg **segs_in,
const BoundSeg **segs_out,
gint *num_segs_in,
gint *num_segs_out,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean gimp_channel_bounds (GimpChannel *mask,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gint gimp_channel_value (GimpChannel *mask,
gint x,
gint y);
gboolean gimp_channel_is_empty (GimpChannel *mask);
void gimp_channel_add_segment (GimpChannel *mask,
gint x,
gint y,
gint width,
gint value);
void gimp_channel_sub_segment (GimpChannel *mask,
gint x,
gint y,
gint width,
gint value);
void gimp_channel_combine_rect (GimpChannel *mask,
GimpChannelOps op,
gint x,
gint y,
gint w,
gint h);
void gimp_channel_combine_ellipse (GimpChannel *mask,
GimpChannelOps op,
gint x,
gint y,
gint w,
gint h,
gboolean antialias);
void gimp_channel_combine_mask (GimpChannel *mask,
GimpChannel *add_on,
GimpChannelOps op,
gint off_x,
gint off_y);
void gimp_channel_feather (GimpChannel *mask,
gdouble radius_x,
gdouble radius_y,
gboolean push_undo);
void gimp_channel_sharpen (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_clear (GimpChannel *mask,
const gchar *undo_desc,
gboolean push_undo);
void gimp_channel_all (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_invert (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_border (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean push_undo);
void gimp_channel_grow (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean push_undo);
void gimp_channel_shrink (GimpChannel *mask,
gint radius_x,
gint radius_y,
gboolean edge_lock,
gboolean push_undo);
void gimp_channel_load (GimpChannel *mask,
GimpChannel *channel,
gboolean push_undo);
#endif /* __GIMP_CHANNEL_H__ */
......@@ -28,8 +28,6 @@
#include "paint-funcs/paint-funcs.h"
#include "paint/gimppaintcore-stroke.h"
#include "gimp.h"
#include "gimpchannel.h"
#include "gimpcontainer.h"
......@@ -41,7 +39,7 @@
#include "gimplayer.h"
#include "gimplayer-floating-sel.h"
#include "gimplayermask.h"
#include "gimppaintinfo.h"
#include "gimpselection.h"
#include "gimp-intl.h"
......@@ -55,146 +53,176 @@ gimp_image_mask_boundary (GimpImage *gimage,
gint *num_segs_in,
gint *num_segs_out)
{
GimpDrawable *drawable;
GimpLayer *layer;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (segs_in != NULL, FALSE);
g_return_val_if_fail (segs_out != NULL, FALSE);
g_return_val_if_fail (num_segs_in != NULL, FALSE);
g_return_val_if_fail (num_segs_out != NULL, FALSE);
if ((layer = gimp_image_floating_sel (gimage)))
{
/* If there is a floating selection, then
* we need to do some slightly different boundaries.
* Instead of inside and outside boundaries being defined
* by the extents of the layer, the inside boundary (the one
* that actually marches and is black/white) is the boundary of
* the floating selection. The outside boundary (doesn't move,
* is black/gray) is defined as the normal selection mask
*/
return gimp_channel_boundary (gimp_image_get_mask (gimage),
segs_in, segs_out,
num_segs_in, num_segs_out,
0, 0, 0, 0);
}
/* Find the selection mask boundary */
gimp_channel_boundary (gimp_image_get_mask (gimage),
segs_in, segs_out,
num_segs_in, num_segs_out,
0, 0, 0, 0);
gboolean
gimp_image_mask_bounds (GimpImage *gimage,
gint *x1,
gint *y1,
gint *x2,
gint *y2)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
/* Find the floating selection boundary */
*segs_in = floating_sel_boundary (layer, num_segs_in);
return gimp_channel_bounds (gimp_image_get_mask (gimage), x1, y1, x2, y2);
}
return TRUE;
}
else if ((drawable = gimp_image_active_drawable (gimage)) &&
GIMP_IS_CHANNEL (drawable))
{
/* Otherwise, return the boundary...if a channel is active */
gint
gimp_image_mask_value (GimpImage *gimage,
gint x,
gint y)
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), 0);
return gimp_channel_boundary (gimp_image_get_mask (gimage),
segs_in, segs_out,
num_segs_in, num_segs_out,
0, 0, gimage->width, gimage->height);
}
else if ((layer = gimp_image_get_active_layer (gimage)))