gimp/app/tools/gimpbrushtool.h

186 lines
7.0 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#ifndef __GIMP_PAINT_TOOL_H__
#define __GIMP_PAINT_TOOL_H__
1997-11-25 06:05:25 +08:00
app/core/Makefile.am app/core/core-types.h added an "application object" 2001-07-04 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimp.[ch]: added an "application object" called Gimp. Currently, it contains the image list, the clipboard, the data factories, the procedural hashtable and the tool info list. It's the toplevel object of the core object system. Finally, creating a Gimp object will return a standalone gimp core engine instance with no other global states/variables involved. * app/app_procs.[ch]: allocate a "Gimp" instance called "the_gimp" :) Removed stuff which is now done by the "Gimp" object. Merged gimp_init() into app_init() because gimp_init() is taken now. * app/context_manager.[ch]: removed stuff done by "Gimp". * app/batch.[ch] * app/gimage.[ch] * app/xcf/xcf-load.[ch] * app/xcf/xcf.[ch] * app/core/gimpedit.[ch] * app/tools/tool_manager.[ch]: pass around an additional "Gimp" argument. * app/pdb/procedural_db.[ch]: pass a "Gimp" pointer as first parameter to all internal procedures and to all procedural_db_* functions. * app/core/gimpcontext.[ch] * app/core/gimpimage.[ch]: added a "Gimp" pointer to the structs. * app/devices.c * app/errors.c * app/file-open.c * app/file-save.c * app/gimphelp.c * app/gimpunit.c * app/image_new.c * app/main.c * app/nav_window.c * app/plug_in.c * app/base/base.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimptoolinfo.[ch] * app/gui/brush-select.c * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/test-commands.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimppainttool.h * app/tools/gimptexttool.c * app/tools/gimptransformtool.h * app/widgets/gimpbufferview.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpcursor.c * app/widgets/gimpdnd.c * app/widgets/gimpimagedock.c: changed accordingly. Cleaned up lots of includes. Many files still access the global "the_gimp" variable exported by app_procs.h. * tools/pdbgen/app.pl * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. Don't use "the_gimp" here because all procedures get passed a "Gimp" pointer now. * app/pdb/*: regenerated.
2001-07-05 03:31:35 +08:00
#include "gimpdrawtool.h"
1997-11-25 06:05:25 +08:00
/* the different states that the painting function can be called with */
typedef enum /*< skip >*/
{
INIT_PAINT, /* Setup PaintFunc internals */
MOTION_PAINT, /* PaintFunc performs motion-related rendering */
PAUSE_PAINT, /* Unused. Reserved */
RESUME_PAINT, /* Unused. Reserved */
FINISH_PAINT, /* Cleanup and/or reset PaintFunc operation */
PRETRACE_PAINT, /* PaintFunc performs window tracing activity prior to rendering */
POSTTRACE_PAINT /* PaintFunc performs window tracing activity following rendering */
} PaintState;
1997-11-25 06:05:25 +08:00
typedef enum /*< skip >*/
{
TOOL_CAN_HANDLE_CHANGING_BRUSH = 0x0001, /* Set for tools that don't mind
* if the brush changes while
* painting.
*/
TOOL_TRACES_ON_WINDOW /* Set for tools that perform temporary
* rendering directly to the window. These
* require sequencing with gdisplay_flush()
* routines. See clone.c for example.
*/
} ToolFlags;
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
#define GIMP_PAINT_TOOL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PAINT_TOOL, GimpPaintTool))
#define GIMP_IS_PAINT_TOOL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PAINT_TOOL))
#define GIMP_PAINT_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PAINT_TOOL, GimpPaintToolClass))
#define GIMP_IS_PAINT_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PAINT_TOOL))
typedef struct _GimpPaintToolClass GimpPaintToolClass;
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
struct _GimpPaintTool
1997-11-25 06:05:25 +08:00
{
GimpDrawTool parent_instance;
1997-11-25 06:05:25 +08:00
gdouble startx; /* starting x coord */
gdouble starty; /* starting y coord */
gdouble startpressure; /* starting pressure */
gdouble startxtilt; /* starting xtilt */
gdouble startytilt; /* starting ytilt */
1997-11-25 06:05:25 +08:00
gdouble curx; /* current x coord */
gdouble cury; /* current y coord */
gdouble curpressure; /* current pressure */
gdouble curxtilt; /* current xtilt */
gdouble curytilt; /* current ytilt */
1997-11-25 06:05:25 +08:00
gdouble lastx; /* last x coord */
gdouble lasty; /* last y coord */
gdouble lastpressure; /* last pressure */
gdouble lastxtilt; /* last xtilt */
gdouble lastytilt; /* last ytilt */
1997-11-25 06:05:25 +08:00
gint state; /* state of buttons and keys */
1997-11-25 06:05:25 +08:00
gdouble distance; /* distance traveled by brush */
gdouble pixel_dist; /* distance in pixels */
gdouble spacing; /* spacing */
1997-11-25 06:05:25 +08:00
gint x1, y1; /* image space coordinate */
gint x2, y2; /* image space coords */
1997-11-25 06:05:25 +08:00
GimpBrush * brush; /* current brush */
1997-11-25 06:05:25 +08:00
gboolean pick_colors; /* pick color if ctrl or alt is pressed */
gboolean pick_state; /* was ctrl or alt pressed when clicked? */
ToolFlags flags; /* tool flags, see ToolFlags above */
guint context_id; /* for the statusbar */
1997-11-25 06:05:25 +08:00
};
struct _GimpPaintToolClass
{
GimpDrawToolClass parent_class;
void (* paint) (GimpPaintTool *tool,
GimpDrawable *drawable,
PaintState paint_state);
};
1997-11-25 06:05:25 +08:00
/* Special undo type */
typedef struct _PaintUndo PaintUndo;
1997-11-25 06:05:25 +08:00
struct _PaintUndo
1997-11-25 06:05:25 +08:00
{
gint tool_ID;
GtkType tool_type;
gdouble lastx;
gdouble lasty;
gdouble lastpressure;
gdouble lastxtilt;
gdouble lastytilt;
1997-11-25 06:05:25 +08:00
};
GtkType gimp_paint_tool_get_type (void);
void gimp_paint_tool_paint (GimpPaintTool *tool,
GimpDrawable *drawable,
PaintState state);
void gimp_paint_tool_no_draw (GimpPaintTool *tool);
int gimp_paint_tool_start (GimpPaintTool *tool,
GimpDrawable *drawable,
gdouble x,
gdouble y);
void gimp_paint_tool_interpolate (GimpPaintTool *tool,
GimpDrawable *drawable);
void gimp_paint_tool_finish (GimpPaintTool *tool,
GimpDrawable *drawable);
void gimp_paint_tool_cleanup (void);
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
gdouble gradient_length,
GimpRGB *color,
GradientPaintMode mode);
1997-11-25 06:05:25 +08:00
/* paint tool painting functions */
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *tool,
GimpDrawable *drawable,
gdouble scale);
TempBuf * gimp_paint_tool_get_orig_image (GimpPaintTool *tool,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2);
void gimp_paint_tool_paste_canvas (GimpPaintTool *tool,
GimpDrawable *drawable,
gint brush_opacity,
gint image_opacity,
LayerModeEffects paint_mode,
BrushApplicationMode brush_hardness,
gdouble brush_scale,
PaintApplicationMode mode);
void gimp_paint_tool_replace_canvas (GimpPaintTool *tool,
GimpDrawable *drawable,
gint brush_opacity,
gint image_opacity,
BrushApplicationMode brush_hardness,
gdouble brush_scale,
PaintApplicationMode mode);
void gimp_paint_tool_color_area_with_pixmap (GimpPaintTool *tool,
GimpImage *dest,
GimpDrawable *drawable,
TempBuf *area,
gdouble scale,
BrushApplicationMode mode);
1997-11-25 06:05:25 +08:00
#endif /* __GIMP_PAINT_TOOL_H__ */