summaryrefslogtreecommitdiffstats
path: root/app/tools/gimpdrawtool.h
blob: 68b72d5742b674c1b10b2bbd04030b4d721e1cc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others.
 *
 * 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 3 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, see <https://www.gnu.org/licenses/>.
 */

#ifndef __GIMP_DRAW_TOOL_H__
#define __GIMP_DRAW_TOOL_H__


#include "gimptool.h"


#define GIMP_TOOL_HANDLE_SIZE_CIRCLE    13
#define GIMP_TOOL_HANDLE_SIZE_CROSS     15
#define GIMP_TOOL_HANDLE_SIZE_CROSSHAIR 43
#define GIMP_TOOL_HANDLE_SIZE_LARGE     25
#define GIMP_TOOL_HANDLE_SIZE_SMALL     7


#define GIMP_TYPE_DRAW_TOOL            (gimp_draw_tool_get_type ())
#define GIMP_DRAW_TOOL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DRAW_TOOL, GimpDrawTool))
#define GIMP_DRAW_TOOL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAW_TOOL, GimpDrawToolClass))
#define GIMP_IS_DRAW_TOOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DRAW_TOOL))
#define GIMP_IS_DRAW_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAW_TOOL))
#define GIMP_DRAW_TOOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DRAW_TOOL, GimpDrawToolClass))


typedef struct _GimpDrawToolClass GimpDrawToolClass;

struct _GimpDrawTool
{
  GimpTool        parent_instance;

  GimpDisplay    *display;        /*  The display we are drawing to (may be
                                   *  a different one than tool->display)
                                   */

  gint            paused_count;   /*  count to keep track of multiple pauses  */
  guint           draw_timeout;   /*  draw delay timeout ID                   */
  guint64         last_draw_time; /*  time of last draw(), monotonically      */

  GimpToolWidget *widget;
  gchar          *default_status;
  GimpCanvasItem *preview;
  GimpCanvasItem *item;
  GList          *group_stack;
};

struct _GimpDrawToolClass
{
  GimpToolClass   parent_class;

  /*  virtual function  */

  void (* draw) (GimpDrawTool *draw_tool);
};


GType            gimp_draw_tool_get_type             (void) G_GNUC_CONST;

void             gimp_draw_tool_start                (GimpDrawTool     *draw_tool,
                                                      GimpDisplay      *display);
void             gimp_draw_tool_stop                 (GimpDrawTool     *draw_tool);

gboolean         gimp_draw_tool_is_active            (GimpDrawTool     *draw_tool);

void             gimp_draw_tool_pause                (GimpDrawTool     *draw_tool);
void             gimp_draw_tool_resume               (GimpDrawTool     *draw_tool);

gdouble          gimp_draw_tool_calc_distance        (GimpDrawTool     *draw_tool,
                                                      GimpDisplay      *display,
                                                      gdouble           x1,
                                                      gdouble           y1,
                                                      gdouble           x2,
                                                      gdouble           y2);
gdouble          gimp_draw_tool_calc_distance_square (GimpDrawTool     *draw_tool,
                                                      GimpDisplay      *display,
                                                      gdouble           x1,
                                                      gdouble           y1,
                                                      gdouble           x2,
                                                      gdouble           y2);

void             gimp_draw_tool_set_widget           (GimpDrawTool     *draw_tool,
                                                      GimpToolWidget   *widget);
void             gimp_draw_tool_set_default_status   (GimpDrawTool     *draw_tool,
                                                      const gchar      *status);

void             gimp_draw_tool_add_preview          (GimpDrawTool     *draw_tool,
                                                      GimpCanvasItem   *item);
void             gimp_draw_tool_remove_preview       (GimpDrawTool     *draw_tool,
                                                      GimpCanvasItem   *item);

void             gimp_draw_tool_add_item             (GimpDrawTool     *draw_tool,
                                                      GimpCanvasItem   *item);
void             gimp_draw_tool_remove_item          (GimpDrawTool     *draw_tool,
                                                      GimpCanvasItem   *item);

GimpCanvasGroup* gimp_draw_tool_add_stroke_group     (GimpDrawTool     *draw_tool);
GimpCanvasGroup* gimp_draw_tool_add_fill_group       (GimpDrawTool     *draw_tool);

