gimppaintcore.h 8.8 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

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

28
typedef enum
29
{
30
  INIT_PAINT,       /* Setup PaintFunc internals */
31 32
  MOTION_PAINT,     /* PaintFunc performs motion-related rendering */
  FINISH_PAINT,     /* Cleanup and/or reset PaintFunc operation */
33 34 35 36 37 38
  PRETRACE_PAINT,   /* PaintFunc performs window tracing activity
                     * prior to rendering
                     */
  POSTTRACE_PAINT   /* PaintFunc performs window tracing activity
                     * following rendering
                     */
39
} GimpPaintCoreState;
Elliot Lee's avatar
Elliot Lee committed
40

41
typedef enum
42
{
43 44 45 46 47 48 49 50 51 52 53 54 55 56
  CORE_HANDLES_CHANGING_BRUSH = 0x1 << 0, /*  Set for tools that don't
                                           *  mind if the brush
                                           *  changes while painting.
                                           */
  CORE_TRACES_ON_WINDOW       = 0x1 << 1  /*  Set for tools that
                                           *  perform temporary
                                           *  rendering directly to
                                           *  the window. These
                                           *  require sequencing with
                                           *  gdisplay_flush()
                                           *  routines.  See
                                           *  gimpclone.c for example.
                                           */

57
} GimpPaintCoreFlags;
58

59

60 61 62 63 64 65
#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))
66 67


68
typedef struct _GimpPaintCoreClass GimpPaintCoreClass;
69

70
struct _GimpPaintCore
Elliot Lee's avatar
Elliot Lee committed
71
{
72
  GimpObject          parent_instance;
Elliot Lee's avatar
Elliot Lee committed
73

74
  gint                ID;            /*  unique instance ID               */
Elliot Lee's avatar
Elliot Lee committed
75

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

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

81
  GimpVector2         last_paint;    /*  last point that was painted      */
82

83 84 85 86 87
  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
88

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

  /*  undo blocks variables  */
93 94
  TileManager        *undo_tiles;
  TileManager        *canvas_tiles;
95 96

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

101
struct _GimpPaintCoreClass
102
{
103
  GimpObjectClass  parent_class;
104

105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
  /*  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,
125 126
                                GimpDrawable       *drawable,
                                GimpPaintOptions   *paint_options);
127 128
};

Elliot Lee's avatar
Elliot Lee committed
129

130
GType     gimp_paint_core_get_type       (void) G_GNUC_CONST;
131

132 133 134 135
void      gimp_paint_core_paint          (GimpPaintCore      *core,
                                          GimpDrawable       *drawable,
                                          GimpPaintOptions   *paint_options,
                                          GimpPaintCoreState  state);
136

137 138 139 140 141 142 143 144 145
gboolean  gimp_paint_core_start          (GimpPaintCore      *core,
                                          GimpDrawable       *drawable,
                                          GimpPaintOptions   *paint_options,
                                          GimpCoords         *coords);
void      gimp_paint_core_finish         (GimpPaintCore      *core,
                                          GimpDrawable       *drawable);
void      gimp_paint_core_cancel         (GimpPaintCore      *core,
                                          GimpDrawable       *drawable);
void      gimp_paint_core_cleanup        (GimpPaintCore      *core);
146

147
void      gimp_paint_core_constrain      (GimpPaintCore      *core);
148

149 150 151
void      gimp_paint_core_interpolate    (GimpPaintCore      *core,
                                          GimpDrawable       *drawable,
                                          GimpPaintOptions   *paint_options);
152 153


154
/*  protected functions  */
Sven Neumann's avatar
Sven Neumann committed
155

156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
TempBuf * gimp_paint_core_get_paint_area (GimpPaintCore      *core,
                                          GimpDrawable       *drawable,
                                          GimpPaintOptions   *options);
TempBuf * gimp_paint_core_get_orig_image (GimpPaintCore      *core,
                                          GimpDrawable       *drawable,
                                          gint                x1,
                                          gint                y1,
                                          gint                x2,
                                          gint                y2);

void      gimp_paint_core_paste    (GimpPaintCore            *core,
                                    PixelRegion              *paint_maskPR,
                                    GimpDrawable             *drawable,
                                    gdouble	              paint_opacity,
                                    gdouble	              image_opacity,
                                    GimpLayerModeEffects      paint_mode,
                                    GimpPaintApplicationMode  mode);
void      gimp_paint_core_replace  (GimpPaintCore            *core,
                                    PixelRegion              *paint_maskPR,
                                    GimpDrawable             *drawable,
                                    gdouble	              paint_opacity,
                                    gdouble                   image_opacity,
                                    GimpPaintApplicationMode  mode);

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);
191

192

193
#endif  /*  __GIMP_PAINT_CORE_H__  */