gimppaintcore.h 7.01 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 29
typedef enum /*< skip >*/
{
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 /*< 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 55 56 57 58 59 60 61

#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;
62

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

67 68 69 70 71
  gdouble         startx;        /*  starting x coord           */
  gdouble         starty;        /*  starting y coord           */
  gdouble         startpressure; /*  starting pressure          */
  gdouble         startxtilt;    /*  starting xtilt             */
  gdouble         startytilt;    /*  starting ytilt             */
Elliot Lee's avatar
Elliot Lee committed
72

73 74 75 76 77
  gdouble         curx;          /*  current x coord            */
  gdouble         cury;          /*  current y coord            */
  gdouble         curpressure;   /*  current pressure           */
  gdouble         curxtilt;      /*  current xtilt              */
  gdouble         curytilt;      /*  current ytilt              */
Elliot Lee's avatar
Elliot Lee committed
78

79 80 81 82 83
  gdouble         lastx;         /*  last x coord               */
  gdouble         lasty;         /*  last y coord               */
  gdouble         lastpressure;  /*  last pressure              */
  gdouble         lastxtilt;     /*  last xtilt                 */
  gdouble         lastytilt;     /*  last ytilt                 */
Elliot Lee's avatar
Elliot Lee committed
84

85
  gint            state;         /*  state of buttons and keys  */
Elliot Lee's avatar
Elliot Lee committed
86

87 88 89
  gdouble         distance;      /*  distance traveled by brush */
  gdouble         pixel_dist;    /*  distance in pixels         */
  gdouble         spacing;       /*  spacing                    */
Elliot Lee's avatar
Elliot Lee committed
90

91 92
  gint            x1, y1;        /*  image space coordinate     */
  gint            x2, y2;        /*  image space coords         */
Elliot Lee's avatar
Elliot Lee committed
93

94
  GimpBrush     * brush;         /*  current brush	        */
Elliot Lee's avatar
Elliot Lee committed
95

96 97
  gboolean        pick_colors;   /*  pick color if ctrl or alt is pressed  */
  gboolean        pick_state;    /*  was ctrl or alt pressed when clicked? */
98
  ToolFlags       flags;	 /*  tool flags, see ToolFlags above       */
99 100

  guint           context_id;    /*  for the statusbar          */
Elliot Lee's avatar
Elliot Lee committed
101 102
};

103 104 105 106
struct _GimpPaintToolClass
{
  GimpDrawToolClass parent_class;

107 108 109
  void (* paint) (GimpPaintTool *tool,
		  GimpDrawable 	*drawable,
		  PaintState     paint_state);
110 111
};

Elliot Lee's avatar
Elliot Lee committed
112 113

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

116
struct _PaintUndo
Elliot Lee's avatar
Elliot Lee committed
117
{
118 119
  gint     tool_ID;
  GtkType  tool_type;
120

121 122 123 124 125
  gdouble  lastx;
  gdouble  lasty;
  gdouble  lastpressure;
  gdouble  lastxtilt;
  gdouble  lastytilt;
Elliot Lee's avatar
Elliot Lee committed
126 127
};

128 129 130 131 132 133 134 135 136 137 138 139 140

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);
141
void  gimp_paint_tool_interpolate     (GimpPaintTool    *tool,
142
				       GimpDrawable        *drawable);
143
void  gimp_paint_tool_finish          (GimpPaintTool    *tool,
144
				       GimpDrawable        *drawable);
145
void  gimp_paint_tool_cleanup         (void);
Sven Neumann's avatar
Sven Neumann committed
146

147
void  gimp_paint_tool_get_color_from_gradient (GimpPaintTool         *tool,
148 149 150
					       gdouble               gradient_length,
					       GimpRGB              *color,
					       GradientPaintMode     mode);
Elliot Lee's avatar
Elliot Lee committed
151 152

/*  paint tool painting functions  */
153
TempBuf * gimp_paint_tool_get_paint_area  (GimpPaintTool     *tool,
Sven Neumann's avatar
Sven Neumann committed
154 155
					  GimpDrawable         *drawable,
					  gdouble               scale);
156
TempBuf * gimp_paint_tool_get_orig_image  (GimpPaintTool     *tool,
Sven Neumann's avatar
Sven Neumann committed
157
					  GimpDrawable         *drawable,
158 159
					  gint                  x1,
					  gint                  y1,
Sven Neumann's avatar
Sven Neumann committed
160 161
					  gint                  x2,
					  gint                  y2);
162
void  gimp_paint_tool_paste_canvas    (GimpPaintTool     *tool,
163 164 165 166 167 168 169
				       GimpDrawable         *drawable,
				       gint                  brush_opacity,
				       gint                  image_opacity,
				       LayerModeEffects      paint_mode,
				       BrushApplicationMode  brush_hardness,
				       gdouble               brush_scale,
				       PaintApplicationMode  mode);
170
void  gimp_paint_tool_replace_canvas  (GimpPaintTool     *tool,
171 172 173 174 175 176
				       GimpDrawable         *drawable,
				       gint                  brush_opacity,
				       gint                  image_opacity,
				       BrushApplicationMode  brush_hardness,
				       gdouble               brush_scale,
				       PaintApplicationMode  mode);
177
void gimp_paint_tool_color_area_with_pixmap (GimpPaintTool     *tool,
178 179 180 181 182
					     GimpImage            *dest, 
					     GimpDrawable         *drawable,
					     TempBuf              *area, 
					     gdouble               scale, 
					     BrushApplicationMode  mode);
Elliot Lee's avatar
Elliot Lee committed
183

184

185
#endif  /*  __GIMP_PAINT_TOOL_H__  */