added new enum GimpStrokeMethod which can be one of { LIBART, PAINT_CORE

2004-10-22  Michael Natterer  <mitch@gimp.org>

	* app/core/core-enums.[ch]: added new enum GimpStrokeMethod which
	can be one of { LIBART, PAINT_CORE }.

	* app/core/Makefile.am
	* app/core/core-types.h
	* app/core/gimpstrokedesc.[ch]: new object which encapsulates
	the params and setup logic for the different stroke methods.

	* app/core/gimpitem.[ch]: use it in GimpItem::stroke() and
	in the gimp_item_stroke() wrapper.

	* app/core/gimpchannel.c (gimp_channel_stroke)
	* app/core/gimpselection.c (gimp_selection_stroke)
	* app/vectors/gimpvectors.c (gimp_vectors_stroke): changed accprdingly.

	* app/actions/select-commands.c
	* app/actions/vectors-commands.c
	* app/dialogs/stroke-dialog.c
	* tools/pdbgen/pdb/edit.pdb
	* tools/pdbgen/pdb/paths.pdb: use GimpStrokeDesc. Simplifies the
	code quite a bit.

	* app/pdb/edit_cmds.c
	* app/pdb/paths_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2004-10-22 12:32:31 +00:00 committed by Michael Natterer
parent fbfa5666e7
commit 06447c00c2
19 changed files with 727 additions and 342 deletions

View File

@ -1,3 +1,30 @@
2004-10-22 Michael Natterer <mitch@gimp.org>
* app/core/core-enums.[ch]: added new enum GimpStrokeMethod which
can be one of { LIBART, PAINT_CORE }.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpstrokedesc.[ch]: new object which encapsulates
the params and setup logic for the different stroke methods.
* app/core/gimpitem.[ch]: use it in GimpItem::stroke() and
in the gimp_item_stroke() wrapper.
* app/core/gimpchannel.c (gimp_channel_stroke)
* app/core/gimpselection.c (gimp_selection_stroke)
* app/vectors/gimpvectors.c (gimp_vectors_stroke): changed accprdingly.
* app/actions/select-commands.c
* app/actions/vectors-commands.c
* app/dialogs/stroke-dialog.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/paths.pdb: use GimpStrokeDesc. Simplifies the
code quite a bit.
* app/pdb/edit_cmds.c
* app/pdb/paths_cmds.c: regenerated.
2004-10-22 Michael Natterer <mitch@gimp.org> 2004-10-22 Michael Natterer <mitch@gimp.org>
* app/widgets/gimppropwidgets.c: remember the param_spec with each * app/widgets/gimppropwidgets.c: remember the param_spec with each

View File

@ -30,7 +30,7 @@
#include "core/gimpchannel-select.h" #include "core/gimpchannel-select.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpselection.h" #include "core/gimpselection.h"
#include "core/gimpstrokeoptions.h" #include "core/gimpstrokedesc.h"
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
#include "widgets/gimpdialogfactory.h" #include "widgets/gimpdialogfactory.h"
@ -288,8 +288,7 @@ select_stroke_last_vals_cmd_callback (GtkAction *action,
GimpImage *image; GimpImage *image;
GimpDrawable *drawable; GimpDrawable *drawable;
GimpContext *context; GimpContext *context;
GimpObject *options; GimpStrokeDesc *desc;
gboolean libart_stroking;
return_if_no_image (image, data); return_if_no_image (image, data);
drawable = gimp_image_active_drawable (image); drawable = gimp_image_active_drawable (image);
@ -302,36 +301,17 @@ select_stroke_last_vals_cmd_callback (GtkAction *action,
context = gimp_get_user_context (image->gimp); context = gimp_get_user_context (image->gimp);
options = g_object_get_data (G_OBJECT (context), "saved-stroke-options"); desc = g_object_get_data (G_OBJECT (context), "saved-stroke-desc");
if (options) if (desc)
{ g_object_ref (desc);
g_object_ref (options);
libart_stroking = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (options),
"libart-stroking"));
}
else else
{ desc = gimp_stroke_desc_new (image->gimp, context);
options = g_object_new (GIMP_TYPE_STROKE_OPTIONS,
"gimp", image->gimp,
NULL);
libart_stroking = TRUE;
}
if (libart_stroking)
{
gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)), gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
drawable, context, options, FALSE); drawable, context, desc, FALSE);
}
else
{
gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
drawable, context,
g_object_get_data (G_OBJECT (options),
"gimp-paint-info"), FALSE);
}
g_object_unref (options); g_object_unref (desc);
gimp_image_flush (image); gimp_image_flush (image);
} }

View File

@ -36,7 +36,7 @@
#include "core/gimpimage-undo.h" #include "core/gimpimage-undo.h"
#include "core/gimpitemundo.h" #include "core/gimpitemundo.h"
#include "core/gimpprogress.h" #include "core/gimpprogress.h"
#include "core/gimpstrokeoptions.h" #include "core/gimpstrokedesc.h"
#include "core/gimptoolinfo.h" #include "core/gimptoolinfo.h"
#include "pdb/procedural_db.h" #include "pdb/procedural_db.h"
@ -375,8 +375,7 @@ vectors_stroke_last_vals_cmd_callback (GtkAction *action,
GimpVectors *vectors; GimpVectors *vectors;
GimpDrawable *drawable; GimpDrawable *drawable;
GimpContext *context; GimpContext *context;
GimpObject *options; GimpStrokeDesc *desc;
gboolean libart_stroking;
return_if_no_vectors (image, vectors, data); return_if_no_vectors (image, vectors, data);
drawable = gimp_image_active_drawable (image); drawable = gimp_image_active_drawable (image);
@ -389,36 +388,16 @@ vectors_stroke_last_vals_cmd_callback (GtkAction *action,
context = gimp_get_user_context (image->gimp); context = gimp_get_user_context (image->gimp);
options = g_object_get_data (G_OBJECT (context), "saved-stroke-options"); desc = g_object_get_data (G_OBJECT (context), "saved-stroke-desc");
if (options) if (desc)
{ g_object_ref (desc);
g_object_ref (options);
libart_stroking = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (options),
"libart-stroking"));
}
else else
{ desc = gimp_stroke_desc_new (image->gimp, context);
options = g_object_new (GIMP_TYPE_STROKE_OPTIONS,
"gimp", image->gimp,
NULL);
libart_stroking = TRUE;
}
if (libart_stroking) gimp_item_stroke (GIMP_ITEM (vectors), drawable, context, desc, FALSE);
{
gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, options, FALSE);
}
else
{
gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context,
g_object_get_data (G_OBJECT (options),
"gimp-paint-info"), FALSE);
}
g_object_unref (options); g_object_unref (desc);
gimp_image_flush (image); gimp_image_flush (image);
} }

