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...
This commit is contained in:
Michael Natterer 2003-09-01 17:56:44 +00:00 committed by Michael Natterer
parent db72f974b1
commit dcb6f225d9
24 changed files with 368 additions and 171 deletions

View File

@ -1,3 +1,42 @@
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

View File

@ -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);
}

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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;
}

View File

@ -1,4 +1,4 @@
/* 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__ */

View File

@ -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 ();

View File

@ -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 */

View File

@ -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)
{

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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);
}

View File

@ -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)

View File

@ -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);

View File

@ -29,11 +29,13 @@
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpedit.h"
#include "core/gimpimage-mask.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimptoolinfo.h"
static ProcRecord edit_cut_proc;
static ProcRecord edit_copy_proc;
@ -324,7 +326,6 @@ edit_stroke_invoker (Gimp *gimp,
{
gboolean success = TRUE;
GimpDrawable *drawable;
GimpImage *gimage;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_DRAWABLE (drawable))
@ -332,8 +333,14 @@ edit_stroke_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage;
GimpToolInfo *tool_info;
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_image_mask_stroke (gimage, drawable, gimp_get_current_context (gimage->gimp));
tool_info = gimp_context_get_tool (gimp_get_current_context (gimp));
success = gimp_image_mask_stroke (gimage, drawable, tool_info->paint_info);
}
return procedural_db_return_args (&edit_stroke_proc, success);

View File

@ -29,6 +29,9 @@
#include "core/gimpimage.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimpmarshal.h"
#include "core/gimppaintinfo.h"
#include "paint/gimppaintcore-stroke.h"
#include "gimpanchor.h"
#include "gimpstroke.h"
@ -85,14 +88,19 @@ static void gimp_vectors_rotate (GimpItem *item,
gdouble center_x,
gdouble center_y,
gboolean clip_result);
static void gimp_vectors_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interp_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static void gimp_vectors_transform (GimpItem *item,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interp_type,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data);
static gboolean gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
#
static void gimp_vectors_real_thaw (GimpVectors *vectors);
static void gimp_vectors_real_stroke_add (GimpVectors *vectors,
GimpStroke *stroke);
@ -203,6 +211,7 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
item_class->flip = gimp_vectors_flip;
item_class->rotate = gimp_vectors_rotate;
item_class->transform = gimp_vectors_transform;
item_class->stroke = gimp_vectors_stroke;
item_class->default_name = _("Path");
item_class->rename_desc = _("Rename Path");
@ -520,6 +529,34 @@ gimp_vectors_transform (GimpItem *item,
gimp_vectors_thaw (vectors);
}
static gboolean
gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
{
GimpVectors *vectors;
GimpPaintCore *core;
gboolean retval;
vectors = GIMP_VECTORS (item);
if (! vectors->strokes)
{
g_message (_("Cannot stroke empty path."));
return FALSE;
}
core = g_object_new (paint_info->paint_type, NULL);
retval = gimp_paint_core_stroke_vectors (core, drawable,
paint_info->paint_options,
vectors);
g_object_unref (core);
return retval;
}
static void
gimp_vectors_real_thaw (GimpVectors *vectors)
{

View File

@ -349,13 +349,17 @@ static void
gimp_selection_editor_stroke_clicked (GtkWidget *widget,
GimpImageEditor *editor)
{
if (editor->gimage)
GimpImage *gimage = editor->gimage;
if (gimage)
{
GimpImage *gimage = editor->gimage;
GimpToolInfo *tool_info;
tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
gimp_image_mask_stroke (gimage,
gimp_image_active_drawable (gimage),
gimp_get_current_context (gimage->gimp));
tool_info->paint_info);
gimp_image_flush (gimage);
}
}

View File

@ -28,10 +28,13 @@
#include "widgets-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask-select.h"
#include "core/gimptoolinfo.h"
#include "vectors/gimpvectors.h"
@ -301,6 +304,23 @@ gimp_vectors_tree_view_stroke_clicked (GtkWidget *widget,
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
if (item && view->stroke_item_func)
view->stroke_item_func (GIMP_VECTORS (item));
if (item)
{
GimpDrawable *active_drawable;
GimpToolInfo *tool_info;
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 (item, active_drawable, tool_info->paint_info);
gimp_image_flush (gimage);
}
}

View File

@ -40,7 +40,6 @@ struct _GimpVectorsTreeView
{
GimpItemTreeView parent_instance;
GimpStrokeItemFunc stroke_item_func;
GimpSelectionToVectorsFunc selection_to_vectors_func;
GtkWidget *toselection_button;

View File

@ -127,7 +127,6 @@ typedef void (* GimpMenuPositionFunc) (GtkMenu *menu,
gint *y,
gpointer data);
typedef void (* GimpStrokeItemFunc) (GimpVectors *vectors);
typedef void (* GimpSelectionToVectorsFunc) (GimpImage *gimage,
gboolean advanced);

View File

@ -160,8 +160,23 @@ HELP
&std_pdb_misc;
&inargs('stroke to');
&invoke('gimp_image_mask_stroke (gimage, drawable, gimp_get_current_context (gimage->gimp))');
push @{$invoke{headers}}, qw("core/gimpimage-mask.h");
%invoke = (
headers => [ qw("core/gimpimage-mask.h" "core/gimpcontext.h"
"core/gimptoolinfo.h") ],
code => <<'CODE'
{
GimpImage *gimage;
GimpToolInfo *tool_info;
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
tool_info = gimp_context_get_tool (gimp_get_current_context (gimp));
success = gimp_image_mask_stroke (gimage, drawable, tool_info->paint_info);
}
CODE
);
}
@headers = qw("core/gimpimage.h");