From 3f76868aeee1618e90df5c96a1eba268b9c2c649 Mon Sep 17 00:00:00 2001 From: Simon Budig Date: Sat, 27 Sep 2003 02:34:18 +0000 Subject: [PATCH] This still is very much in progress. I just want to commit this to avoid 2003-09-27 Simon Budig This still is very much in progress. I just want to commit this to avoid lossage. It kind of works but there definitely is code in the wrong place now. * app/gui/stroke-dialog.[ch]: New files implementing a dialog containing Svens GimpStrokeEditor-Widget. * app/gui/Makefile.am: changed accordingly. * app/gui/vectors-commands.c: Open the StrokeOptions-Dialog when the "stroke" menu entry gets selected. * app/vectors/gimpvectors.c: Remove bad #ifdef hacks and use Libart/Paintcore-Stroking depending on the type of the stroke_desc Parameter. * app/core/gimpstrokeoptions.c: Proper handle the Enum-Properties. * app/core/gimpscanconvert.[ch]: make the antialias-parameter to gimp_scan_convert_new a gboolean. * app/tools/gimpiscissorstool.c * app/core/gimpdrawable-stroke.c * app/core/gimpimage-mask-select.c: Changed accordingly. --- ChangeLog | 27 ++++++ app/actions/vectors-commands.c | 10 ++ app/core/gimpchannel-select.c | 12 +-- app/core/gimpdrawable-stroke.c | 2 +- app/core/gimpimage-mask-select.c | 12 +-- app/core/gimpscanconvert.c | 9 +- app/core/gimpscanconvert.h | 2 +- app/core/gimpstrokeoptions.c | 8 +- app/dialogs/stroke-dialog.c | 161 +++++++++++++++++++++++++++++++ app/dialogs/stroke-dialog.h | 30 ++++++ app/gui/Makefile.am | 2 + app/gui/stroke-dialog.c | 161 +++++++++++++++++++++++++++++++ app/gui/stroke-dialog.h | 30 ++++++ app/gui/vectors-commands.c | 10 ++ app/tools/gimpiscissorstool.c | 4 +- app/vectors/gimpvectors.c | 116 ++++++++++++---------- 16 files changed, 512 insertions(+), 84 deletions(-) create mode 100644 app/dialogs/stroke-dialog.c create mode 100644 app/dialogs/stroke-dialog.h create mode 100644 app/gui/stroke-dialog.c create mode 100644 app/gui/stroke-dialog.h diff --git a/ChangeLog b/ChangeLog index d37b6af947..f2c93a5206 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2003-09-27 Simon Budig + + This still is very much in progress. I just want to commit this + to avoid lossage. It kind of works but there definitely is + code in the wrong place now. + + * app/gui/stroke-dialog.[ch]: New files implementing a dialog + containing Svens GimpStrokeEditor-Widget. + + * app/gui/Makefile.am: changed accordingly. + + * app/gui/vectors-commands.c: Open the StrokeOptions-Dialog when + the "stroke" menu entry gets selected. + + * app/vectors/gimpvectors.c: Remove bad #ifdef hacks and use + Libart/Paintcore-Stroking depending on the type of the stroke_desc + Parameter. + + * app/core/gimpstrokeoptions.c: Proper handle the Enum-Properties. + + * app/core/gimpscanconvert.[ch]: make the antialias-parameter + to gimp_scan_convert_new a gboolean. + + * app/tools/gimpiscissorstool.c + * app/core/gimpdrawable-stroke.c + * app/core/gimpimage-mask-select.c: Changed accordingly. + 2003-09-26 Sven Neumann * app/widgets/Makefile.am diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c index 3884265b24..7322fb2eb2 100644 --- a/app/actions/vectors-commands.c +++ b/app/actions/vectors-commands.c @@ -25,6 +25,7 @@ #include "libgimpwidgets/gimpwidgets.h" #include "gui-types.h" +#include "stroke-dialog.h" #include "core/gimp.h" #include "core/gimpchannel.h" @@ -186,6 +187,7 @@ vectors_stroke_cmd_callback (GtkWidget *widget, GimpVectors *active_vectors; GimpDrawable *active_drawable; GimpToolInfo *tool_info; + GtkWidget *dialog; return_if_no_vectors (gimage, active_vectors, data); active_drawable = gimp_image_active_drawable (gimage); @@ -196,11 +198,19 @@ vectors_stroke_cmd_callback (GtkWidget *widget, return; } + dialog = stroke_dialog_new (active_drawable, + GIMP_ITEM (active_vectors), + NULL); + + gtk_widget_show (dialog); + + /* tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp)); gimp_item_stroke (GIMP_ITEM (active_vectors), active_drawable, GIMP_OBJECT (tool_info->paint_info)); gimp_image_flush (gimage); + */ } void diff --git a/app/core/gimpchannel-select.c b/app/core/gimpchannel-select.c index 33c1ecd1de..a5e6bce41b 100644 --- a/app/core/gimpchannel-select.c +++ b/app/core/gimpchannel-select.c @@ -167,11 +167,9 @@ gimp_image_mask_select_polygon (GimpImage *gimage, else gimp_channel_push_undo (selection, undo_desc); -#define SUPERSAMPLE 3 - scan_convert = gimp_scan_convert_new (gimage->width, gimage->height, - antialias ? SUPERSAMPLE : 1); + antialias); gimp_scan_convert_add_polyline (scan_convert, n_points, points, TRUE); @@ -179,8 +177,6 @@ gimp_image_mask_select_polygon (GimpImage *gimage, gimp_scan_convert_free (scan_convert); -#undef SUPERSAMPLE - if (mask) { if (feather) @@ -227,13 +223,9 @@ gimp_image_mask_select_vectors (GimpImage *gimage, else gimp_channel_push_undo (selection, undo_desc); -#define SUPERSAMPLE 3 - scan_convert = gimp_scan_convert_new (gimage->width, gimage->height, - antialias ? SUPERSAMPLE : 1); - -#undef SUPERSAMPLE + antialias); for (stroke = vectors->strokes; stroke; stroke = stroke->next) { diff --git a/app/core/gimpdrawable-stroke.c b/app/core/gimpdrawable-stroke.c index 7d3435371f..2e460d74b4 100644 --- a/app/core/gimpdrawable-stroke.c +++ b/app/core/gimpdrawable-stroke.c @@ -82,7 +82,7 @@ gimp_drawable_stroke_vectors (GimpDrawable *drawable, gimp_item_offsets (GIMP_ITEM (drawable), &x2, &y2); - scan_convert = gimp_scan_convert_new (w, h, antialias ? 1 : 0); + scan_convert = gimp_scan_convert_new (w, h, antialias); /* For each Stroke in the vector, interpolate it, and add it to the * ScanConvert */ diff --git a/app/core/gimpimage-mask-select.c b/app/core/gimpimage-mask-select.c index 33c1ecd1de..a5e6bce41b 100644 --- a/app/core/gimpimage-mask-select.c +++ b/app/core/gimpimage-mask-select.c @@ -167,11 +167,9 @@ gimp_image_mask_select_polygon (GimpImage *gimage, else gimp_channel_push_undo (selection, undo_desc); -#define SUPERSAMPLE 3 - scan_convert = gimp_scan_convert_new (gimage->width, gimage->height, - antialias ? SUPERSAMPLE : 1); + antialias); gimp_scan_convert_add_polyline (scan_convert, n_points, points, TRUE); @@ -179,8 +177,6 @@ gimp_image_mask_select_polygon (GimpImage *gimage, gimp_scan_convert_free (scan_convert); -#undef SUPERSAMPLE - if (mask) { if (feather) @@ -227,13 +223,9 @@ gimp_image_mask_select_vectors (GimpImage *gimage, else gimp_channel_push_undo (selection, undo_desc); -#define SUPERSAMPLE 3 - scan_convert = gimp_scan_convert_new (gimage->width, gimage->height, - antialias ? SUPERSAMPLE : 1); - -#undef SUPERSAMPLE + antialias); for (stroke = vectors->strokes; stroke; stroke = stroke->next) { diff --git a/app/core/gimpscanconvert.c b/app/core/gimpscanconvert.c index 04932a0a62..2f4cfd3481 100644 --- a/app/core/gimpscanconvert.c +++ b/app/core/gimpscanconvert.c @@ -63,19 +63,18 @@ static void gimp_scan_convert_close_add_points (GimpScanConvert *sc); /* public functions */ GimpScanConvert * -gimp_scan_convert_new (guint width, - guint height, - guint antialias) +gimp_scan_convert_new (guint width, + guint height, + gboolean antialias) { GimpScanConvert *sc; g_return_val_if_fail (width > 0, NULL); g_return_val_if_fail (height > 0, NULL); - g_return_val_if_fail (antialias > 0, NULL); sc = g_new0 (GimpScanConvert, 1); - sc->antialias = (antialias != 0 ? TRUE : FALSE); + sc->antialias = antialias; sc->width = width; sc->height = height; diff --git a/app/core/gimpscanconvert.h b/app/core/gimpscanconvert.h index 2a2409148d..a6deb6b91c 100644 --- a/app/core/gimpscanconvert.h +++ b/app/core/gimpscanconvert.h @@ -28,7 +28,7 @@ typedef struct _GimpScanConvert GimpScanConvert; */ GimpScanConvert * gimp_scan_convert_new (guint width, guint height, - guint antialias); + gboolean antialias); void gimp_scan_convert_free (GimpScanConvert *scan_converter); diff --git a/app/core/gimpstrokeoptions.c b/app/core/gimpstrokeoptions.c index eaff77d001..bd5d2c9f43 100644 --- a/app/core/gimpstrokeoptions.c +++ b/app/core/gimpstrokeoptions.c @@ -185,10 +185,10 @@ gimp_stroke_options_set_property (GObject *object, options->width = g_value_get_double (value); break; case PROP_CAP_STYLE: - options->cap_style = g_value_get_int (value); + options->cap_style = g_value_get_enum (value); break; case PROP_JOIN_STYLE: - options->join_style = g_value_get_int (value); + options->join_style = g_value_get_enum (value); break; case PROP_MITER: options->miter = g_value_get_double (value); @@ -253,10 +253,10 @@ gimp_stroke_options_get_property (GObject *object, g_value_set_double (value, options->width); break; case PROP_CAP_STYLE: - g_value_set_int (value, options->cap_style); + g_value_set_enum (value, options->cap_style); break; case PROP_JOIN_STYLE: - g_value_set_int (value, options->join_style); + g_value_set_enum (value, options->join_style); break; case PROP_MITER: g_value_set_double (value, options->miter); diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c new file mode 100644 index 0000000000..4833379152 --- /dev/null +++ b/app/dialogs/stroke-dialog.c @@ -0,0 +1,161 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Copyright (C) 2003 Henrik Brix Andersen + * + * 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 + +#include "libgimpbase/gimplimits.h" +#include "libgimpwidgets/gimpwidgets.h" + +#include "gui-types.h" + +#include "config/gimpconfig.h" +#include "config/gimpconfig-types.h" +#include "config/gimpconfig-utils.h" + +#include "core/gimp.h" +#include "core/gimpdrawable.h" +#include "core/gimpimage.h" +#include "core/gimpstrokeoptions.h" + +#include "display/gimpdisplay.h" +#include "display/gimpdisplayshell.h" + +#include "widgets/gimphelp-ids.h" +#include "widgets/gimpviewabledialog.h" +#include "widgets/gimppropwidgets.h" +#include "widgets/gimpstrokeeditor.h" + +#include "stroke-dialog.h" + +#include "gimp-intl.h" + + +#define STROKE_COLOR_SIZE 20 + + +/* local functions */ + + +static void reset_callback (GtkWidget *widget, + GtkWidget *dialog); +static void cancel_callback (GtkWidget *widget, + GtkWidget *dialog); +static void ok_callback (GtkWidget *widget, + GtkWidget *dialog); + + +/* public function */ + + +GtkWidget * +stroke_dialog_new (GimpDrawable *drawable, + GimpItem *item, + GimpStrokeOptions *stroke_options) +{ + GtkWidget *dialog; + GtkWidget *stroke_editor; + + g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL); + + if (!stroke_options) + stroke_options = g_object_new (GIMP_TYPE_STROKE_OPTIONS, + "gimp", GIMP_IMAGE (GIMP_ITEM (drawable)->gimage)->gimp, + NULL); + + /* the dialog */ + dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (GIMP_ITEM (drawable)->gimage), + _("Stroke Options"), "configure_grid", + GIMP_STOCK_GRID, _("Configure Stroke Appearance"), + gimp_standard_help_func, + GIMP_HELP_IMAGE_GRID, + + GIMP_STOCK_RESET, reset_callback, + NULL, NULL, NULL, FALSE, FALSE, + + GTK_STOCK_CANCEL, cancel_callback, + NULL, NULL, NULL, FALSE, TRUE, + + GTK_STOCK_OK, ok_callback, + NULL, NULL, NULL, TRUE, FALSE, + + NULL); + + g_object_set_data (G_OBJECT (dialog), "drawable", drawable); + g_object_set_data (G_OBJECT (dialog), "item", item); + g_object_set_data (G_OBJECT (dialog), "stroke_options", stroke_options); + + stroke_editor = gimp_stroke_editor_new (stroke_options); + + gtk_widget_show (stroke_editor); + + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), + stroke_editor); + + gtk_widget_show (stroke_editor); + + return dialog; +} + + +/* local functions */ + +static void +reset_callback (GtkWidget *widget, + GtkWidget *dialog) +{ + /* something should reset the values here */ +} + + +static void +cancel_callback (GtkWidget *widget, + GtkWidget *dialog) +{ + GimpStrokeOptions *stroke_options; + + stroke_options = g_object_get_data (G_OBJECT (dialog), "stroke_options"); + + g_object_unref (stroke_options); + gtk_widget_destroy (dialog); +} + + +static void +ok_callback (GtkWidget *widget, + GtkWidget *dialog) +{ + GimpDrawable *drawable; + GimpItem *item; + GimpStrokeOptions *stroke_options; + + item = g_object_get_data (G_OBJECT (dialog), "item"); + drawable = g_object_get_data (G_OBJECT (dialog), "drawable"); + stroke_options = g_object_get_data (G_OBJECT (dialog), "stroke_options"); + + gimp_item_stroke (item, drawable, GIMP_OBJECT (stroke_options)); + + gimp_image_flush (GIMP_ITEM (drawable)->gimage); + + g_object_unref (stroke_options); + gtk_widget_destroy (dialog); +} diff --git a/app/dialogs/stroke-dialog.h b/app/dialogs/stroke-dialog.h new file mode 100644 index 0000000000..f04af8a72c --- /dev/null +++ b/app/dialogs/stroke-dialog.h @@ -0,0 +1,30 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __STROKE_DIALOG_H__ +#define __STROKE_DIALOG_H__ + + +GtkWidget * stroke_dialog_new (GimpDrawable *drawable, + GimpItem *item, + GimpStrokeOptions *stroke_options); + + +#endif /* __STROKE_DIALOG_H__ */ diff --git a/app/gui/Makefile.am b/app/gui/Makefile.am index 28774a82cb..cfcaf40ca1 100644 --- a/app/gui/Makefile.am +++ b/app/gui/Makefile.am @@ -49,6 +49,8 @@ dialogs_sources = \ resize-dialog.h \ resolution-calibrate-dialog.c \ resolution-calibrate-dialog.h \ + stroke-dialog.c \ + stroke-dialog.h \ templates-commands.c \ templates-commands.h \ templates-menu.c \ diff --git a/app/gui/stroke-dialog.c b/app/gui/stroke-dialog.c new file mode 100644 index 0000000000..4833379152 --- /dev/null +++ b/app/gui/stroke-dialog.c @@ -0,0 +1,161 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Copyright (C) 2003 Henrik Brix Andersen + * + * 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 + +#include "libgimpbase/gimplimits.h" +#include "libgimpwidgets/gimpwidgets.h" + +#include "gui-types.h" + +#include "config/gimpconfig.h" +#include "config/gimpconfig-types.h" +#include "config/gimpconfig-utils.h" + +#include "core/gimp.h" +#include "core/gimpdrawable.h" +#include "core/gimpimage.h" +#include "core/gimpstrokeoptions.h" + +#include "display/gimpdisplay.h" +#include "display/gimpdisplayshell.h" + +#include "widgets/gimphelp-ids.h" +#include "widgets/gimpviewabledialog.h" +#include "widgets/gimppropwidgets.h" +#include "widgets/gimpstrokeeditor.h" + +#include "stroke-dialog.h" + +#include "gimp-intl.h" + + +#define STROKE_COLOR_SIZE 20 + + +/* local functions */ + + +static void reset_callback (GtkWidget *widget, + GtkWidget *dialog); +static void cancel_callback (GtkWidget *widget, + GtkWidget *dialog); +static void ok_callback (GtkWidget *widget, + GtkWidget *dialog); + + +/* public function */ + + +GtkWidget * +stroke_dialog_new (GimpDrawable *drawable, + GimpItem *item, + GimpStrokeOptions *stroke_options) +{ + GtkWidget *dialog; + GtkWidget *stroke_editor; + + g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL); + + if (!stroke_options) + stroke_options = g_object_new (GIMP_TYPE_STROKE_OPTIONS, + "gimp", GIMP_IMAGE (GIMP_ITEM (drawable)->gimage)->gimp, + NULL); + + /* the dialog */ + dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (GIMP_ITEM (drawable)->gimage), + _("Stroke Options"), "configure_grid", + GIMP_STOCK_GRID, _("Configure Stroke Appearance"), + gimp_standard_help_func, + GIMP_HELP_IMAGE_GRID, + + GIMP_STOCK_RESET, reset_callback, + NULL, NULL, NULL, FALSE, FALSE, + + GTK_STOCK_CANCEL, cancel_callback, + NULL, NULL, NULL, FALSE, TRUE, + + GTK_STOCK_OK, ok_callback, + NULL, NULL, NULL, TRUE, FALSE, + + NULL); + + g_object_set_data (G_OBJECT (dialog), "drawable", drawable); + g_object_set_data (G_OBJECT (dialog), "item", item); + g_object_set_data (G_OBJECT (dialog), "stroke_options", stroke_options); + + stroke_editor = gimp_stroke_editor_new (stroke_options); + + gtk_widget_show (stroke_editor); + + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), + stroke_editor); + + gtk_widget_show (stroke_editor); + + return dialog; +} + + +/* local functions */ + +static void +reset_callback (GtkWidget *widget, + GtkWidget *dialog) +{ + /* something should reset the values here */ +} + + +static void +cancel_callback (GtkWidget *widget, + GtkWidget *dialog) +{ + GimpStrokeOptions *stroke_options; + + stroke_options = g_object_get_data (G_OBJECT (dialog), "stroke_options"); + + g_object_unref (stroke_options); + gtk_widget_destroy (dialog); +} + + +static void +ok_callback (GtkWidget *widget, + GtkWidget *dialog) +{ + GimpDrawable *drawable; + GimpItem *item; + GimpStrokeOptions *stroke_options; + + item = g_object_get_data (G_OBJECT (dialog), "item"); + drawable = g_object_get_data (G_OBJECT (dialog), "drawable"); + stroke_options = g_object_get_data (G_OBJECT (dialog), "stroke_options"); + + gimp_item_stroke (item, drawable, GIMP_OBJECT (stroke_options)); + + gimp_image_flush (GIMP_ITEM (drawable)->gimage); + + g_object_unref (stroke_options); + gtk_widget_destroy (dialog); +} diff --git a/app/gui/stroke-dialog.h b/app/gui/stroke-dialog.h new file mode 100644 index 0000000000..f04af8a72c --- /dev/null +++ b/app/gui/stroke-dialog.h @@ -0,0 +1,30 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __STROKE_DIALOG_H__ +#define __STROKE_DIALOG_H__ + + +GtkWidget * stroke_dialog_new (GimpDrawable *drawable, + GimpItem *item, + GimpStrokeOptions *stroke_options); + + +#endif /* __STROKE_DIALOG_H__ */ diff --git a/app/gui/vectors-commands.c b/app/gui/vectors-commands.c index 3884265b24..7322fb2eb2 100644 --- a/app/gui/vectors-commands.c +++ b/app/gui/vectors-commands.c @@ -25,6 +25,7 @@ #include "libgimpwidgets/gimpwidgets.h" #include "gui-types.h" +#include "stroke-dialog.h" #include "core/gimp.h" #include "core/gimpchannel.h" @@ -186,6 +187,7 @@ vectors_stroke_cmd_callback (GtkWidget *widget, GimpVectors *active_vectors; GimpDrawable *active_drawable; GimpToolInfo *tool_info; + GtkWidget *dialog; return_if_no_vectors (gimage, active_vectors, data); active_drawable = gimp_image_active_drawable (gimage); @@ -196,11 +198,19 @@ vectors_stroke_cmd_callback (GtkWidget *widget, return; } + dialog = stroke_dialog_new (active_drawable, + GIMP_ITEM (active_vectors), + NULL); + + gtk_widget_show (dialog); + + /* tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp)); gimp_item_stroke (GIMP_ITEM (active_vectors), active_drawable, GIMP_OBJECT (tool_info->paint_info)); gimp_image_flush (gimage); + */ } void diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c index c7b132b0f9..691771e952 100644 --- a/app/tools/gimpiscissorstool.c +++ b/app/tools/gimpiscissorstool.c @@ -539,7 +539,9 @@ iscissors_convert (GimpIscissorsTool *iscissors, gint i; gint index; - sc = gimp_scan_convert_new (gdisp->gimage->width, gdisp->gimage->height, 1); + sc = gimp_scan_convert_new (gdisp->gimage->width, + gdisp->gimage->height, + TRUE); /* go over the curves in reverse order, adding the points we have */ list = iscissors->curves; diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c index 87126b03c8..2458c0d3ed 100644 --- a/app/vectors/gimpvectors.c +++ b/app/vectors/gimpvectors.c @@ -25,23 +25,18 @@ #include "vectors-types.h" +#include "core/gimp.h" +#include "core/gimpcontext.h" +#include "core/gimpdrawable-stroke.h" #include "core/gimp-transform-utils.h" #include "core/gimpimage.h" #include "core/gimpimage-undo-push.h" #include "core/gimpmarshal.h" #include "core/gimppaintinfo.h" +#include "core/gimpstrokeoptions.h" -#define LIBART_STROKE -#undef LIBART_STROKE_BAD_HACK - -#ifdef LIBART_STROKE -# include "libgimpcolor/gimpcolor.h" -# include "core/gimp.h" -# include "core/gimpcontext.h" -# include "core/gimpdrawable-stroke.h" -#else -# include "paint/gimppaintcore-stroke.h" -#endif +#include "libgimpcolor/gimpcolor.h" +#include "paint/gimppaintcore-stroke.h" #include "gimpanchor.h" #include "gimpstroke.h" @@ -545,9 +540,13 @@ gimp_vectors_stroke (GimpItem *item, GimpDrawable *drawable, GimpObject *stroke_desc) { - GimpVectors *vectors; - GimpPaintInfo *paint_info = GIMP_PAINT_INFO (stroke_desc); - gboolean retval; + GimpVectors *vectors; + GimpPaintInfo *paint_info; + GimpStrokeOptions *stroke_options; + gboolean retval; + + g_return_val_if_fail (GIMP_IS_PAINT_INFO (stroke_desc) || + GIMP_IS_STROKE_OPTIONS (stroke_desc), FALSE); vectors = GIMP_VECTORS (item); @@ -557,48 +556,61 @@ gimp_vectors_stroke (GimpItem *item, return FALSE; } -#ifdef LIBART_STROKE - { - GimpContext *context; - GimpRGB color; - gfloat opacity; + if (GIMP_IS_STROKE_OPTIONS (stroke_desc)) + { + GimpContext *context; + GimpRGB color; + gdouble width; + gboolean antialias; + GimpCapStyle cap_style; + GimpJoinStyle join_style; + GValue value = { 0, }; - context = gimp_get_current_context ( - gimp_item_get_image (GIMP_ITEM (drawable))->gimp); - gimp_context_get_foreground (context, &color); - opacity = gimp_context_get_opacity (context); + stroke_options = GIMP_STROKE_OPTIONS (stroke_desc); -#ifdef LIBART_STROKE_BAD_HACK - /* Bad hack to be able to change the size of the stroke interactively: - * use the opacity value as the width... - */ - gimp_drawable_stroke_vectors (drawable, vectors, - 1.0, - &color, - gimp_context_get_paint_mode (context), - MAX (0.1, opacity * 100), - GIMP_JOIN_MITER, GIMP_CAP_BUTT, TRUE); -#else - gimp_drawable_stroke_vectors (drawable, vectors, - opacity, - &color, - gimp_context_get_paint_mode (context), - 5.0, - GIMP_JOIN_MITER, GIMP_CAP_BUTT, TRUE); -#endif - retval = TRUE; - } -#else - { - GimpPaintCore *core = g_object_new (paint_info->paint_type, NULL); + context = GIMP_CONTEXT (stroke_options); + gimp_context_get_foreground (context, &color); - retval = gimp_paint_core_stroke_vectors (core, drawable, - paint_info->paint_options, - vectors); + g_value_init (&value, G_TYPE_DOUBLE); + g_object_get_property (G_OBJECT (stroke_options), "width", &value); + width = g_value_get_double (&value); + g_value_unset (&value); - g_object_unref (core); - } -#endif + g_value_init (&value, GIMP_TYPE_CAP_STYLE); + g_object_get_property (G_OBJECT (stroke_options), "cap-style", &value); + cap_style = g_value_get_enum (&value); + g_value_unset (&value); + + g_value_init (&value, GIMP_TYPE_JOIN_STYLE); + g_object_get_property (G_OBJECT (stroke_options), "join-style", &value); + join_style = g_value_get_enum (&value); + g_value_unset (&value); + + g_value_init (&value, G_TYPE_BOOLEAN); + g_object_get_property (G_OBJECT (stroke_options), "antialias", &value); + antialias = g_value_get_boolean (&value); + g_value_unset (&value); + + gimp_drawable_stroke_vectors (drawable, vectors, + gimp_context_get_opacity (context), + &color, + gimp_context_get_paint_mode (context), + width, join_style, cap_style, antialias); + retval = TRUE; + } + else + { + GimpPaintCore *core; + + paint_info = GIMP_PAINT_INFO (stroke_desc); + 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; }