1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * gimptoolwidget.h 5 * Copyright (C) 2017 Michael Natterer <mitch@gimp.org> 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __GIMP_TOOL_WIDGET_H__ 22 #define __GIMP_TOOL_WIDGET_H__ 23 24 25 #include "core/gimpobject.h" 26 27 28 #define GIMP_TOOL_WIDGET_RESPONSE_CONFIRM -1 29 #define GIMP_TOOL_WIDGET_RESPONSE_CANCEL -2 30 #define GIMP_TOOL_WIDGET_RESPONSE_RESET -3 31 32 33 #define GIMP_TYPE_TOOL_WIDGET (gimp_tool_widget_get_type ()) 34 #define GIMP_TOOL_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_WIDGET, GimpToolWidget)) 35 #define GIMP_TOOL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_WIDGET, GimpToolWidgetClass)) 36 #define GIMP_IS_TOOL_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_WIDGET)) 37 #define GIMP_IS_TOOL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_WIDGET)) 38 #define GIMP_TOOL_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_WIDGET, GimpToolWidgetClass)) 39 40 41 typedef struct _GimpToolWidgetPrivate GimpToolWidgetPrivate; 42 typedef struct _GimpToolWidgetClass GimpToolWidgetClass; 43 44 struct _GimpToolWidget 45 { 46 GimpObject parent_instance; 47 48 GimpToolWidgetPrivate *private; 49 }; 50 51 struct _GimpToolWidgetClass 52 { 53 GimpObjectClass parent_class; 54 55 /* signals */ 56 void (* changed) (GimpToolWidget *widget); 57 void (* response) (GimpToolWidget *widget, 58 gint response_id); 59 void (* snap_offsets) (GimpToolWidget *widget, 60 gint offset_x, 61 gint offset_y, 62 gint width, 63 gint height); 64 void (* status) (GimpToolWidget *widget, 65 const gchar *status); 66 void (* status_coords) (GimpToolWidget *widget, 67 const gchar *title, 68 gdouble x, 69 const gchar *separator, 70 gdouble y, 71 const gchar *help); 72 void (* message) (GimpToolWidget *widget, 73 const gchar *message); 74 void (* focus_changed) (GimpToolWidget *widget); 75 76 /* virtual functions */ 77 gint (* button_press) (GimpToolWidget *widget, 78 const GimpCoords *coords, 79 guint32 time, 80 GdkModifierType state, 81 GimpButtonPressType press_type); 82 void (* button_release) (GimpToolWidget *widget, 83 const GimpCoords *coords, 84 guint32 time, 85 GdkModifierType state, 86 GimpButtonReleaseType release_type); 87 void (* motion) (GimpToolWidget *widget, 88 const GimpCoords *coords, 89 guint32 time, 90 GdkModifierType state); 91 92 GimpHit (* hit) (GimpToolWidget *widget, 93 const GimpCoords *coords, 94 GdkModifierType state, 95 gboolean proximity); 96 void (* hover) (GimpToolWidget *widget, 97 const GimpCoords *coords, 98 GdkModifierType state, 99 gboolean proximity); 100 void (* leave_notify) (GimpToolWidget *widget); 101 102 gboolean (* key_press) (GimpToolWidget *widget, 103 GdkEventKey *kevent); 104 gboolean (* key_release) (GimpToolWidget *widget, 105 GdkEventKey *kevent); 106 107 void (* motion_modifier) (GimpToolWidget *widget, 108 GdkModifierType key, 109 gboolean press, 110 GdkModifierType state); 111 void (* hover_modifier) (GimpToolWidget *widget, 112 GdkModifierType key, 113 gboolean press, 114 GdkModifierType state); 115 116 gboolean (* get_cursor) (GimpToolWidget *widget, 117 const GimpCoords *coords, 118 GdkModifierType state, 119 GimpCursorType *cursor, 120 GimpToolCursorType *tool_cursor, 121 GimpCursorModifier *modifier); 122 123 gboolean update_on_scale; 124 gboolean update_on_scroll; 125 gboolean update_on_rotate; 126 }; 127 128 129 GType gimp_tool_widget_get_type (void) G_GNUC_CONST; 130 131 GimpDisplayShell * gimp_tool_widget_get_shell (GimpToolWidget *widget); 132 GimpCanvasItem * gimp_tool_widget_get_item (GimpToolWidget *widget); 133 134 void gimp_tool_widget_set_visible (GimpToolWidget *widget, 135 gboolean visible); 136 gboolean gimp_tool_widget_get_visible (GimpToolWidget *widget); 137 138 void gimp_tool_widget_set_focus (GimpToolWidget *widget, 139 gboolean focus); 140 gboolean gimp_tool_widget_get_focus (GimpToolWidget *widget); 141 142 /* for subclasses, to notify the handling tool 143 */ 144 void gimp_tool_widget_changed (GimpToolWidget *widget); 145 146 void gimp_tool_widget_response (GimpToolWidget *widget, 147 gint response_id); 148 149 void gimp_tool_widget_set_snap_offsets (GimpToolWidget *widget, 150 gint offset_x, 151 gint offset_y, 152 gint width, 153 gint height); 154 void gimp_tool_widget_get_snap_offsets (GimpToolWidget *widget, 155 gint *offset_x, 156 gint *offset_y, 157 gint *width, 158 gint *height); 159 160 void gimp_tool_widget_set_status (GimpToolWidget *widget, 161 const gchar *status); 162 void gimp_tool_widget_set_status_coords (GimpToolWidget *widget, 163 const gchar *title, 164 gdouble x, 165 const gchar *separator, 166 gdouble y, 167 const gchar *help); 168 169 void gimp_tool_widget_message (GimpToolWidget *widget, 170 const gchar *format, 171 ...) G_GNUC_PRINTF (2, 3); 172 void gimp_tool_widget_message_literal (GimpToolWidget *widget, 173 const gchar *message); 174 175 /* for subclasses, to add and manage their items 176 */ 177 void gimp_tool_widget_add_item (GimpToolWidget *widget, 178 GimpCanvasItem *item); 179 void gimp_tool_widget_remove_item (GimpToolWidget *widget, 180 GimpCanvasItem *item); 181 182 GimpCanvasGroup * gimp_tool_widget_add_group (GimpToolWidget *widget); 183 GimpCanvasGroup * gimp_tool_widget_add_stroke_group (GimpToolWidget *widget); 184 GimpCanvasGroup * gimp_tool_widget_add_fill_group (GimpToolWidget *widget); 185 186 void gimp_tool_widget_push_group (GimpToolWidget *widget, 187 GimpCanvasGroup *group); 188 void gimp_tool_widget_pop_group (GimpToolWidget *widget); 189 190 /* for subclasses, convenience functions to add specific items 191 */ 192 GimpCanvasItem * gimp_tool_widget_add_line (GimpToolWidget *widget, 193 gdouble x1, 194 gdouble y1, 195 gdouble x2, 196 gdouble y2); 197 GimpCanvasItem * gimp_tool_widget_add_rectangle (GimpToolWidget *widget, 198 gdouble x, 199 gdouble y, 200 gdouble width, 201 gdouble height, 202 gboolean filled); 203 GimpCanvasItem * gimp_tool_widget_add_arc (GimpToolWidget *widget, 204 gdouble center_x, 205 gdouble center_y, 206 gdouble radius_x, 207 gdouble radius_y, 208 gdouble start_angle, 209 gdouble slice_angle, 210 gboolean filled); 211 GimpCanvasItem * gimp_tool_widget_add_limit (GimpToolWidget *widget, 212 GimpLimitType type, 213 gdouble x, 214 gdouble y, 215 gdouble radius, 216 gdouble aspect_ratio, 217 gdouble angle, 218 gboolean dashed); 219 GimpCanvasItem * gimp_tool_widget_add_polygon (GimpToolWidget *widget, 220 GimpMatrix3 *transform, 221 const GimpVector2 *points, 222 gint n_points, 223 gboolean filled); 224 GimpCanvasItem * gimp_tool_widget_add_polygon_from_coords 225 (GimpToolWidget *widget, 226 GimpMatrix3 *transform, 227 const GimpCoords *points, 228 gint n_points, 229 gboolean filled); 230 GimpCanvasItem * gimp_tool_widget_add_path (GimpToolWidget *widget, 231 const GimpBezierDesc *desc); 232 233 GimpCanvasItem * gimp_tool_widget_add_handle (GimpToolWidget *widget, 234 GimpHandleType type, 235 gdouble x, 236 gdouble y, 237 gint width, 238 gint height, 239 GimpHandleAnchor anchor); 240 GimpCanvasItem * gimp_tool_widget_add_corner (GimpToolWidget *widget, 241 gdouble x, 242 gdouble y, 243 gdouble width, 244 gdouble height, 245 GimpHandleAnchor anchor, 246 gint corner_width, 247 gint corner_height, 248 gboolean outside); 249 250 GimpCanvasItem * gimp_tool_widget_add_rectangle_guides 251 (GimpToolWidget *widget, 252 gdouble x, 253 gdouble y, 254 gdouble width, 255 gdouble height, 256 GimpGuidesType type); 257 GimpCanvasItem * gimp_tool_widget_add_transform_guides 258 (GimpToolWidget *widget, 259 const GimpMatrix3 *transform, 260 gdouble x1, 261 gdouble y1, 262 gdouble x2, 263 gdouble y2, 264 GimpGuidesType type, 265 gint n_guides, 266 gboolean clip); 267 268 /* for tools, to be called from the respective GimpTool method 269 * implementations 270 */ 271 gint gimp_tool_widget_button_press (GimpToolWidget *widget, 272 const GimpCoords *coords, 273 guint32 time, 274 GdkModifierType state, 275 GimpButtonPressType press_type); 276 void gimp_tool_widget_button_release (GimpToolWidget *widget, 277 const GimpCoords *coords, 278 guint32 time, 279 GdkModifierType state, 280 GimpButtonReleaseType release_type); 281 void gimp_tool_widget_motion (GimpToolWidget *widget, 282 const GimpCoords *coords, 283 guint32 time, 284 GdkModifierType state); 285 286 GimpHit gimp_tool_widget_hit (GimpToolWidget *widget, 287 const GimpCoords *coords, 288 GdkModifierType state, 289 gboolean proximity); 290 void gimp_tool_widget_hover (GimpToolWidget *widget, 291 const GimpCoords *coords, 292 GdkModifierType state, 293 gboolean proximity); 294 void gimp_tool_widget_leave_notify (GimpToolWidget *widget); 295 296 gboolean gimp_tool_widget_key_press (GimpToolWidget *widget, 297 GdkEventKey *kevent); 298 gboolean gimp_tool_widget_key_release (GimpToolWidget *widget, 299 GdkEventKey *kevent); 300 301 void gimp_tool_widget_motion_modifier (GimpToolWidget *widget, 302 GdkModifierType key, 303 gboolean press, 304 GdkModifierType state); 305 void gimp_tool_widget_hover_modifier (GimpToolWidget *widget, 306 GdkModifierType key, 307 gboolean press, 308 GdkModifierType state); 309 310 gboolean gimp_tool_widget_get_cursor (GimpToolWidget *widget, 311 const GimpCoords *coords, 312 GdkModifierType state, 313 GimpCursorType *cursor, 314 GimpToolCursorType *tool_cursor, 315 GimpCursorModifier *modifier); 316 317 318 #endif /* __GIMP_TOOL_WIDGET_H__ */ 319