Commit dcb6f225 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added new virtual function GimpItem::stroke().

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

	* app/core/gimpitem.[ch]: added new virtual function
	GimpItem::stroke().

	* app/core/gimpchannel.c
	* app/vectors/gimpvectors.c: implement GimpItem::stroke().

	* app/core/gimpimage-mask.[ch] (gimp_image_mask_stroke): changed
	signature to match gimp_item_stroke() (the selection mask *really*
	should be a GimpChannel subclass).
	Removed global variable "gboolean gimp_image_mask_stroking"...

	* app/core/gimpimage.[ch]: ...and added "gboolean mask_stroking"
	to the GimpImage struct.

	* app/gui/vectors-commands.[ch]: removed vectors_stroke_vectors().

	* app/widgets/widgets-types.h: removed GimpStrokeItemFunc typedef.

	* app/widgets/gimpvectorstreeview.[ch]: removed "stroke_item_func"
	member and use gimp_item_stroke() instead.

	* app/gui/dialogs-constructors.c (dialogs_vectors_list_view_new)
	* app/gui/edit-commands.c (edit_stroke_cmd_callback)
	* app/gui/vectors-commands. (vectors_stroke_cmd_callback)
	* app/widgets/gimpselectioneditor.c
	(gimp_selection_editor_stroke_clicked)
	* tools/pdbgen/pdb/edit.pdb (gimp_edit_stroke): changed accordingly.

	* app/pdb/edit_cmds.c: regenerated.

	Note that there is no GUI for "stroke channel", although it would
	be utterly cool to have one, since currently slelection stroking
	cannot be masked by a selection (because we stroke the selection).
	Anyway, if anyone has an idea how to trigger "stroke channel" with
	another drawable active (the one to stroke to), please let me
	know...
parent db72f974
2003-09-01 Michael Natterer <mitch@gimp.org>
* app/core/gimpitem.[ch]: added new virtual function
GimpItem::stroke().
* app/core/gimpchannel.c
* app/vectors/gimpvectors.c: implement GimpItem::stroke().
* app/core/gimpimage-mask.[ch] (gimp_image_mask_stroke): changed
signature to match gimp_item_stroke() (the selection mask *really*
should be a GimpChannel subclass).
Removed global variable "gboolean gimp_image_mask_stroking"...
* app/core/gimpimage.[ch]: ...and added "gboolean mask_stroking"
to the GimpImage struct.
* app/gui/vectors-commands.[ch]: removed vectors_stroke_vectors().
* app/widgets/widgets-types.h: removed GimpStrokeItemFunc typedef.
* app/widgets/gimpvectorstreeview.[ch]: removed "stroke_item_func"
member and use gimp_item_stroke() instead.
* app/gui/dialogs-constructors.c (dialogs_vectors_list_view_new)
* app/gui/edit-commands.c (edit_stroke_cmd_callback)
* app/gui/vectors-commands. (vectors_stroke_cmd_callback)
* app/widgets/gimpselectioneditor.c
(gimp_selection_editor_stroke_clicked)
* tools/pdbgen/pdb/edit.pdb (gimp_edit_stroke): changed accordingly.
* app/pdb/edit_cmds.c: regenerated.
Note that there is no GUI for "stroke channel", although it would
be utterly cool to have one, since currently slelection stroking
cannot be masked by a selection (because we stroke the selection).
Anyway, if anyone has an idea how to trigger "stroke channel" with
another drawable active (the one to stroke to), please let me
know...
2003-09-01 Manish Singh <yosh@gimp.org>
 
