New Object, holding the Options for a Libart-Stroke.

2003-09-26  Simon Budig  <simon@gimp.org>

	* app/core/gimpstrokeoptions.[ch]: New Object, holding the
	Options for a Libart-Stroke.

	* app/core/Makefile.am
	* app/core/core-types.h: Changed accordingly.

	* app/core/gimpitem.[ch]: Changed the Signature of
	gimp_item_stroke to accept a GimpObject instead of a
	GimpPaintInfo. This enables us to pass GimpStrokeOptions
	to it. To be cleaned up for 2.2.

	* app/core/gimpselection.c
	* app/core/gimpchannel.c
	* app/vectors/gimpvectors.c: Changed accordingly

	* app/gui/edit-commands.c
	* app/gui/vectors-commands.c
	* app/pdb/edit_cmds.c
	* app/pdb/paths_cmds.c
	* app/widgets/gimpselectioneditor.c
	* app/widgets/gimpvectorstreeview.c: Fixed warnings by
	casting the GimpPaintInfo to GimpObject.
This commit is contained in:
Simon Budig 2003-09-26 15:37:53 +00:00 committed by Simon Budig
parent fc58b707a3
commit 10a5269e22
18 changed files with 424 additions and 22 deletions

View File

@ -1,3 +1,28 @@
2003-09-26 Simon Budig <simon@gimp.org>
* app/core/gimpstrokeoptions.[ch]: New Object, holding the
Options for a Libart-Stroke.
* app/core/Makefile.am
* app/core/core-types.h: Changed accordingly.
* app/core/gimpitem.[ch]: Changed the Signature of
gimp_item_stroke to accept a GimpObject instead of a
GimpPaintInfo. This enables us to pass GimpStrokeOptions
to it. To be cleaned up for 2.2.
* app/core/gimpselection.c
* app/core/gimpchannel.c
* app/vectors/gimpvectors.c: Changed accordingly
* app/gui/edit-commands.c
* app/gui/vectors-commands.c
* app/pdb/edit_cmds.c
* app/pdb/paths_cmds.c
* app/widgets/gimpselectioneditor.c
* app/widgets/gimpvectorstreeview.c: Fixed warnings by
casting the GimpPaintInfo to GimpObject.
2003-09-26 Michael Natterer <mitch@gimp.org>
* app/widgets/gimppaletteeditor.c: removed inclusion of

View File

@ -276,7 +276,7 @@ edit_stroke_cmd_callback (GtkWidget *widget,
tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
active_drawable, tool_info->paint_info);
active_drawable, GIMP_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
}

View File

@ -199,7 +199,7 @@ vectors_stroke_cmd_callback (GtkWidget *widget,
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_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
}

View File

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

View File

@ -65,6 +65,7 @@ typedef struct _GimpItem GimpItem;
typedef struct _GimpBuffer GimpBuffer;
typedef struct _GimpPaintInfo GimpPaintInfo;
typedef struct _GimpStrokeOptions GimpStrokeOptions;
typedef struct _GimpToolInfo GimpToolInfo;
typedef struct _GimpToolOptions GimpToolOptions;

View File

