1 /* GIMP - The GNU Image Manipulation Program
2  *
3  * gimpseamlessclonetool.h
4  * Copyright (C) 2011 Barak Itkin <lightningismyname@gmail.com>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __GIMP_SEAMLESS_CLONE_TOOL_H__
21 #define __GIMP_SEAMLESS_CLONE_TOOL_H__
22 
23 
24 #include "gimpdrawtool.h"
25 
26 
27 #define GIMP_TYPE_SEAMLESS_CLONE_TOOL            (gimp_seamless_clone_tool_get_type ())
28 #define GIMP_SEAMLESS_CLONE_TOOL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SEAMLESS_CLONE_TOOL, GimpSeamlessCloneTool))
29 #define GIMP_SEAMLESS_CLONE_TOOL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SEAMLESS_CLONE_TOOL, GimpSeamlessCloneToolClass))
30 #define GIMP_IS_SEAMLESS_CLONE_TOOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SEAMLESS_CLONE_TOOL))
31 #define GIMP_IS_SEAMLESS_CLONE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SEAMLESS_CLONE_TOOL))
32 #define GIMP_SEAMLESS_CLONE_TOOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SEAMLESS_CLONE_TOOL, GimpSeamlessCloneToolClass))
33 
34 #define GIMP_SEAMLESS_CLONE_TOOL_GET_OPTIONS(t)  (GIMP_SEAMLESS_CLONE_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
35 
36 
37 typedef struct _GimpSeamlessCloneTool      GimpSeamlessCloneTool;
38 typedef struct _GimpSeamlessCloneToolClass GimpSeamlessCloneToolClass;
39 
40 struct _GimpSeamlessCloneTool
41 {
42   GimpDrawTool    parent_instance;
43 
44   GeglBuffer     *paste;         /* A buffer containing the original
45                                   * paste that will be used in the
46                                   * rendering process */
47 
48   GeglNode       *render_node;    /* The parent of the Gegl graph that
49                                    * renders the seamless cloning */
50 
51   GeglNode       *sc_node;        /* A Gegl node to do the seamless
52                                    * cloning live with translation of
53                                    * the paste */
54 
55   gint            tool_state;     /* The current state in the tool's
56                                    * state machine */
57 
58   GimpDrawableFilter *filter;     /* The filter object which renders
59                                    * the live preview, and commits it
60                                    * when at the end */
61 
62   gint width, height;             /* The width and height of the paste.
63                                    * Needed for mouse hit detection */
64 
65   gint xoff, yoff;                /* The current offset of the paste */
66   gint xoff_p, yoff_p;            /* The previous offset of the paste */
67 
68   gdouble xclick, yclick;         /* The image location of the last
69                                    * mouse click. To be used when the
70                                    * mouse is in motion, to recalculate
71                                    * the xoff and yoff values */
72 };
73 
74 struct _GimpSeamlessCloneToolClass
75 {
76   GimpDrawToolClass parent_class;
77 };
78 
79 
80 void    gimp_seamless_clone_tool_register (GimpToolRegisterCallback  callback,
81                                            gpointer                  data);
82 
83 GType   gimp_seamless_clone_tool_get_type (void) G_GNUC_CONST;
84 
85 
86 #endif  /*  __GIMP_SEAMLESS_CLONE_TOOL_H__  */
87