1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others. 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_DRAW_TOOL_H__ 19 #define __GIMP_DRAW_TOOL_H__ 20 21 22 #include "gimptool.h" 23 24 25 #define GIMP_TOOL_HANDLE_SIZE_CIRCLE 13 26 #define GIMP_TOOL_HANDLE_SIZE_CROSS 15 27 #define GIMP_TOOL_HANDLE_SIZE_CROSSHAIR 43 28 #define GIMP_TOOL_HANDLE_SIZE_LARGE 25 29 #define GIMP_TOOL_HANDLE_SIZE_SMALL 7 30 31 32 #define GIMP_TYPE_DRAW_TOOL (gimp_draw_tool_get_type ()) 33 #define GIMP_DRAW_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DRAW_TOOL, GimpDrawTool)) 34 #define GIMP_DRAW_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAW_TOOL, GimpDrawToolClass)) 35 #define GIMP_IS_DRAW_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DRAW_TOOL)) 36 #define GIMP_IS_DRAW_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAW_TOOL)) 37 #define GIMP_DRAW_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DRAW_TOOL, GimpDrawToolClass)) 38 39 40 typedef struct _GimpDrawToolClass GimpDrawToolClass; 41 42 struct _GimpDrawTool 43 { 44 GimpTool parent_instance; 45 46 GimpDisplay *display; /* The display we are drawing to (may be 47 * a different one than tool->display) 48 */ 49 50 gint paused_count; /* count to keep track of multiple pauses */ 51 guint draw_timeout; /* draw delay timeout ID */ 52 guint64 last_draw_time; /* time of last draw(), monotonically */ 53 54 GimpToolWidget *widget; 55 gchar *default_status; 56 GimpCanvasItem *preview; 57 GimpCanvasItem *item; 58 GList *group_stack; 59 }; 60 61 struct _GimpDrawToolClass 62 { 63 GimpToolClass parent_class; 64 65 /* virtual function */ 66 67 void (* draw) (GimpDrawTool *draw_tool); 68 }; 69 70 71 GType gimp_draw_tool_get_type (void) G_GNUC_CONST; 72 73 void gimp_draw_tool_start (GimpDrawTool *draw_tool, 74 GimpDisplay *display); 75 void gimp_draw_tool_stop (GimpDrawTool *draw_tool); 76 77 gboolean gimp_draw_tool_is_active (GimpDrawTool *draw_tool); 78 79 void gimp_draw_tool_pause (GimpDrawTool *draw_tool); 80 void gimp_draw_tool_resume (GimpDrawTool *draw_tool); 81 82 gdouble gimp_draw_tool_calc_distance (GimpDrawTool *draw_tool, 83 GimpDisplay *display, 84 gdouble x1, 85 gdouble y1, 86 gdouble x2, 87 gdouble y2); 88 gdouble gimp_draw_tool_calc_distance_square (GimpDrawTool *draw_tool, 89 GimpDisplay *display, 90 gdouble x1, 91 gdouble y1, 92 gdouble x2, 93 gdouble y2); 94 95 void gimp_draw_tool_set_widget (GimpDrawTool *draw_tool, 96 GimpToolWidget *widget); 97 void gimp_draw_tool_set_default_status (GimpDrawTool *draw_tool, 98 const gchar *status); 99 100 void gimp_draw_tool_add_preview (GimpDrawTool *draw_tool, 101 GimpCanvasItem *item); 102 void gimp_draw_tool_remove_preview (GimpDrawTool *draw_tool, 103 GimpCanvasItem *item); 104 105 void gimp_draw_tool_add_item (GimpDrawTool *draw_tool, 106 GimpCanvasItem *item); 107 void gimp_draw_tool_remove_item (GimpDrawTool *draw_tool, 108 GimpCanvasItem *item); 109 110 GimpCanvasGroup* gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool); 111 GimpCanvasGroup* gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool); 112 113 void gimp_draw_tool_push_group (GimpDrawTool *draw_tool, 114 GimpCanvasGroup *group); 115 void gimp_draw_tool_pop_group (GimpDrawTool *draw_tool); 116 117 GimpCanvasItem * gimp_draw_tool_add_line (GimpDrawTool *draw_tool, 118 gdouble x1, 119 gdouble y1, 120 gdouble x2, 121 gdouble y2); 122 GimpCanvasItem * gimp_draw_tool_add_guide (GimpDrawTool *draw_tool, 123 GimpOrientationType orientation, 124 gint position, 125 GimpGuideStyle style); 126 GimpCanvasItem * gimp_draw_tool_add_crosshair (GimpDrawTool *draw_tool, 127 gint position_x, 128 gint position_y); 129 GimpCanvasItem * gimp_draw_tool_add_sample_point (GimpDrawTool *draw_tool, 130 gint x, 131 gint y, 132 gint index); 133 GimpCanvasItem * gimp_draw_tool_add_rectangle (GimpDrawTool *draw_tool, 134 gboolean filled, 135 gdouble x, 136 gdouble y, 137 gdouble width, 138 gdouble height); 139 GimpCanvasItem * gimp_draw_tool_add_arc (GimpDrawTool *draw_tool, 140 gboolean filled, 141 gdouble x, 142 gdouble y, 143 gdouble width, 144 gdouble height, 145 gdouble start_angle, 146 gdouble slice_angle); 147 GimpCanvasItem * gimp_draw_tool_add_transform_preview(GimpDrawTool *draw_tool, 148 GimpPickable *pickable, 149 const GimpMatrix3 *transform, 150 gdouble x1, 151 gdouble y1, 152 gdouble x2, 153 gdouble y2); 154 155 GimpCanvasItem * gimp_draw_tool_add_handle (GimpDrawTool *draw_tool, 156 GimpHandleType type, 157 gdouble x, 158 gdouble y, 159 gint width, 160 gint height, 161 GimpHandleAnchor anchor); 162 163 GimpCanvasItem * gimp_draw_tool_add_lines (GimpDrawTool *draw_tool, 164 const GimpVector2 *points, 165 gint n_points, 166 GimpMatrix3 *transform, 167 gboolean filled); 168 169 GimpCanvasItem * gimp_draw_tool_add_strokes (GimpDrawTool *draw_tool, 170 const GimpCoords *points, 171 gint n_points, 172 GimpMatrix3 *transform, 173 gboolean filled); 174 175 GimpCanvasItem * gimp_draw_tool_add_pen (GimpDrawTool *draw_tool, 176 const GimpVector2 *points, 177 gint n_points, 178 GimpContext *context, 179 GimpActiveColor color, 180 gint width); 181 182 GimpCanvasItem * gimp_draw_tool_add_boundary (GimpDrawTool *draw_tool, 183 const GimpBoundSeg *bound_segs, 184 gint n_bound_segs, 185 GimpMatrix3 *transform, 186 gdouble offset_x, 187 gdouble offset_y); 188 189 GimpCanvasItem * gimp_draw_tool_add_text_cursor (GimpDrawTool *draw_tool, 190 PangoRectangle *cursor, 191 gboolean overwrite, 192 GimpTextDirection direction); 193 194 gboolean gimp_draw_tool_on_handle (GimpDrawTool *draw_tool, 195 GimpDisplay *display, 196 gdouble x, 197 gdouble y, 198 GimpHandleType type, 199 gdouble handle_x, 200 gdouble handle_y, 201 gint width, 202 gint height, 203 GimpHandleAnchor anchor); 204 205 206 #endif /* __GIMP_DRAW_TOOL_H__ */ 207