gimppaintcore.h 8.54 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_CORE_H__
#define __GIMP_PAINT_CORE_H__
Elliot Lee's avatar
Elliot Lee committed
21

22

23
#include "core/gimpobject.h"
24

25

Sven Neumann's avatar
Sven Neumann committed
26 27 28 29
#define PAINT_CORE_SUBSAMPLE        4
#define PAINT_CORE_SOLID_SUBSAMPLE  2

#define PRESSURE_SCALE              1.5
30 31


Elliot Lee's avatar
Elliot Lee committed
32
/* the different states that the painting function can be called with  */
33

34
typedef enum
35
{
36
  INIT_PAINT,       /* Setup PaintFunc internals */
37 38 39 40 41 42
  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 */
43
} GimpPaintCoreState;
Elliot Lee's avatar
Elliot Lee committed
44

45
typedef enum
46
{
47 48 49 50 51
  /*  Set for tools that don't mind if
   *  the brush changes while painting.
   */
  CORE_HANDLES_CHANGING_BRUSH = 0x1 << 0,

52 53 54 55 56
  /*  Set for tools that perform
   *  temporary rendering directly to the
   *  window. These require sequencing with
   *  gdisplay_flush() routines.
   *  See gimpclone.c for example.
57 58
   */
  CORE_TRACES_ON_WINDOW       = 0x1 << 1
59
} GimpPaintCoreFlags;
60

61

62 63 64 65 66 67
#define GIMP_TYPE_PAINT_CORE            (gimp_paint_core_get_type ())
#define GIMP_PAINT_CORE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PAINT_CORE, GimpPaintCore))
#define GIMP_PAINT_CORE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PAINT_CORE, GimpPaintCoreClass))
#define GIMP_IS_PAINT_CORE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PAINT_CORE))
#define GIMP_IS_PAINT_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PAINT_CORE))
#define GIMP_PAINT_CORE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PAINT_CORE, GimpPaintCoreClass))
68 69


70
typedef struct _GimpPaintCoreClass GimpPaintCoreClass;
71

72
struct _GimpPaintCore
Elliot Lee's avatar
Elliot Lee committed
73
{
74
  GimpObject          parent_instance;
Elliot Lee's avatar
Elliot Lee committed
75

76
  gint                ID;            /*  unique instance ID               */
Elliot Lee's avatar
Elliot Lee committed
77

78
  GimpCoords          start_coords;  /*  starting coords (for undo only)  */
Elliot Lee's avatar
Elliot Lee committed
79

80 81
  GimpCoords          cur_coords;    /*  current coords                   */
  GimpCoords          last_coords;   /*  last coords                      */
Elliot Lee's avatar
Elliot Lee committed
82

83
  GimpVector2         last_paint;    /*  last point that was painted      */
84

85 86 87 88 89
  gdouble             distance;      /*  distance traveled by brush       */
  gdouble             pixel_dist;    /*  distance in pixels               */

  gint                x1, y1;        /*  undo extents in image coords     */
  gint                x2, y2;        /*  undo extents in image coords     */
Elliot Lee's avatar
Elliot Lee committed
90

91 92
  GimpPaintCoreFlags  flags;         /*  tool flags, see ToolFlags above  */
  gboolean            use_pressure;  /*  look at coords->pressure         */
93 94

  /*  undo blocks variables  */
95 96
  TileManager        *undo_tiles;
  TileManager        *canvas_tiles;
97 98

  /*  paint buffers variables  */
99 100
  TempBuf            *orig_buf;
  TempBuf            *canvas_buf;
Elliot Lee's avatar
Elliot Lee committed
101 102
};