View File

@ -200,6 +200,8 @@ libappcore_a_sources = \
gimpscanconvert.h \ gimpscanconvert.h \
gimpselection.c \ gimpselection.c \
gimpselection.h \ gimpselection.h \
gimpstrokedesc.c \
gimpstrokedesc.h \
gimpstrokeoptions.c \ gimpstrokeoptions.c \
gimpstrokeoptions.h \ gimpstrokeoptions.h \
gimptemplate.c \ gimptemplate.c \

View File

@ -264,6 +264,24 @@ gimp_grid_style_get_type (void)
return type; return type;
} }
GType
gimp_stroke_method_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_STROKE_METHOD_LIBART, N_("Stroke line"), "libart" },
{ GIMP_STROKE_METHOD_PAINT_CORE, N_("Stroke with a paint tool"), "paint-core" },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
type = g_enum_register_static ("GimpStrokeMethod", values);
return type;
}
GType GType
gimp_stroke_style_get_type (void) gimp_stroke_style_get_type (void)
{ {

View File

@ -211,6 +211,17 @@ typedef enum /*< pdb-skip >*/
} GimpGridStyle; } GimpGridStyle;
#define GIMP_TYPE_STROKE_METHOD (gimp_stroke_method_get_type ())
GType gimp_stroke_method_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_STROKE_METHOD_LIBART, /*< desc="Stroke line" >*/
GIMP_STROKE_METHOD_PAINT_CORE /*< desc="Stroke with a paint tool" >*/
} GimpStrokeMethod;
#define GIMP_TYPE_STROKE_STYLE (gimp_stroke_style_get_type ()) #define GIMP_TYPE_STROKE_STYLE (gimp_stroke_style_get_type ())
GType gimp_stroke_style_get_type (void) G_GNUC_CONST; GType gimp_stroke_style_get_type (void) G_GNUC_CONST;

View File

@ -116,6 +116,7 @@ typedef struct _GimpImageMap GimpImageMap;
typedef struct _GimpParasiteList GimpParasiteList; typedef struct _GimpParasiteList GimpParasiteList;
typedef struct _GimpPdbProgress GimpPdbProgress; typedef struct _GimpPdbProgress GimpPdbProgress;
typedef struct _GimpProjection GimpProjection; typedef struct _GimpProjection GimpProjection;
typedef struct _GimpStrokeDesc GimpStrokeDesc;
/* typedef struct _GimpTemplate GimpTemplate; in config-types.h */ /* typedef struct _GimpTemplate GimpTemplate; in config-types.h */

View File