@ -97,7 +97,7 @@ static void gimp_channel_transform (GimpItem *item,
gpointer progress_data);
static gboolean gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
GimpObject *stroke_desc);
static void gimp_channel_invalidate_boundary (GimpDrawable *drawable);
@ -579,7 +579,8 @@ gimp_channel_transform (GimpItem *item,
static gboolean
gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
GimpObject *stroke_desc)
{
GimpChannel *channel;
GimpImage *gimage;
@ -588,6 +589,7 @@ gimp_channel_stroke (GimpItem *item,
gint num_segs_in;
gint num_segs_out;
GimpPaintCore *core;
GimpPaintInfo *paint_info;
gboolean retval;
channel = GIMP_CHANNEL (item);
@ -596,6 +598,8 @@ gimp_channel_stroke (GimpItem *item,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
paint_info = GIMP_PAINT_INFO (stroke_desc);
if (! gimp_channel_boundary (channel, &bs_in, &bs_out,
&num_segs_in, &num_segs_out,
0, 0, 0, 0))

View File

@ -40,6 +40,7 @@
#include "gimpmarshal.h"
#include "gimppaintinfo.h"
#include "gimpparasitelist.h"
#include "gimpstrokeoptions.h"
#include "vectors/gimpvectors.h"
@ -770,18 +771,19 @@ gimp_item_transform (GimpItem *item,
gboolean
gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
GimpObject *stroke_desc)
{
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);
g_return_val_if_fail (GIMP_IS_PAINT_INFO (stroke_desc) ||
GIMP_IS_STROKE_OPTIONS (stroke_desc), FALSE);
item_class = GIMP_ITEM_GET_CLASS (item);
if (item_class->stroke)
return item_class->stroke (item, drawable, paint_info);
return item_class->stroke (item, drawable, stroke_desc);
return FALSE;
}

View File

@ -104,7 +104,7 @@ struct _GimpItemClass
gpointer progress_data);
gboolean (* stroke) (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
GimpObject *stroke_desc);
const gchar *default_name;
const gchar *rename_desc;
@ -188,7 +188,7 @@ void gimp_item_transform (GimpItem *item,
gboolean gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
GimpObject *stroke_desc);
gint gimp_item_get_ID (GimpItem *item);
GimpItem * gimp_item_get_by_ID (Gimp *gimp,

View File

@ -69,7 +69,7 @@ static void gimp_selection_rotate (GimpItem *item,
gboolean clip_result);
static gboolean gimp_selection_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
GimpObject *stroke_desc);
static void gimp_selection_invalidate_boundary (GimpDrawable *drawable);
@ -280,7 +280,7 @@ gimp_selection_rotate (GimpItem *item,
static gboolean
gimp_selection_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
GimpObject *stroke_desc)
{
GimpSelection *selection;
GimpImage *gimage;
@ -308,7 +308,7 @@ gimp_selection_stroke (GimpItem *item,
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT,
_("Stroke Selection"));
retval = GIMP_ITEM_CLASS (parent_class)->stroke (item, drawable, paint_info);
retval = GIMP_ITEM_CLASS (parent_class)->stroke (item, drawable, stroke_desc);
gimp_image_undo_group_end (gimage);

View File

@ -0,0 +1,301 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpstrokeoptions.c
* Copyright (C) 2003 Simon Budig
*
* 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 "gimpstrokeoptions.h"
enum
{
PROP_0,
PROP_WIDTH,
PROP_CAP_STYLE,
PROP_JOIN_STYLE,
PROP_MITER,
PROP_ANTIALIAS,
PROP_DASH_OFFSET,
PROP_DASH_INFO
};
static void gimp_stroke_options_init (GimpStrokeOptions *options);
static void gimp_stroke_options_class_init (GimpStrokeOptionsClass *options_class);
static void gimp_stroke_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_stroke_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GimpContextClass *parent_class = NULL;
GType
gimp_stroke_options_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo info =
{
sizeof (GimpStrokeOptionsClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_stroke_options_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpStrokeOptions),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_stroke_options_init,
};
type = g_type_register_static (GIMP_TYPE_CONTEXT,
"GimpStrokeOptions",
&info, 0);
}
return type;
}
static void
gimp_stroke_options_class_init (GimpStrokeOptionsClass *klass)
{
GObjectClass *object_class;
GParamSpec *array_spec;
object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->set_property = gimp_stroke_options_set_property;
object_class->get_property = gimp_stroke_options_get_property;
g_object_class_install_property (object_class, PROP_WIDTH,
g_param_spec_double ("width",
NULL, NULL,
0.0, 2000.0,
5.0,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_CAP_STYLE,
g_param_spec_enum ("cap-style",
NULL, NULL,
GIMP_TYPE_CAP_STYLE,
GIMP_CAP_BUTT,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_JOIN_STYLE,
g_param_spec_enum ("join-style",
NULL, NULL,
GIMP_TYPE_JOIN_STYLE,
GIMP_JOIN_MITER,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_MITER,
g_param_spec_double ("miter",
NULL, NULL,
0.0, 100.0,
10.0,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_ANTIALIAS,
g_param_spec_boolean ("antialias",
NULL, NULL,
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_DASH_OFFSET,
g_param_spec_double ("dash-offset",
NULL, NULL,
0.0, 2000.0,
0.0,
G_PARAM_READWRITE));
array_spec = g_param_spec_double ("dash-length", NULL, NULL,
0.0, 2000.0, 1.0, G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_DASH_INFO,
g_param_spec_value_array ("dash-info",
NULL, NULL,
array_spec,
G_PARAM_READWRITE));
}
static void
gimp_stroke_options_init (GimpStrokeOptions *options)
{
options->width = 5.0;
options->cap_style = GIMP_CAP_BUTT;
options->join_style = GIMP_JOIN_MITER;
options->miter = 10.0;
options->antialias = TRUE;
options->dash_offset = 0.0;
options->dash_info = NULL;
}
static void
gimp_stroke_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpStrokeOptions *options;
GValueArray *val_array;
GValue *item;
gint i;
gdouble val;
options = GIMP_STROKE_OPTIONS (object);
switch (property_id)
{
case PROP_WIDTH:
options->width = g_value_get_double (value);
break;
case PROP_CAP_STYLE:
options->cap_style = g_value_get_int (value);
break;
case PROP_JOIN_STYLE:
options->join_style = g_value_get_int (value);
break;
case PROP_MITER:
options->miter = g_value_get_double (value);
break;
case PROP_ANTIALIAS:
options->antialias = g_value_get_boolean (value);
break;
case PROP_DASH_OFFSET:
options->dash_offset = g_value_get_double (value);
break;
case PROP_DASH_INFO:
if (options->dash_info)
g_array_free (options->dash_info, TRUE);
val_array = g_value_get_boxed (value);
if (val_array == NULL || val_array->n_values == 0)
{
options->dash_info = NULL;
}
else
{
options->dash_info = g_array_sized_new (FALSE, FALSE,
sizeof (gdouble),
val_array->n_values);
for (i=0; i < val_array->n_values; i++)
{
item = g_value_array_get_nth (val_array, i);
g_return_if_fail (G_VALUE_HOLDS_DOUBLE (item));
val = g_value_get_double (item);
options->dash_info = g_array_append_val (options->dash_info, val);
}
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_stroke_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpStrokeOptions *options;
GValueArray *val_array;
GValue item;
gint i;
options = GIMP_STROKE_OPTIONS (object);
switch (property_id)
{
case PROP_WIDTH:
g_value_set_double (value, options->width);
break;
case PROP_CAP_STYLE:
g_value_set_int (value, options->cap_style);
break;
case PROP_JOIN_STYLE:
g_value_set_int (value, options->join_style);
break;
case PROP_MITER:
g_value_set_double (value, options->miter);
break;
case PROP_ANTIALIAS:
g_value_set_boolean (value, options->antialias);
break;
case PROP_DASH_OFFSET:
g_value_set_double (value, options->dash_offset);
break;
case PROP_DASH_INFO:
if (options->dash_info)
g_array_free (options->dash_info, TRUE);
if (options->dash_info == NULL || options->dash_info->len == 0)
{
g_value_set_boxed (value, NULL);
}
else
{
val_array = g_value_array_new (options->dash_info->len);
for (i=0; i < options->dash_info->len; i++)
{
g_value_set_double (&item, g_array_index (options->dash_info,
gdouble,
i));
g_value_array_append (val_array, &item);
}
g_value_set_boxed (value, val_array);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,64 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpstrokeoptions.h
* Copyright (C) 2003 Simon Budig
*
* 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_OPTIONS_H__
#define __GIMP_STROKE_OPTIONS_H__
#include "gimpcontext.h"
#define GIMP_TYPE_STROKE_OPTIONS (gimp_stroke_options_get_type ())
#define GIMP_STROKE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STROKE_OPTIONS, GimpStrokeOptions))
#define GIMP_STROKE_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STROKE_OPTIONS, GimpStrokeOptionsClass))
#define GIMP_IS_STROKE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_STROKE_OPTIONS))
#define GIMP_IS_STROKE_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_STROKE_OPTIONS))
#define GIMP_STROKE_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_STROKE_OPTIONS, GimpStrokeOptionsClass))
typedef struct _GimpStrokeOptionsClass GimpStrokeOptionsClass;
struct _GimpStrokeOptions
{
GimpContext parent_instance;
gdouble width;
GimpCapStyle cap_style;
GimpJoinStyle join_style;
gdouble miter;
gboolean antialias;
gdouble dash_offset;
GArray *dash_info;
};
struct _GimpStrokeOptionsClass
{
GimpContextClass parent_class;
};
GType gimp_stroke_options_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_STROKE_OPTIONS_H__ */

View File

@ -276,7 +276,7 @@ edit_stroke_cmd_callback (GtkWidget *widget,
tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
active_drawable, tool_info->paint_info);
active_drawable, GIMP_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
}

View File

@ -199,7 +199,7 @@ vectors_stroke_cmd_callback (GtkWidget *widget,
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_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
}

View File

@ -340,7 +340,8 @@ edit_stroke_invoker (Gimp *gimp,
tool_info = gimp_context_get_tool (gimp_get_current_context (gimp));
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
drawable, tool_info->paint_info);
drawable,
GIMP_OBJECT (tool_info->paint_info));
}
return procedural_db_return_args (&edit_stroke_proc, success);

View File

@ -599,7 +599,7 @@ path_stroke_current_invoker (Gimp *gimp,
tool_info = gimp_context_get_tool (gimp_get_current_context (gimp));
success = gimp_item_stroke (GIMP_ITEM (vectors), drawable,
tool_info->paint_info);
GIMP_OBJECT (tool_info->paint_info));
}
else
success = FALSE;

View File

@ -107,7 +107,7 @@ static void gimp_vectors_transform (GimpItem *item,
gpointer progress_data);
static gboolean gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info);
GimpObject *stroke_desc);
#
@ -543,10 +543,11 @@ gimp_vectors_transform (GimpItem *item,
static gboolean
gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpPaintInfo *paint_info)
GimpObject *stroke_desc)
{
GimpVectors *vectors;
gboolean retval;
GimpVectors *vectors;
GimpPaintInfo *paint_info = GIMP_PAINT_INFO (stroke_desc);
gboolean retval;
vectors = GIMP_VECTORS (item);

View File

@ -358,7 +358,7 @@ gimp_selection_editor_stroke_clicked (GtkWidget *widget,
gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
gimp_image_active_drawable (gimage),
tool_info->paint_info);
GIMP_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
}
}

View File

@ -321,7 +321,8 @@ gimp_vectors_tree_view_stroke_clicked (GtkWidget *widget,
tool_info =
gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
gimp_item_stroke (item, active_drawable, tool_info->paint_info);
gimp_item_stroke (item, active_drawable,
GIMP_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
}
}