103
struct _GimpPaintCoreClass
104
{
105
  GimpObjectClass  parent_class;
106

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
  /*  virtual functions  */
  gboolean  (* start)          (GimpPaintCore      *core,
                                GimpDrawable       *drawable,
                                GimpPaintOptions   *paint_options,
                                GimpCoords         *coords);

  gboolean  (* pre_paint)      (GimpPaintCore      *core,
                                GimpDrawable       *drawable,
                                GimpPaintOptions   *paint_options,
                                GimpPaintCoreState  paint_state);
  void      (* paint)          (GimpPaintCore      *core,
                                GimpDrawable       *drawable,
                                GimpPaintOptions   *paint_options,
                                GimpPaintCoreState  paint_state);

  void      (* interpolate)    (GimpPaintCore      *core,
                                GimpDrawable       *drawable,
                                GimpPaintOptions   *paint_options);

  TempBuf * (* get_paint_area) (GimpPaintCore      *core,
127 128
                                GimpDrawable       *drawable,
                                GimpPaintOptions   *paint_options);
129 130
};

Elliot Lee's avatar
Elliot Lee committed
131

132 133 134 135
GType     gimp_paint_core_get_type    (void) G_GNUC_CONST;

void      gimp_paint_core_paint       (GimpPaintCore       *core,
                                       GimpDrawable        *drawable,
136
                                       GimpPaintOptions    *paint_options,
137 138 139 140
                                       GimpPaintCoreState   state);

gboolean  gimp_paint_core_start       (GimpPaintCore       *core,
                                       GimpDrawable        *drawable,
141
                                       GimpPaintOptions    *paint_options,
142 143 144
                                       GimpCoords          *coords);
void      gimp_paint_core_finish      (GimpPaintCore       *core,
                                       GimpDrawable        *drawable);
145 146
void      gimp_paint_core_cancel      (GimpPaintCore       *core,
                                       GimpDrawable        *drawable);
147 148 149 150 151 152
void      gimp_paint_core_cleanup     (GimpPaintCore       *core);

void      gimp_paint_core_constrain   (GimpPaintCore       *core);

void      gimp_paint_core_interpolate (GimpPaintCore       *core,
                                       GimpDrawable        *drawable,
153
                                       GimpPaintOptions    *paint_options);
154 155


156
/*  protected functions  */
Sven Neumann's avatar
Sven Neumann committed
157

158 159
TempBuf * gimp_paint_core_get_paint_area (GimpPaintCore            *core,
                                          GimpDrawable             *drawable,
160
                                          GimpPaintOptions         *options);
161 162 163 164 165 166
TempBuf * gimp_paint_core_get_orig_image (GimpPaintCore            *core,
                                          GimpDrawable             *drawable,
                                          gint                      x1,
                                          gint                      y1,
                                          gint                      x2,
                                          gint                      y2);
167 168

void      gimp_paint_core_paste          (GimpPaintCore            *core,
169
                                          PixelRegion              *paint_maskPR,
170 171 172
                                          GimpDrawable	           *drawable,
                                          gdouble	            paint_opacity,
                                          gdouble	            image_opacity,
173 174
                                          GimpLayerModeEffects      paint_mode,
                                          GimpPaintApplicationMode  mode);
175
void      gimp_paint_core_replace        (GimpPaintCore            *core,
176
                                          PixelRegion              *paint_maskPR,
177 178
                                          GimpDrawable	           *drawable,
                                          gdouble	            paint_opacity,
179 180
                                          gdouble                   image_opacity,
                                          GimpPaintApplicationMode  mode);
Elliot Lee's avatar
Elliot Lee committed
181

182 183 184 185 186 187 188 189 190 191 192 193
void   gimp_paint_core_validate_undo_tiles   (GimpPaintCore *core,
                                              GimpDrawable  *drawable,
                                              gint           x,
                                              gint           y,
                                              gint           w,
                                              gint           h);
void   gimp_paint_core_validate_canvas_tiles (GimpPaintCore *core,
                                              gint           x,
                                              gint           y,
                                              gint           w,
                                              gint           h);

194

195
#endif  /*  __GIMP_PAINT_CORE_H__  */