From e1e943b9fa7426601af325572bda09c8d8155985 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 14 Jul 2003 15:43:21 +0000 Subject: [PATCH] app/paint/Makefile.am removed. 2003-07-14 Michael Natterer * app/paint/Makefile.am * app/paint/gimppencil.[ch]: removed. * app/paint/gimppenciloptions.[ch]: new files. Does nothing except setting the default value of "hard" to TRUE. * app/paint/paint.c * app/tools/tool_manager.c: changed accordingly. * app/tools/gimppenciltool.c * tools/pdbgen/pdb/paint_tools.pdb: use the pintbrush core for pencil drawing. * app/pdb/paint_tools_cmds.c: regenerated. * app/tools/gimppaintoptions-gui.c: show all paintbrush options except "Hardness" for the pencil tool. --- ChangeLog | 20 +++ app/paint/Makefile.am | 4 +- app/paint/gimppencil.c | 219 ------------------------------- app/paint/gimppencil.h | 58 -------- app/paint/gimppenciloptions.c | 147 +++++++++++++++++++++ app/paint/gimppenciloptions.h | 41 ++++++ app/paint/paint.c | 12 +- app/pdb/paint_tools_cmds.c | 6 +- app/tools/gimppenciltool.c | 14 +- app/tools/tool_manager.c | 2 +- tools/pdbgen/pdb/paint_tools.pdb | 6 +- 11 files changed, 227 insertions(+), 302 deletions(-) delete mode 100644 app/paint/gimppencil.c delete mode 100644 app/paint/gimppencil.h create mode 100644 app/paint/gimppenciloptions.c create mode 100644 app/paint/gimppenciloptions.h diff --git a/ChangeLog b/ChangeLog index 0aa80f81ab..a7dbca8417 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2003-07-14 Michael Natterer + + * app/paint/Makefile.am + * app/paint/gimppencil.[ch]: removed. + + * app/paint/gimppenciloptions.[ch]: new files. Does nothing except + setting the default value of "hard" to TRUE. + + * app/paint/paint.c + * app/tools/tool_manager.c: changed accordingly. + + * app/tools/gimppenciltool.c + * tools/pdbgen/pdb/paint_tools.pdb: use the pintbrush core for + pencil drawing. + + * app/pdb/paint_tools_cmds.c: regenerated. + + * app/tools/gimppaintoptions-gui.c: show all paintbrush options + except "Hardness" for the pencil tool. + 2003-07-14 Michael Natterer * app/paint/gimperaseroptions.[ch]: removed "gboolean hard" diff --git a/app/paint/Makefile.am b/app/paint/Makefile.am index 932be6823a..c728d3a5ce 100644 --- a/app/paint/Makefile.am +++ b/app/paint/Makefile.am @@ -49,8 +49,8 @@ libapppaint_a_sources = \ gimppaintcore-undo.h \ gimppaintoptions.c \ gimppaintoptions.h \ - gimppencil.c \ - gimppencil.h \ + gimppenciloptions.c \ + gimppenciloptions.h \ gimppaintbrush.c \ gimppaintbrush.h \ gimpsmudge.c \ diff --git a/app/paint/gimppencil.c b/app/paint/gimppencil.c deleted file mode 100644 index 3a10ef1fb7..0000000000 --- a/app/paint/gimppencil.c +++ /dev/null @@ -1,219 +0,0 @@ -/* 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 - * 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 "libgimpcolor/gimpcolor.h" - -#include "paint-types.h" - -#include "base/temp-buf.h" - -#include "paint-funcs/paint-funcs.h" - -#include "core/gimp.h" -#include "core/gimpbrush.h" -#include "core/gimpdrawable.h" -#include "core/gimpgradient.h" -#include "core/gimpimage.h" - -#include "gimppaintoptions.h" -#include "gimppencil.h" - -#include "gimp-intl.h" - - -static void gimp_pencil_class_init (GimpPencilClass *klass); -static void gimp_pencil_init (GimpPencil *pencil); - -static void gimp_pencil_paint (GimpPaintCore *paint_core, - GimpDrawable *drawable, - GimpPaintOptions *paint_options, - GimpPaintCoreState paint_state); - -static void gimp_pencil_motion (GimpPaintCore *paint_core, - GimpDrawable *drawable, - GimpPaintOptions *paint_options); - - -static GimpPaintCoreClass *parent_class = NULL; - - -void -gimp_pencil_register (Gimp *gimp, - GimpPaintRegisterCallback callback) -{ - (* callback) (gimp, - GIMP_TYPE_PENCIL, - GIMP_TYPE_PAINT_OPTIONS, - _("Pencil")); -} - -GType -gimp_pencil_get_type (void) -{ - static GType type = 0; - - if (! type) - { - static const GTypeInfo info = - { - sizeof (GimpPencilClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gimp_pencil_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GimpPencil), - 0, /* n_preallocs */ - (GInstanceInitFunc) gimp_pencil_init, - }; - - type = g_type_register_static (GIMP_TYPE_PAINT_CORE, - "GimpPencil", - &info, 0); - } - - return type; -} - -static void -gimp_pencil_class_init (GimpPencilClass *klass) -{ - GimpPaintCoreClass *paint_core_class; - - paint_core_class = GIMP_PAINT_CORE_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - paint_core_class->paint = gimp_pencil_paint; -} - -static void -gimp_pencil_init (GimpPencil *pencil) -{ - GimpPaintCore *paint_core; - - paint_core = GIMP_PAINT_CORE (pencil); - - paint_core->flags |= CORE_HANDLES_CHANGING_BRUSH; -} - -static void -gimp_pencil_paint (GimpPaintCore *paint_core, - GimpDrawable *drawable, - GimpPaintOptions *paint_options, - GimpPaintCoreState paint_state) -{ - switch (paint_state) - { - case MOTION_PAINT: - gimp_pencil_motion (paint_core, drawable, paint_options); - break; - - default: - break; - } -} - -static void -gimp_pencil_motion (GimpPaintCore *paint_core, - GimpDrawable *drawable, - GimpPaintOptions *paint_options) -{ - GimpPressureOptions *pressure_options; - GimpContext *context; - GimpImage *gimage; - TempBuf *area; - guchar col[MAX_CHANNELS]; - gdouble opacity; - gdouble scale; - GimpPaintApplicationMode paint_appl_mode; - - context = GIMP_CONTEXT (paint_options); - - pressure_options = paint_options->pressure_options; - - gimage = gimp_item_get_image (GIMP_ITEM (drawable)); - - paint_appl_mode = paint_options->application_mode; - - if (pressure_options->size) - scale = paint_core->cur_coords.pressure; - else - scale = 1.0; - - /* Get a region which can be used to paint to */ - if (! (area = gimp_paint_core_get_paint_area (paint_core, drawable, scale))) - return; - - /* color the pixels */ - if (pressure_options->color) - { - GimpRGB color; - - gimp_gradient_get_color_at (gimp_context_get_gradient (context), - paint_core->cur_coords.pressure, - &color); - - gimp_rgba_get_uchar (&color, - &col[RED_PIX], - &col[GREEN_PIX], - &col[BLUE_PIX], - &col[ALPHA_PIX]); - - color_pixels (temp_buf_data (area), col, - area->width * area->height, - area->bytes); - - paint_appl_mode = GIMP_PAINT_INCREMENTAL; - } - else if (paint_core->brush && paint_core->brush->pixmap) - { - /* if it's a pixmap, do pixmap stuff */ - gimp_paint_core_color_area_with_pixmap (paint_core, - gimage, drawable, - area, scale, GIMP_BRUSH_HARD); - - paint_appl_mode = GIMP_PAINT_INCREMENTAL; - } - else - { - gimp_image_get_foreground (gimage, drawable, col); - col[area->bytes - 1] = OPAQUE_OPACITY; - color_pixels (temp_buf_data (area), col, - area->width * area->height, - area->bytes); - } - - opacity = gimp_context_get_opacity (context); - - if (pressure_options->opacity) - opacity = opacity * 2.0 * paint_core->cur_coords.pressure; - - /* paste the newly painted canvas to the gimage which is being worked on */ - gimp_paint_core_paste_canvas (paint_core, drawable, - MIN (opacity, GIMP_OPACITY_OPAQUE), - gimp_context_get_opacity (context), - gimp_context_get_paint_mode (context), - GIMP_BRUSH_HARD, - scale, - paint_appl_mode); -} diff --git a/app/paint/gimppencil.h b/app/paint/gimppencil.h deleted file mode 100644 index 39f9e275db..0000000000 --- a/app/paint/gimppencil.h +++ /dev/null @@ -1,58 +0,0 @@ -/* 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 - * 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_PENCIL_H__ -#define __GIMP_PENCIL_H__ - -/* FIXME: This whole core should probably just be a paintbrush core that - * has an option of hard edge. It'll give the "pencil core" all the - * flashy stuff the paintbrush core has, and not duplicate code. - */ - -#include "gimppaintcore.h" - - -#define GIMP_TYPE_PENCIL (gimp_pencil_get_type ()) -#define GIMP_PENCIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PENCIL, GimpPencil)) -#define GIMP_PENCIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PENCIL, GimpPencilClass)) -#define GIMP_IS_PENCIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PENCIL)) -#define GIMP_IS_PENCIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PENCIL)) -#define GIMP_PENCIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PENCIL, GimpPencilClass)) - - -typedef struct _GimpPencil GimpPencil; -typedef struct _GimpPencilClass GimpPencilClass; - -struct _GimpPencil -{ - GimpPaintCore parent_instance; -}; - -struct _GimpPencilClass -{ - GimpPaintCoreClass parent_class; -}; - - -void gimp_pencil_register (Gimp *gimp, - GimpPaintRegisterCallback callback); - -GType gimp_pencil_get_type (void) G_GNUC_CONST; - - -#endif /* __GIMP_PENCIL_H__ */ diff --git a/app/paint/gimppenciloptions.c b/app/paint/gimppenciloptions.c new file mode 100644 index 0000000000..2c2caf25e0 --- /dev/null +++ b/app/paint/gimppenciloptions.c @@ -0,0 +1,147 @@ +/* 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 + * 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 "paint-types.h" + +#include "config/gimpconfig-params.h" + +#include "gimppenciloptions.h" + + +#define PENCIL_DEFAULT_HARD TRUE + + +enum +{ + PROP_0, + PROP_HARD +}; + + +static void gimp_pencil_options_init (GimpPencilOptions *options); +static void gimp_pencil_options_class_init (GimpPencilOptionsClass *options_class); + +static void gimp_pencil_options_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_pencil_options_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + + +static GimpPaintOptionsClass *parent_class = NULL; + + +GType +gimp_pencil_options_get_type (void) +{ + static GType type = 0; + + if (! type) + { + static const GTypeInfo info = + { + sizeof (GimpPencilOptionsClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gimp_pencil_options_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpPencilOptions), + 0, /* n_preallocs */ + (GInstanceInitFunc) gimp_pencil_options_init, + }; + + type = g_type_register_static (GIMP_TYPE_PAINT_OPTIONS, + "GimpPencilOptions", + &info, 0); + } + + return type; +} + +static void +gimp_pencil_options_class_init (GimpPencilOptionsClass *klass) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->set_property = gimp_pencil_options_set_property; + object_class->get_property = gimp_pencil_options_get_property; + + GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_HARD, + "hard", NULL, + PENCIL_DEFAULT_HARD, + 0); +} + +static void +gimp_pencil_options_init (GimpPencilOptions *options) +{ +} + +static void +gimp_pencil_options_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpPencilOptions *options; + + options = GIMP_PENCIL_OPTIONS (object); + + switch (property_id) + { + case PROP_HARD: + options->hard = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_pencil_options_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpPencilOptions *options; + + options = GIMP_PENCIL_OPTIONS (object); + + switch (property_id) + { + case PROP_HARD: + g_value_set_boolean (value, options->hard); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} diff --git a/app/paint/gimppenciloptions.h b/app/paint/gimppenciloptions.h new file mode 100644 index 0000000000..39c7a30aaa --- /dev/null +++ b/app/paint/gimppenciloptions.h @@ -0,0 +1,41 @@ +/* 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 + * 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_PENCIL_OPTIONS_H__ +#define __GIMP_PENCIL_OPTIONS_H__ + + +#include "gimppaintoptions.h" + + +#define GIMP_TYPE_PENCIL_OPTIONS (gimp_pencil_options_get_type ()) +#define GIMP_PENCIL_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PENCIL_OPTIONS, GimpPencilOptions)) +#define GIMP_PENCIL_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PENCIL_OPTIONS, GimpPencilOptionsClass)) +#define GIMP_IS_PENCIL_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PENCIL_OPTIONS)) +#define GIMP_IS_PENCIL_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PENCIL_OPTIONS)) +#define GIMP_PENCIL_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PENCIL_OPTIONS, GimpPencilOptionsClass)) + + +typedef struct _GimpPaintOptions GimpPencilOptions; +typedef struct _GimpPaintOptionsClass GimpPencilOptionsClass; + + +GType gimp_pencil_options_get_type (void) G_GNUC_CONST; + + +#endif /* __GIMP_PENCIL_OPTIONS_H__ */ diff --git a/app/paint/paint.c b/app/paint/paint.c index 77100f4cd2..343fd60641 100644 --- a/app/paint/paint.c +++ b/app/paint/paint.c @@ -33,7 +33,6 @@ #include "gimpdodgeburn.h" #include "gimperaser.h" #include "gimppaintbrush.h" -#include "gimppencil.h" #include "gimpsmudge.h" @@ -58,8 +57,7 @@ paint_init (Gimp *gimp) gimp_clone_register, gimp_airbrush_register, gimp_eraser_register, - gimp_paintbrush_register, - gimp_pencil_register, + gimp_paintbrush_register }; gint i; @@ -104,12 +102,8 @@ paint_register (Gimp *gimp, g_return_if_fail (g_type_is_a (paint_type, GIMP_TYPE_PAINT_CORE)); g_return_if_fail (g_type_is_a (paint_options_type, GIMP_TYPE_PAINT_OPTIONS)); g_return_if_fail (blurb != NULL); - - if (paint_type == GIMP_TYPE_PENCIL) - { - pdb_string = "gimp_pencil"; - } - else if (paint_type == GIMP_TYPE_PAINTBRUSH) + + if (paint_type == GIMP_TYPE_PAINTBRUSH) { pdb_string = "gimp_paintbrush_default"; } diff --git a/app/pdb/paint_tools_cmds.c b/app/pdb/paint_tools_cmds.c index 9f3c5e1616..f10242923b 100644 --- a/app/pdb/paint_tools_cmds.c +++ b/app/pdb/paint_tools_cmds.c @@ -42,7 +42,7 @@ #include "paint/gimperaseroptions.h" #include "paint/gimppaintbrush.h" #include "paint/gimppaintcore-stroke.h" -#include "paint/gimppencil.h" +#include "paint/gimppenciloptions.h" #include "paint/gimpsmudge.h" #include "paint/gimpsmudgeoptions.h" #include "paint/paint-types.h" @@ -1191,10 +1191,10 @@ pencil_invoker (Gimp *gimp, if (success) { - options = gimp_paint_options_new (gimp, GIMP_TYPE_PAINT_OPTIONS); + options = gimp_paint_options_new (gimp, GIMP_TYPE_PENCIL_OPTIONS); success = paint_tools_stroke (gimp, - GIMP_TYPE_PENCIL, + GIMP_TYPE_PAINTBRUSH, options, drawable, num_strokes, strokes); diff --git a/app/tools/gimppenciltool.c b/app/tools/gimppenciltool.c index 29148699c2..3baff407a3 100644 --- a/app/tools/gimppenciltool.c +++ b/app/tools/gimppenciltool.c @@ -24,8 +24,8 @@ #include "tools-types.h" -#include "paint/gimppencil.h" -#include "paint/gimppaintoptions.h" +#include "paint/gimppaintbrush.h" +#include "paint/gimppenciloptions.h" #include "gimppenciltool.h" #include "gimppaintoptions-gui.h" @@ -48,7 +48,7 @@ gimp_pencil_tool_register (GimpToolRegisterCallback callback, gpointer data) { (* callback) (GIMP_TYPE_PENCIL_TOOL, - GIMP_TYPE_PAINT_OPTIONS, + GIMP_TYPE_PENCIL_OPTIONS, gimp_paint_options_gui, GIMP_PAINT_OPTIONS_CONTEXT_MASK, "gimp-pencil-tool", @@ -81,16 +81,16 @@ gimp_pencil_tool_get_type (void) }; tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL, - "GimpPencilTool", + "GimpPencilTool", &tool_info, 0); } return tool_type; } -static void +static void gimp_pencil_tool_class_init (GimpPencilToolClass *klass) -{ +{ GimpPaintToolClass *paint_tool_class; paint_tool_class = GIMP_PAINT_TOOL_CLASS (klass); @@ -111,5 +111,5 @@ gimp_pencil_tool_init (GimpPencilTool *pencil) gimp_tool_control_set_tool_cursor (tool->control, GIMP_PENCIL_TOOL_CURSOR); paint_tool->pick_colors = TRUE; - paint_tool->core = g_object_new (GIMP_TYPE_PENCIL, NULL); + paint_tool->core = g_object_new (GIMP_TYPE_PAINTBRUSH, NULL); } diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c index b013d329fa..5ee360f5e0 100644 --- a/app/tools/tool_manager.c +++ b/app/tools/tool_manager.c @@ -525,7 +525,7 @@ tool_manager_register_tool (GType tool_type, if (tool_type == GIMP_TYPE_PENCIL_TOOL) { - paint_core_name = "GimpPencil"; + paint_core_name = "GimpPaintbrush"; } else if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL) { diff --git a/tools/pdbgen/pdb/paint_tools.pdb b/tools/pdbgen/pdb/paint_tools.pdb index a6568c123d..08fc0cd075 100644 --- a/tools/pdbgen/pdb/paint_tools.pdb +++ b/tools/pdbgen/pdb/paint_tools.pdb @@ -546,14 +546,14 @@ HELP ); %invoke = ( - headers => [ qw("paint/gimppencil.h") ], + headers => [ qw("paint/gimppenciloptions.h") ], vars => [ "GimpPaintOptions *options" ], code => <<'CODE' { - options = gimp_paint_options_new (gimp, GIMP_TYPE_PAINT_OPTIONS); + options = gimp_paint_options_new (gimp, GIMP_TYPE_PENCIL_OPTIONS); success = paint_tools_stroke (gimp, - GIMP_TYPE_PENCIL, + GIMP_TYPE_PAINTBRUSH, options, drawable, num_strokes, strokes);