@ -52,7 +52,7 @@
#include "gimpmarshal.h" #include "gimpmarshal.h"
#include "gimppaintinfo.h" #include "gimppaintinfo.h"
#include "gimpprojection.h" #include "gimpprojection.h"
#include "gimpstrokeoptions.h" #include "gimpstrokedesc.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -119,7 +119,7 @@ static void gimp_channel_transform (GimpItem *item,
static gboolean gimp_channel_stroke (GimpItem *item, static gboolean gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc); GimpStrokeDesc *stroke_desc);
static void gimp_channel_invalidate_boundary (GimpDrawable *drawable); static void gimp_channel_invalidate_boundary (GimpDrawable *drawable);
static void gimp_channel_get_active_components (const GimpDrawable *drawable, static void gimp_channel_get_active_components (const GimpDrawable *drawable,
@ -613,7 +613,7 @@ static gboolean
gimp_channel_stroke (GimpItem *item, gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc) GimpStrokeDesc *stroke_desc)
{ {
GimpChannel *channel = GIMP_CHANNEL (item); GimpChannel *channel = GIMP_CHANNEL (item);
@ -634,28 +634,34 @@ gimp_channel_stroke (GimpItem *item,
gimp_item_offsets (GIMP_ITEM (channel), &offset_x, &offset_y); gimp_item_offsets (GIMP_ITEM (channel), &offset_x, &offset_y);
if (GIMP_IS_STROKE_OPTIONS (stroke_desc)) switch (stroke_desc->method)
{ {
case GIMP_STROKE_METHOD_LIBART:
gimp_drawable_stroke_boundary (drawable, gimp_drawable_stroke_boundary (drawable,
GIMP_STROKE_OPTIONS (stroke_desc), stroke_desc->stroke_options,
segs_in, n_segs_in, segs_in, n_segs_in,
offset_x, offset_y); offset_x, offset_y);
retval = TRUE; retval = TRUE;
} break;
else if (GIMP_IS_PAINT_OPTIONS (stroke_desc))
case GIMP_STROKE_METHOD_PAINT_CORE:
{ {
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (stroke_desc);
GimpPaintCore *core; GimpPaintCore *core;
core = g_object_new (paint_options->paint_info->paint_type, NULL); core = g_object_new (stroke_desc->paint_info->paint_type, NULL);
retval = gimp_paint_core_stroke_boundary (core, drawable, retval = gimp_paint_core_stroke_boundary (core, drawable,
paint_options, stroke_desc->paint_options,
segs_in, n_segs_in, segs_in, n_segs_in,
offset_x, offset_y); offset_x, offset_y);
g_object_unref (core); g_object_unref (core);
} }
break;
default:
g_return_val_if_reached (FALSE);
}
return retval; return retval;
} }

View File

@ -27,11 +27,6 @@
#include "core-types.h" #include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpcoreconfig.h"
#include "paint/gimppaintoptions.h"
#include "gimp.h" #include "gimp.h"
#include "gimp-parasites.h" #include "gimp-parasites.h"
#include "gimpdrawable.h" #include "gimpdrawable.h"
@ -42,10 +37,9 @@
#include "gimpitem-preview.h" #include "gimpitem-preview.h"
#include "gimplist.h" #include "gimplist.h"
#include "gimpmarshal.h" #include "gimpmarshal.h"
#include "gimppaintinfo.h"
#include "gimpparasitelist.h" #include "gimpparasitelist.h"
#include "gimpprogress.h" #include "gimpprogress.h"
#include "gimpstrokeoptions.h" #include "gimpstrokedesc.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -976,7 +970,7 @@ gboolean
gimp_item_stroke (GimpItem *item, gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc, GimpStrokeDesc *stroke_desc,
gboolean use_default_values) gboolean use_default_values)
{ {
GimpItemClass *item_class; GimpItemClass *item_class;
@ -985,8 +979,7 @@ gimp_item_stroke (GimpItem *item,
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE); 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_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE); g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_PAINT_INFO (stroke_desc) || g_return_val_if_fail (GIMP_IS_STROKE_DESC (stroke_desc), FALSE);
GIMP_IS_STROKE_OPTIONS (stroke_desc), FALSE);
item_class = GIMP_ITEM_GET_CLASS (item); item_class = GIMP_ITEM_GET_CLASS (item);
@ -994,66 +987,16 @@ gimp_item_stroke (GimpItem *item,
{ {
GimpImage *gimage = gimp_item_get_image (item); GimpImage *gimage = gimp_item_get_image (item);
gimp_stroke_desc_prepare (stroke_desc, context, use_default_values);
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT, gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT,
item_class->stroke_desc); item_class->stroke_desc);
if (GIMP_IS_STROKE_OPTIONS (stroke_desc))
{
g_object_ref (stroke_desc);
}
else if (GIMP_IS_PAINT_INFO (stroke_desc))
{
GimpPaintInfo *paint_info = GIMP_PAINT_INFO (stroke_desc);
GimpPaintOptions *paint_options;
if (use_default_values)
{
paint_options = gimp_paint_options_new (paint_info);
/* undefine the paint-relevant context properties and get them
* from the passed context
*/
gimp_context_define_properties (GIMP_CONTEXT (paint_options),
GIMP_CONTEXT_PAINT_PROPS_MASK,
FALSE);
gimp_context_set_parent (GIMP_CONTEXT (paint_options), context);
}
else
{
GimpCoreConfig *config = context->gimp->config;
GimpContextPropMask global_props = 0;
paint_options =
gimp_config_duplicate (GIMP_CONFIG (paint_info->paint_options));
/* FG and BG are always shared between all tools */
global_props |= GIMP_CONTEXT_FOREGROUND_MASK;
global_props |= GIMP_CONTEXT_BACKGROUND_MASK;
if (config->global_brush)
global_props |= GIMP_CONTEXT_BRUSH_MASK;
if (config->global_pattern)
global_props |= GIMP_CONTEXT_PATTERN_MASK;
if (config->global_palette)
global_props |= GIMP_CONTEXT_PALETTE_MASK;
if (config->global_gradient)
global_props |= GIMP_CONTEXT_GRADIENT_MASK;
if (config->global_font)
global_props |= GIMP_CONTEXT_FONT_MASK;
gimp_context_copy_properties (context,
GIMP_CONTEXT (paint_options),
global_props);
}
stroke_desc = GIMP_OBJECT (paint_options);
}
retval = item_class->stroke (item, drawable, context, stroke_desc); retval = item_class->stroke (item, drawable, context, stroke_desc);
g_object_unref (stroke_desc);
gimp_image_undo_group_end (gimage); gimp_image_undo_group_end (gimage);
gimp_stroke_desc_finish (stroke_desc);
} }
return retval; return retval;

View File

@ -115,7 +115,7 @@ struct _GimpItemClass
gboolean (* stroke) (GimpItem *item, gboolean (* stroke) (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc); GimpStrokeDesc *stroke_desc);
const gchar *default_name; const gchar *default_name;
const gchar *rename_desc; const gchar *rename_desc;
@ -221,7 +221,7 @@ void gimp_item_transform (GimpItem *item,
gboolean gimp_item_stroke (GimpItem *item, gboolean gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc, GimpStrokeDesc *stroke_desc,
gboolean use_default_values); gboolean use_default_values);
gint gimp_item_get_ID (GimpItem *item); gint gimp_item_get_ID (GimpItem *item);

View File

