gimppaintcore.h 7.42 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* 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
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
17
 */
18

19 20
#ifndef __GIMP_PAINT_TOOL_H__
#define __GIMP_PAINT_TOOL_H__
Elliot Lee's avatar
Elliot Lee committed
21

22

23
#include "gimpdrawtool.h"
24

Elliot Lee's avatar
Elliot Lee committed
25 26

/* the different states that the painting function can be called with  */
27

28
typedef enum /*< pdb-skip >*/
29
{
30
  INIT_PAINT,       /* Setup PaintFunc internals */
31 32 33 34 35 36 37
  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;
Elliot Lee's avatar
Elliot Lee committed
38

39
typedef enum /*< pdb-skip >*/
40
{
41 42 43 44 45 46 47 48 49 50
  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.
                                            */
51
} ToolFlags;
52

53 54

#define GIMP_TYPE_PAINT_TOOL            (gimp_paint_tool_get_type ())
55 56
#define GIMP_PAINT_TOOL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PAINT_TOOL, GimpPaintTool))
#define GIMP_PAINT_TOOL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PAINT_TOOL, GimpPaintToolClass))
57
#define GIMP_IS_PAINT_TOOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PAINT_TOOL))
58
#define GIMP_IS_PAINT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PAINT_TOOL))
59
#define GIMP_PAINT_TOOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PAINT_TOOL, GimpPaintToolClass))
60 61 62


typedef struct _GimpPaintToolClass GimpPaintToolClass;
63

64
struct _GimpPaintTool
Elliot Lee's avatar
Elliot Lee committed
65
{
66
  GimpDrawTool    parent_instance;
Elliot Lee's avatar
Elliot Lee committed
67

68 69 70
  GimpCoords      start_coords;  /*  starting coords            */
  GimpCoords      cur_coords;    /*  current coords             */
  GimpCoords      last_coords;   /*  last coords                */
Elliot Lee's avatar
Elliot Lee committed
71

72
  gint            state;         /*  state of buttons and keys  */
Elliot Lee's avatar
Elliot Lee committed
73

74 75 76
  gdouble         distance;      /*  distance traveled by brush */
  gdouble         pixel_dist;    /*  distance in pixels         */
  gdouble         spacing;       /*  spacing                    */
Elliot Lee's avatar
Elliot Lee committed
77

78 79
  gint            x1, y1;        /*  image space coordinate     */
  gint            x2, y2;        /*  image space coords         */
Elliot Lee's avatar
Elliot Lee committed
80

81
  GimpBrush     * brush;         /*  current brush	        */
Elliot Lee's avatar
Elliot Lee committed
82

83 84
  gboolean        pick_colors;   /*  pick color if ctrl or alt is pressed  */
  gboolean        pick_state;    /*  was ctrl or alt pressed when clicked? */
85
  ToolFlags       flags;	 /*  tool flags, see ToolFlags above       */
86 87

  guint           context_id;    /*  for the statusbar          */
Elliot Lee's avatar
Elliot Lee committed
88 89
};

90 91 92 93
struct _GimpPaintToolClass
{
  GimpDrawToolClass parent_class;

94 95
  /*  virtual function  */

96 97 98
  void (* paint) (GimpPaintTool *tool,
		  GimpDrawable 	*drawable,
		  PaintState     paint_state);
99 100
};

Elliot Lee's avatar
Elliot Lee committed
101 102

/*  Special undo type  */
103
typedef struct _PaintUndo PaintUndo;
Elliot Lee's avatar
Elliot Lee committed
104

105
struct _PaintUndo
Elliot Lee's avatar
Elliot Lee committed
106
{
107 108 109 110
  gint        tool_ID;
  GType       tool_type;

  GimpCoords  last_coords;
Elliot Lee's avatar
Elliot Lee committed
111 112
};

113

114
GType   gimp_paint_tool_get_type        (void) G_GNUC_CONST;
115

116
void    gimp_paint_tool_paint           (GimpPaintTool       *paint_tool,
117
					 GimpDrawable        *drawable,
118
					 PaintState	      state);
119

120
int     gimp_paint_tool_start           (GimpPaintTool       *paint_tool,
121 122 123
					 GimpDrawable        *drawable,
					 gdouble              x,
					 gdouble              y);
124
void    gimp_paint_tool_interpolate     (GimpPaintTool       *paint_tool,
125
					 GimpDrawable        *drawable);
126
void    gimp_paint_tool_finish          (GimpPaintTool       *paint_tool,
127
					 GimpDrawable        *drawable);
128
void    gimp_paint_tool_cleanup         (GimpPaintTool       *paint_tool);
Sven Neumann's avatar
Sven Neumann committed
129

130
void    gimp_paint_tool_get_color_from_gradient (GimpPaintTool     *paint_tool,
131 132 133 134
                                                 GimpGradient      *gradient,
						 gdouble            gradient_length,
						 GimpRGB           *color,
						 GradientPaintMode  mode);
Elliot Lee's avatar
Elliot Lee committed
135 136

/*  paint tool painting functions  */
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
TempBuf * gimp_paint_tool_get_paint_area        (GimpPaintTool        *paint_tool,
                                                 GimpDrawable         *drawable,
                                                 gdouble               scale);
TempBuf * gimp_paint_tool_get_orig_image        (GimpPaintTool        *paint_tool,
                                                 GimpDrawable         *drawable,
                                                 gint                  x1,
                                                 gint                  y1,
                                                 gint                  x2,
                                                 gint                  y2);
void      gimp_paint_tool_paste_canvas          (GimpPaintTool        *paint_tool,
                                                 GimpDrawable         *drawable,
                                                 gint                  brush_opacity,
                                                 gint                  image_opacity,
                                                 GimpLayerModeEffects  paint_mode,
                                                 BrushApplicationMode  brush_hardness,
                                                 gdouble               brush_scale,
                                                 PaintApplicationMode  mode);
void      gimp_paint_tool_replace_canvas        (GimpPaintTool        *paint_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        *paint_tool,
                                                 GimpImage            *dest, 
                                                 GimpDrawable         *drawable,
                                                 TempBuf              *area, 
                                                 gdouble               scale, 
                                                 BrushApplicationMode  mode);
Elliot Lee's avatar
Elliot Lee committed
167

168

169
#endif  /*  __GIMP_PAINT_TOOL_H__  */