summaryrefslogtreecommitdiffstats
path: root/app/display/gimptoolwidget.h
blob: 742aa2aa2d0635c8ee220bbd28e0d091c8e6c393 (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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * gimptoolwidget.h
 * Copyright (C) 2017 Michael Natterer <mitch@gimp.org>
 *
 * 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_TOOL_WIDGET_H__
#define __GIMP_TOOL_WIDGET_H__


#include "core/gimpobject.h"


#define GIMP_TOOL_WIDGET_RESPONSE_CONFIRM -1
#define GIMP_TOOL_WIDGET_RESPONSE_CANCEL  -2
#define GIMP_TOOL_WIDGET_RESPONSE_RESET   -3


#define GIMP_TYPE_TOOL_WIDGET            (gimp_tool_widget_get_type ())
#define GIMP_TOOL_WIDGET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_WIDGET, GimpToolWidget))
#define GIMP_TOOL_WIDGET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_WIDGET, GimpToolWidgetClass))
#define GIMP_IS_TOOL_WIDGET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_WIDGET))
#define GIMP_IS_TOOL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_WIDGET))
#define GIMP_TOOL_WIDGET_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_WIDGET, GimpToolWidgetClass))


typedef struct _GimpToolWidgetPrivate GimpToolWidgetPrivate;
typedef struct _GimpToolWidgetClass   GimpToolWidgetClass;

struct _GimpToolWidget
{
  GimpObject             parent_instance;

  GimpToolWidgetPrivate *private;
};

struct _GimpToolWidgetClass
{
  GimpObjectClass  parent_class;

  /*  signals  */
  void     (* changed)         (GimpToolWidget        *widget);
  void     (* response)        (GimpToolWidget        *widget,
                                gint                   response_id);
  void     (* snap_offsets)    (GimpToolWidget        *widget,
                                gint                   offset_x,
                                gint                   offset_y,
                                gint                   width,
                                gint                   height);
  void     (* status)          (GimpToolWidget        *widget,
                                const gchar           *status);
  void     (* status_coords)   (GimpToolWidget        *widget,
                                const gchar           *title,
                                gdouble                x,
                                const gchar           *separator,
                                gdouble                y,
                                const gchar           *help);
  void     (* message)         (GimpToolWidget        *widget,
                                const gchar           *message);
  void     (* focus_changed)   (GimpToolWidget        *widget);

  /*  virtual functions  */
  gint     (* button_press)    (GimpToolWidget        *widget,
                                const GimpCoords      *coords,
                                guint32                time,
                                GdkModifierType        state,
                                GimpButtonPressType    press_type);
  void     (* button_release)  (GimpToolWidget        *widget,
                                const GimpCoords      *coords,
                                guint32                time,
                                GdkModifierType        state,
                                GimpButtonReleaseType  release_type);
  void     (* motion)          (GimpToolWidget        *widget,
                                const GimpCoords      *coords,
                                guint32                time,
                                GdkModifierType        state);

  GimpHit  (* hit)             (GimpToolWidget        *widget,
                                const GimpCoords      *coords,
                                GdkModifierType        state,
                                gboolean               proximity);
  void     (* hover)           (GimpToolWidget        *widget,
                                const GimpCoords      *coords,
                                GdkModifierType        state,
                                gboolean               proximity);
  void     (* leave_notify)    (GimpToolWidget        *widget);

  gboolean (* key_press)       (GimpToolWidget        *widget,
                                GdkEventKey           *kevent);
  gboolean (* key_release)     (GimpToolWidget        *widget,
                                GdkEventKey           *kevent);

  void     (* motion_modifier) (GimpToolWidget        *widget,
                                GdkModifierType        key,
                                gboolean               press,
                                GdkModifierType        state);
  void     (* hover_modifier)  (GimpToolWidget        *widget,
                                GdkModifierType        key,
                                gboolean               press,
                                GdkModifierType        state);

  gboolean (* get_cursor)      (GimpToolWidget        *widget,
                                const GimpCoords      *coords,
                                GdkModifierType        state,
                                GimpCursorType        *cursor,
                                GimpToolCursorType    *tool_cursor,
                                GimpCursorModifier    *modifier);

  gboolean update_on_scale;
  gboolean update_on_scroll;
  gboolean update_on_rotate;
};


GType              gimp_tool_widget_get_type          (void) G_GNUC_CONST;

GimpDisplayShell * gimp_tool_widget_get_shell         (GimpToolWidget  *widget);
GimpCanvasItem   * gimp_tool_widget_get_item          (GimpToolWidget  *widget);

void               gimp_tool_widget_set_visible       (GimpToolWidget  *widget,
                                                       gboolean         visible);
gboolean           gimp_tool_widget_get_visible       (GimpToolWidget  *widget);

void               gimp_tool_widget_set_focus         (GimpToolWidget  *widget,
                                                       gboolean         focus);
gboolean           gimp_tool_widget_get_focus         (GimpToolWidget  *widget);

/*  for subclasses, to notify the handling tool
 */
void               gimp_tool_widget_changed           (GimpToolWidget  *widget);

void               gimp_tool_widget_response          (GimpToolWidget  *widget,
                                                       gint             response_id);

void               gimp_tool_widget_set_snap_offsets  (GimpToolWidget  *widget,
                                                       gint             offset_x,
                                                       gint             offset_y,
                                                       gint             width,
                                                       gint             height);
void               gimp_tool_widget_get_snap_offsets  (GimpToolWidget  *widget,
                                                       gint            *offset_x,
                                                       gint            *offset_y,
                                                       gint            *width,
                                                       gint            *height);

void               gimp_tool_widget_set_status        (GimpToolWidget  *widget,
                                                       const gchar     *status);
void               gimp_tool_widget_set_status_coords (GimpToolWidget  *widget,
                                                       const gchar     *title,
                                                       gdouble          x,
                                                       const gchar     *separator,
                                                       gdouble          y,
                                                       const gchar     *help);

void               gimp_tool_widget_message           (GimpToolWidget  *widget,
                                                       const gchar     *format,
                                                       ...) G_GNUC_PRINTF (2, 3);
void               gimp_tool_widget_message_literal   (GimpToolWidget  *widget,
                                                       const gchar     *message);

/*  for subclasses, to add and manage their items
 */
void               gimp_tool_widget_add_item         (GimpToolWidget  *widget,
                                                      GimpCanvasItem  *item);
void               gimp_tool_widget_remove_item      (GimpToolWidget  *widget,
                                                      GimpCanvasItem  *item);

GimpCanvasGroup  * gimp_tool_widget_add_group        (GimpToolWidget  *widget);
GimpCanvasGroup  * gimp_tool_widget_add_stroke_group (GimpToolWidget  *widget);
GimpCanvasGroup  * gimp_tool_widget_add_fill_group   (GimpToolWidget  *widget);

void               gimp_tool_widget_push_group       (GimpToolWidget  *widget,
                                                      GimpCanvasGroup *group);
void               gimp_tool_widget_pop_group        (GimpToolWidget  *widget);

/*  for subclasses, convenience functions to add specific items
 */
GimpCanvasItem * gimp_tool_widget_add_line      (GimpToolWidget       *widget,
                                                 gdouble               x1,
                                                 gdouble               y1,
                                                 gdouble               x2,
                                                 gdouble               y2);
GimpCanvasItem * gimp_tool_widget_add_rectangle (GimpToolWidget       *widget,
                                                 gdouble               x,
                                                 gdouble               y,
                                                 gdouble               width,
                                                 gdouble               height,
                                                 gboolean              filled);
GimpCanvasItem * gimp_tool_widget_add_arc       (GimpToolWidget       *widget,
                                                 gdouble               center_x,
                                                 gdouble               center_y,
                                                 gdouble               radius_x,
                                                 gdouble               radius_y,
                                                 gdouble               start_angle,
                                                 gdouble               slice_angle,
                                                 gboolean              filled);
GimpCanvasItem * gimp_tool_widget_add_limit     (GimpToolWidget       *widget,
                                                 GimpLimitType         type,
                                                 gdouble               x,
                                                 gdouble               y,
                                                 gdouble               radius,
                                                 gdouble               aspect_ratio,
                                                 gdouble               angle,
                                                 gboolean              dashed);
GimpCanvasItem * gimp_tool_widget_add_polygon   (GimpToolWidget       *widget,
                                                 GimpMatrix3          *transform,
                                                 const GimpVector2    *points,
                                                 gint                  n_points,
                                                 gboolean              filled);
GimpCanvasItem * gimp_tool_widget_add_polygon_from_coords
                                                (GimpToolWidget       *widget,
                                                 GimpMatrix3          *transform,
                                                 const GimpCoords     *points,
                                                 gint                  n_points,
                                                 gboolean              filled);
GimpCanvasItem * gimp_tool_widget_add_path      (GimpToolWidget       *widget,
                                                 const GimpBezierDesc *desc);

GimpCanvasItem * gimp_tool_widget_add_handle    (GimpToolWidget       *widget,
                                                 GimpHandleType        type,
                                                 gdouble               x,
                                                 gdouble               y,
                                                 gint                  width,
                                                 gint                  height,
                                                 GimpHandleAnchor      anchor);
GimpCanvasItem * gimp_tool_widget_add_corner    (GimpToolWidget       *widget,
                                                 gdouble               x,
                                                 gdouble               y,
                                                 gdouble               width,
                                                 gdouble               height,
                                                 GimpHandleAnchor      anchor,
                                                 gint                  corner_width,
                                                 gint                  corner_height,
                                                 gboolean              outside);

GimpCanvasItem * gimp_tool_widget_add_rectangle_guides
                                                (GimpToolWidget       *widget,
                                                 gdouble               x,
                                                 gdouble               y,
                                                 gdouble               width,
                                                 gdouble               height,
                                                 GimpGuidesType        type);
GimpCanvasItem * gimp_tool_widget_add_transform_guides
                                                (GimpToolWidget       *widget,
                                                 const GimpMatrix3    *transform,
                                                 gdouble               x1,
                                                 gdouble               y1,
                                                 gdouble               x2,
                                                 gdouble               y2,
                                                 GimpGuidesType        type,
                                                 gint                  n_guides,
                                                 gboolean              clip);

/*  for tools, to be called from the respective GimpTool method
 *  implementations
 */
gint       gimp_tool_widget_button_press    (GimpToolWidget        *widget,
                                             const GimpCoords      *coords,
                                             guint32                time,
                                             GdkModifierType        state,
                                             GimpButtonPressType    press_type);
void       gimp_tool_widget_button_release  (GimpToolWidget        *widget,
                                             const GimpCoords      *coords,
                                             guint32                time,
                                             GdkModifierType        state,
                                             GimpButtonReleaseType  release_type);
void       gimp_tool_widget_motion          (GimpToolWidget        *widget,
                                             const GimpCoords      *coords,
                                             guint32                time,
                                             GdkModifierType        state);

GimpHit    gimp_tool_widget_hit             (GimpToolWidget        *widget,
                                             const GimpCoords      *coords,
                                             GdkModifierType        state,
                                             gboolean               proximity);
void       gimp_tool_widget_hover           (GimpToolWidget        *widget,
                                             const GimpCoords      *coords,
                                             GdkModifierType        state,
                                             gboolean               proximity);
void       gimp_tool_widget_leave_notify    (GimpToolWidget        *widget);

gboolean   gimp_tool_widget_key_press       (GimpToolWidget        *widget,
                                             GdkEventKey           *kevent);
gboolean   gimp_tool_widget_key_release     (GimpToolWidget        *widget,
                                             GdkEventKey           *kevent);

void       gimp_tool_widget_motion_modifier (GimpToolWidget        *widget,
                                             GdkModifierType        key,
                                             gboolean               press,
                                             GdkModifierType        state);
void       gimp_tool_widget_hover_modifier  (GimpToolWidget        *widget,
                                             GdkModifierType        key,
                                             gboolean               press,
                                             GdkModifierType        state);

gboolean   gimp_tool_widget_get_cursor      (GimpToolWidget        *widget,
                                             const GimpCoords      *coords,
                                             GdkModifierType        state,
                                             GimpCursorType        *cursor,
                                             GimpToolCursorType    *tool_cursor,
                                             GimpCursorModifier    *modifier);


#endif /* __GIMP_TOOL_WIDGET_H__ */