@ -77,7 +77,7 @@ static void gimp_selection_rotate (GimpItem *item,
static gboolean gimp_selection_stroke (GimpItem *item, static gboolean gimp_selection_stroke (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc); GimpStrokeDesc *stroke_desc);
static void gimp_selection_invalidate_boundary (GimpDrawable *drawable); static void gimp_selection_invalidate_boundary (GimpDrawable *drawable);
@ -290,7 +290,7 @@ static gboolean
gimp_selection_stroke (GimpItem *item, gimp_selection_stroke (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc) GimpStrokeDesc *stroke_desc)
{ {
GimpSelection *selection = GIMP_SELECTION (item); GimpSelection *selection = GIMP_SELECTION (item);
const BoundSeg *dummy_in; const BoundSeg *dummy_in;

380
app/core/gimpstrokedesc.c Normal file
View File

@ -0,0 +1,380 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpstrokedesc.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimptoolinfo.h"
#include "gimppaintinfo.h"
#include "gimpstrokedesc.h"
#include "gimpstrokeoptions.h"
#include "paint/gimppaintoptions.h"
enum
{
PROP_0,
PROP_GIMP,
PROP_METHOD,
PROP_STROKE_OPTIONS,
PROP_PAINT_INFO,
PROP_PAINT_OPTIONS
};
static void gimp_stroke_desc_class_init (GimpStrokeDescClass *klass);
static GObject * gimp_stroke_desc_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_stroke_desc_finalize (GObject *object);
static void gimp_stroke_desc_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_stroke_desc_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GimpObjectClass *parent_class = NULL;
GType
gimp_stroke_desc_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo info =
{
sizeof (GimpStrokeDescClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_stroke_desc_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpStrokeDesc),
0, /* n_preallocs */
NULL /* instance_init */
};
static const GInterfaceInfo config_iface_info =
{
NULL, /* ifact_init */
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GIMP_TYPE_OBJECT,
"GimpStrokeDesc",
&info, 0);
g_type_add_interface_static (type, GIMP_TYPE_CONFIG,
&config_iface_info);
}
return type;
}
static void
gimp_stroke_desc_class_init (GimpStrokeDescClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_stroke_desc_constructor;
object_class->finalize = gimp_stroke_desc_finalize;
object_class->set_property = gimp_stroke_desc_set_property;
object_class->get_property = gimp_stroke_desc_get_property;
g_object_class_install_property (object_class, PROP_GIMP,
g_param_spec_object ("gimp",
NULL, NULL,
GIMP_TYPE_GIMP,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_METHOD,
"method", NULL,
GIMP_TYPE_STROKE_METHOD,
GIMP_STROKE_METHOD_LIBART,
0);
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_STROKE_OPTIONS,
"stroke-options", NULL,
GIMP_TYPE_STROKE_OPTIONS,
GIMP_PARAM_AGGREGATE);
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_PAINT_INFO,
"paint-info", NULL,
GIMP_TYPE_PAINT_INFO,
0);
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_PAINT_OPTIONS,
"paint-options", NULL,
GIMP_TYPE_PAINT_OPTIONS,
0);
}
static GObject *
gimp_stroke_desc_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpStrokeDesc *desc;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
desc = GIMP_STROKE_DESC (object);
g_assert (GIMP_IS_GIMP (desc->gimp));
desc->stroke_options = g_object_new (GIMP_TYPE_STROKE_OPTIONS,
"gimp", desc->gimp,
NULL);
return object;
}
static void
gimp_stroke_desc_finalize (GObject *object)
{
GimpStrokeDesc *desc = GIMP_STROKE_DESC (object);
if (desc->stroke_options)
{
g_object_unref (desc->stroke_options);
desc->stroke_options = NULL;
}
if (desc->paint_info)
{
g_object_unref (desc->paint_info);
desc->paint_info = NULL;
}
if (desc->paint_options)
{
g_object_unref (desc->paint_options);
desc->paint_options = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_stroke_desc_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpStrokeDesc *desc = GIMP_STROKE_DESC (object);
switch (property_id)
{
case PROP_GIMP:
desc->gimp = g_value_get_object (value);
break;
case PROP_METHOD:
desc->method = g_value_get_enum (value);
break;
case PROP_STROKE_OPTIONS:
if (g_value_get_object (value))
gimp_config_sync (GIMP_CONFIG (g_value_get_object (value)),
GIMP_CONFIG (desc->stroke_options), 0);
break;
case PROP_PAINT_INFO:
if (desc->paint_info)
g_object_unref (desc->paint_info);
desc->paint_info = (GimpPaintInfo *) g_value_dup_object (value);
break;
case PROP_PAINT_OPTIONS:
if (desc->paint_options)
g_object_unref (desc->paint_options);
desc->paint_options = (GimpPaintOptions *) g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_stroke_desc_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpStrokeDesc *desc = GIMP_STROKE_DESC (object);
switch (property_id)
{
case PROP_GIMP:
g_value_set_object (value, desc->gimp);
break;
case PROP_METHOD:
g_value_set_enum (value, desc->method);
break;
case PROP_STROKE_OPTIONS:
g_value_set_object (value, desc->stroke_options);
break;
case PROP_PAINT_INFO:
g_value_set_object (value, desc->paint_info);
break;
case PROP_PAINT_OPTIONS:
g_value_set_object (value, desc->paint_options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* public functions */
GimpStrokeDesc *
gimp_stroke_desc_new (Gimp *gimp,
GimpContext *context)
{
GimpPaintInfo *paint_info = NULL;
GimpStrokeDesc *desc;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
if (context)
{
GimpToolInfo *tool_info = gimp_context_get_tool (context);
if (tool_info)
paint_info = tool_info->paint_info;
}
desc = g_object_new (GIMP_TYPE_STROKE_DESC,
"gimp", gimp,
"paint-info", paint_info,
NULL);
gimp_context_define_properties (GIMP_CONTEXT (desc->stroke_options),
GIMP_CONTEXT_FOREGROUND_MASK |
GIMP_CONTEXT_PATTERN_MASK,
FALSE);
if (context)
gimp_context_set_parent (GIMP_CONTEXT (desc->stroke_options), context);
return desc;
}
void
gimp_stroke_desc_prepare (GimpStrokeDesc *desc,
GimpContext *context,
gboolean use_default_values)
{
g_return_if_fail (GIMP_IS_STROKE_DESC (desc));
g_return_if_fail (GIMP_IS_CONTEXT (context));
switch (desc->method)
{
case GIMP_STROKE_METHOD_LIBART:
break;
case GIMP_STROKE_METHOD_PAINT_CORE:
{
GimpPaintInfo *paint_info = desc->paint_info;
GimpPaintOptions *paint_options;
if (use_default_values)
{
paint_options = gimp_paint_options_new (paint_info);
/* undefine the paint-relevant context properties and get them
* from the passed context
*/
gimp_context_define_properties (GIMP_CONTEXT (paint_options),
GIMP_CONTEXT_PAINT_PROPS_MASK,
FALSE);
gimp_context_set_parent (GIMP_CONTEXT (paint_options), context);
}
else
{
GimpCoreConfig *config = context->gimp->config;
GimpContextPropMask global_props = 0;
paint_options =
gimp_config_duplicate (GIMP_CONFIG (paint_info->paint_options));
/* FG and BG are always shared between all tools */
global_props |= GIMP_CONTEXT_FOREGROUND_MASK;
global_props |= GIMP_CONTEXT_BACKGROUND_MASK;
if (config->global_brush)
global_props |= GIMP_CONTEXT_BRUSH_MASK;
if (config->global_pattern)
global_props |= GIMP_CONTEXT_PATTERN_MASK;
if (config->global_palette)
global_props |= GIMP_CONTEXT_PALETTE_MASK;
if (config->global_gradient)
global_props |= GIMP_CONTEXT_GRADIENT_MASK;
if (config->global_font)
global_props |= GIMP_CONTEXT_FONT_MASK;
gimp_context_copy_properties (context,
GIMP_CONTEXT (paint_options),
global_props);
}
g_object_set (desc, "paint-options", paint_options, NULL);
g_object_unref (paint_options);
}
break;
default:
g_return_if_reached ();
}
}
void
gimp_stroke_desc_finish (GimpStrokeDesc *desc)
{
g_return_if_fail (GIMP_IS_STROKE_DESC (desc));
g_object_set (desc, "paint-options", NULL, NULL);
}

70
app/core/gimpstrokedesc.h Normal file
View File

@ -0,0 +1,70 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpstrokedesc.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_STROKE_DESC_H__
#define __GIMP_STROKE_DESC_H__
#include "gimpcontext.h"
#define GIMP_TYPE_STROKE_DESC (gimp_stroke_desc_get_type ())
#define GIMP_STROKE_DESC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STROKE_DESC, GimpStrokeDesc))
#define GIMP_STROKE_DESC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STROKE_DESC, GimpStrokeDescClass))
#define GIMP_IS_STROKE_DESC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_STROKE_DESC))
#define GIMP_IS_STROKE_DESC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_STROKE_DESC))
#define GIMP_STROKE_DESC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_STROKE_DESC, GimpStrokeDescClass))
typedef struct _GimpStrokeDescClass GimpStrokeDescClass;
struct _GimpStrokeDesc
{
GimpObject parent_instance;
Gimp *gimp;
GimpStrokeMethod method;
GimpStrokeOptions *stroke_options;
GimpPaintInfo *paint_info;
GimpPaintOptions *paint_options;
};
struct _GimpStrokeDescClass
{
GimpObjectClass parent_class;
};
GType gimp_stroke_desc_get_type (void) G_GNUC_CONST;
GimpStrokeDesc * gimp_stroke_desc_new (Gimp *gimp,
GimpContext *context);
void gimp_stroke_desc_prepare (GimpStrokeDesc *desc,
GimpContext *context,
gboolean use_default_values);
void gimp_stroke_desc_finish (GimpStrokeDesc *desc);
#endif /* __GIMP_STROKE_DESC_H__ */

View File

@ -33,11 +33,13 @@
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimppaintinfo.h" #include "core/gimppaintinfo.h"
#include "core/gimpstrokedesc.h"
#include "core/gimpstrokeoptions.h" #include "core/gimpstrokeoptions.h"
#include "core/gimptoolinfo.h" #include "core/gimptoolinfo.h"
#include "widgets/gimpcontainercombobox.h" #include "widgets/gimpcontainercombobox.h"
#include "widgets/gimpcontainerview.h" #include "widgets/gimpcontainerview.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpviewabledialog.h" #include "widgets/gimpviewabledialog.h"
#include "widgets/gimpstrokeeditor.h" #include "widgets/gimpstrokeeditor.h"
@ -57,12 +59,11 @@ static void stroke_dialog_response (GtkWidget *widget,
static void stroke_dialog_paint_info_selected (GimpContainerView *view, static void stroke_dialog_paint_info_selected (GimpContainerView *view,
GimpViewable *viewable, GimpViewable *viewable,
gpointer insert_data, gpointer insert_data,
GtkWidget *dialog); GimpStrokeDesc *desc);
/* public function */ /* public function */
GtkWidget * GtkWidget *
stroke_dialog_new (GimpItem *item, stroke_dialog_new (GimpItem *item,
const gchar *stock_id, const gchar *stock_id,
@ -70,17 +71,16 @@ stroke_dialog_new (GimpItem *item,
GtkWidget *parent) GtkWidget *parent)
{ {
GimpContext *context; GimpContext *context;
GimpStrokeOptions *options; GimpStrokeDesc *desc;
GimpStrokeOptions *saved_options; GimpStrokeDesc *saved_desc;
GimpImage *image; GimpImage *image;
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *main_vbox; GtkWidget *main_vbox;
GtkWidget *button; GtkWidget *radio_box;
GtkWidget *libart_radio;
GtkWidget *paint_radio;
GSList *group; GSList *group;
GtkWidget *frame; GtkWidget *frame;
GimpToolInfo *tool_info;
gboolean libart_stroking = TRUE;
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL); g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
g_return_val_if_fail (stock_id != NULL, NULL); g_return_val_if_fail (stock_id != NULL, NULL);
@ -89,37 +89,13 @@ stroke_dialog_new (GimpItem *item,
image = gimp_item_get_image (item); image = gimp_item_get_image (item);
context = gimp_get_user_context (image->gimp); context = gimp_get_user_context (image->gimp);
tool_info = gimp_context_get_tool (context);
options = g_object_new (GIMP_TYPE_STROKE_OPTIONS, desc = gimp_stroke_desc_new (context->gimp, context);
"gimp", image->gimp,
NULL);
g_object_set_data (G_OBJECT (options), "libart-stroking",
GINT_TO_POINTER (libart_stroking));
g_object_set_data (G_OBJECT (options), "gimp-paint-info",
gimp_context_get_tool (context)->paint_info);
saved_options = g_object_get_data (G_OBJECT (context), saved_desc = g_object_get_data (G_OBJECT (context), "saved-stroke-desc");
"saved-stroke-options");
if (saved_options)
{
gimp_config_sync (GIMP_CONFIG (saved_options), GIMP_CONFIG (options), 0);
libart_stroking = GPOINTER_TO_INT (g_object_get_data
(G_OBJECT (saved_options),
"libart-stroking"));
g_object_set_data (G_OBJECT (options), "libart-stroking", if (saved_desc)
GINT_TO_POINTER (libart_stroking)); gimp_config_sync (GIMP_CONFIG (saved_desc), GIMP_CONFIG (desc), 0);
g_object_set_data (G_OBJECT (options), "gimp-paint-info",
g_object_get_data (G_OBJECT (saved_options),
"gimp-paint-info"));
}
gimp_context_set_parent (GIMP_CONTEXT (options), context);
gimp_context_define_properties (GIMP_CONTEXT (options),
GIMP_CONTEXT_FOREGROUND_MASK |
GIMP_CONTEXT_PATTERN_MASK,
FALSE);
/* the dialog */ /* the dialog */
dialog = dialog =
@ -142,7 +118,7 @@ stroke_dialog_new (GimpItem *item,
dialog); dialog);
g_object_set_data (G_OBJECT (dialog), "gimp-item", item); g_object_set_data (G_OBJECT (dialog), "gimp-item", item);
g_object_set_data_full (G_OBJECT (dialog), "gimp-stroke-options", options, g_object_set_data_full (G_OBJECT (dialog), "gimp-stroke-desc", desc,
(GDestroyNotify) g_object_unref); (GDestroyNotify) g_object_unref);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
@ -152,6 +128,31 @@ stroke_dialog_new (GimpItem *item,
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
gtk_widget_show (main_vbox); gtk_widget_show (main_vbox);
radio_box = gimp_prop_enum_radio_box_new (G_OBJECT (desc), "method", -1, -1);
group = gtk_radio_button_get_group (g_object_get_data (G_OBJECT (radio_box),
"radio-button"));
libart_radio = g_object_ref (group->next->data);
gtk_container_remove (GTK_CONTAINER (radio_box), libart_radio);
paint_radio = g_object_ref (group->data);
gtk_container_remove (GTK_CONTAINER (radio_box), paint_radio);
gtk_widget_destroy (radio_box);
{
PangoFontDescription *font_desc;
font_desc = pango_font_description_new ();
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
gtk_widget_modify_font (GTK_BIN (libart_radio)->child, font_desc);
gtk_widget_modify_font (GTK_BIN (paint_radio)->child, font_desc);
pango_font_description_free (font_desc);
}
/* the stroke frame */ /* the stroke frame */
@ -159,28 +160,26 @@ stroke_dialog_new (GimpItem *item,
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame); gtk_widget_show (frame);
button = gtk_radio_button_new_with_label (NULL, _("Stroke line")); gtk_frame_set_label_widget (GTK_FRAME (frame), libart_radio);
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); g_object_unref (libart_radio);
gtk_frame_set_label_widget (GTK_FRAME (frame), button);
gtk_widget_show (button);
g_signal_connect (button, "toggled", g_signal_connect (libart_radio, "toggled",
G_CALLBACK (gimp_toggle_button_sensitive_update), G_CALLBACK (gimp_toggle_button_sensitive_update),
NULL); NULL);
g_object_set_data (G_OBJECT (dialog), "gimp-stroke-button", button);
{ {
GtkWidget *stroke_editor; GtkWidget *stroke_editor;
stroke_editor = gimp_stroke_editor_new (options, image->yresolution); stroke_editor = gimp_stroke_editor_new (desc->stroke_options,
image->yresolution);
gtk_container_add (GTK_CONTAINER (frame), stroke_editor); gtk_container_add (GTK_CONTAINER (frame), stroke_editor);
gtk_widget_show (stroke_editor); gtk_widget_show (stroke_editor);
g_object_set_data (G_OBJECT (button), "set_sensitive", stroke_editor); gtk_widget_set_sensitive (stroke_editor,
desc->method == GIMP_STROKE_METHOD_LIBART);
g_object_set_data (G_OBJECT (libart_radio), "set_sensitive", stroke_editor);
} }
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), libart_stroking);
/* the paint tool frame */ /* the paint tool frame */
@ -188,13 +187,10 @@ stroke_dialog_new (GimpItem *item,
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame); gtk_widget_show (frame);
button = gtk_radio_button_new_with_label (group, gtk_frame_set_label_widget (GTK_FRAME (frame), paint_radio);
_("Stroke with a paint tool")); g_object_unref (paint_radio);
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
gtk_frame_set_label_widget (GTK_FRAME (frame), button);
gtk_widget_show (button);
g_signal_connect (button, "toggled", g_signal_connect (paint_radio, "toggled",
G_CALLBACK (gimp_toggle_button_sensitive_update), G_CALLBACK (gimp_toggle_button_sensitive_update),
NULL); NULL);
@ -202,14 +198,14 @@ stroke_dialog_new (GimpItem *item,
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *label; GtkWidget *label;
GtkWidget *combo; GtkWidget *combo;
GimpPaintInfo *paint_info;
hbox = gtk_hbox_new (FALSE, 6); hbox = gtk_hbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (frame), hbox); gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox); gtk_widget_show (hbox);
gtk_widget_set_sensitive (GTK_WIDGET (hbox), FALSE); gtk_widget_set_sensitive (hbox,
g_object_set_data (G_OBJECT (button), "set_sensitive", hbox); desc->method == GIMP_STROKE_METHOD_PAINT_CORE);
g_object_set_data (G_OBJECT (paint_radio), "set_sensitive", hbox);
label = gtk_label_new (_("Paint Tool:")); label = gtk_label_new (_("Paint Tool:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
@ -217,24 +213,19 @@ stroke_dialog_new (GimpItem *item,
combo = gimp_container_combo_box_new (image->gimp->paint_info_list, NULL, combo = gimp_container_combo_box_new (image->gimp->paint_info_list, NULL,
16, 0); 16, 0);
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (combo),
GIMP_VIEWABLE (desc->paint_info));
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo); gtk_widget_show (combo);
g_signal_connect (combo, "select_item", g_signal_connect (combo, "select_item",
G_CALLBACK (stroke_dialog_paint_info_selected), G_CALLBACK (stroke_dialog_paint_info_selected),
dialog); desc);
paint_info = GIMP_PAINT_INFO (g_object_get_data (G_OBJECT (options),
"gimp-paint-info"));
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (combo),
GIMP_VIEWABLE (paint_info));
g_object_set_data (G_OBJECT (dialog), "gimp-tool-menu", combo); g_object_set_data (G_OBJECT (dialog), "gimp-tool-menu", combo);
g_object_set_data (G_OBJECT (dialog), "gimp-paint-info", paint_info);
} }
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), !libart_stroking);
return dialog; return dialog;
} }
@ -246,13 +237,13 @@ stroke_dialog_response (GtkWidget *widget,
gint response_id, gint response_id,
GtkWidget *dialog) GtkWidget *dialog)
{ {
GimpContext *context; GimpStrokeDesc *desc;
GimpItem *item; GimpItem *item;
GtkWidget *button;
GimpImage *image; GimpImage *image;
GimpContext *context;
item = g_object_get_data (G_OBJECT (dialog), "gimp-item"); item = g_object_get_data (G_OBJECT (dialog), "gimp-item");
button = g_object_get_data (G_OBJECT (dialog), "gimp-stroke-button"); desc = g_object_get_data (G_OBJECT (dialog), "gimp-stroke-desc");
image = gimp_item_get_image (item); image = gimp_item_get_image (item);
context = gimp_get_user_context (image->gimp); context = gimp_get_user_context (image->gimp);
@ -261,28 +252,22 @@ stroke_dialog_response (GtkWidget *widget,
{ {
case RESPONSE_RESET: case RESPONSE_RESET:
{ {
GObject *options; GimpToolInfo *tool_info = gimp_context_get_tool (context);
GtkWidget *combo; GtkWidget *combo = g_object_get_data (G_OBJECT (dialog),
GimpToolInfo *tool_info; "gimp-tool-menu");;
options = g_object_get_data (G_OBJECT (dialog), "gimp-stroke-options"); gimp_config_reset (GIMP_CONFIG (desc));
combo = g_object_get_data (G_OBJECT (dialog), "gimp-tool-menu");
tool_info = gimp_context_get_tool (context);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (combo), gimp_container_view_select_item (GIMP_CONTAINER_VIEW (combo),
GIMP_VIEWABLE (tool_info->paint_info)); GIMP_VIEWABLE (tool_info->paint_info));
gimp_config_reset (GIMP_CONFIG (options));
} }
break; break;
case GTK_RESPONSE_OK: case GTK_RESPONSE_OK:
{ {
GimpDrawable *drawable; GimpDrawable *drawable;
GimpObject *options; GimpStrokeDesc *saved_desc;
GObject *saved_options;
drawable = gimp_image_active_drawable (image); drawable = gimp_image_active_drawable (image);
@ -292,42 +277,21 @@ stroke_dialog_response (GtkWidget *widget,
return; return;
} }
saved_options = g_object_get_data (G_OBJECT (context), saved_desc = g_object_get_data (G_OBJECT (context),
"saved-stroke-options"); "saved-stroke-desc");
options = g_object_get_data (G_OBJECT (dialog),
"gimp-stroke-options");
if (saved_options) if (saved_desc)
{ g_object_ref (saved_desc);
gimp_config_sync (GIMP_CONFIG (options),
GIMP_CONFIG (saved_options), 0);
}
else else
{ saved_desc = gimp_stroke_desc_new (context->gimp, context);
g_object_set_data_full (G_OBJECT (context),
"saved-stroke-options", gimp_config_sync (GIMP_CONFIG (desc), GIMP_CONFIG (saved_desc), 0);
g_object_ref (options),
g_object_set_data_full (G_OBJECT (context), "saved-stroke-desc",
saved_desc,
(GDestroyNotify) g_object_unref); (GDestroyNotify) g_object_unref);
saved_options = G_OBJECT (options);
}
g_object_set_data (saved_options, "gimp-paint-info", gimp_item_stroke (item, drawable, context, desc, FALSE);
g_object_get_data (G_OBJECT (dialog),
"gimp-paint-info"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{
g_object_set_data (saved_options, "libart-stroking",
GINT_TO_POINTER (TRUE));
}
else
{
g_object_set_data (saved_options, "libart-stroking",
GINT_TO_POINTER (FALSE));
options = g_object_get_data (G_OBJECT (dialog), "gimp-paint-info");
}
gimp_item_stroke (item, drawable, context, options, FALSE);
gimp_image_flush (image); gimp_image_flush (image);
} }
/* fallthrough */ /* fallthrough */
@ -342,7 +306,7 @@ static void
stroke_dialog_paint_info_selected (GimpContainerView *view, stroke_dialog_paint_info_selected (GimpContainerView *view,
GimpViewable *viewable, GimpViewable *viewable,
gpointer insert_data, gpointer insert_data,
GtkWidget *dialog) GimpStrokeDesc *desc)
{ {
g_object_set_data (G_OBJECT (dialog), "gimp-paint-info", viewable); g_object_set (desc, "paint-info", viewable, NULL);
} }

View File

@ -29,14 +29,13 @@
#include "core/gimp-edit.h" #include "core/gimp-edit.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpchannel.h" #include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable-blend.h" #include "core/gimpdrawable-blend.h"
#include "core/gimpdrawable-bucket-fill.h" #include "core/gimpdrawable-bucket-fill.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimplayer.h" #include "core/gimplayer.h"
#include "core/gimpprogress.h" #include "core/gimpprogress.h"
#include "core/gimptoolinfo.h" #include "core/gimpstrokedesc.h"
#include "gimp-intl.h" #include "gimp-intl.h"
static ProcRecord edit_cut_proc; static ProcRecord edit_cut_proc;
@ -729,17 +728,15 @@ edit_stroke_invoker (Gimp *gimp,
if (success) if (success)
{ {
GimpImage *gimage; GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpToolInfo *tool_info; GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
gimage = gimp_item_get_image (GIMP_ITEM (drawable)); g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
tool_info = gimp_context_get_tool (context);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)), success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable, context, drawable, context, desc, TRUE);
GIMP_OBJECT (tool_info->paint_info),
TRUE /* use defaults, not tool option values */); g_object_unref (desc);
} }
return procedural_db_return_args (&edit_stroke_proc, success); return procedural_db_return_args (&edit_stroke_proc, success);

View File

@ -29,10 +29,9 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpchannel-select.h" #include "core/gimpchannel-select.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimplist.h" #include "core/gimplist.h"
#include "core/gimptoolinfo.h" #include "core/gimpstrokedesc.h"
#include "gimp-intl.h" #include "gimp-intl.h"
#include "vectors/gimpanchor.h" #include "vectors/gimpanchor.h"
#include "vectors/gimpbezierstroke.h" #include "vectors/gimpbezierstroke.h"
@ -601,8 +600,6 @@ path_stroke_current_invoker (Gimp *gimp,
{ {
gboolean success = TRUE; gboolean success = TRUE;
GimpImage *gimage; GimpImage *gimage;
GimpVectors *vectors;
GimpDrawable *drawable;
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (gimage)) if (! GIMP_IS_IMAGE (gimage))
@ -610,16 +607,19 @@ path_stroke_current_invoker (Gimp *gimp,
if (success) if (success)
{ {
vectors = gimp_image_get_active_vectors (gimage); GimpVectors *vectors = gimp_image_get_active_vectors (gimage);
drawable = gimp_image_active_drawable (gimage); GimpDrawable *drawable = gimp_image_active_drawable (gimage);
if (vectors && drawable) if (vectors && drawable)
{ {
GimpToolInfo *tool_info = gimp_context_get_tool (context); GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
success = gimp_item_stroke (GIMP_ITEM (vectors), drawable, context, g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
GIMP_OBJECT (tool_info->paint_info),
TRUE /* use defaults, not tool option values */); success = gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, desc, TRUE);
g_object_unref (desc);
} }
else else
success = FALSE; success = FALSE;

View File

@ -36,7 +36,7 @@
#include "core/gimpimage-undo-push.h" #include "core/gimpimage-undo-push.h"
#include "core/gimpmarshal.h" #include "core/gimpmarshal.h"
#include "core/gimppaintinfo.h" #include "core/gimppaintinfo.h"
#include "core/gimpstrokeoptions.h" #include "core/gimpstrokedesc.h"
#include "paint/gimppaintcore-stroke.h" #include "paint/gimppaintcore-stroke.h"
#include "paint/gimppaintoptions.h" #include "paint/gimppaintoptions.h"
@ -113,7 +113,7 @@ static void gimp_vectors_transform (GimpItem *item,
static gboolean gimp_vectors_stroke (GimpItem *item, static gboolean gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc); GimpStrokeDesc *stroke_desc);
static void gimp_vectors_real_thaw (GimpVectors *vectors); static void gimp_vectors_real_thaw (GimpVectors *vectors);
static void gimp_vectors_real_stroke_add (GimpVectors *vectors, static void gimp_vectors_real_stroke_add (GimpVectors *vectors,
@ -558,7 +558,7 @@ static gboolean
gimp_vectors_stroke (GimpItem *item, gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpContext *context, GimpContext *context,
GimpObject *stroke_desc) GimpStrokeDesc *stroke_desc)
{ {
GimpVectors *vectors = GIMP_VECTORS (item); GimpVectors *vectors = GIMP_VECTORS (item);
gboolean retval = FALSE; gboolean retval = FALSE;
@ -569,26 +569,32 @@ gimp_vectors_stroke (GimpItem *item,
return FALSE; return FALSE;
} }
if (GIMP_IS_STROKE_OPTIONS (stroke_desc)) switch (stroke_desc->method)
{ {
case GIMP_STROKE_METHOD_LIBART:
gimp_drawable_stroke_vectors (drawable, gimp_drawable_stroke_vectors (drawable,
GIMP_STROKE_OPTIONS (stroke_desc), stroke_desc->stroke_options,
vectors); vectors);
retval = TRUE; retval = TRUE;
} break;
else if (GIMP_IS_PAINT_OPTIONS (stroke_desc))
case GIMP_STROKE_METHOD_PAINT_CORE:
{ {
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (stroke_desc);
GimpPaintCore *core; GimpPaintCore *core;
core = g_object_new (paint_options->paint_info->paint_type, NULL); core = g_object_new (stroke_desc->paint_info->paint_type, NULL);
retval = gimp_paint_core_stroke_vectors (core, drawable, retval = gimp_paint_core_stroke_vectors (core, drawable,
paint_options, stroke_desc->paint_options,
vectors); vectors);
g_object_unref (core); g_object_unref (core);
} }
break;
default:
g_return_val_if_reached (FALSE);
}
return retval; return retval;
} }

View File

@ -354,20 +354,18 @@ HELP
&inargs('stroke to'); &inargs('stroke to');
%invoke = ( %invoke = (
headers => [ qw("core/gimpcontext.h" "core/gimptoolinfo.h") ], headers => [ qw("core/gimpstrokedesc.h") ],
code => <<'CODE' code => <<'CODE'
{ {
GimpImage *gimage; GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpToolInfo *tool_info; GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
gimage = gimp_item_get_image (GIMP_ITEM (drawable)); g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
tool_info = gimp_context_get_tool (context);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)), success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable, context, drawable, context, desc, TRUE);
GIMP_OBJECT (tool_info->paint_info),
TRUE /* use defaults, not tool option values */); g_object_unref (desc);
} }
CODE CODE
); );

View File

@ -302,19 +302,22 @@ HELP
stroke.'; stroke.';
%invoke = ( %invoke = (
vars => [ 'GimpVectors *vectors', 'GimpDrawable *drawable' ], headers => [ qw("core/gimpstrokedesc.h") ],
code => <<'CODE' code => <<'CODE'
{ {
vectors = gimp_image_get_active_vectors (gimage); GimpVectors *vectors = gimp_image_get_active_vectors (gimage);
drawable = gimp_image_active_drawable (gimage); GimpDrawable *drawable = gimp_image_active_drawable (gimage);
if (vectors && drawable) if (vectors && drawable)
{ {
GimpToolInfo *tool_info = gimp_context_get_tool (context); GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
success = gimp_item_stroke (GIMP_ITEM (vectors), drawable, context, g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
GIMP_OBJECT (tool_info->paint_info),
TRUE /* use defaults, not tool option values */); success = gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, desc, TRUE);
g_object_unref (desc);
} }
else else
success = FALSE; success = FALSE;
@ -703,8 +706,8 @@ HELP
); );
} }
@headers = qw(<string.h> "core/gimp.h" "core/gimpcontext.h" "core/gimplist.h" @headers = qw(<string.h> "core/gimp.h" "core/gimplist.h"
"core/gimptoolinfo.h" "core/gimpchannel-select.h" "core/gimpchannel-select.h"
"vectors/gimpanchor.h" "vectors/gimpbezierstroke.h" "vectors/gimpanchor.h" "vectors/gimpbezierstroke.h"
"vectors/gimpvectors.h" "vectors/gimpvectors-compat.h" "vectors/gimpvectors.h" "vectors/gimpvectors-compat.h"
"gimp-intl.h"); "gimp-intl.h");