void             gimp_draw_tool_push_group           (GimpDrawTool     *draw_tool,
                                                      GimpCanvasGroup  *group);
void             gimp_draw_tool_pop_group            (GimpDrawTool     *draw_tool);

GimpCanvasItem * gimp_draw_tool_add_line             (GimpDrawTool     *draw_tool,
                                                      gdouble           x1,
                                                      gdouble           y1,
                                                      gdouble           x2,
                                                      gdouble           y2);
GimpCanvasItem * gimp_draw_tool_add_guide            (GimpDrawTool     *draw_tool,
                                                      GimpOrientationType  orientation,
                                                      gint              position,
                                                      GimpGuideStyle    style);
GimpCanvasItem * gimp_draw_tool_add_crosshair        (GimpDrawTool     *draw_tool,
                                                      gint              position_x,
                                                      gint              position_y);
GimpCanvasItem * gimp_draw_tool_add_sample_point     (GimpDrawTool     *draw_tool,
                                                      gint              x,
                                                      gint              y,
                                                      gint              index);
GimpCanvasItem * gimp_draw_tool_add_rectangle        (GimpDrawTool     *draw_tool,
                                                      gboolean          filled,
                                                      gdouble           x,
                                                      gdouble           y,
                                                      gdouble           width,
                                                      gdouble           height);
GimpCanvasItem * gimp_draw_tool_add_arc              (GimpDrawTool     *draw_tool,
                                                      gboolean          filled,
                                                      gdouble           x,
                                                      gdouble           y,
                                                      gdouble           width,
                                                      gdouble           height,
                                                      gdouble           start_angle,
                                                      gdouble           slice_angle);
GimpCanvasItem * gimp_draw_tool_add_transform_preview(GimpDrawTool     *draw_tool,
                                                      GimpPickable     *pickable,
                                                      const GimpMatrix3 *transform,
                                                      gdouble           x1,
                                                      gdouble           y1,
                                                      gdouble           x2,
                                                      gdouble           y2);

GimpCanvasItem * gimp_draw_tool_add_handle           (GimpDrawTool     *draw_tool,
                                                      GimpHandleType    type,
                                                      gdouble           x,
                                                      gdouble           y,
                                                      gint              width,
                                                      gint              height,
                                                      GimpHandleAnchor  anchor);

GimpCanvasItem * gimp_draw_tool_add_lines            (GimpDrawTool     *draw_tool,
                                                      const GimpVector2 *points,
                                                      gint              n_points,
                                                      GimpMatrix3      *transform,
                                                      gboolean          filled);

GimpCanvasItem * gimp_draw_tool_add_strokes          (GimpDrawTool     *draw_tool,
                                                      const GimpCoords *points,
                                                      gint              n_points,
                                                      GimpMatrix3      *transform,
                                                      gboolean          filled);

GimpCanvasItem * gimp_draw_tool_add_pen              (GimpDrawTool     *draw_tool,
                                                      const GimpVector2 *points,
                                                      gint              n_points,
                                                      GimpContext      *context,
                                                      GimpActiveColor   color,
                                                      gint              width);

GimpCanvasItem * gimp_draw_tool_add_boundary         (GimpDrawTool     *draw_tool,
                                                      const GimpBoundSeg *bound_segs,
                                                      gint              n_bound_segs,
                                                      GimpMatrix3      *transform,
                                                      gdouble           offset_x,
                                                      gdouble           offset_y);

GimpCanvasItem * gimp_draw_tool_add_text_cursor      (GimpDrawTool     *draw_tool,
                                                      PangoRectangle   *cursor,
                                                      gboolean          overwrite,
                                                      GimpTextDirection direction);

gboolean         gimp_draw_tool_on_handle            (GimpDrawTool     *draw_tool,
                                                      GimpDisplay      *display,
                                                      gdouble           x,
                                                      gdouble           y,
                                                      GimpHandleType    type,
                                                      gdouble           handle_x,
                                                      gdouble           handle_y,
                                                      gint              width,
                                                      gint              height,
                                                      GimpHandleAnchor  anchor);


#endif  /*  __GIMP_DRAW_TOOL_H__  */