* app/gui/preferences-dialog.c: added a shadow around the comment
......@@ -36,6 +36,7 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-undo.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay.h"
......@@ -260,12 +261,22 @@ void
edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpImage *gimage;
GimpDrawable *active_drawable;
GimpToolInfo *tool_info;
return_if_no_image (gimage, data);
gimp_image_mask_stroke (gimage,
gimp_image_active_drawable (gimage),
gimp_get_current_context (gimage->gimp));
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active layer or channel to stroke to."));
return;
}
tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
gimp_image_mask_stroke (gimage, active_drawable, tool_info->paint_info);
gimp_image_flush (gimage);
}
......
......@@ -32,14 +32,8 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimplist.h"
#include "core/gimppaintinfo.h"
#include "core/gimptoolinfo.h"
#include "paint/gimppaintcore.h"
#include "paint/gimppaintcore-stroke.h"
#include "paint/gimppaintoptions.h"
#include "pdb/procedural_db.h"
#include "plug-in/plug-in-run.h"
......@@ -179,11 +173,25 @@ void
vectors_stroke_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpVectors *active_vectors;
GimpImage *gimage;
GimpVectors *active_vectors;
GimpDrawable *active_drawable;
GimpToolInfo *tool_info;
return_if_no_vectors (gimage, active_vectors, data);
vectors_stroke_vectors (active_vectors);
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active layer or channel to stroke to."));
return;
}
tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
gimp_item_stroke (GIMP_ITEM (active_vectors), active_drawable,
tool_info->paint_info);
gimp_image_flush (gimage);
}
void
......@@ -258,45 +266,6 @@ vectors_edit_attributes_cmd_callback (GtkWidget *widget,
vectors_edit_vectors_query (active_vectors);
}
void
vectors_stroke_vectors (GimpVectors *vectors)
{
GimpImage *gimage;
GimpDrawable *active_drawable;
g_return_if_fail (GIMP_IS_VECTORS (vectors));
gimage = gimp_item_get_image (GIMP_ITEM (vectors));
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active Layer or Channel to stroke to"));
return;
}
if (vectors && vectors->strokes)
{
GimpToolInfo *tool_info;
GimpPaintInfo *paint_info;
GimpPaintCore *core;
tool_info = gimp_context_get_tool (gimp_get_user_context (gimage->gimp));
paint_info = tool_info->paint_info;
core = g_object_new (paint_info->paint_type, NULL);
gimp_paint_core_stroke_vectors (core, active_drawable,
paint_info->paint_options,
vectors);
g_object_unref (core);
gimp_image_flush (gimage);
}
}
void
vectors_selection_to_vectors (GimpImage *gimage,
gboolean advanced)
......
......@@ -50,7 +50,6 @@ void vectors_vectors_tool_cmd_callback (GtkWidget *widget,
void vectors_edit_attributes_cmd_callback (GtkWidget *widget,
gpointer data);
void vectors_stroke_vectors (GimpVectors *vectors);
void vectors_selection_to_vectors (GimpImage *gimage,
gboolean advanced);
void vectors_vectors_tool (GimpVectors *vectors);
......
......@@ -38,6 +38,8 @@
#include "paint-funcs/paint-funcs.h"
#include "paint/gimppaintcore-stroke.h"
#include "gimp-utils.h"
#include "gimpimage.h"
#include "gimpimage-projection.h"
......@@ -45,6 +47,7 @@
#include "gimpimage-undo-push.h"
#include "gimpchannel.h"
#include "gimplayer.h"
#include "gimppaintinfo.h"
#include "gimpparasitelist.h"
#include "gimp-intl.h"
......@@ -70,7 +73,7 @@ static void gimp_channel_scale (GimpItem *item,
gint new_height,
gint new_offset_x,
gint new_offset_y,
GimpInterpolationType interp_type);
GimpInterpolationType interp_type);
static void gimp_channel_resize (GimpItem *item,
gint new_width,
gint new_height,
......@@ -85,13 +88,16 @@ static void gimp_channel_rotate (GimpItem *item,
gdouble center_x,
gdouble center_y,
gboolean flip_result);
static void gimp_channel_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static void gimp_channel_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static gboolean gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
static void gimp_channel_push_undo (GimpChannel *mask,
const gchar *undo_desc);
......@@ -158,6 +164,7 @@ gimp_channel_class_init (GimpChannelClass *klass)
item_class->flip = gimp_channel_flip;
item_class->rotate = gimp_channel_rotate;
item_class->transform = gimp_channel_transform;
item_class->stroke = gimp_channel_stroke;
item_class->default_name = _("Channel");
item_class->rename_desc = _("Rename Channel");
}
......@@ -499,6 +506,51 @@ gimp_channel_transform (GimpItem *item,
channel->bounds_known = FALSE;
}
static gboolean
gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
{
GimpChannel *channel;
GimpImage *gimage;
const BoundSeg *bs_in;
const BoundSeg *bs_out;
gint num_segs_in;
gint num_segs_out;
GimpPaintCore *core;
gboolean retval;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (GIMP_ITEM (channel));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
if (! gimp_channel_boundary (channel, &bs_in, &bs_out,
&num_segs_in, &num_segs_out,
0, 0, 0, 0))
{
g_message (_("Cannot stroke empty channel."));
return FALSE;
}
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT,
_("Stroke Channel"));
core = g_object_new (paint_info->paint_type, NULL);
retval = gimp_paint_core_stroke_boundary (core, drawable,
paint_info->paint_options,
bs_in, num_segs_in,
0, 0);
g_object_unref (core);
gimp_image_undo_group_end (gimage);
return retval;
}
static void
gimp_channel_push_undo (GimpChannel *mask,
const gchar *undo_desc)
......
......@@ -38,6 +38,8 @@
#include "paint-funcs/paint-funcs.h"
#include "paint/gimppaintcore-stroke.h"
#include "gimp-utils.h"
#include "gimpimage.h"
#include "gimpimage-projection.h"
......@@ -45,6 +47,7 @@
#include "gimpimage-undo-push.h"
#include "gimpchannel.h"
#include "gimplayer.h"
#include "gimppaintinfo.h"
#include "gimpparasitelist.h"
#include "gimp-intl.h"
......@@ -70,7 +73,7 @@ static void gimp_channel_scale (GimpItem *item,
gint new_height,
gint new_offset_x,
gint new_offset_y,
GimpInterpolationType interp_type);
GimpInterpolationType interp_type);
static void gimp_channel_resize (GimpItem *item,
gint new_width,
gint new_height,
......@@ -85,13 +88,16 @@ static void gimp_channel_rotate (GimpItem *item,
gdouble center_x,
gdouble center_y,
gboolean flip_result);
static void gimp_channel_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static void gimp_channel_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static gboolean gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
static void gimp_channel_push_undo (GimpChannel *mask,
const gchar *undo_desc);
......@@ -158,6 +164,7 @@ gimp_channel_class_init (GimpChannelClass *klass)
item_class->flip = gimp_channel_flip;
item_class->rotate = gimp_channel_rotate;
item_class->transform = gimp_channel_transform;
item_class->stroke = gimp_channel_stroke;
item_class->default_name = _("Channel");
item_class->rename_desc = _("Rename Channel");
}
......@@ -499,6 +506,51 @@ gimp_channel_transform (GimpItem *item,
channel->bounds_known = FALSE;
}
static gboolean
gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
{
GimpChannel *channel;
GimpImage *gimage;
const BoundSeg *bs_in;
const BoundSeg *bs_out;
gint num_segs_in;
gint num_segs_out;
GimpPaintCore *core;
gboolean retval;
channel = GIMP_CHANNEL (item);
gimage = gimp_item_get_image (GIMP_ITEM (channel));
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
if (! gimp_channel_boundary (channel, &bs_in, &bs_out,
&num_segs_in, &num_segs_out,
0, 0, 0, 0))
{
g_message (_("Cannot stroke empty channel."));
return FALSE;
}
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT,
_("Stroke Channel"));
core = g_object_new (paint_info->paint_type, NULL);
retval = gimp_paint_core_stroke_boundary (core, drawable,
paint_info->paint_options,
bs_in, num_segs_in,
0, 0);
g_object_unref (core);
gimp_image_undo_group_end (gimage);
return retval;
}
static void
gimp_channel_push_undo (GimpChannel *mask,
const gchar *undo_desc)
......
......@@ -28,9 +28,7 @@
#include "paint-funcs/paint-funcs.h"
#include "paint/gimppaintcore.h"
#include "paint/gimppaintcore-stroke.h"
#include "paint/gimppaintoptions.h"
#include "gimp.h"
#include "gimpchannel.h"
......@@ -44,16 +42,10 @@
#include "gimplayer-floating-sel.h"
#include "gimplayermask.h"
#include "gimppaintinfo.h"
#include "gimptoolinfo.h"
#include "gimp-intl.h"
/* local variables */
static gboolean gimp_image_mask_stroking = FALSE;
/* public functions */
gboolean
......@@ -196,7 +188,7 @@ gimp_image_mask_is_empty (GimpImage *gimage)
* that the selection mask is empty so that it doesn't mask the paint
* during the stroke operation.
*/
if (gimp_image_mask_stroking)
if (gimage->mask_stroking)
return TRUE;
else
return gimp_channel_is_empty (gimp_image_get_mask (gimage));
......@@ -624,22 +616,20 @@ gimp_image_mask_save (GimpImage *gimage)
}
gboolean
gimp_image_mask_stroke (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context)
gimp_image_mask_stroke (GimpImage *gimage,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
{
const BoundSeg *bs_in;
const BoundSeg *bs_out;
gint num_segs_in;
gint num_segs_out;
GimpToolInfo *tool_info;
GimpPaintInfo *paint_info;
GimpPaintCore *core;
gboolean retval;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_PAINT_INFO (paint_info), FALSE);
if (! gimp_image_mask_boundary (gimage, &bs_in, &bs_out,
&num_segs_in, &num_segs_out))
......@@ -648,14 +638,11 @@ gimp_image_mask_stroke (GimpImage *gimage,
return FALSE;
}
gimp_image_mask_stroking = TRUE;
gimage->mask_stroking = TRUE;
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT,
_("Stroke Selection"));
tool_info = gimp_context_get_tool (context);
paint_info = tool_info->paint_info;
core = g_object_new (paint_info->paint_type, NULL);
retval = gimp_paint_core_stroke_boundary (core, drawable,
......@@ -667,7 +654,7 @@ gimp_image_mask_stroke (GimpImage *gimage,
gimp_image_undo_group_end (gimage);
gimp_image_mask_stroking = FALSE;
gimage->mask_stroking = FALSE;
return retval;
}
/* The GIMP -- an image manipulation program
#/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
......@@ -89,7 +89,7 @@ GimpChannel * gimp_image_mask_save (GimpImage *gimage);
gboolean gimp_image_mask_stroke (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context);
GimpPaintInfo *paint_info);
#endif /* __GIMP_IMAGE_MASK_H__ */
......@@ -483,6 +483,7 @@ gimp_image_init (GimpImage *gimage)
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;
gimage->mask_stroking = FALSE;
gimage->parasites = gimp_parasite_list_new ();
......
......@@ -138,6 +138,7 @@ struct _GimpImage
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
gboolean mask_stroking; /* is a stroke being done */
GimpParasiteList *parasites; /* Plug-in parasite data */
......
......@@ -38,6 +38,7 @@
#include "gimplayer.h"
#include "gimplist.h"
#include "gimpmarshal.h"
#include "gimppaintinfo.h"
#include "gimpparasitelist.h"
#include "vectors/gimpvectors.h"
......@@ -171,6 +172,7 @@ gimp_item_class_init (GimpItemClass *klass)
klass->flip = NULL;
klass->rotate = NULL;
klass->transform = NULL;
klass->stroke = NULL;
}
static void
......@@ -751,6 +753,25 @@ gimp_item_transform (GimpItem *item,
progress_callback, progress_data);
}
gboolean
gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
{
GimpItemClass *item_class;
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_PAINT_INFO (paint_info), FALSE);
item_class = GIMP_ITEM_GET_CLASS (item);
if (item_class->stroke)
return item_class->stroke (item, drawable, paint_info);
return FALSE;
}
gint
gimp_item_get_ID (GimpItem *item)
{
......
......@@ -100,6 +100,9 @@ struct _GimpItemClass
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
gboolean (* stroke) (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
const gchar *default_name;
const gchar *rename_desc;
......@@ -173,13 +176,17 @@ void gimp_item_rotate (GimpItem *item,
gdouble center_x,
gdouble center_y,
gboolean flip_result);
void gimp_item_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
void gimp_item_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
gboolean gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
gint gimp_item_get_ID (GimpItem *item);
GimpItem * gimp_item_get_by_ID (Gimp *gimp,
......
......@@ -825,7 +825,6 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
vectors_view = GIMP_VECTORS_TREE_VIEW (view);
vectors_view->stroke_item_func = vectors_stroke_vectors;
vectors_view->selection_to_vectors_func = vectors_selection_to_vectors;
dockable = dialogs_dockable_new (view,
......
......@@ -825,7 +825,6 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
vectors_view = GIMP_VECTORS_TREE_VIEW (view);
vectors_view->stroke_item_func = vectors_stroke_vectors;
vectors_view->selection_to_vectors_func = vectors_selection_to_vectors;
dockable = dialogs_dockable_new (view,
......
......@@ -36,6 +36,7 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage-undo.h"
#include "core/gimptoolinfo.h"
#include "display/gimpdisplay.h"
......@@ -260,12 +261,22 @@ void
edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpImage *gimage;
GimpDrawable *active_drawable;
GimpToolInfo *tool_info;
return_if_no_image (gimage, data);
gimp_image_mask_stroke (gimage,
gimp_image_active_drawable (gimage),
gimp_get_current_context (gimage->gimp));
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{