gimp/app/core/gimpbrush.c

941 lines
31 KiB
C
Raw Normal View History

/* GIMP - The GNU 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "core-types.h"
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
#include "gimpbezierdesc.h"
#include "gimpbrush.h"
#include "gimpbrush-boundary.h"
#include "gimpbrush-load.h"
#include "gimpbrush-mipmap.h"
#include "gimpbrush-private.h"
#include "gimpbrush-save.h"
#include "gimpbrush-transform.h"
#include "gimpbrushcache.h"
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
#include "gimpbrushgenerated.h"
#include "gimpbrushpipe.h"
#include "gimptagged.h"
#include "gimptempbuf.h"
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
#include "gimp-intl.h"
removed GimpFillType. 2001-06-29 Michael Natterer <mitch@gimp.org> * app/appenums.h: removed GimpFillType. * app/gimprc.c: parse the session-info's new "aux-info" field. * app/global_edit.[ch]: removed the old "Paste Named" dialog and prefixed all functions with "gimp_". * app/core/core-types.h: added GimpFillType. * app/core/gimpbrush.[ch]: new signal "spacing_changed". * app/gui/Makefile.am * app/gui/tools-commands.[ch]: one more file cut out of commands.[ch]. * app/gui/commands.[ch]: removed the tools stuff here. * app/gui/brush-select.[ch] * app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView (see below). * app/gui/dialogs-commands.[ch] * app/gui/menus.[ch]: - Made it 64bit safe again by passing the dialog factory's identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT(). - Added a "gchar *quark_string" field to GimpItemFactoryEntry which gets transformed into a GQuark by menus_create_item(). - Added SEPARATOR() and BRANCH() macros which make the *_entries[] arrays more readable. - Added a menu item to show/hide GimpImageDock's image menu. - Removed file_last_opened_cmd_callback(). * app/gui/edit-commands.c: the global_edit functions are "gimp_" prefixed now. * app/gui/file-commands.[ch]: added file_last_opened_cmd_callback() here. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpbrushfactoryview.[ch]: new widget: a GimpDataFactory subclass with a "spacing" scale. * app/widgets/gimpcontainereditor.[ch]: - Connect to the GimpContainerView's "select_item", "activate_item" and "context_item" signals here once instead of in each subclass and dispatch them via new virtual functions. - Added a convenience function which makes DND to the buttons much less painful for subclasses. * app/widgets/gimpbufferview.c * app/widgets/gimpdatafactoryview.[ch]: changed accordingly. * app/widgets/gimpdialogfactory.[ch]: - Added gimp_dialog_factory_dialog_raise() which can raise toplevel dialogs _and_ dockables (and creates them if they are not open yet). - Keep track of all created dialogs (not only toplevels). - Added an "aux_info" field to GimpSessionInfo which is a GList of gchar* and is saved in sessionrc. - Remember if GimpImageDock's image menu is visible by using an aux_info string. - The code did not become nicer with all those new constraints. I have to add comments before I forget how it works. * app/widgets/gimpdockbook.c: set the state of the "Show Image Menu" menu item before popping up the item factory. * app/widgets/gimpimagedock.[ch]: added gimp_image_dock_set_show_image_meu(). * plug-ins/gdyntext/gdyntext.c * plug-ins/perl/examples/fit-text * plug-ins/perl/examples/terral_text * plug-ins/perl/examples/tex-to-float: register all text rendering plug-ins under <Image>/Filters/Text * app/pdb/brush_select_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/enums.pl * po/POTFILES.in: changed according to all the stuff above.
2001-06-30 03:25:03 +08:00
enum
{
SPACING_CHANGED,
LAST_SIGNAL
};
enum
{
PROP_0,
PROP_SPACING
};
removed GimpFillType. 2001-06-29 Michael Natterer <mitch@gimp.org> * app/appenums.h: removed GimpFillType. * app/gimprc.c: parse the session-info's new "aux-info" field. * app/global_edit.[ch]: removed the old "Paste Named" dialog and prefixed all functions with "gimp_". * app/core/core-types.h: added GimpFillType. * app/core/gimpbrush.[ch]: new signal "spacing_changed". * app/gui/Makefile.am * app/gui/tools-commands.[ch]: one more file cut out of commands.[ch]. * app/gui/commands.[ch]: removed the tools stuff here. * app/gui/brush-select.[ch] * app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView (see below). * app/gui/dialogs-commands.[ch] * app/gui/menus.[ch]: - Made it 64bit safe again by passing the dialog factory's identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT(). - Added a "gchar *quark_string" field to GimpItemFactoryEntry which gets transformed into a GQuark by menus_create_item(). - Added SEPARATOR() and BRANCH() macros which make the *_entries[] arrays more readable. - Added a menu item to show/hide GimpImageDock's image menu. - Removed file_last_opened_cmd_callback(). * app/gui/edit-commands.c: the global_edit functions are "gimp_" prefixed now. * app/gui/file-commands.[ch]: added file_last_opened_cmd_callback() here. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpbrushfactoryview.[ch]: new widget: a GimpDataFactory subclass with a "spacing" scale. * app/widgets/gimpcontainereditor.[ch]: - Connect to the GimpContainerView's "select_item", "activate_item" and "context_item" signals here once instead of in each subclass and dispatch them via new virtual functions. - Added a convenience function which makes DND to the buttons much less painful for subclasses. * app/widgets/gimpbufferview.c * app/widgets/gimpdatafactoryview.[ch]: changed accordingly. * app/widgets/gimpdialogfactory.[ch]: - Added gimp_dialog_factory_dialog_raise() which can raise toplevel dialogs _and_ dockables (and creates them if they are not open yet). - Keep track of all created dialogs (not only toplevels). - Added an "aux_info" field to GimpSessionInfo which is a GList of gchar* and is saved in sessionrc. - Remember if GimpImageDock's image menu is visible by using an aux_info string. - The code did not become nicer with all those new constraints. I have to add comments before I forget how it works. * app/widgets/gimpdockbook.c: set the state of the "Show Image Menu" menu item before popping up the item factory. * app/widgets/gimpimagedock.[ch]: added gimp_image_dock_set_show_image_meu(). * plug-ins/gdyntext/gdyntext.c * plug-ins/perl/examples/fit-text * plug-ins/perl/examples/terral_text * plug-ins/perl/examples/tex-to-float: register all text rendering plug-ins under <Image>/Filters/Text * app/pdb/brush_select_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/enums.pl * po/POTFILES.in: changed according to all the stuff above.
2001-06-30 03:25:03 +08:00
static void gimp_brush_tagged_iface_init (GimpTaggedInterface *iface);
static void gimp_brush_finalize (GObject *object);
static void gimp_brush_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_brush_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static gint64 gimp_brush_get_memsize (GimpObject *object,
gint64 *gui_size);
static gboolean gimp_brush_get_size (GimpViewable *viewable,
gint *width,
gint *height);
2012-04-09 02:25:49 +08:00
static GimpTempBuf * gimp_brush_get_new_preview (GimpViewable *viewable,
GimpContext *context,
gint width,
gint height);
static gchar * gimp_brush_get_description (GimpViewable *viewable,
gchar **tooltip);
static void gimp_brush_dirty (GimpData *data);
static const gchar * gimp_brush_get_extension (GimpData *data);
static void gimp_brush_copy (GimpData *data,
GimpData *src_data);
static void gimp_brush_real_begin_use (GimpBrush *brush);
static void gimp_brush_real_end_use (GimpBrush *brush);
static GimpBrush * gimp_brush_real_select_brush (GimpBrush *brush,
const GimpCoords *last_coords,
const GimpCoords *current_coords);
static gboolean gimp_brush_real_want_null_motion (GimpBrush *brush,
const GimpCoords *last_coords,
const GimpCoords *current_coords);
static gchar * gimp_brush_get_checksum (GimpTagged *tagged);
G_DEFINE_TYPE_WITH_CODE (GimpBrush, gimp_brush, GIMP_TYPE_DATA,
G_ADD_PRIVATE (GimpBrush)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_TAGGED,
gimp_brush_tagged_iface_init))
#define parent_class gimp_brush_parent_class
static guint brush_signals[LAST_SIGNAL] = { 0 };
static void
gimp_brush_class_init (GimpBrushClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpDataClass *data_class = GIMP_DATA_CLASS (klass);
brush_signals[SPACING_CHANGED] =
g_signal_new ("spacing-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpBrushClass, spacing_changed),
NULL, NULL, NULL,
G_TYPE_NONE, 0);
removed GimpFillType. 2001-06-29 Michael Natterer <mitch@gimp.org> * app/appenums.h: removed GimpFillType. * app/gimprc.c: parse the session-info's new "aux-info" field. * app/global_edit.[ch]: removed the old "Paste Named" dialog and prefixed all functions with "gimp_". * app/core/core-types.h: added GimpFillType. * app/core/gimpbrush.[ch]: new signal "spacing_changed". * app/gui/Makefile.am * app/gui/tools-commands.[ch]: one more file cut out of commands.[ch]. * app/gui/commands.[ch]: removed the tools stuff here. * app/gui/brush-select.[ch] * app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView (see below). * app/gui/dialogs-commands.[ch] * app/gui/menus.[ch]: - Made it 64bit safe again by passing the dialog factory's identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT(). - Added a "gchar *quark_string" field to GimpItemFactoryEntry which gets transformed into a GQuark by menus_create_item(). - Added SEPARATOR() and BRANCH() macros which make the *_entries[] arrays more readable. - Added a menu item to show/hide GimpImageDock's image menu. - Removed file_last_opened_cmd_callback(). * app/gui/edit-commands.c: the global_edit functions are "gimp_" prefixed now. * app/gui/file-commands.[ch]: added file_last_opened_cmd_callback() here. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpbrushfactoryview.[ch]: new widget: a GimpDataFactory subclass with a "spacing" scale. * app/widgets/gimpcontainereditor.[ch]: - Connect to the GimpContainerView's "select_item", "activate_item" and "context_item" signals here once instead of in each subclass and dispatch them via new virtual functions. - Added a convenience function which makes DND to the buttons much less painful for subclasses. * app/widgets/gimpbufferview.c * app/widgets/gimpdatafactoryview.[ch]: changed accordingly. * app/widgets/gimpdialogfactory.[ch]: - Added gimp_dialog_factory_dialog_raise() which can raise toplevel dialogs _and_ dockables (and creates them if they are not open yet). - Keep track of all created dialogs (not only toplevels). - Added an "aux_info" field to GimpSessionInfo which is a GList of gchar* and is saved in sessionrc. - Remember if GimpImageDock's image menu is visible by using an aux_info string. - The code did not become nicer with all those new constraints. I have to add comments before I forget how it works. * app/widgets/gimpdockbook.c: set the state of the "Show Image Menu" menu item before popping up the item factory. * app/widgets/gimpimagedock.[ch]: added gimp_image_dock_set_show_image_meu(). * plug-ins/gdyntext/gdyntext.c * plug-ins/perl/examples/fit-text * plug-ins/perl/examples/terral_text * plug-ins/perl/examples/tex-to-float: register all text rendering plug-ins under <Image>/Filters/Text * app/pdb/brush_select_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/enums.pl * po/POTFILES.in: changed according to all the stuff above.
2001-06-30 03:25:03 +08:00
object_class->finalize = gimp_brush_finalize;
object_class->get_property = gimp_brush_get_property;
object_class->set_property = gimp_brush_set_property;
gimp_object_class->get_memsize = gimp_brush_get_memsize;
viewable_class->default_icon_name = "gimp-tool-paintbrush";
viewable_class->get_size = gimp_brush_get_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview;
viewable_class->get_description = gimp_brush_get_description;
data_class->dirty = gimp_brush_dirty;
data_class->save = gimp_brush_save;
data_class->get_extension = gimp_brush_get_extension;
data_class->copy = gimp_brush_copy;
klass->begin_use = gimp_brush_real_begin_use;
klass->end_use = gimp_brush_real_end_use;
klass->select_brush = gimp_brush_real_select_brush;
klass->want_null_motion = gimp_brush_real_want_null_motion;
klass->transform_size = gimp_brush_real_transform_size;
klass->transform_mask = gimp_brush_real_transform_mask;
klass->transform_pixmap = gimp_brush_real_transform_pixmap;
klass->transform_boundary = gimp_brush_real_transform_boundary;
klass->spacing_changed = NULL;
g_object_class_install_property (object_class, PROP_SPACING,
g_param_spec_double ("spacing", NULL,
_("Brush Spacing"),
1.0, 5000.0, 20.0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
gimp_brush_tagged_iface_init (GimpTaggedInterface *iface)
{
iface->get_checksum = gimp_brush_get_checksum;
}
static void
gimp_brush_init (GimpBrush *brush)
{
brush->priv = gimp_brush_get_instance_private (brush);
brush->priv->spacing = 20;
brush->priv->x_axis.x = 15.0;
brush->priv->x_axis.y = 0.0;
brush->priv->y_axis.x = 0.0;
brush->priv->y_axis.y = 15.0;
brush->priv->blur_hardness = 1.0;
}
static void
gimp_brush_finalize (GObject *object)
{
GimpBrush *brush = GIMP_BRUSH (object);
g_clear_pointer (&brush->priv->mask, gimp_temp_buf_unref);
g_clear_pointer (&brush->priv->pixmap, gimp_temp_buf_unref);
g_clear_pointer (&brush->priv->blurred_mask, gimp_temp_buf_unref);
g_clear_pointer (&brush->priv->blurred_pixmap, gimp_temp_buf_unref);
gimp_brush_mipmap_clear (brush);
g_clear_object (&brush->priv->mask_cache);
g_clear_object (&brush->priv->pixmap_cache);
g_clear_object (&brush->priv->boundary_cache);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_brush_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpBrush *brush = GIMP_BRUSH (object);
switch (property_id)
{
case PROP_SPACING:
gimp_brush_set_spacing (brush, g_value_get_double (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_brush_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpBrush *brush = GIMP_BRUSH (object);
switch (property_id)
{
case PROP_SPACING:
g_value_set_double (value, gimp_brush_get_spacing (brush));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gint64
changed GimpObject::get_memsize() to return a second value named 2003-08-25 Michael Natterer <mitch@gimp.org> * app/core/gimpobject.[ch]: changed GimpObject::get_memsize() to return a second value named "gui_size", where the primary return value is the "constant" actual size (as long as no operation is performed on the object), and the second "gui_size" return value is the size of temporary stuff like preview caches or boundary segments (which may change asynchronously, even if the object is on the undo stack). * app/core/gimp.c * app/core/gimpbrush.c * app/core/gimpbrushpipe.c * app/core/gimpbuffer.c * app/core/gimpchannel.c * app/core/gimpcontainer.c * app/core/gimpcontext.c * app/core/gimpdata.c * app/core/gimpdatafactory.c * app/core/gimpdrawable.c * app/core/gimpgradient.c * app/core/gimpimage-undo.c * app/core/gimpimage.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimplist.c * app/core/gimppalette.c * app/core/gimpparasitelist.c * app/core/gimppattern.c * app/core/gimpundo.c * app/core/gimpundostack.c * app/core/gimpviewable.c * app/text/gimptextlayer.c * app/vectors/gimpstroke.c * app/vectors/gimpvectors.c: changed get_memsize() implementations accordingly. * app/display/gimpdisplayshell-title.c * app/gui/debug-commands.c * app/widgets/gimppreview.c: changed callers accordingly. * app/core/gimpimage-undo-push.c: changed layer, channel, vectors and layer_mask undo steps to add/subtract the size of the resp. objects whenever they take/drop ownership of them. Ignore the objects' "gui_size" to get identical sizes on adding/subtracting. Fixes bug #120429.
2003-08-25 18:49:33 +08:00
gimp_brush_get_memsize (GimpObject *object,
gint64 *gui_size)
{
GimpBrush *brush = GIMP_BRUSH (object);
gint64 memsize = 0;
memsize += gimp_temp_buf_get_memsize (brush->priv->mask);
memsize += gimp_temp_buf_get_memsize (brush->priv->pixmap);
memsize += gimp_brush_mipmap_get_memsize (brush);
changed GimpObject::get_memsize() to return a second value named 2003-08-25 Michael Natterer <mitch@gimp.org> * app/core/gimpobject.[ch]: changed GimpObject::get_memsize() to return a second value named "gui_size", where the primary return value is the "constant" actual size (as long as no operation is performed on the object), and the second "gui_size" return value is the size of temporary stuff like preview caches or boundary segments (which may change asynchronously, even if the object is on the undo stack). * app/core/gimp.c * app/core/gimpbrush.c * app/core/gimpbrushpipe.c * app/core/gimpbuffer.c * app/core/gimpchannel.c * app/core/gimpcontainer.c * app/core/gimpcontext.c * app/core/gimpdata.c * app/core/gimpdatafactory.c * app/core/gimpdrawable.c * app/core/gimpgradient.c * app/core/gimpimage-undo.c * app/core/gimpimage.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimplist.c * app/core/gimppalette.c * app/core/gimpparasitelist.c * app/core/gimppattern.c * app/core/gimpundo.c * app/core/gimpundostack.c * app/core/gimpviewable.c * app/text/gimptextlayer.c * app/vectors/gimpstroke.c * app/vectors/gimpvectors.c: changed get_memsize() implementations accordingly. * app/display/gimpdisplayshell-title.c * app/gui/debug-commands.c * app/widgets/gimppreview.c: changed callers accordingly. * app/core/gimpimage-undo-push.c: changed layer, channel, vectors and layer_mask undo steps to add/subtract the size of the resp. objects whenever they take/drop ownership of them. Ignore the objects' "gui_size" to get identical sizes on adding/subtracting. Fixes bug #120429.
2003-08-25 18:49:33 +08:00
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
}
added virtual function get_popup_size() which returns a boolean indicating 2003-02-27 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added virtual function get_popup_size() which returns a boolean indicating if a popup is needed and its size. * app/core/gimpbrush.c * app/core/gimpbrushpipe.c * app/core/gimpbuffer.c * app/core/gimpdrawable-preview.[ch] * app/core/gimpdrawable.c * app/core/gimpgradient.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpundo.c: implement it. * app/widgets/gimppreview.[ch]: removed virtual functions needs_popup() and create_popup(). Removed the code which creates the popup and the popup members of the GimpPreview struct. * app/widgets/gimppreview-popup.[ch]: new files providing the utility function gimp_preview_popup_show() which can show popups from any widget, not just from a GimpPreview. Checks if a popup is needed using gimp_viewable_get_popup_size(). * app/widgets/gimpcellrendererviewable.c: show popups here too. * app/widgets/gimpbrushpreview.c * app/widgets/gimpbufferpreview.c * app/widgets/gimpdrawablepreview.c * app/widgets/gimpimagepreview.c: removed needs_popup() and create_popup() implementations. * app/widgets/gimpnavigationpreview.c: removed empty render() implementation. * app/widgets/gimpundoeditor.c: use a tree instead of a list view. * app/widgets/gimpgradientpreview.[ch] * app/widgets/gimppalettepreview.[ch] * app/widgets/gimppatternpreview.[ch]: removed because they only implemented the removed popup functions. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenuitem.c * app/widgets/gimppreview-utils.c: changed accordingly
2003-02-27 21:59:41 +08:00
static gboolean
gimp_brush_get_size (GimpViewable *viewable,
gint *width,
gint *height)
added virtual function get_popup_size() which returns a boolean indicating 2003-02-27 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added virtual function get_popup_size() which returns a boolean indicating if a popup is needed and its size. * app/core/gimpbrush.c * app/core/gimpbrushpipe.c * app/core/gimpbuffer.c * app/core/gimpdrawable-preview.[ch] * app/core/gimpdrawable.c * app/core/gimpgradient.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpundo.c: implement it. * app/widgets/gimppreview.[ch]: removed virtual functions needs_popup() and create_popup(). Removed the code which creates the popup and the popup members of the GimpPreview struct. * app/widgets/gimppreview-popup.[ch]: new files providing the utility function gimp_preview_popup_show() which can show popups from any widget, not just from a GimpPreview. Checks if a popup is needed using gimp_viewable_get_popup_size(). * app/widgets/gimpcellrendererviewable.c: show popups here too. * app/widgets/gimpbrushpreview.c * app/widgets/gimpbufferpreview.c * app/widgets/gimpdrawablepreview.c * app/widgets/gimpimagepreview.c: removed needs_popup() and create_popup() implementations. * app/widgets/gimpnavigationpreview.c: removed empty render() implementation. * app/widgets/gimpundoeditor.c: use a tree instead of a list view. * app/widgets/gimpgradientpreview.[ch] * app/widgets/gimppalettepreview.[ch] * app/widgets/gimppatternpreview.[ch]: removed because they only implemented the removed popup functions. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenuitem.c * app/widgets/gimppreview-utils.c: changed accordingly
2003-02-27 21:59:41 +08:00
{
GimpBrush *brush = GIMP_BRUSH (viewable);
added virtual function get_popup_size() which returns a boolean indicating 2003-02-27 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added virtual function get_popup_size() which returns a boolean indicating if a popup is needed and its size. * app/core/gimpbrush.c * app/core/gimpbrushpipe.c * app/core/gimpbuffer.c * app/core/gimpdrawable-preview.[ch] * app/core/gimpdrawable.c * app/core/gimpgradient.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpundo.c: implement it. * app/widgets/gimppreview.[ch]: removed virtual functions needs_popup() and create_popup(). Removed the code which creates the popup and the popup members of the GimpPreview struct. * app/widgets/gimppreview-popup.[ch]: new files providing the utility function gimp_preview_popup_show() which can show popups from any widget, not just from a GimpPreview. Checks if a popup is needed using gimp_viewable_get_popup_size(). * app/widgets/gimpcellrendererviewable.c: show popups here too. * app/widgets/gimpbrushpreview.c * app/widgets/gimpbufferpreview.c * app/widgets/gimpdrawablepreview.c * app/widgets/gimpimagepreview.c: removed needs_popup() and create_popup() implementations. * app/widgets/gimpnavigationpreview.c: removed empty render() implementation. * app/widgets/gimpundoeditor.c: use a tree instead of a list view. * app/widgets/gimpgradientpreview.[ch] * app/widgets/gimppalettepreview.[ch] * app/widgets/gimppatternpreview.[ch]: removed because they only implemented the removed popup functions. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenuitem.c * app/widgets/gimppreview-utils.c: changed accordingly
2003-02-27 21:59:41 +08:00
*width = gimp_temp_buf_get_width (brush->priv->mask);
*height = gimp_temp_buf_get_height (brush->priv->mask);
added virtual function get_popup_size() which returns a boolean indicating 2003-02-27 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added virtual function get_popup_size() which returns a boolean indicating if a popup is needed and its size. * app/core/gimpbrush.c * app/core/gimpbrushpipe.c * app/core/gimpbuffer.c * app/core/gimpdrawable-preview.[ch] * app/core/gimpdrawable.c * app/core/gimpgradient.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpundo.c: implement it. * app/widgets/gimppreview.[ch]: removed virtual functions needs_popup() and create_popup(). Removed the code which creates the popup and the popup members of the GimpPreview struct. * app/widgets/gimppreview-popup.[ch]: new files providing the utility function gimp_preview_popup_show() which can show popups from any widget, not just from a GimpPreview. Checks if a popup is needed using gimp_viewable_get_popup_size(). * app/widgets/gimpcellrendererviewable.c: show popups here too. * app/widgets/gimpbrushpreview.c * app/widgets/gimpbufferpreview.c * app/widgets/gimpdrawablepreview.c * app/widgets/gimpimagepreview.c: removed needs_popup() and create_popup() implementations. * app/widgets/gimpnavigationpreview.c: removed empty render() implementation. * app/widgets/gimpundoeditor.c: use a tree instead of a list view. * app/widgets/gimpgradientpreview.[ch] * app/widgets/gimppalettepreview.[ch] * app/widgets/gimppatternpreview.[ch]: removed because they only implemented the removed popup functions. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenuitem.c * app/widgets/gimppreview-utils.c: changed accordingly
2003-02-27 21:59:41 +08:00
return TRUE;
added virtual function get_popup_size() which returns a boolean indicating 2003-02-27 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added virtual function get_popup_size() which returns a boolean indicating if a popup is needed and its size. * app/core/gimpbrush.c * app/core/gimpbrushpipe.c * app/core/gimpbuffer.c * app/core/gimpdrawable-preview.[ch] * app/core/gimpdrawable.c * app/core/gimpgradient.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpundo.c: implement it. * app/widgets/gimppreview.[ch]: removed virtual functions needs_popup() and create_popup(). Removed the code which creates the popup and the popup members of the GimpPreview struct. * app/widgets/gimppreview-popup.[ch]: new files providing the utility function gimp_preview_popup_show() which can show popups from any widget, not just from a GimpPreview. Checks if a popup is needed using gimp_viewable_get_popup_size(). * app/widgets/gimpcellrendererviewable.c: show popups here too. * app/widgets/gimpbrushpreview.c * app/widgets/gimpbufferpreview.c * app/widgets/gimpdrawablepreview.c * app/widgets/gimpimagepreview.c: removed needs_popup() and create_popup() implementations. * app/widgets/gimpnavigationpreview.c: removed empty render() implementation. * app/widgets/gimpundoeditor.c: use a tree instead of a list view. * app/widgets/gimpgradientpreview.[ch] * app/widgets/gimppalettepreview.[ch] * app/widgets/gimppatternpreview.[ch]: removed because they only implemented the removed popup functions. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenuitem.c * app/widgets/gimppreview-utils.c: changed accordingly
2003-02-27 21:59:41 +08:00
}
2012-04-09 02:25:49 +08:00
static GimpTempBuf *
gimp_brush_get_new_preview (GimpViewable *viewable,
Changed GimpViewable preview rendering to have a context to get 2006-08-29 Michael Natterer <mitch@gimp.org> Changed GimpViewable preview rendering to have a context to get FG/BG/whatever from. Use the context to enable dynamic FG/BG colors in gradients. Fixes bug #127676 and bug #352214. Addresses bug #128367 (doesn't fix it because there's no loading/saving and no GUI yet). * app/core/core-enums.[ch]: added enum GimpGradientColor to enable specifying gradient colors in terms of foreground and background. * app/core/gimpgradient.[ch]: added color_type members to the GimpGradientSegment struct and honor them in gimp_gradient_get_color_at(). Added GimpContext parameters to all functions which finally call get_color_at(). * app/core/gimp-gradients.c: use the new method to implement the builtin gradients. * app/core/gimpviewable.[ch]: added GimpContext parameters to all get_preview() and get_pixbuf() functions. * app/core/gimpbrush.c * app/core/gimpbuffer.c * app/core/gimpdrawable-preview.[ch] * app/core/gimpgradient.c * app/core/gimpimage-preview.[ch] * app/core/gimpimagefile.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpundo.[ch] * app/text/gimpfont.c * app/vectors/gimpvectors-preview.[ch]: changed ::get_preview() and ::get_pixbuf() implementations accordingly. * app/core/gimpdrawable-blend.c * app/core/gimppalette-import.[ch] * app/dialogs/dialogs-constructors.c * app/dialogs/palette-import-dialog.c * app/dialogs/resize-dialog.c * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell.c * app/display/gimpnavigationeditor.c * app/paint/gimppaintoptions.c * app/tools/gimpeditselectiontool.c * app/tools/gimptexttool.c * app/actions/gradient-editor-commands.c * app/widgets/gimpaction.c * app/widgets/gimpbrusheditor.[ch] * app/widgets/gimpbufferview.c * app/widgets/gimpcellrendererviewable.c * app/widgets/gimpchanneltreeview.c * app/widgets/gimpclipboard.c * app/widgets/gimpcoloreditor.c * app/widgets/gimpcomponenteditor.c * app/widgets/gimpcontainerbox.c * app/widgets/gimpcontainercombobox.c * app/widgets/gimpcontainereditor.c * app/widgets/gimpcontainerentry.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainertreeview.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdevicestatus.c * app/widgets/gimpdnd.[ch] * app/widgets/gimpdrawabletreeview.c * app/widgets/gimpfiledialog.c * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpgradientselect.c * app/widgets/gimpitemtreeview.c * app/widgets/gimplayertreeview.c * app/widgets/gimppaletteeditor.[ch] * app/widgets/gimppropwidgets.[ch] * app/widgets/gimpselectioneditor.c * app/widgets/gimpthumbbox.[ch] * app/widgets/gimptoolbox-image-area.c * app/widgets/gimptoolbox-indicator-area.c * app/widgets/gimptooloptionseditor.c * app/widgets/gimpundoeditor.c * app/widgets/gimpvectorstreeview.c * app/widgets/gimpview-popup.[ch] * app/widgets/gimpview.[ch] * app/widgets/gimpviewablebutton.c * app/widgets/gimpviewabledialog.c * app/widgets/gimpviewrenderer.[ch] * app/widgets/gimpviewrenderer-frame.c * app/widgets/gimpviewrendererbrush.c * app/widgets/gimpviewrendererbuffer.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrenderergradient.c * app/widgets/gimpviewrendererimage.c * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb: added tons of GimpContext members and parameters, implement GimpDocked::set_context() in many widgets. Pass these locally remembered contexts to GimpViewable functions. Did some minor cleanups on the way. There are still some minor FIXMEs around where the code uses a NULL context (which is allowed by the APIs) * app/pdb/drawable_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c: regenerated.
2006-08-30 05:44:51 +08:00
GimpContext *context,
gint width,
gint height)
{
2012-04-09 02:25:49 +08:00
GimpBrush *brush = GIMP_BRUSH (viewable);
const GimpTempBuf *mask_buf = brush->priv->mask;
const GimpTempBuf *pixmap_buf = brush->priv->pixmap;
2012-04-09 02:25:49 +08:00
GimpTempBuf *return_buf = NULL;
gint mask_width;
gint mask_height;
guchar *mask_data;
2012-04-09 02:25:49 +08:00
guchar *mask;
guchar *buf;
gint x, y;
gboolean scaled = FALSE;
mask_width = gimp_temp_buf_get_width (mask_buf);
mask_height = gimp_temp_buf_get_height (mask_buf);
if (mask_width > width || mask_height > height)
{
gdouble ratio_x = (gdouble) width / (gdouble) mask_width;
gdouble ratio_y = (gdouble) height / (gdouble) mask_height;
gdouble scale = MIN (ratio_x, ratio_y);
if (scale != 1.0)
{
gimp_brush_begin_use (brush);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
GimpBrushGenerated *gen_brush = GIMP_BRUSH_GENERATED (brush);
mask_buf = gimp_brush_transform_mask (brush, scale,
(gimp_brush_generated_get_aspect_ratio (gen_brush) - 1.0) * 20.0 / 19.0,
gimp_brush_generated_get_angle (gen_brush) / 360.0,
FALSE,
gimp_brush_generated_get_hardness (gen_brush));
}
else
mask_buf = gimp_brush_transform_mask (brush, scale,
0.0, 0.0, FALSE, 1.0);
if (! mask_buf)
{
mask_buf = gimp_temp_buf_new (1, 1, babl_format ("Y u8"));
gimp_temp_buf_data_clear ((GimpTempBuf *) mask_buf);
}
else
{
gimp_temp_buf_ref ((GimpTempBuf *) mask_buf);
}
if (pixmap_buf)
pixmap_buf = gimp_brush_transform_pixmap (brush, scale,
0.0, 0.0, FALSE, 1.0);
mask_width = gimp_temp_buf_get_width (mask_buf);
mask_height = gimp_temp_buf_get_height (mask_buf);
scaled = TRUE;
}
}
return_buf = gimp_temp_buf_new (mask_width, mask_height,
babl_format ("R'G'B'A u8"));
mask = mask_data = gimp_temp_buf_lock (mask_buf, babl_format ("Y u8"),
GEGL_ACCESS_READ);
buf = gimp_temp_buf_get_data (return_buf);
if (pixmap_buf)
{
guchar *pixmap_data;
guchar *pixmap;
pixmap = pixmap_data = gimp_temp_buf_lock (pixmap_buf,
babl_format ("R'G'B' u8"),
GEGL_ACCESS_READ);
for (y = 0; y < mask_height; y++)
{
for (x = 0; x < mask_width ; x++)
{
added "gchar *stock_id" to the GimpViewable struct. It is used by the GUI 2003-02-25 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added "gchar *stock_id" to the GimpViewable struct. It is used by the GUI if the get_preview() functions return NULL. Default to GTK_STOCK_DIALOG_QUESTION. * app/core/gimptoolinfo.[ch]: set the tool's stock_id. Removed the cached GdkPixbuf. Don't implement any preview function so the GUI uses the stock_id. * app/tools/tool_manager.c: removed GdkPixbuf creation, removed the #warning about the buggy way we created the pixbuf. * app/gui/dialogs-constructors.c * app/gui/image-menu.c * app/tools/gimpcroptool.c * app/tools/gimphistogramtool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptoolbox.c: use viewable->stock_id instead of tool_info->stock_id. * app/core/gimpbrush.c * app/core/gimpgradient.c * app/core/gimpimagefile.c * app/core/gimpundo.c: simplified get_preview() implementations: - never scale previews up, only down. - don't render white or checks backgrounds but simply return TempBufs with alpha and let the preview system do its job. - don't add padding but simply return previews smaller than requested. * app/display/gimpdisplayshell-render.[ch]: added "render_blend_white", a 2d lookup table for blending on white, just as the check lookup tables. Added "render_white_buf". * app/widgets/gimppreview.[ch]: changed a lot: - don't render the preview's border into the buffer. - added "GdkGC *border_gc" and draw the preview's border in expose() using gdk_draw_rectangle(). - added "GdkPixbuf *no_preview_pixbuf" and create it in gimp_preview_real_render() if gimp_viewable_get_preview() returned NULL. - factored the actual preview rendering out to gimp_preview_render_to_buffer(). Added configurable background rendering for the preview itself and it's padding area (the area the preview is larger than the buffer returned by gimp_viewable_get_preview()). - changed gimp_preview_render_and_flush() to gimp_preview_render_preview() and added "inside_bg" and "outside_bg" parameters. - use the new render buffers for blending on white. * app/widgets/gimpbrushpreview.c * app/widgets/gimpbufferpreview.c * app/widgets/gimpdrawablepreview.c * app/widgets/gimpgradientpreview.c * app/widgets/gimpimagepreview.c * app/widgets/gimppalettepreview.c * app/widgets/gimppatternpreview.c: don't create large white TempBufs to center the previews in but simply set the TempBuf's offsets to get them centered. Simplified & cleaned up many preview render functions. Pass the correct GimpPreviewBG modes to gimp_preview_render_preview(). * app/widgets/gimpcellrendererviewable.[ch]: new GtkCellRenderer class derived from GtkCellRendererPixbuf which knows how to use gimp_viewable_get_preview_size() and renders the viewable's stock item if no preview can be created. * app/widgets/gimpcontainertreeview.c: added a GtkTreeCellDataFunc which creates the preview pixbuf if needed so we don't create it unconditionally upon item insertion. Fixed preview size assertion to use GIMP_PREVIEW_MAX_SIZE, not "64". Block "selection_changed" while reordering the selected item. * app/widgets/gimpcontainerview.c: cosmetic. * app/widgets/gimpimagefilepreview.[ch] * app/widgets/gimptoolinfopreview.[ch] * app/widgets/gimpundopreview.[ch]: removed because the default implementation is good enough. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimppreview-utils.c: changed accordingly. * app/gui/dialogs-constructors.[ch] * app/gui/dialogs-menu.c * app/gui/dialogs.c * app/gui/image-menu.c * app/gui/toolbox-menu.c: register grid and tree view variants of the document history. Unrelated: * app/gui/gui.c (gui_exit_finish_callback): disconnect from signals earlier. * app/gui/user-install-dialog.c: create the "tool-options" subdir of the user's ~/.gimp-1.3 directory.
2003-02-27 00:15:50 +08:00
*buf++ = *pixmap++;
*buf++ = *pixmap++;
*buf++ = *pixmap++;
*buf++ = *mask++;
}
}
gimp_temp_buf_unlock (pixmap_buf, pixmap_data);
}
else
{
for (y = 0; y < mask_height; y++)
{
for (x = 0; x < mask_width ; x++)
{
added "gchar *stock_id" to the GimpViewable struct. It is used by the GUI 2003-02-25 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added "gchar *stock_id" to the GimpViewable struct. It is used by the GUI if the get_preview() functions return NULL. Default to GTK_STOCK_DIALOG_QUESTION. * app/core/gimptoolinfo.[ch]: set the tool's stock_id. Removed the cached GdkPixbuf. Don't implement any preview function so the GUI uses the stock_id. * app/tools/tool_manager.c: removed GdkPixbuf creation, removed the #warning about the buggy way we created the pixbuf. * app/gui/dialogs-constructors.c * app/gui/image-menu.c * app/tools/gimpcroptool.c * app/tools/gimphistogramtool.c * app/tools/gimpimagemaptool.c * app/tools/gimpmeasuretool.c * app/tools/gimptransformtool.c * app/widgets/gimptoolbox.c: use viewable->stock_id instead of tool_info->stock_id. * app/core/gimpbrush.c * app/core/gimpgradient.c * app/core/gimpimagefile.c * app/core/gimpundo.c: simplified get_preview() implementations: - never scale previews up, only down. - don't render white or checks backgrounds but simply return TempBufs with alpha and let the preview system do its job. - don't add padding but simply return previews smaller than requested. * app/display/gimpdisplayshell-render.[ch]: added "render_blend_white", a 2d lookup table for blending on white, just as the check lookup tables. Added "render_white_buf". * app/widgets/gimppreview.[ch]: changed a lot: - don't render the preview's border into the buffer. - added "GdkGC *border_gc" and draw the preview's border in expose() using gdk_draw_rectangle(). - added "GdkPixbuf *no_preview_pixbuf" and create it in gimp_preview_real_render() if gimp_viewable_get_preview() returned NULL. - factored the actual preview rendering out to gimp_preview_render_to_buffer(). Added configurable background rendering for the preview itself and it's padding area (the area the preview is larger than the buffer returned by gimp_viewable_get_preview()). - changed gimp_preview_render_and_flush() to gimp_preview_render_preview() and added "inside_bg" and "outside_bg" parameters. - use the new render buffers for blending on white. * app/widgets/gimpbrushpreview.c * app/widgets/gimpbufferpreview.c * app/widgets/gimpdrawablepreview.c * app/widgets/gimpgradientpreview.c * app/widgets/gimpimagepreview.c * app/widgets/gimppalettepreview.c * app/widgets/gimppatternpreview.c: don't create large white TempBufs to center the previews in but simply set the TempBuf's offsets to get them centered. Simplified & cleaned up many preview render functions. Pass the correct GimpPreviewBG modes to gimp_preview_render_preview(). * app/widgets/gimpcellrendererviewable.[ch]: new GtkCellRenderer class derived from GtkCellRendererPixbuf which knows how to use gimp_viewable_get_preview_size() and renders the viewable's stock item if no preview can be created. * app/widgets/gimpcontainertreeview.c: added a GtkTreeCellDataFunc which creates the preview pixbuf if needed so we don't create it unconditionally upon item insertion. Fixed preview size assertion to use GIMP_PREVIEW_MAX_SIZE, not "64". Block "selection_changed" while reordering the selected item. * app/widgets/gimpcontainerview.c: cosmetic. * app/widgets/gimpimagefilepreview.[ch] * app/widgets/gimptoolinfopreview.[ch] * app/widgets/gimpundopreview.[ch]: removed because the default implementation is good enough. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimppreview-utils.c: changed accordingly. * app/gui/dialogs-constructors.[ch] * app/gui/dialogs-menu.c * app/gui/dialogs.c * app/gui/image-menu.c * app/gui/toolbox-menu.c: register grid and tree view variants of the document history. Unrelated: * app/gui/gui.c (gui_exit_finish_callback): disconnect from signals earlier. * app/gui/user-install-dialog.c: create the "tool-options" subdir of the user's ~/.gimp-1.3 directory.
2003-02-27 00:15:50 +08:00
*buf++ = 0;
*buf++ = 0;
*buf++ = 0;
*buf++ = *mask++;
}
}
}
gimp_temp_buf_unlock (mask_buf, mask_data);
if (scaled)
{
gimp_temp_buf_unref ((GimpTempBuf *) mask_buf);
gimp_brush_end_use (brush);
}
return return_buf;
}
added vitrual function GimpViewable::get_description() which returns the 2003-04-08 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added vitrual function GimpViewable::get_description() which returns the string that should be presented to the user plus an optional tooltip with more information. The default implementation just returns the object's name and no tooltip. * app/core/gimpbrush.c * app/core/gimpbuffer.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimptoolinfo.c: implement get_description(). * app/core/gimpimagefile.[ch]: ditto. Renamed gimp_imagefile_get_description() to gimp_imagefile_get_desc_string(). Well, um, gimme a better name... * app/gui/file-open-dialog.c: changed accordingly. * app/file/file-utils.[ch]: renamed readXVThumb() to file_utils_readXVThumb(). * tools/pdbgen/pdb/fileops.pdb: changed accordingly. * app/widgets/widgets-types.h: removed GimpItemGetNameFunc typedef. * app/widgets/gimpcontainerview-utils.[ch]: removed the the actual get_name_funcs. They now live in the core as GimpViewable::get_description() implementations. * app/widgets/gimpcontainermenu.[ch] * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpcontainertreeview.c * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpmenuitem.[ch] * app/widgets/gimpviewabledialog.c: removed get_name_func stuff and use gimp_viewable_get_description(). * app/widgets/gimpcontainermenu.[ch]: added "preview_border_width" to gimp_container_menu_set_preview_size(). * app/widgets/gimpimagedock.c: changed accordingly. * app/pdb/fileops_cmds.c: regenerated.
2003-04-09 00:01:01 +08:00
static gchar *
gimp_brush_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpBrush *brush = GIMP_BRUSH (viewable);
added vitrual function GimpViewable::get_description() which returns the 2003-04-08 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added vitrual function GimpViewable::get_description() which returns the string that should be presented to the user plus an optional tooltip with more information. The default implementation just returns the object's name and no tooltip. * app/core/gimpbrush.c * app/core/gimpbuffer.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimptoolinfo.c: implement get_description(). * app/core/gimpimagefile.[ch]: ditto. Renamed gimp_imagefile_get_description() to gimp_imagefile_get_desc_string(). Well, um, gimme a better name... * app/gui/file-open-dialog.c: changed accordingly. * app/file/file-utils.[ch]: renamed readXVThumb() to file_utils_readXVThumb(). * tools/pdbgen/pdb/fileops.pdb: changed accordingly. * app/widgets/widgets-types.h: removed GimpItemGetNameFunc typedef. * app/widgets/gimpcontainerview-utils.[ch]: removed the the actual get_name_funcs. They now live in the core as GimpViewable::get_description() implementations. * app/widgets/gimpcontainermenu.[ch] * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpcontainertreeview.c * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpmenuitem.[ch] * app/widgets/gimpviewabledialog.c: removed get_name_func stuff and use gimp_viewable_get_description(). * app/widgets/gimpcontainermenu.[ch]: added "preview_border_width" to gimp_container_menu_set_preview_size(). * app/widgets/gimpimagedock.c: changed accordingly. * app/pdb/fileops_cmds.c: regenerated.
2003-04-09 00:01:01 +08:00
return g_strdup_printf ("%s (%d × %d)",
gimp_object_get_name (brush),
gimp_temp_buf_get_width (brush->priv->mask),
gimp_temp_buf_get_height (brush->priv->mask));
added vitrual function GimpViewable::get_description() which returns the 2003-04-08 Michael Natterer <mitch@gimp.org> * app/core/gimpviewable.[ch]: added vitrual function GimpViewable::get_description() which returns the string that should be presented to the user plus an optional tooltip with more information. The default implementation just returns the object's name and no tooltip. * app/core/gimpbrush.c * app/core/gimpbuffer.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimptoolinfo.c: implement get_description(). * app/core/gimpimagefile.[ch]: ditto. Renamed gimp_imagefile_get_description() to gimp_imagefile_get_desc_string(). Well, um, gimme a better name... * app/gui/file-open-dialog.c: changed accordingly. * app/file/file-utils.[ch]: renamed readXVThumb() to file_utils_readXVThumb(). * tools/pdbgen/pdb/fileops.pdb: changed accordingly. * app/widgets/widgets-types.h: removed GimpItemGetNameFunc typedef. * app/widgets/gimpcontainerview-utils.[ch]: removed the the actual get_name_funcs. They now live in the core as GimpViewable::get_description() implementations. * app/widgets/gimpcontainermenu.[ch] * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpcontainertreeview.c * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpmenuitem.[ch] * app/widgets/gimpviewabledialog.c: removed get_name_func stuff and use gimp_viewable_get_description(). * app/widgets/gimpcontainermenu.[ch]: added "preview_border_width" to gimp_container_menu_set_preview_size(). * app/widgets/gimpimagedock.c: changed accordingly. * app/pdb/fileops_cmds.c: regenerated.
2003-04-09 00:01:01 +08:00
}
static void
gimp_brush_dirty (GimpData *data)
{
GimpBrush *brush = GIMP_BRUSH (data);
if (brush->priv->mask_cache)
gimp_brush_cache_clear (brush->priv->mask_cache);
if (brush->priv->pixmap_cache)
gimp_brush_cache_clear (brush->priv->pixmap_cache);
if (brush->priv->boundary_cache)
gimp_brush_cache_clear (brush->priv->boundary_cache);
gimp_brush_mipmap_clear (brush);
g_clear_pointer (&brush->priv->blurred_mask, gimp_temp_buf_unref);
g_clear_pointer (&brush->priv->blurred_pixmap, gimp_temp_buf_unref);
GIMP_DATA_CLASS (parent_class)->dirty (data);
}
static const gchar *
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
gimp_brush_get_extension (GimpData *data)
{
return GIMP_BRUSH_FILE_EXTENSION;
}
static void
gimp_brush_copy (GimpData *data,
GimpData *src_data)
{
GimpBrush *brush = GIMP_BRUSH (data);
GimpBrush *src_brush = GIMP_BRUSH (src_data);
g_clear_pointer (&brush->priv->mask, gimp_temp_buf_unref);
if (src_brush->priv->mask)
brush->priv->mask = gimp_temp_buf_copy (src_brush->priv->mask);
g_clear_pointer (&brush->priv->pixmap, gimp_temp_buf_unref);
if (src_brush->priv->pixmap)
brush->priv->pixmap = gimp_temp_buf_copy (src_brush->priv->pixmap);
brush->priv->spacing = src_brush->priv->spacing;
brush->priv->x_axis = src_brush->priv->x_axis;
brush->priv->y_axis = src_brush->priv->y_axis;
gimp_data_dirty (data);
}
static void
gimp_brush_real_begin_use (GimpBrush *brush)
{
brush->priv->mask_cache =
gimp_brush_cache_new ((GDestroyNotify) gimp_temp_buf_unref, 'M', 'm');
brush->priv->pixmap_cache =
gimp_brush_cache_new ((GDestroyNotify) gimp_temp_buf_unref, 'P', 'p');
brush->priv->boundary_cache =
gimp_brush_cache_new ((GDestroyNotify) gimp_bezier_desc_free, 'B', 'b');
}
static void
gimp_brush_real_end_use (GimpBrush *brush)
{
g_clear_object (&brush->priv->mask_cache);
g_clear_object (&brush->priv->pixmap_cache);
g_clear_object (&brush->priv->boundary_cache);
g_clear_pointer (&brush->priv->blurred_mask, gimp_temp_buf_unref);
g_clear_pointer (&brush->priv->blurred_pixmap, gimp_temp_buf_unref);
}
static GimpBrush *
gimp_brush_real_select_brush (GimpBrush *brush,
const GimpCoords *last_coords,
const GimpCoords *current_coords)
{
return brush;
}
static gboolean
gimp_brush_real_want_null_motion (GimpBrush *brush,
const GimpCoords *last_coords,
const GimpCoords *current_coords)
{
return TRUE;
}
static gchar *
gimp_brush_get_checksum (GimpTagged *tagged)
{
GimpBrush *brush = GIMP_BRUSH (tagged);
gchar *checksum_string = NULL;
if (brush->priv->mask)
{
GChecksum *checksum = g_checksum_new (G_CHECKSUM_MD5);
g_checksum_update (checksum,
gimp_temp_buf_get_data (brush->priv->mask),
gimp_temp_buf_get_data_size (brush->priv->mask));
if (brush->priv->pixmap)
g_checksum_update (checksum,
gimp_temp_buf_get_data (brush->priv->pixmap),
gimp_temp_buf_get_data_size (brush->priv->pixmap));
g_checksum_update (checksum,
(const guchar *) &brush->priv->spacing,
sizeof (brush->priv->spacing));
g_checksum_update (checksum,
(const guchar *) &brush->priv->x_axis,
sizeof (brush->priv->x_axis));
g_checksum_update (checksum,
(const guchar *) &brush->priv->y_axis,
sizeof (brush->priv->y_axis));
checksum_string = g_strdup (g_checksum_get_string (checksum));
g_checksum_free (checksum);
}
return checksum_string;
}
/* public functions */
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
GimpData *
gimp_brush_new (GimpContext *context,
const gchar *name)
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
{
g_return_val_if_fail (name != NULL, NULL);
return gimp_brush_generated_new (name,
GIMP_BRUSH_GENERATED_CIRCLE,
5.0, 2, 0.5, 1.0, 0.0);
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
}
added a note about apptype.h and about not including headers in headers. 2001-02-14 Michael Natterer <mitch@gimp.org> * HACKING: added a note about apptype.h and about not including headers in headers. * app/apptypes.h: added GimpTool and BitmapCursor. * app/cursorutil.h * app/devices.h * app/draw_core.h * app/tools/color_picker.h * app/tools/tool.h * app/tools/tool_options.h * app/gimpcontext.h: removed includes of "tools/tool.h" * app/gimprc.[ch]: indentadion cleanup, added "module_db_load_inhibit". * app/module_db.c: removed the above variable here. * app/gimpdata.[ch]: added a vitrual "duplicate" method. * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushpipe.[ch] * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch]: all "load", "new" and "get_standard" functions return a GimpData pointer now. * app/gimpdatafactory.[ch]: made some stuff const. * app/gimpdatafactoryview.c: activate the "duplicate" button and set the initial button sensitivity correctly. * app/brush_select.c * app/gradient_select.c * app/pattern_select.c: use the new GimpDataFactoryView. * libgimp/Makefile.am: grouped the file to sort out what _may_ go to subdirs or separate libs. * libgimp/gimpenv.[ch]: added many "const". * app/app_procs.c * app/brush_edit.c * app/gimpcontext.c * app/gimpdnd.c * app/gradient_editor.c * app/palette.c * app/palette_import.c * app/user_install.c: many related changes. * libgimpmath/gimpmathtypes.h * libgimpmath/gimpvector.[ch]: minor cleanups. * plug-ins/script-fu/script-fu.c: gimp_data_directory() is const now.
2001-02-14 22:57:14 +08:00
GimpData *
gimp_brush_get_standard (GimpContext *context)
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
{
static GimpData *standard_brush = NULL;
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
if (! standard_brush)
{
standard_brush = gimp_brush_new (context, "Standard");
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
gimp_data_clean (standard_brush);
gimp_data_make_internal (standard_brush, "gimp-brush-standard");
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
g_object_add_weak_pointer (G_OBJECT (standard_brush),
(gpointer *) &standard_brush);
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
}
return standard_brush;
gimprc.in user_install user_install.bat app/gimprc.[ch] removed the 2001-02-13 Michael Natterer <mitch@gimp.org> * gimprc.in * user_install * user_install.bat * app/gimprc.[ch] * app/preferences_dialog.c: removed the "brush_vbr_path" variable, because all data types will be editable and saveable soon. * app/Makefile.am * app/apptypes.h * app/gimpdatafactory.[ch]: new object which holds a data list and knows how to create, edit, duplicate etc. the items in it. Will completely replace the brushes.[ch], patterns.[ch], ... files soon. * po/POTFILES.in * app/gimpdatacontainerview.[ch]: removed. * app/gimpdatafactoryview.[ch]: added. A view on the GimpDataFactory with a GUI for creating, editing, deleting etc. items (mostly unimplemented). * app/context_manager.[ch]: replaced the global data lists by global data factories. * app/brush_select.c * app/brushes.[ch] * app/commands.c * app/convert.c * app/devices.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.c * app/gimpcontext.c * app/gimpdata.[ch] * app/gimpdatalist.[ch] * app/gimpdnd.c * app/gimpgradient.[ch] * app/gimppalette.[ch] * app/gimppattern.[ch] * app/gradient_editor.c * app/gradient_select.c * app/gradients.[ch] * app/indicator_area.c * app/palette.c * app/palette_import.c * app/palette_select.c * app/palettes.[ch] * app/pattern_select.c * app/patterns.[ch] * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/pattern_select_cmds.c * app/pdb/patterns_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly.
2001-02-14 03:53:07 +08:00
}
void
gimp_brush_begin_use (GimpBrush *brush)
{
g_return_if_fail (GIMP_IS_BRUSH (brush));
brush->priv->use_count++;
if (brush->priv->use_count == 1)
GIMP_BRUSH_GET_CLASS (brush)->begin_use (brush);
}
void
gimp_brush_end_use (GimpBrush *brush)
{
g_return_if_fail (GIMP_IS_BRUSH (brush));
g_return_if_fail (brush->priv->use_count > 0);
brush->priv->use_count--;
if (brush->priv->use_count == 0)
GIMP_BRUSH_GET_CLASS (brush)->end_use (brush);
}
GimpBrush *
gimp_brush_select_brush (GimpBrush *brush,
const GimpCoords *last_coords,
const GimpCoords *current_coords)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
g_return_val_if_fail (last_coords != NULL, NULL);
g_return_val_if_fail (current_coords != NULL, NULL);
return GIMP_BRUSH_GET_CLASS (brush)->select_brush (brush,
last_coords,
current_coords);
}
gboolean
gimp_brush_want_null_motion (GimpBrush *brush,
const GimpCoords *last_coords,
const GimpCoords *current_coords)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), FALSE);
g_return_val_if_fail (last_coords != NULL, FALSE);
g_return_val_if_fail (current_coords != NULL, FALSE);
return GIMP_BRUSH_GET_CLASS (brush)->want_null_motion (brush,
last_coords,
current_coords);
}
void
gimp_brush_transform_size (GimpBrush *brush,
2009-04-26 01:53:09 +08:00
gdouble scale,
gdouble aspect_ratio,
gdouble angle,
gboolean reflect,
gint *width,
gint *height)
{
g_return_if_fail (GIMP_IS_BRUSH (brush));
2009-04-26 01:53:09 +08:00
g_return_if_fail (scale > 0.0);
g_return_if_fail (width != NULL);
g_return_if_fail (height != NULL);
if (scale == 1.0 &&
aspect_ratio == 0.0 &&
fmod (angle, 0.5) == 0.0)
{
*width = gimp_temp_buf_get_width (brush->priv->mask);
2014-11-14 02:32:59 +08:00
*height = gimp_temp_buf_get_height (brush->priv->mask);
return;
}
GIMP_BRUSH_GET_CLASS (brush)->transform_size (brush,
scale, aspect_ratio, angle, reflect,
width, height);
}
2012-04-09 02:25:49 +08:00
const GimpTempBuf *
gimp_brush_transform_mask (GimpBrush *brush,
2009-04-26 01:53:09 +08:00
gdouble scale,
gdouble aspect_ratio,
gdouble angle,
gboolean reflect,
gdouble hardness)
{
2012-04-09 02:25:49 +08:00
const GimpTempBuf *mask;
gint width;
gint height;
gdouble effective_hardness = hardness;
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
2009-04-26 01:53:09 +08:00
g_return_val_if_fail (scale > 0.0, NULL);
gimp_brush_transform_size (brush,
scale, aspect_ratio, angle, reflect,
&width, &height);
mask = gimp_brush_cache_get (brush->priv->mask_cache,
width, height,
scale, aspect_ratio, angle, reflect, hardness);
if (! mask)
{
#if 0
/* This code makes sure that brushes using blur for hardness
* (all of them but generated) are blurred once and no more.
* It also makes hardnes dynamics not work for these brushes.
* This is intentional. Confoliving for each stamp is too expensive.*/
if (! brush->priv->blurred_mask &&
! GIMP_IS_BRUSH_GENERATED(brush) &&
! GIMP_IS_BRUSH_PIPE(brush) && /*Can't cache pipes. Sanely anyway*/
hardness < 1.0)
{
brush->priv->blurred_mask = GIMP_BRUSH_GET_CLASS (brush)->transform_mask (brush,
1.0,
0.0,
0.0,
FALSE,
hardness);
brush->priv->blur_hardness = hardness;
}
if (brush->priv->blurred_mask)
{
effective_hardness = 1.0; /*Hardness has already been applied*/
}
#endif
mask = GIMP_BRUSH_GET_CLASS (brush)->transform_mask (brush,
scale,
aspect_ratio,
angle,
reflect,
effective_hardness);
gimp_brush_cache_add (brush->priv->mask_cache,
(gpointer) mask,
width, height,
scale, aspect_ratio, angle, reflect, effective_hardness);
}
return mask;
}
2012-04-09 02:25:49 +08:00
const GimpTempBuf *
gimp_brush_transform_pixmap (GimpBrush *brush,
2009-04-26 01:53:09 +08:00
gdouble scale,
gdouble aspect_ratio,
gdouble angle,
gboolean reflect,
gdouble hardness)
{
2012-04-09 02:25:49 +08:00
const GimpTempBuf *pixmap;
gint width;
gint height;
gdouble effective_hardness = hardness;
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
g_return_val_if_fail (brush->priv->pixmap != NULL, NULL);
2009-04-26 01:53:09 +08:00
g_return_val_if_fail (scale > 0.0, NULL);
gimp_brush_transform_size (brush,
scale, aspect_ratio, angle, reflect,
&width, &height);
pixmap = gimp_brush_cache_get (brush->priv->pixmap_cache,
width, height,
scale, aspect_ratio, angle, reflect, hardness);
if (! pixmap)
{
#if 0
if (! brush->priv->blurred_pixmap &&
! GIMP_IS_BRUSH_GENERATED(brush) &&
! GIMP_IS_BRUSH_PIPE(brush) /*Can't cache pipes. Sanely anyway*/
&& hardness < 1.0)
{
brush->priv->blurred_pixmap = GIMP_BRUSH_GET_CLASS (brush)->transform_pixmap (brush,
1.0,
0.0,
0.0,
FALSE,
hardness);
brush->priv->blur_hardness = hardness;
}
if (brush->priv->blurred_pixmap) {
effective_hardness = 1.0; /*Hardness has already been applied*/
}
#endif
pixmap = GIMP_BRUSH_GET_CLASS (brush)->transform_pixmap (brush,
scale,
aspect_ratio,
angle,
reflect,
effective_hardness);
gimp_brush_cache_add (brush->priv->pixmap_cache,
(gpointer) pixmap,
width, height,
scale, aspect_ratio, angle, reflect, effective_hardness);
}
return pixmap;
}
const GimpBezierDesc *
gimp_brush_transform_boundary (GimpBrush *brush,
gdouble scale,
gdouble aspect_ratio,
gdouble angle,
gboolean reflect,
gdouble hardness,
gint *width,
gint *height)
{
const GimpBezierDesc *boundary;
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
g_return_val_if_fail (scale > 0.0, NULL);
g_return_val_if_fail (width != NULL, NULL);
g_return_val_if_fail (height != NULL, NULL);
gimp_brush_transform_size (brush,
scale, aspect_ratio, angle, reflect,
width, height);
boundary = gimp_brush_cache_get (brush->priv->boundary_cache,
*width, *height,
scale, aspect_ratio, angle, reflect, hardness);
if (! boundary)
{
boundary = GIMP_BRUSH_GET_CLASS (brush)->transform_boundary (brush,
scale,
aspect_ratio,
angle,
reflect,
hardness,
width,
height);
/* while the brush mask is always at least 1x1 pixels, its
* outline can correctly be NULL
*
* FIXME: make the cache handle NULL things when it is
* properly implemented
*/
if (boundary)
gimp_brush_cache_add (brush->priv->boundary_cache,
(gpointer) boundary,
*width, *height,
scale, aspect_ratio, angle, reflect, hardness);
}
return boundary;
}
2012-04-09 02:25:49 +08:00
GimpTempBuf *
gimp_brush_get_mask (GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
if (brush->priv->blurred_mask)
{
return brush->priv->blurred_mask;
}
return brush->priv->mask;
}
2012-04-09 02:25:49 +08:00
GimpTempBuf *
gimp_brush_get_pixmap (GimpBrush *brush)
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
if(brush->priv->blurred_pixmap)
{
return brush->priv->blurred_pixmap;
}
return brush->priv->pixmap;
}
void
gimp_brush_flush_blur_caches (GimpBrush *brush)
{
#if 0
g_clear_pointer (&brush->priv->blurred_mask, gimp_temp_buf_unref);
g_clear_pointer (&brush->priv->blurred_pixmap, gimp_temp_buf_unref);
if (brush->priv->mask_cache)
gimp_brush_cache_clear (brush->priv->mask_cache);
if (brush->priv->pixmap_cache)
gimp_brush_cache_clear (brush->priv->pixmap_cache);
if (brush->priv->boundary_cache)
gimp_brush_cache_clear (brush->priv->boundary_cache);
#endif
}
gdouble
gimp_brush_get_blur_hardness (GimpBrush *brush)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), 0);
return brush->priv->blur_hardness;
}
gint
gimp_brush_get_width (GimpBrush *brush)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), 0);
if (brush->priv->blurred_mask)
return gimp_temp_buf_get_width (brush->priv->blurred_mask);
if (brush->priv->blurred_pixmap)
return gimp_temp_buf_get_width (brush->priv->blurred_pixmap);
return gimp_temp_buf_get_width (brush->priv->mask);
}
gint
gimp_brush_get_height (GimpBrush *brush)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), 0);
if (brush->priv->blurred_mask)
return gimp_temp_buf_get_height (brush->priv->blurred_mask);
if (brush->priv->blurred_pixmap)
return gimp_temp_buf_get_height (brush->priv->blurred_pixmap);
return gimp_temp_buf_get_height (brush->priv->mask);
Jens Lautenbacher <jtl@gimp.org> 2000-12-18 Sven Neumann <sven@gimp.org> Jens Lautenbacher <jtl@gimp.org> * app/Makefile.am * app/gimpbrushlistP.h * app/gimpbrushpipeP.h * app/gimpobjectP.h: removed these three files * app/parasitelistP.h * app/channels_dialog.c * app/docindex.c * app/gimpdrawable.c * app/gimpdrawableP.h * app/gimpimage.c * app/gimpimageP.h * app/gimplist.[ch] * app/gimpobject.c * app/gimpobject.h * app/gimpsetP.h: changed according to header removal * app/airbrush.c * app/brush_select.[ch] * app/brushes_cmds.c * app/gimpbrush.[ch] * app/gimpbrushgenerated.[ch] * app/gimpbrushlist.[ch] * app/gimpbrushpipe.[ch] * app/gimpcontextpreview.c * app/paint_core.c * app/paintbrush.c * app/pencil.c * tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup. The GimpBrush* object hierarchy and the file formats were broken by "design". This made it overly difficult to read and write pixmap brushes and brush pipes, leading to the situation that The GIMP was not able to read it's very own file formats. Since the GimpBrush format did support arbitrary color depths, the introduction of a file format for pixmap brushes was unnecessary. The GimpBrushPixmap object is dead. GimpBrush has an additional pixmap temp_buf and handles pixmap brushes transparently. The file format of pixmap brushes is not any longer a grayscale brush plus a pattern, but a simple brush with RGBA data. The old brushes can still be loaded, but the .gpb format is deprecated. GimpBrushPipe derives from GimpBrush. The fileformat is still a text header, followed by a number of brushes, but those brushes are stored in the new GimpBrush format (no pattern anymore). The pipe does not care about the depth of the contained GimpBrushes, so we get grayscale BrushPipes for free. Since the brush loader still loads the old format, old .gih files can also still be loaded. Since the brushes in the GimpBrushPipe do not any longer contain a pointer to the pipe object, we do only temporarily switch brushes in the paint_core routines. This is not very elegant, but the best we can do without a major redesign. * app/patterns.[ch]: changed the loader to work with a filedescriptor instead of a filehandle to make it work with the new brush loading code. * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl * plug-ins/common/gih.c: new plug-in that saves GIH files in the new format (loader will follow soon) * plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer supported as a special file format. * plug-ins/common/gbr.c: load and save brushes in the new brush format which allows RGBA brushes too. * plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
}
gint
gimp_brush_get_spacing (GimpBrush *brush)
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), 0);
return brush->priv->spacing;
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
}
void
gimp_brush_set_spacing (GimpBrush *brush,
gint spacing)
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
{
g_return_if_fail (GIMP_IS_BRUSH (brush));
if (brush->priv->spacing != spacing)
removed GimpFillType. 2001-06-29 Michael Natterer <mitch@gimp.org> * app/appenums.h: removed GimpFillType. * app/gimprc.c: parse the session-info's new "aux-info" field. * app/global_edit.[ch]: removed the old "Paste Named" dialog and prefixed all functions with "gimp_". * app/core/core-types.h: added GimpFillType. * app/core/gimpbrush.[ch]: new signal "spacing_changed". * app/gui/Makefile.am * app/gui/tools-commands.[ch]: one more file cut out of commands.[ch]. * app/gui/commands.[ch]: removed the tools stuff here. * app/gui/brush-select.[ch] * app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView (see below). * app/gui/dialogs-commands.[ch] * app/gui/menus.[ch]: - Made it 64bit safe again by passing the dialog factory's identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT(). - Added a "gchar *quark_string" field to GimpItemFactoryEntry which gets transformed into a GQuark by menus_create_item(). - Added SEPARATOR() and BRANCH() macros which make the *_entries[] arrays more readable. - Added a menu item to show/hide GimpImageDock's image menu. - Removed file_last_opened_cmd_callback(). * app/gui/edit-commands.c: the global_edit functions are "gimp_" prefixed now. * app/gui/file-commands.[ch]: added file_last_opened_cmd_callback() here. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpbrushfactoryview.[ch]: new widget: a GimpDataFactory subclass with a "spacing" scale. * app/widgets/gimpcontainereditor.[ch]: - Connect to the GimpContainerView's "select_item", "activate_item" and "context_item" signals here once instead of in each subclass and dispatch them via new virtual functions. - Added a convenience function which makes DND to the buttons much less painful for subclasses. * app/widgets/gimpbufferview.c * app/widgets/gimpdatafactoryview.[ch]: changed accordingly. * app/widgets/gimpdialogfactory.[ch]: - Added gimp_dialog_factory_dialog_raise() which can raise toplevel dialogs _and_ dockables (and creates them if they are not open yet). - Keep track of all created dialogs (not only toplevels). - Added an "aux_info" field to GimpSessionInfo which is a GList of gchar* and is saved in sessionrc. - Remember if GimpImageDock's image menu is visible by using an aux_info string. - The code did not become nicer with all those new constraints. I have to add comments before I forget how it works. * app/widgets/gimpdockbook.c: set the state of the "Show Image Menu" menu item before popping up the item factory. * app/widgets/gimpimagedock.[ch]: added gimp_image_dock_set_show_image_meu(). * plug-ins/gdyntext/gdyntext.c * plug-ins/perl/examples/fit-text * plug-ins/perl/examples/terral_text * plug-ins/perl/examples/tex-to-float: register all text rendering plug-ins under <Image>/Filters/Text * app/pdb/brush_select_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/enums.pl * po/POTFILES.in: changed according to all the stuff above.
2001-06-30 03:25:03 +08:00
{
brush->priv->spacing = spacing;
removed GimpFillType. 2001-06-29 Michael Natterer <mitch@gimp.org> * app/appenums.h: removed GimpFillType. * app/gimprc.c: parse the session-info's new "aux-info" field. * app/global_edit.[ch]: removed the old "Paste Named" dialog and prefixed all functions with "gimp_". * app/core/core-types.h: added GimpFillType. * app/core/gimpbrush.[ch]: new signal "spacing_changed". * app/gui/Makefile.am * app/gui/tools-commands.[ch]: one more file cut out of commands.[ch]. * app/gui/commands.[ch]: removed the tools stuff here. * app/gui/brush-select.[ch] * app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView (see below). * app/gui/dialogs-commands.[ch] * app/gui/menus.[ch]: - Made it 64bit safe again by passing the dialog factory's identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT(). - Added a "gchar *quark_string" field to GimpItemFactoryEntry which gets transformed into a GQuark by menus_create_item(). - Added SEPARATOR() and BRANCH() macros which make the *_entries[] arrays more readable. - Added a menu item to show/hide GimpImageDock's image menu. - Removed file_last_opened_cmd_callback(). * app/gui/edit-commands.c: the global_edit functions are "gimp_" prefixed now. * app/gui/file-commands.[ch]: added file_last_opened_cmd_callback() here. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpbrushfactoryview.[ch]: new widget: a GimpDataFactory subclass with a "spacing" scale. * app/widgets/gimpcontainereditor.[ch]: - Connect to the GimpContainerView's "select_item", "activate_item" and "context_item" signals here once instead of in each subclass and dispatch them via new virtual functions. - Added a convenience function which makes DND to the buttons much less painful for subclasses. * app/widgets/gimpbufferview.c * app/widgets/gimpdatafactoryview.[ch]: changed accordingly. * app/widgets/gimpdialogfactory.[ch]: - Added gimp_dialog_factory_dialog_raise() which can raise toplevel dialogs _and_ dockables (and creates them if they are not open yet). - Keep track of all created dialogs (not only toplevels). - Added an "aux_info" field to GimpSessionInfo which is a GList of gchar* and is saved in sessionrc. - Remember if GimpImageDock's image menu is visible by using an aux_info string. - The code did not become nicer with all those new constraints. I have to add comments before I forget how it works. * app/widgets/gimpdockbook.c: set the state of the "Show Image Menu" menu item before popping up the item factory. * app/widgets/gimpimagedock.[ch]: added gimp_image_dock_set_show_image_meu(). * plug-ins/gdyntext/gdyntext.c * plug-ins/perl/examples/fit-text * plug-ins/perl/examples/terral_text * plug-ins/perl/examples/tex-to-float: register all text rendering plug-ins under <Image>/Filters/Text * app/pdb/brush_select_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/enums.pl * po/POTFILES.in: changed according to all the stuff above.
2001-06-30 03:25:03 +08:00
g_signal_emit (brush, brush_signals[SPACING_CHANGED], 0);
g_object_notify (G_OBJECT (brush), "spacing");
removed GimpFillType. 2001-06-29 Michael Natterer <mitch@gimp.org> * app/appenums.h: removed GimpFillType. * app/gimprc.c: parse the session-info's new "aux-info" field. * app/global_edit.[ch]: removed the old "Paste Named" dialog and prefixed all functions with "gimp_". * app/core/core-types.h: added GimpFillType. * app/core/gimpbrush.[ch]: new signal "spacing_changed". * app/gui/Makefile.am * app/gui/tools-commands.[ch]: one more file cut out of commands.[ch]. * app/gui/commands.[ch]: removed the tools stuff here. * app/gui/brush-select.[ch] * app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView (see below). * app/gui/dialogs-commands.[ch] * app/gui/menus.[ch]: - Made it 64bit safe again by passing the dialog factory's identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT(). - Added a "gchar *quark_string" field to GimpItemFactoryEntry which gets transformed into a GQuark by menus_create_item(). - Added SEPARATOR() and BRANCH() macros which make the *_entries[] arrays more readable. - Added a menu item to show/hide GimpImageDock's image menu. - Removed file_last_opened_cmd_callback(). * app/gui/edit-commands.c: the global_edit functions are "gimp_" prefixed now. * app/gui/file-commands.[ch]: added file_last_opened_cmd_callback() here. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpbrushfactoryview.[ch]: new widget: a GimpDataFactory subclass with a "spacing" scale. * app/widgets/gimpcontainereditor.[ch]: - Connect to the GimpContainerView's "select_item", "activate_item" and "context_item" signals here once instead of in each subclass and dispatch them via new virtual functions. - Added a convenience function which makes DND to the buttons much less painful for subclasses. * app/widgets/gimpbufferview.c * app/widgets/gimpdatafactoryview.[ch]: changed accordingly. * app/widgets/gimpdialogfactory.[ch]: - Added gimp_dialog_factory_dialog_raise() which can raise toplevel dialogs _and_ dockables (and creates them if they are not open yet). - Keep track of all created dialogs (not only toplevels). - Added an "aux_info" field to GimpSessionInfo which is a GList of gchar* and is saved in sessionrc. - Remember if GimpImageDock's image menu is visible by using an aux_info string. - The code did not become nicer with all those new constraints. I have to add comments before I forget how it works. * app/widgets/gimpdockbook.c: set the state of the "Show Image Menu" menu item before popping up the item factory. * app/widgets/gimpimagedock.[ch]: added gimp_image_dock_set_show_image_meu(). * plug-ins/gdyntext/gdyntext.c * plug-ins/perl/examples/fit-text * plug-ins/perl/examples/terral_text * plug-ins/perl/examples/tex-to-float: register all text rendering plug-ins under <Image>/Filters/Text * app/pdb/brush_select_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/enums.pl * po/POTFILES.in: changed according to all the stuff above.
2001-06-30 03:25:03 +08:00
}
}
static const GimpVector2 fail = { 0.0, 0.0 };
GimpVector2
gimp_brush_get_x_axis (GimpBrush *brush)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), fail);
return brush->priv->x_axis;
}
GimpVector2
gimp_brush_get_y_axis (GimpBrush *brush)
{
g_return_val_if_fail (GIMP_IS_BRUSH (brush), fail);
return brush->priv->y_axis;
}