1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __GIMP_ISCISSORS_TOOL_H__
19 #define __GIMP_ISCISSORS_TOOL_H__
20 
21 
22 #include "gimpselectiontool.h"
23 
24 
25 /*  The possible states...  */
26 typedef enum
27 {
28   NO_ACTION,
29   SEED_PLACEMENT,
30   SEED_ADJUSTMENT,
31   WAITING
32 } IscissorsState;
33 
34 /*  For oper_update & cursor_update  */
35 typedef enum
36 {
37   ISCISSORS_OP_NONE,
38   ISCISSORS_OP_SELECT,
39   ISCISSORS_OP_MOVE_POINT,
40   ISCISSORS_OP_ADD_POINT,
41   ISCISSORS_OP_REMOVE_POINT,
42   ISCISSORS_OP_CONNECT,
43   ISCISSORS_OP_IMPOSSIBLE
44 } IscissorsOps;
45 
46 typedef struct _ISegment ISegment;
47 typedef struct _ICurve   ICurve;
48 
49 
50 #define GIMP_TYPE_ISCISSORS_TOOL            (gimp_iscissors_tool_get_type ())
51 #define GIMP_ISCISSORS_TOOL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ISCISSORS_TOOL, GimpIscissorsTool))
52 #define GIMP_ISCISSORS_TOOL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ISCISSORS_TOOL, GimpIscissorsToolClass))
53 #define GIMP_IS_ISCISSORS_TOOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ISCISSORS_TOOL))
54 #define GIMP_IS_ISCISSORS_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ISCISSORS_TOOL))
55 #define GIMP_ISCISSORS_TOOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ISCISSORS_TOOL, GimpIscissorsToolClass))
56 
57 #define GIMP_ISCISSORS_TOOL_GET_OPTIONS(t)  (GIMP_ISCISSORS_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
58 
59 
60 typedef struct _GimpIscissorsTool      GimpIscissorsTool;
61 typedef struct _GimpIscissorsToolClass GimpIscissorsToolClass;
62 
63 struct _GimpIscissorsTool
64 {
65   GimpSelectionTool  parent_instance;
66 
67   IscissorsOps    op;
68 
69   gint            x, y;         /*  mouse coordinates                       */
70 
71   ISegment       *segment1;     /*  1st segment connected to current point  */
72   ISegment       *segment2;     /*  2nd segment connected to current point  */
73 
74   ICurve         *curve;        /*  the curve                               */
75 
76   GList          *undo_stack;   /*  stack of ICurves for undo               */
77   GList          *redo_stack;   /*  stack of ICurves for redo               */
78 
79   IscissorsState  state;        /*  state of iscissors                      */
80 
81   GeglBuffer     *gradient_map; /*  lazily filled gradient map              */
82   GimpChannel    *mask;         /*  selection mask                          */
83 };
84 
85 struct _GimpIscissorsToolClass
86 {
87   GimpSelectionToolClass parent_class;
88 };
89 
90 
91 void    gimp_iscissors_tool_register (GimpToolRegisterCallback  callback,
92                                       gpointer                  data);
93 
94 GType   gimp_iscissors_tool_get_type (void) G_GNUC_CONST;
95 
96 
97 #endif  /*  __GIMP_ISCISSORS_TOOL_H__  */
98