87
59
GIMP_CONTEXT_PATTERN_MASK,
90
_("Paint using Patterns or Image Regions"),
62
_("Clone Tool: Selectively copy from an image or pattern, using a brush"),
92
64
NULL, GIMP_HELP_TOOL_CLONE,
93
65
GIMP_STOCK_TOOL_CLONE,
98
gimp_clone_tool_get_type (void)
100
static GType tool_type = 0;
104
static const GTypeInfo tool_info =
106
sizeof (GimpCloneToolClass),
107
(GBaseInitFunc) NULL,
108
(GBaseFinalizeFunc) NULL,
109
(GClassInitFunc) gimp_clone_tool_class_init,
110
NULL, /* class_finalize */
111
NULL, /* class_data */
112
sizeof (GimpCloneTool),
114
(GInstanceInitFunc) gimp_clone_tool_init,
117
tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL,
126
70
gimp_clone_tool_class_init (GimpCloneToolClass *klass)
128
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
129
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
131
parent_class = g_type_class_peek_parent (klass);
133
tool_class->button_press = gimp_clone_tool_button_press;
134
tool_class->motion = gimp_clone_tool_motion;
135
tool_class->cursor_update = gimp_clone_tool_cursor_update;
137
draw_tool_class->draw = gimp_clone_tool_draw;
141
75
gimp_clone_tool_init (GimpCloneTool *clone)
143
GimpTool *tool = GIMP_TOOL (clone);
145
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CLONE);
149
gimp_clone_tool_button_press (GimpTool *tool,
152
GdkModifierType state,
155
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
156
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (tool);
158
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
160
GIMP_CLONE (paint_tool->core)->set_source = TRUE;
162
if (gdisp != clone_tool->src_gdisp)
164
if (clone_tool->src_gdisp)
165
g_object_remove_weak_pointer (G_OBJECT (clone_tool->src_gdisp),
166
(gpointer *) &clone_tool->src_gdisp);
168
clone_tool->src_gdisp = gdisp;
169
g_object_add_weak_pointer (G_OBJECT (gdisp),
170
(gpointer *) &clone_tool->src_gdisp);
174
GIMP_CLONE (paint_tool->core)->set_source = FALSE;
176
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
181
gimp_clone_tool_motion (GimpTool *tool,
184
GdkModifierType state,
187
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
189
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
190
GIMP_CLONE (paint_tool->core)->set_source = TRUE;
192
GIMP_CLONE (paint_tool->core)->set_source = FALSE;
194
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, gdisp);
198
gimp_clone_tool_cursor_update (GimpTool *tool,
200
GdkModifierType state,
203
GimpCloneOptions *options;
204
GimpCursorType ctype = GIMP_CURSOR_MOUSE;
206
options = (GimpCloneOptions *) tool->tool_info->tool_options;
208
if (gimp_image_coords_in_active_drawable (gdisp->gimage, coords))
210
GimpChannel *selection = gimp_image_get_mask (gdisp->gimage);
212
/* One more test--is there a selected region?
213
* if so, is cursor inside?
215
if (gimp_channel_is_empty (selection))
216
ctype = GIMP_CURSOR_MOUSE;
217
else if (gimp_channel_value (selection, coords->x, coords->y))
218
ctype = GIMP_CURSOR_MOUSE;
221
if (options->clone_type == GIMP_IMAGE_CLONE)
223
if ((state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
224
ctype = GIMP_CURSOR_CROSSHAIR_SMALL;
225
else if (! GIMP_CLONE (GIMP_PAINT_TOOL (tool)->core)->src_drawable)
226
ctype = GIMP_CURSOR_BAD;
229
gimp_tool_control_set_cursor (tool->control, ctype);
231
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
235
gimp_clone_tool_draw (GimpDrawTool *draw_tool)
237
GimpTool *tool = GIMP_TOOL (draw_tool);
239
if (gimp_tool_control_is_active (tool->control))
241
GimpClone *clone = GIMP_CLONE (GIMP_PAINT_TOOL (draw_tool)->core);
242
GimpCloneOptions *options;
244
options = (GimpCloneOptions *) tool->tool_info->tool_options;
246
if (options->clone_type == GIMP_IMAGE_CLONE && clone->src_drawable)
250
GimpDisplay *tmp_gdisp;
251
GimpCloneTool *clone_tool = GIMP_CLONE_TOOL (draw_tool);
253
gimp_item_offsets (GIMP_ITEM (clone->src_drawable), &off_x, &off_y);
255
tmp_gdisp = draw_tool->gdisp;
256
draw_tool->gdisp = clone_tool->src_gdisp;
258
if (draw_tool->gdisp)
259
gimp_draw_tool_draw_handle (draw_tool,
261
clone->src_x + off_x,
262
clone->src_y + off_y,
263
TARGET_WIDTH, TARGET_WIDTH,
267
draw_tool->gdisp = tmp_gdisp;
271
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
77
GimpTool *tool = GIMP_TOOL (clone);
78
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
79
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
81
gimp_tool_control_set_tool_cursor (tool->control,
82
GIMP_TOOL_CURSOR_CLONE);
83
gimp_tool_control_set_action_object_2 (tool->control,
84
"context/context-pattern-select-set");
86
paint_tool->status = _("Click to clone");
87
paint_tool->status_ctrl = _("%s to set a new clone source");
89
source_tool->status_paint = _("Click to clone");
90
source_tool->status_set_source = _("Click to set a new clone source");
91
source_tool->status_set_source_ctrl = _("%s to set a new clone source");
278
98
gimp_clone_options_gui (GimpToolOptions *tool_options)
280
100
GObject *config = G_OBJECT (tool_options);
101
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
282
102
GtkWidget *frame;
285
vbox = gimp_paint_options_gui (tool_options);
287
108
frame = gimp_prop_enum_radio_frame_new (config, "clone-type",
290
110
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
291
111
gtk_widget_show (frame);
293
hbox = gimp_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2);
113
button = gimp_prop_check_button_new (config, "sample-merged",
115
gimp_enum_radio_frame_add (GTK_FRAME (frame), button, GIMP_IMAGE_CLONE);
117
hbox = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
118
"pattern-view-type", "pattern-view-size");
294
119
gimp_enum_radio_frame_add (GTK_FRAME (frame), hbox, GIMP_PATTERN_CLONE);
296
frame = gimp_prop_enum_radio_frame_new (config, "align-mode",
299
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
300
gtk_widget_show (frame);
121
table = gtk_table_new (1, 2, FALSE);
122
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
123
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
124
gtk_widget_show (table);
126
combo = gimp_prop_enum_combo_box_new (config, "align-mode", 0, 0);
127
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
128
_("Alignment:"), 0.0, 0.5,