paint_core.h 4.66 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 21 22
 */
#ifndef __PAINT_CORE_H__
#define __PAINT_CORE_H__

#include "draw_core.h"
#include "temp_buf.h"
23
#include "gimpbrush.h"
24
#include "gimpdrawableF.h"
Elliot Lee's avatar
Elliot Lee committed
25 26 27 28 29 30 31 32 33 34 35

/* the different states that the painting function can be called with  */
#define INIT_PAINT      0
#define MOTION_PAINT    1
#define PAUSE_PAINT     2
#define RESUME_PAINT    3
#define FINISH_PAINT    4

/* brush application types  */
#define HARD            0  /* pencil */
#define SOFT            1  /* paintbrush */
36
#define PRESSURE        2  /* paintbrush with variable pressure */
Elliot Lee's avatar
Elliot Lee committed
37 38 39 40 41 42

/* paint application modes  */
#define CONSTANT        0  /* pencil, paintbrush, airbrush, clone */
#define INCREMENTAL     1  /* convolve, smudge */

typedef struct _paint_core PaintCore;
43
typedef void * (* PaintFunc)   (PaintCore *, GimpDrawable *, int);
Elliot Lee's avatar
Elliot Lee committed
44 45 46 47 48 49
struct _paint_core
{
  DrawCore *      core;         /*  Core select object          */

  double          startx;       /*  starting x coord            */
  double          starty;       /*  starting y coord            */
50 51 52
  double          startpressure;  /* starting pressure          */
  double          startxtilt;    /* starting xtilt              */
  double          startytilt;  /* starting ytilt                */
Elliot Lee's avatar
Elliot Lee committed
53 54 55

  double          curx;         /*  current x coord             */
  double          cury;         /*  current y coord             */
56 57 58
  double          curpressure;   /*  current pressure            */
  double          curxtilt;     /*  current xtilt               */
  double          curytilt;     /*  current ytilt               */
Elliot Lee's avatar
Elliot Lee committed
59 60 61

  double          lastx;        /*  last x coord                */
  double          lasty;        /*  last y coord                */
62 63 64
  double          lastpressure; /* last pressure               */
  double          lastxtilt;    /* last xtilt                  */
  double          lastytilt;    /* last ytilt                  */
Elliot Lee's avatar
Elliot Lee committed
65 66 67 68 69 70 71 72 73

  int             state;        /*  state of buttons and keys   */

  double          distance;     /*  distance traveled by brush  */
  double          spacing;      /*  distance traveled by brush  */

  int             x1, y1;       /*  image space coordinate      */
  int             x2, y2;       /*  image space coords          */

74
  GimpBrush *     brush;        /*  current brush	        */
Elliot Lee's avatar
Elliot Lee committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88

  PaintFunc       paint_func;   /*  painting function           */
};

extern PaintCore  non_gui_paint_core;

/*  Special undo type  */
typedef struct _paint_undo PaintUndo;

struct _paint_undo
{
  int             tool_ID;
  double          lastx;
  double          lasty;
89 90 91
  double	  lastpressure;
  double          lastxtilt;
  double          lastytilt;
Elliot Lee's avatar
Elliot Lee committed
92 93 94 95 96 97 98 99 100 101 102 103 104
};

/*  paint tool action functions  */
void          paint_core_button_press      (Tool *, GdkEventButton *, gpointer);
void          paint_core_button_release    (Tool *, GdkEventButton *, gpointer);
void          paint_core_motion            (Tool *, GdkEventMotion *, gpointer);
void          paint_core_cursor_update     (Tool *, GdkEventMotion *, gpointer);
void          paint_core_control           (Tool *, int, gpointer);

/*  paint tool functions  */
void          paint_core_no_draw      (Tool *);
Tool *        paint_core_new          (int);
void          paint_core_free         (Tool *);
105 106 107
int           paint_core_init         (PaintCore *, GimpDrawable *, double, double);
void          paint_core_interpolate  (PaintCore *, GimpDrawable *);
void          paint_core_finish       (PaintCore *, GimpDrawable *, int);
Elliot Lee's avatar
Elliot Lee committed
108 109 110
void          paint_core_cleanup      (void);

/*  paint tool painting functions  */
111 112 113 114
TempBuf *     paint_core_get_paint_area    (PaintCore *, GimpDrawable *);
TempBuf *     paint_core_get_orig_image    (PaintCore *, GimpDrawable *, int, int, int, int);
void          paint_core_paste_canvas      (PaintCore *, GimpDrawable *, int, int, int, int, int);
void          paint_core_replace_canvas    (PaintCore *, GimpDrawable *, int, int, int, int);
Elliot Lee's avatar
Elliot Lee committed
115 116

#endif  /*  __PAINT_CORE_H__  */