1 #define __SP_CLONE_TILER_C__
3 /*
4 * Clone tiling dialog
5 *
6 * Authors:
7 * bulia byak <buliabyak@users.sf.net>
8 *
9 * Copyright (C) 2004-2005 Authors
10 * Released under GNU GPL
11 */
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16 #include <glib/gmem.h>
17 #include <gtk/gtk.h>
18 #include <glibmm/i18n.h>
20 #include "application/application.h"
21 #include "application/editor.h"
22 #include "helper/window.h"
23 #include "helper/unit-menu.h"
24 #include "helper/units.h"
25 #include "widgets/icon.h"
26 #include "../inkscape.h"
27 #include "../prefs-utils.h"
28 #include "dialog-events.h"
29 #include "../macros.h"
30 #include "../verbs.h"
31 #include "../interface.h"
32 #include "../selection.h"
33 #include "../style.h"
34 #include "../desktop.h"
35 #include "../desktop-handles.h"
36 #include "../sp-namedview.h"
37 #include "../document.h"
38 #include "../message-stack.h"
39 #include "../sp-use.h"
40 #include "unclump.h"
42 #include "xml/repr.h"
44 #include "svg/svg.h"
45 #include "svg/svg-color.h"
47 #include "libnr/nr-matrix-fns.h"
48 #include "libnr/nr-matrix-ops.h"
50 #include "libnr/nr-matrix-translate-ops.h"
51 #include "libnr/nr-translate-ops.h"
52 #include "libnr/nr-translate-rotate-ops.h"
53 #include "libnr/nr-translate-scale-ops.h"
55 #include "display/nr-arena.h"
56 #include "display/nr-arena-item.h"
58 #include "ui/widget/color-picker.h"
60 static GtkWidget *dlg = NULL;
61 static win_data wd;
63 // impossible original values to make sure they are read from prefs
64 static gint x = -1000, y = -1000, w = 0, h = 0;
65 static gchar *prefs_path = "dialogs.clonetiler";
67 #define SB_MARGIN 1
68 #define VB_MARGIN 4
70 enum {
71 PICK_COLOR,
72 PICK_OPACITY,
73 PICK_R,
74 PICK_G,
75 PICK_B,
76 PICK_H,
77 PICK_S,
78 PICK_L
79 };
81 static GtkSizeGroup* table_row_labels = NULL;
83 static sigc::connection _shutdown_connection;
84 static sigc::connection _dialogs_hidden_connection;
85 static sigc::connection _dialogs_unhidden_connection;
86 static sigc::connection _desktop_activated_connection;
87 static sigc::connection _color_changed_connection;
89 static Inkscape::UI::Widget::ColorPicker *color_picker;
91 static void
92 clonetiler_dialog_destroy (GtkObject *object, gpointer data)
93 {
94 if (Inkscape::NSApplication::Application::getNewGui())
95 {
96 _shutdown_connection.disconnect();
97 _dialogs_hidden_connection.disconnect();
98 _dialogs_unhidden_connection.disconnect();
99 _desktop_activated_connection.disconnect();
100 } else {
101 sp_signal_disconnect_by_data (INKSCAPE, dlg);
102 }
103 _color_changed_connection.disconnect();
105 delete color_picker;
107 wd.win = dlg = NULL;
108 wd.stop = 0;
110 }
112 static gboolean
113 clonetiler_dialog_delete (GtkObject *object, GdkEvent * /*event*/, gpointer data)
114 {
115 gtk_window_get_position ((GtkWindow *) dlg, &x, &y);
116 gtk_window_get_size ((GtkWindow *) dlg, &w, &h);
118 if (x<0) x=0;
119 if (y<0) y=0;
121 prefs_set_int_attribute (prefs_path, "x", x);
122 prefs_set_int_attribute (prefs_path, "y", y);
123 prefs_set_int_attribute (prefs_path, "w", w);
124 prefs_set_int_attribute (prefs_path, "h", h);
126 return FALSE; // which means, go ahead and destroy it
128 }
130 static void on_delete()
131 {
132 (void)clonetiler_dialog_delete (0, 0, NULL);
133 }
135 static void
136 on_picker_color_changed (guint rgba)
137 {
138 static bool is_updating = false;
139 if (is_updating || !SP_ACTIVE_DESKTOP)
140 return;
142 is_updating = true;
144 Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, prefs_path);
145 gchar c[32];
146 sp_svg_write_color(c, 32, rgba);
147 repr->setAttribute("initial_color", c);
149 is_updating = false;
150 }
152 static guint clonetiler_number_of_clones (SPObject *obj);
154 static void
155 clonetiler_change_selection (Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg)
156 {
157 GtkWidget *buttons = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles");
158 GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status");
160 if (selection->isEmpty()) {
161 gtk_widget_set_sensitive (buttons, FALSE);
162 gtk_label_set_markup (GTK_LABEL(status), _("<small>Nothing selected.</small>"));
163 return;
164 }
166 if (g_slist_length ((GSList *) selection->itemList()) > 1) {
167 gtk_widget_set_sensitive (buttons, FALSE);
168 gtk_label_set_markup (GTK_LABEL(status), _("<small>More than one object selected.</small>"));
169 return;
170 }
172 guint n = clonetiler_number_of_clones(selection->singleItem());
173 if (n > 0) {
174 gtk_widget_set_sensitive (buttons, TRUE);
175 gchar *sta = g_strdup_printf (_("<small>Object has <b>%d</b> tiled clones.</small>"), n);
176 gtk_label_set_markup (GTK_LABEL(status), sta);
177 g_free (sta);
178 } else {
179 gtk_widget_set_sensitive (buttons, FALSE);
180 gtk_label_set_markup (GTK_LABEL(status), _("<small>Object has no tiled clones.</small>"));
181 }
182 }
184 static void
185 clonetiler_external_change (Inkscape::Application * /*inkscape*/, GtkWidget *dlg)
186 {
187 clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
188 }
190 static void clonetiler_disconnect_gsignal (GObject *widget, gpointer source) {
191 if (source && G_IS_OBJECT(source))
192 sp_signal_disconnect_by_data (source, widget);
193 }
196 enum {
197 TILE_P1,
198 TILE_P2,
199 TILE_PM,
200 TILE_PG,
201 TILE_CM,
202 TILE_PMM,
203 TILE_PMG,
204 TILE_PGG,
205 TILE_CMM,
206 TILE_P4,
207 TILE_P4M,
208 TILE_P4G,
209 TILE_P3,
210 TILE_P31M,
211 TILE_P3M1,
212 TILE_P6,
213 TILE_P6M
214 };
217 static NR::Matrix
218 clonetiler_get_transform (
219 // symmetry group
220 int type,
221 // row, column
222 int x, int y,
223 // center, width, height of the tile
224 double cx, double cy,
225 double w, double h,
227 // values from the dialog:
228 double d_x_per_x, double d_y_per_x, double d_x_per_y, double d_y_per_y,
229 int alternate_x, int alternate_y, double rand_x, double rand_y,
230 double d_per_x_exp, double d_per_y_exp,
231 double d_rot_per_x, double d_rot_per_y, int alternate_rotx, int alternate_roty, double rand_rot,
232 double d_scalex_per_x, double d_scaley_per_x, double d_scalex_per_y, double d_scaley_per_y,
233 int alternate_scalex, int alternate_scaley, double rand_scalex, double rand_scaley
234 )
235 {
236 // in abs units
237 double eff_x = (alternate_x? (x%2) : pow ((double) x, d_per_x_exp));
238 double eff_y = (alternate_y? (y%2) : pow ((double) y, d_per_y_exp));
239 double dx = d_x_per_x * w * eff_x + d_x_per_y * w * eff_y + rand_x * w * g_random_double_range (-1, 1);
240 double dy = d_y_per_x * h * eff_x + d_y_per_y * h * eff_y + rand_y * h * g_random_double_range (-1, 1);
242 NR::Matrix rect_translate (NR::translate (w * pow ((double) x, d_per_x_exp) + dx, h * pow ((double) y, d_per_y_exp) + dy));
244 // in deg
245 double eff_x_rot = (alternate_rotx? (x%2) : (x));
246 double eff_y_rot = (alternate_roty? (y%2) : (y));
247 double drot = d_rot_per_x * eff_x_rot + d_rot_per_y * eff_y_rot + rand_rot * 180 * g_random_double_range (-1, 1);
249 // times the original
250 double eff_x_s = (alternate_scalex? (x%2) : (x));
251 double eff_y_s = (alternate_scaley? (y%2) : (y));
252 double rand_scale_x, rand_scale_y;
253 if (rand_scaley == rand_scalex) {
254 // if rands are equal, scale proportionally
255 rand_scale_x = rand_scale_y = rand_scalex * 1 * g_random_double_range (-1, 1);
256 } else {
257 rand_scale_x = rand_scalex * 1 * g_random_double_range (-1, 1);
258 rand_scale_y = rand_scaley * 1 * g_random_double_range (-1, 1);
259 }
260 double dscalex = 1 + d_scalex_per_x * eff_x_s + d_scalex_per_y * eff_y_s + rand_scale_x;
261 if (dscalex < 0) dscalex = 0;
262 double dscaley = 1 + d_scaley_per_x * eff_x_s + d_scaley_per_y * eff_y_s + rand_scale_y;
263 if (dscaley < 0) dscaley = 0;
265 NR::Matrix drot_c = NR::translate(-cx, -cy) * NR::rotate (M_PI*drot/180) * NR::translate(cx, cy);
267 NR::Matrix dscale_c = NR::translate(-cx, -cy) * NR::scale (dscalex, dscaley) * NR::translate(cx, cy);
269 NR::Matrix d_s_r = dscale_c * drot_c;
271 NR::Matrix rotate_180_c = NR::translate(-cx, -cy) * NR::rotate (M_PI) * NR::translate(cx, cy);
273 NR::Matrix rotate_90_c = NR::translate(-cx, -cy) * NR::rotate (-M_PI/2) * NR::translate(cx, cy);
274 NR::Matrix rotate_m90_c = NR::translate(-cx, -cy) * NR::rotate (M_PI/2) * NR::translate(cx, cy);
276 NR::Matrix rotate_120_c = NR::translate(-cx, -cy) * NR::rotate (-2*M_PI/3) * NR::translate(cx, cy);
277 NR::Matrix rotate_m120_c = NR::translate(-cx, -cy) * NR::rotate (2*M_PI/3) * NR::translate(cx, cy);
279 NR::Matrix rotate_60_c = NR::translate(-cx, -cy) * NR::rotate (-M_PI/3) * NR::translate(cx, cy);
280 NR::Matrix rotate_m60_c = NR::translate(-cx, -cy) * NR::rotate (M_PI/3) * NR::translate(cx, cy);
282 double cos60 = cos(M_PI/3);
283 double sin60 = sin(M_PI/3);
284 double cos30 = cos(M_PI/6);
285 double sin30 = sin(M_PI/6);
287 NR::Matrix flip_x = NR::translate(-cx, -cy) * NR::scale (-1, 1) * NR::translate(cx, cy);
288 NR::Matrix flip_y = NR::translate(-cx, -cy) * NR::scale (1, -1) * NR::translate(cx, cy);
290 x = (int) pow ((double) x, d_per_x_exp);
291 y = (int) pow ((double) y, d_per_y_exp);
293 switch (type) {
295 case TILE_P1:
296 return d_s_r * rect_translate;
297 break;
299 case TILE_P2:
300 if (x % 2 == 0) {
301 return d_s_r * rect_translate;
302 } else {
303 return d_s_r * rotate_180_c * rect_translate;
304 }
305 break;
307 case TILE_PM:
308 if (x % 2 == 0) {
309 return d_s_r * rect_translate;
310 } else {
311 return d_s_r * flip_x * rect_translate;
312 }
313 break;
315 case TILE_PG:
316 if (y % 2 == 0) {
317 return d_s_r * rect_translate;
318 } else {
319 return d_s_r * flip_x * rect_translate;
320 }
321 break;
323 case TILE_CM:
324 if ((x + y) % 2 == 0) {
325 return d_s_r * rect_translate;
326 } else {
327 return d_s_r * flip_x * rect_translate;
328 }
329 break;
331 case TILE_PMM:
332 if (y % 2 == 0) {
333 if (x % 2 == 0) {
334 return d_s_r * rect_translate;
335 } else {
336 return d_s_r * flip_x * rect_translate;
337 }
338 } else {
339 if (x % 2 == 0) {
340 return d_s_r * flip_y * rect_translate;
341 } else {
342 return d_s_r * flip_x * flip_y * rect_translate;
343 }
344 }
345 break;
347 case TILE_PMG:
348 if (y % 4 == 0) {
349 return d_s_r * rect_translate;
350 } else if (y % 4 == 1) {
351 return d_s_r * flip_y * rect_translate;
352 } else if (y % 4 == 2) {
353 return d_s_r * flip_x * rect_translate;
354 } else if (y % 4 == 3) {
355 return d_s_r * flip_x * flip_y * rect_translate;
356 }
357 break;
359 case TILE_PGG:
360 if (y % 2 == 0) {
361 if (x % 2 == 0) {
362 return d_s_r * rect_translate;
363 } else {
364 return d_s_r * flip_y * rect_translate;
365 }
366 } else {
367 if (x % 2 == 0) {
368 return d_s_r * rotate_180_c * rect_translate;
369 } else {
370 return d_s_r * rotate_180_c * flip_y * rect_translate;
371 }
372 }
373 break;
375 case TILE_CMM:
376 if (y % 4 == 0) {
377 if (x % 2 == 0) {
378 return d_s_r * rect_translate;
379 } else {
380 return d_s_r * flip_x * rect_translate;
381 }
382 } else if (y % 4 == 1) {
383 if (x % 2 == 0) {
384 return d_s_r * flip_y * rect_translate;
385 } else {
386 return d_s_r * flip_x * flip_y * rect_translate;
387 }
388 } else if (y % 4 == 2) {
389 if (x % 2 == 1) {
390 return d_s_r * rect_translate;
391 } else {
392 return d_s_r * flip_x * rect_translate;
393 }
394 } else {
395 if (x % 2 == 1) {
396 return d_s_r * flip_y * rect_translate;
397 } else {
398 return d_s_r * flip_x * flip_y * rect_translate;
399 }
400 }
401 break;
403 case TILE_P4:
404 {
405 NR::Matrix ori (NR::translate ((w + h) * (x/2) + dx, (h + w) * (y/2) + dy));
406 NR::Matrix dia1 (NR::translate (w/2 + h/2, -h/2 + w/2));
407 NR::Matrix dia2 (NR::translate (-w/2 + h/2, h/2 + w/2));
408 if (y % 2 == 0) {
409 if (x % 2 == 0) {
410 return d_s_r * ori;
411 } else {
412 return d_s_r * rotate_m90_c * dia1 * ori;
413 }
414 } else {
415 if (x % 2 == 0) {
416 return d_s_r * rotate_90_c * dia2 * ori;
417 } else {
418 return d_s_r * rotate_180_c * dia1 * dia2 * ori;
419 }
420 }
421 }
422 break;
424 case TILE_P4M:
425 {
426 double max = MAX(w, h);
427 NR::Matrix ori (NR::translate ((max + max) * (x/4) + dx, (max + max) * (y/2) + dy));
428 NR::Matrix dia1 (NR::translate (w/2 - h/2, h/2 - w/2));
429 NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 - h/2));
430 if (y % 2 == 0) {
431 if (x % 4 == 0) {
432 return d_s_r * ori;
433 } else if (x % 4 == 1) {
434 return d_s_r * flip_y * rotate_m90_c * dia1 * ori;
435 } else if (x % 4 == 2) {
436 return d_s_r * rotate_m90_c * dia1 * NR::translate (h, 0) * ori;
437 } else if (x % 4 == 3) {
438 return d_s_r * flip_x * NR::translate (w, 0) * ori;
439 }
440 } else {
441 if (x % 4 == 0) {
442 return d_s_r * flip_y * NR::translate(0, h) * ori;
443 } else if (x % 4 == 1) {
444 return d_s_r * rotate_90_c * dia2 * NR::translate(0, h) * ori;
445 } else if (x % 4 == 2) {
446 return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate(h, 0) * NR::translate(0, h) * ori;
447 } else if (x % 4 == 3) {
448 return d_s_r * flip_y * flip_x * NR::translate(w, 0) * NR::translate(0, h) * ori;
449 }
450 }
451 }
452 break;
454 case TILE_P4G:
455 {
456 double max = MAX(w, h);
457 NR::Matrix ori (NR::translate ((max + max) * (x/4) + dx, (max + max) * y + dy));
458 NR::Matrix dia1 (NR::translate (w/2 + h/2, h/2 - w/2));
459 NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 + h/2));
460 if (((x/4) + y) % 2 == 0) {
461 if (x % 4 == 0) {
462 return d_s_r * ori;
463 } else if (x % 4 == 1) {
464 return d_s_r * rotate_m90_c * dia1 * ori;
465 } else if (x % 4 == 2) {
466 return d_s_r * rotate_90_c * dia2 * ori;
467 } else if (x % 4 == 3) {
468 return d_s_r * rotate_180_c * dia1 * dia2 * ori;
469 }
470 } else {
471 if (x % 4 == 0) {
472 return d_s_r * flip_y * NR::translate (0, h) * ori;
473 } else if (x % 4 == 1) {
474 return d_s_r * flip_y * rotate_m90_c * dia1 * NR::translate (-h, 0) * ori;
475 } else if (x % 4 == 2) {
476 return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate (h, 0) * ori;
477 } else if (x % 4 == 3) {
478 return d_s_r * flip_x * NR::translate (w, 0) * ori;
479 }
480 }
481 }
482 break;
484 case TILE_P3:
485 {
486 double width;
487 double height;
488 NR::Matrix dia1;
489 NR::Matrix dia2;
490 if (w > h) {
491 width = w + w * cos60;
492 height = 2 * w * sin60;
493 dia1 = NR::Matrix (NR::translate (w/2 + w/2 * cos60, -(w/2 * sin60)));
494 dia2 = dia1 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60)));
495 } else {
496 width = h * cos (M_PI/6);
497 height = h;
498 dia1 = NR::Matrix (NR::translate (h/2 * cos30, -(h/2 * sin30)));
499 dia2 = dia1 * NR::Matrix (NR::translate (0, h/2));
500 }
501 NR::Matrix ori (NR::translate (width * (2*(x/3) + y%2) + dx, (height/2) * y + dy));
502 if (x % 3 == 0) {
503 return d_s_r * ori;
504 } else if (x % 3 == 1) {
505 return d_s_r * rotate_m120_c * dia1 * ori;
506 } else if (x % 3 == 2) {
507 return d_s_r * rotate_120_c * dia2 * ori;
508 }
509 }
510 break;
512 case TILE_P31M:
513 {
514 NR::Matrix ori;
515 NR::Matrix dia1;
516 NR::Matrix dia2;
517 NR::Matrix dia3;
518 NR::Matrix dia4;
519 if (w > h) {
520 ori = NR::Matrix(NR::translate (w * (x/6) + w/2 * (y%2) + dx, (w * cos30) * y + dy));
521 dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) );
522 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
523 dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
524 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
525 } else {
526 ori = NR::Matrix (NR::translate (2*h * cos30 * (x/6 + 0.5*(y%2)) + dx, (2*h - h * sin30) * y + dy));
527 dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30));
528 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
529 dia3 = dia2 * NR::Matrix (NR::translate (0, h/2));
530 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
531 }
532 if (x % 6 == 0) {
533 return d_s_r * ori;
534 } else if (x % 6 == 1) {
535 return d_s_r * flip_y * rotate_m120_c * dia1 * ori;
536 } else if (x % 6 == 2) {
537 return d_s_r * rotate_m120_c * dia2 * ori;
538 } else if (x % 6 == 3) {
539 return d_s_r * flip_y * rotate_120_c * dia3 * ori;
540 } else if (x % 6 == 4) {
541 return d_s_r * rotate_120_c * dia4 * ori;
542 } else if (x % 6 == 5) {
543 return d_s_r * flip_y * NR::translate(0, h) * ori;
544 }
545 }
546 break;
548 case TILE_P3M1:
549 {
550 double width;
551 double height;
552 NR::Matrix dia1;
553 NR::Matrix dia2;
554 NR::Matrix dia3;
555 NR::Matrix dia4;
556 if (w > h) {
557 width = w + w * cos60;
558 height = 2 * w * sin60;
559 dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) );
560 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
561 dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
562 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
563 } else {
564 width = 2 * h * cos (M_PI/6);
565 height = 2 * h;
566 dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30));
567 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
568 dia3 = dia2 * NR::Matrix (NR::translate (0, h/2));
569 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
570 }
571 NR::Matrix ori (NR::translate (width * (2*(x/6) + y%2) + dx, (height/2) * y + dy));
572 if (x % 6 == 0) {
573 return d_s_r * ori;
574 } else if (x % 6 == 1) {
575 return d_s_r * flip_y * rotate_m120_c * dia1 * ori;
576 } else if (x % 6 == 2) {
577 return d_s_r * rotate_m120_c * dia2 * ori;
578 } else if (x % 6 == 3) {
579 return d_s_r * flip_y * rotate_120_c * dia3 * ori;
580 } else if (x % 6 == 4) {
581 return d_s_r * rotate_120_c * dia4 * ori;
582 } else if (x % 6 == 5) {
583 return d_s_r * flip_y * NR::translate(0, h) * ori;
584 }
585 }
586 break;
588 case TILE_P6:
589 {
590 NR::Matrix ori;
591 NR::Matrix dia1;
592 NR::Matrix dia2;
593 NR::Matrix dia3;
594 NR::Matrix dia4;
595 NR::Matrix dia5;
596 if (w > h) {
597 ori = NR::Matrix(NR::translate (2*w * (x/6) + w * (y%2) + dx, (2*w * sin60) * y + dy));
598 dia1 = NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60));
599 dia2 = dia1 * NR::Matrix (NR::translate (w/2, 0));
600 dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, w/2 * sin60));
601 dia4 = dia3 * NR::Matrix (NR::translate (-w/2 * cos60, w/2 * sin60));
602 dia5 = dia4 * NR::Matrix (NR::translate (-w/2, 0));
603 } else {
604 ori = NR::Matrix(NR::translate (2*h * cos30 * (x/6 + 0.5*(y%2)) + dx, (h + h * sin30) * y + dy));
605 dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60));
606 dia2 = dia1 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60));
607 dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2));
608 dia4 = dia3 * dia1.inverse();
609 dia5 = dia3 * dia2.inverse();
610 }
611 if (x % 6 == 0) {
612 return d_s_r * ori;
613 } else if (x % 6 == 1) {
614 return d_s_r * rotate_m60_c * dia1 * ori;
615 } else if (x % 6 == 2) {
616 return d_s_r * rotate_m120_c * dia2 * ori;
617 } else if (x % 6 == 3) {
618 return d_s_r * rotate_180_c * dia3 * ori;
619 } else if (x % 6 == 4) {
620 return d_s_r * rotate_120_c * dia4 * ori;
621 } else if (x % 6 == 5) {
622 return d_s_r * rotate_60_c * dia5 * ori;
623 }
624 }
625 break;
627 case TILE_P6M:
628 {
630 NR::Matrix ori;
631 NR::Matrix dia1, dia2, dia3, dia4, dia5, dia6, dia7, dia8, dia9, dia10;
632 if (w > h) {
633 ori = NR::Matrix(NR::translate (2*w * (x/12) + w * (y%2) + dx, (2*w * sin60) * y + dy));
634 dia1 = NR::Matrix (NR::translate (w/2, h/2) * NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, h/2 * sin30));
635 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30));
636 dia3 = dia2 * NR::Matrix (NR::translate (-h/2 * cos30, h/2 * sin30) * NR::translate (w * cos60, 0) * NR::translate (-h/2 * cos30, -h/2 * sin30));
637 dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30));
638 dia5 = dia4 * NR::Matrix (NR::translate (-h/2 * cos30, -h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60) * NR::translate (w/2, -h/2));
639 dia6 = dia5 * NR::Matrix (NR::translate (0, h));
640 dia7 = dia6 * dia1.inverse();
641 dia8 = dia6 * dia2.inverse();
642 dia9 = dia6 * dia3.inverse();
643 dia10 = dia6 * dia4.inverse();
644 } else {
645 ori = NR::Matrix(NR::translate (4*h * cos30 * (x/12 + 0.5*(y%2)) + dx, (2*h + 2*h * sin30) * y + dy));
646 dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60));
647 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30));
648 dia3 = dia2 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h * cos30, 0) * NR::translate (-w/2 * cos60, w/2 * sin60));
649 dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30));
650 dia5 = dia4 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2));
651 dia6 = dia5 * NR::Matrix (NR::translate (0, h));
652 dia7 = dia6 * dia1.inverse();
653 dia8 = dia6 * dia2.inverse();
654 dia9 = dia6 * dia3.inverse();
655 dia10 = dia6 * dia4.inverse();
656 }
657 if (x % 12 == 0) {
658 return d_s_r * ori;
659 } else if (x % 12 == 1) {
660 return d_s_r * flip_y * rotate_m60_c * dia1 * ori;
661 } else if (x % 12 == 2) {
662 return d_s_r * rotate_m60_c * dia2 * ori;
663 } else if (x % 12 == 3) {
664 return d_s_r * flip_y * rotate_m120_c * dia3 * ori;
665 } else if (x % 12 == 4) {
666 return d_s_r * rotate_m120_c * dia4 * ori;
667 } else if (x % 12 == 5) {
668 return d_s_r * flip_x * dia5 * ori;
669 } else if (x % 12 == 6) {
670 return d_s_r * flip_x * flip_y * dia6 * ori;
671 } else if (x % 12 == 7) {
672 return d_s_r * flip_y * rotate_120_c * dia7 * ori;
673 } else if (x % 12 == 8) {
674 return d_s_r * rotate_120_c * dia8 * ori;
675 } else if (x % 12 == 9) {
676 return d_s_r * flip_y * rotate_60_c * dia9 * ori;
677 } else if (x % 12 == 10) {
678 return d_s_r * rotate_60_c * dia10 * ori;
679 } else if (x % 12 == 11) {
680 return d_s_r * flip_y * NR::translate (0, h) * ori;
681 }
682 }
683 break;
685 default:
686 break;
687 }
689 return NR::identity();
690 }
692 static bool
693 clonetiler_is_a_clone_of (SPObject *tile, SPObject *obj)
694 {
695 char *id_href = NULL;
697 if (obj) {
698 Inkscape::XML::Node *obj_repr = SP_OBJECT_REPR(obj);
699 id_href = g_strdup_printf("#%s", obj_repr->attribute("id"));
700 }
702 if (SP_IS_USE(tile) &&
703 SP_OBJECT_REPR(tile)->attribute("xlink:href") &&
704 (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("xlink:href"))) &&
705 SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of") &&
706 (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of"))))
707 {
708 if (id_href)
709 g_free (id_href);
710 return true;
711 } else {
712 if (id_href)
713 g_free (id_href);
714 return false;
715 }
716 }
718 static NRArena const *trace_arena = NULL;
719 static unsigned trace_visionkey;
720 static NRArenaItem *trace_root;
721 static gdouble trace_zoom;
723 static void
724 clonetiler_trace_hide_tiled_clones_recursively (SPObject *from)
725 {
726 if (!trace_arena)
727 return;
729 for (SPObject *o = sp_object_first_child(from); o != NULL; o = SP_OBJECT_NEXT(o)) {
730 if (SP_IS_ITEM(o) && clonetiler_is_a_clone_of (o, NULL))
731 sp_item_invoke_hide(SP_ITEM(o), trace_visionkey); // FIXME: hide each tiled clone's original too!
732 clonetiler_trace_hide_tiled_clones_recursively (o);
733 }
734 }
736 static void
737 clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original)
738 {
739 trace_arena = NRArena::create();
740 /* Create ArenaItem and set transform */
741 trace_visionkey = sp_item_display_key_new(1);
742 trace_root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT (doc)),
743 (NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY);
745 // hide the (current) original and any tiled clones, we only want to pick the background
746 sp_item_invoke_hide(original, trace_visionkey);
747 clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (doc)));
749 sp_document_root (doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
750 sp_document_ensure_up_to_date(doc);
752 trace_zoom = zoom;
753 }
755 static guint32
756 clonetiler_trace_pick (NR::Rect box)
757 {
758 if (!trace_arena)
759 return 0;
761 NRMatrix t;
762 nr_matrix_set_scale(&t, trace_zoom, trace_zoom);
763 nr_arena_item_set_transform(trace_root, &t);
764 NRGC gc(NULL);
765 nr_matrix_set_identity(&gc.transform);
766 nr_arena_item_invoke_update( trace_root, NULL, &gc,
767 NR_ARENA_ITEM_STATE_ALL,
768 NR_ARENA_ITEM_STATE_NONE );
770 /* Item integer bbox in points */
771 NRRectL ibox;
772 ibox.x0 = (int) floor(trace_zoom * box.min()[NR::X] + 0.5);
773 ibox.y0 = (int) floor(trace_zoom * box.min()[NR::Y] + 0.5);
774 ibox.x1 = (int) floor(trace_zoom * box.max()[NR::X] + 0.5);
775 ibox.y1 = (int) floor(trace_zoom * box.max()[NR::Y] + 0.5);
777 /* Find visible area */
778 int width = ibox.x1 - ibox.x0;
779 int height = ibox.y1 - ibox.y0;
781 /* Set up pixblock */
782 guchar *px = g_new(guchar, 4 * width * height);
783 memset(px, 0x00, 4 * width * height);
785 /* Render */
786 NRPixBlock pb;
787 nr_pixblock_setup_extern( &pb, NR_PIXBLOCK_MODE_R8G8B8A8N,
788 ibox.x0, ibox.y0, ibox.x1, ibox.y1,
789 px, 4 * width, FALSE, FALSE );
790 nr_arena_item_invoke_render( trace_root, &ibox, &pb,
791 NR_ARENA_ITEM_RENDER_NO_CACHE );
793 double R = 0, G = 0, B = 0, A = 0;
794 double count = 0;
795 double weight = 0;
797 for (int y = ibox.y0; y < ibox.y1; y++) {
798 const unsigned char *s = NR_PIXBLOCK_PX (&pb) + (y - ibox.y0) * pb.rs;
799 for (int x = ibox.x0; x < ibox.x1; x++) {
800 count += 1;
801 weight += s[3] / 255.0;
802 R += s[0] / 255.0;
803 G += s[1] / 255.0;
804 B += s[2] / 255.0;
805 A += s[3] / 255.0;
806 s += 4;
807 }
808 }
810 nr_pixblock_release(&pb);
812 R = R / weight;
813 G = G / weight;
814 B = B / weight;
815 A = A / count;
817 R = CLAMP (R, 0.0, 1.0);
818 G = CLAMP (G, 0.0, 1.0);
819 B = CLAMP (B, 0.0, 1.0);
820 A = CLAMP (A, 0.0, 1.0);
822 return SP_RGBA32_F_COMPOSE (R, G, B, A);
823 }
825 static void
826 clonetiler_trace_finish ()
827 {
828 if (trace_arena) {
829 ((NRObject *) trace_arena)->unreference();
830 trace_arena = NULL;
831 }
832 }
834 static void
835 clonetiler_unclump (GtkWidget *widget, void *)
836 {
837 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
838 if (desktop == NULL)
839 return;
841 Inkscape::Selection *selection = sp_desktop_selection(desktop);
843 // check if something is selected
844 if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
845 sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
846 return;
847 }
849 SPObject *obj = SP_OBJECT(selection->singleItem());
850 SPObject *parent = SP_OBJECT_PARENT (obj);
852 GSList *to_unclump = NULL; // not including the original
854 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
855 if (clonetiler_is_a_clone_of (child, obj)) {
856 to_unclump = g_slist_prepend (to_unclump, child);
857 }
858 }
860 sp_document_ensure_up_to_date(sp_desktop_document(desktop));
862 unclump (to_unclump);
864 g_slist_free (to_unclump);
866 sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER,
867 /* TODO: annotate */ "clonetiler.cpp:867");
868 }
870 static guint
871 clonetiler_number_of_clones (SPObject *obj)
872 {
873 SPObject *parent = SP_OBJECT_PARENT (obj);
875 guint n = 0;
877 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
878 if (clonetiler_is_a_clone_of (child, obj)) {
879 n ++;
880 }
881 }
883 return n;
884 }
886 static void
887 clonetiler_remove (GtkWidget *widget, void *, bool do_undo = true)
888 {
889 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
890 if (desktop == NULL)
891 return;
893 Inkscape::Selection *selection = sp_desktop_selection(desktop);
895 // check if something is selected
896 if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
897 sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
898 return;
899 }
901 SPObject *obj = SP_OBJECT(selection->singleItem());
902 SPObject *parent = SP_OBJECT_PARENT (obj);
904 // remove old tiling
905 GSList *to_delete = NULL;
906 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
907 if (clonetiler_is_a_clone_of (child, obj)) {
908 to_delete = g_slist_prepend (to_delete, child);
909 }
910 }
911 for (GSList *i = to_delete; i; i = i->next) {
912 SP_OBJECT(i->data)->deleteObject();
913 }
914 g_slist_free (to_delete);
916 clonetiler_change_selection (NULL, selection, dlg);
918 if (do_undo)
919 sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER,
920 /* TODO: annotate */ "clonetiler.cpp:920");
921 }
923 static NR::Rect
924 transform_rect(NR::Rect const &r, NR::Matrix const &m)
925 {
926 using NR::X;
927 using NR::Y;
928 NR::Point const p1 = r.corner(1) * m;
929 NR::Point const p2 = r.corner(2) * m;
930 NR::Point const p3 = r.corner(3) * m;
931 NR::Point const p4 = r.corner(4) * m;
932 return NR::Rect(
933 NR::Point(
934 std::min(std::min(p1[X], p2[X]), std::min(p3[X], p4[X])),
935 std::min(std::min(p1[Y], p2[Y]), std::min(p3[Y], p4[Y]))),
936 NR::Point(
937 std::max(std::max(p1[X], p2[X]), std::max(p3[X], p4[X])),
938 std::max(std::max(p1[Y], p2[Y]), std::max(p3[Y], p4[Y]))));
939 }
941 /**
942 Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same
943 probability of being displaced.
944 */
945 static double
946 randomize01 (double val, double rand)
947 {
948 double base = MIN (val - rand, 1 - 2*rand);
949 if (base < 0) base = 0;
950 val = base + g_random_double_range (0, MIN (2 * rand, 1 - base));
951 return CLAMP(val, 0, 1); // this should be unnecessary with the above provisions, but just in case...
952 }
955 static void
956 clonetiler_apply (GtkWidget *widget, void *)
957 {
958 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
959 if (desktop == NULL)
960 return;
962 Inkscape::Selection *selection = sp_desktop_selection(desktop);
964 // check if something is selected
965 if (selection->isEmpty()) {
966 sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
967 return;
968 }
970 // Check if more than one object is selected.
971 if (g_slist_length((GSList *) selection->itemList()) > 1) {
972 sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
973 return;
974 }
976 SPObject *obj = SP_OBJECT(selection->singleItem());
977 Inkscape::XML::Node *obj_repr = SP_OBJECT_REPR(obj);
978 const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id"));
979 SPObject *parent = SP_OBJECT_PARENT (obj);
981 clonetiler_remove (NULL, NULL, false);
983 double d_x_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_x_per_x", 0, -100, 1000);
984 double d_y_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_y_per_x", 0, -100, 1000);
985 double d_per_x_exp = prefs_get_double_attribute_limited (prefs_path, "d_per_x_exp", 1, 0, 10);
986 double d_x_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_x_per_y", 0, -100, 1000);
987 double d_y_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_y_per_y", 0, -100, 1000);
988 double d_per_y_exp = prefs_get_double_attribute_limited (prefs_path, "d_per_y_exp", 1, 0, 10);
989 int alternate_x = prefs_get_int_attribute (prefs_path, "alternate_x", 0);
990 int alternate_y = prefs_get_int_attribute (prefs_path, "alternate_y", 0);
991 double rand_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_x", 0, 0, 1000);
992 double rand_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_y", 0, 0, 1000);
994 double d_scalex_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scalex_per_x", 0, -100, 1000);
995 double d_scaley_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scaley_per_x", 0, -100, 1000);
996 double d_scalex_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scalex_per_y", 0, -100, 1000);
997 double d_scaley_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scaley_per_y", 0, -100, 1000);
998 int alternate_scalex = prefs_get_int_attribute (prefs_path, "alternate_scalex", 0);
999 int alternate_scaley = prefs_get_int_attribute (prefs_path, "alternate_scaley", 0);
1000 double rand_scalex = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scalex", 0, 0, 1000);
1001 double rand_scaley = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scaley", 0, 0, 1000);
1003 double d_rot_per_x = prefs_get_double_attribute_limited (prefs_path, "d_rot_per_x", 0, -180, 180);
1004 double d_rot_per_y = prefs_get_double_attribute_limited (prefs_path, "d_rot_per_y", 0, -180, 180);
1005 int alternate_rotx = prefs_get_int_attribute (prefs_path, "alternate_rotx", 0);
1006 int alternate_roty = prefs_get_int_attribute (prefs_path, "alternate_roty", 0);
1007 double rand_rot = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_rot", 0, 0, 100);
1009 double d_opacity_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_y", 0, 0, 100);
1010 double d_opacity_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_x", 0, 0, 100);
1011 int alternate_opacityy = prefs_get_int_attribute (prefs_path, "alternate_opacityy", 0);
1012 int alternate_opacityx = prefs_get_int_attribute (prefs_path, "alternate_opacityx", 0);
1013 double rand_opacity = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_opacity", 0, 0, 100);
1015 const gchar *initial_color = prefs_get_string_attribute (prefs_path, "initial_color");
1016 double d_hue_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_hue_per_y", 0, -100, 100);
1017 double d_hue_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_hue_per_x", 0, -100, 100);
1018 double rand_hue = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_hue", 0, 0, 100);
1019 double d_saturation_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_saturation_per_y", 0, -100, 100);
1020 double d_saturation_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_saturation_per_x", 0, -100, 100);
1021 double rand_saturation = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_saturation", 0, 0, 100);
1022 double d_lightness_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_lightness_per_y", 0, -100, 100);
1023 double d_lightness_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_lightness_per_x", 0, -100, 100);
1024 double rand_lightness = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_lightness", 0, 0, 100);
1025 int alternate_color_y = prefs_get_int_attribute (prefs_path, "alternate_color_y", 0);
1026 int alternate_color_x = prefs_get_int_attribute (prefs_path, "alternate_color_x", 0);
1028 int type = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
1030 int keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
1032 int xmax = prefs_get_int_attribute (prefs_path, "xmax", 2);
1033 int ymax = prefs_get_int_attribute (prefs_path, "ymax", 2);
1035 int fillrect = prefs_get_int_attribute (prefs_path, "fillrect", 0);
1036 double fillwidth = prefs_get_double_attribute_limited (prefs_path, "fillwidth", 50, 0, 6000);
1037 double fillheight = prefs_get_double_attribute_limited (prefs_path, "fillheight", 50, 0, 6000);
1039 int dotrace = prefs_get_int_attribute (prefs_path, "dotrace", 0);
1040 int pick = prefs_get_int_attribute (prefs_path, "pick", 0);
1041 int pick_to_presence = prefs_get_int_attribute (prefs_path, "pick_to_presence", 0);
1042 int pick_to_size = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
1043 int pick_to_color = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
1044 int pick_to_opacity = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
1045 double rand_picked = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_picked", 0, 0, 100);
1046 int invert_picked = prefs_get_int_attribute (prefs_path, "invert_picked", 0);
1047 double gamma_picked = prefs_get_double_attribute_limited (prefs_path, "gamma_picked", 0, -10, 10);
1049 if (dotrace) {
1050 clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, SP_ITEM (obj));
1051 }
1053 NR::Point c;
1054 double w;
1055 double h;
1057 if (keepbbox &&
1058 obj_repr->attribute("inkscape:tile-w") &&
1059 obj_repr->attribute("inkscape:tile-h") &&
1060 obj_repr->attribute("inkscape:tile-cx") &&
1061 obj_repr->attribute("inkscape:tile-cy")) {
1063 double cx = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cx", 0);
1064 double cy = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cy", 0);
1066 c = NR::Point (cx, cy);
1068 w = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-w", 0);
1069 h = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-h", 0);
1070 } else {
1071 NR::Rect const r = SP_ITEM(obj)->invokeBbox(sp_item_i2doc_affine(SP_ITEM(obj)));
1072 c = r.midpoint();
1073 w = r.dimensions()[NR::X];
1074 h = r.dimensions()[NR::Y];
1076 sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w);
1077 sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h);
1078 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", c[NR::X]);
1079 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", c[NR::Y]);
1080 }
1082 NR::Point cur = NR::Point (0, 0);
1083 NR::Rect bbox_original = NR::Rect (NR::Point (c[NR::X] - w/2, c[NR::Y] - h/2), NR::Point (c[NR::X] + w/2, c[NR::Y] + h/2));
1085 for (int x = 0;
1086 fillrect?
1087 (fabs(cur[NR::X]) < fillwidth && x < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows
1088 : (x < xmax);
1089 x ++) {
1090 for (int y = 0;
1091 fillrect?
1092 (fabs(cur[NR::Y]) < fillheight && y < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols
1093 : (y < ymax);
1094 y ++) {
1096 // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored
1098 // Get transform from symmetry, shift, scale, rotation
1099 NR::Matrix t = clonetiler_get_transform (type, x, y, c[NR::X], c[NR::Y], w, h,
1100 d_x_per_x, d_y_per_x, d_x_per_y, d_y_per_y, alternate_x, alternate_y, rand_x, rand_y,
1101 d_per_x_exp, d_per_y_exp,
1102 d_rot_per_x, d_rot_per_y, alternate_rotx, alternate_roty, rand_rot,
1103 d_scalex_per_x, d_scaley_per_x, d_scalex_per_y, d_scaley_per_y,
1104 alternate_scalex, alternate_scaley, rand_scalex, rand_scaley);
1106 cur = c * t - c;
1107 if (fillrect) {
1108 if ((cur[NR::X] > fillwidth) || (cur[NR::Y] > fillheight)) { // off limits
1109 continue;
1110 }
1111 }
1113 gchar color_string[32]; *color_string = 0;
1115 // Color tab
1116 if (initial_color) {
1117 guint32 rgba = sp_svg_read_color (initial_color, 0x000000ff);
1118 float hsl[3];
1119 sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba));
1121 double eff_x = (alternate_color_x? (x%2) : (x));
1122 double eff_y = (alternate_color_y? (y%2) : (y));
1124 hsl[0] += d_hue_per_x * eff_x + d_hue_per_y * eff_y + rand_hue * g_random_double_range (-1, 1);
1125 if (hsl[0] < 0) hsl[0] += 1;
1126 if (hsl[0] > 1) hsl[0] -= 1;
1127 hsl[1] += d_saturation_per_x * eff_x + d_saturation_per_y * eff_y + rand_saturation * g_random_double_range (-1, 1);
1128 hsl[1] = CLAMP (hsl[1], 0, 1);
1129 hsl[2] += d_lightness_per_x * eff_x + d_lightness_per_y * eff_y + rand_lightness * g_random_double_range (-1, 1);
1130 hsl[2] = CLAMP (hsl[2], 0, 1);
1132 float rgb[3];
1133 sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]);
1134 sp_svg_write_color(color_string, 32, SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0));
1135 }
1137 // Opacity tab
1138 double opacity = 1.0;
1139 int eff_x = (alternate_opacityx? (x%2) : (x));
1140 int eff_y = (alternate_opacityy? (y%2) : (y));
1141 opacity = 1 - (d_opacity_per_x * eff_x + d_opacity_per_y * eff_y + rand_opacity * g_random_double_range (-1, 1));
1142 opacity = CLAMP (opacity, 0, 1);
1144 // Trace tab
1145 if (dotrace) {
1146 NR::Rect bbox_t = transform_rect (bbox_original, t);
1148 guint32 rgba = clonetiler_trace_pick (bbox_t);
1149 float r = SP_RGBA32_R_F(rgba);
1150 float g = SP_RGBA32_G_F(rgba);
1151 float b = SP_RGBA32_B_F(rgba);
1152 float a = SP_RGBA32_A_F(rgba);
1154 float hsl[3];
1155 sp_color_rgb_to_hsl_floatv (hsl, r, g, b);
1157 gdouble val = 0;
1158 switch (pick) {
1159 case PICK_COLOR:
1160 val = 1 - hsl[2]; // inverse lightness; to match other picks where black = max
1161 break;
1162 case PICK_OPACITY:
1163 val = a;
1164 break;
1165 case PICK_R:
1166 val = r;
1167 break;
1168 case PICK_G:
1169 val = g;
1170 break;
1171 case PICK_B:
1172 val = b;
1173 break;
1174 case PICK_H:
1175 val = hsl[0];
1176 break;
1177 case PICK_S:
1178 val = hsl[1];
1179 break;
1180 case PICK_L:
1181 val = 1 - hsl[2];
1182 break;
1183 default:
1184 break;
1185 }
1187 if (rand_picked > 0) {
1188 val = randomize01 (val, rand_picked);
1189 r = randomize01 (r, rand_picked);
1190 g = randomize01 (g, rand_picked);
1191 b = randomize01 (b, rand_picked);
1192 }
1194 if (gamma_picked != 0) {
1195 double power;
1196 if (gamma_picked < 0)
1197 power = 1/(1 + fabs(gamma_picked));
1198 else
1199 power = 1 + gamma_picked;
1201 val = pow (val, power);
1202 r = pow (r, power);
1203 g = pow (g, power);
1204 b = pow (b, power);
1205 }
1207 if (invert_picked) {
1208 val = 1 - val;
1209 r = 1 - r;
1210 g = 1 - g;
1211 b = 1 - b;
1212 }
1214 val = CLAMP (val, 0, 1);
1215 r = CLAMP (r, 0, 1);
1216 g = CLAMP (g, 0, 1);
1217 b = CLAMP (b, 0, 1);
1219 // recompose tweaked color
1220 rgba = SP_RGBA32_F_COMPOSE(r, g, b, a);
1222 if (pick_to_presence) {
1223 if (g_random_double_range (0, 1) > val) {
1224 continue; // skip!
1225 }
1226 }
1227 if (pick_to_size) {
1228 t = NR::translate(-c[NR::X], -c[NR::Y]) * NR::scale (val, val) * NR::translate(c[NR::X], c[NR::Y]) * t;
1229 }
1230 if (pick_to_opacity) {
1231 opacity *= val;
1232 }
1233 if (pick_to_color) {
1234 sp_svg_write_color(color_string, 32, rgba);
1235 }
1236 }
1238 if (opacity < 1e-6) { // invisibly transparent, skip
1239 continue;
1240 }
1242 if (fabs(t[0]) + fabs (t[1]) + fabs(t[2]) + fabs(t[3]) < 1e-6) { // too small, skip
1243 continue;
1244 }
1246 // Create the clone
1247 Inkscape::XML::Node *clone = sp_repr_new("svg:use");
1248 clone->setAttribute("x", "0");
1249 clone->setAttribute("y", "0");
1250 clone->setAttribute("inkscape:tiled-clone-of", id_href);
1251 clone->setAttribute("xlink:href", id_href);
1253 NR::Point new_center;
1254 bool center_set = false;
1255 if (obj_repr->attribute("inkscape:transform-center-x") || obj_repr->attribute("inkscape:transform-center-y")) {
1256 new_center = desktop->dt2doc(SP_ITEM(obj)->getCenter()) * t;
1257 center_set = true;
1258 }
1260 gchar affinestr[80];
1261 if (sp_svg_transform_write(affinestr, 79, t)) {
1262 clone->setAttribute("transform", affinestr);
1263 } else {
1264 clone->setAttribute("transform", NULL);
1265 }
1267 if (opacity < 1.0) {
1268 sp_repr_set_css_double(clone, "opacity", opacity);
1269 }
1271 if (*color_string) {
1272 clone->setAttribute("fill", color_string);
1273 clone->setAttribute("stroke", color_string);
1274 }
1276 // add the new clone to the top of the original's parent
1277 SP_OBJECT_REPR(parent)->appendChild(clone);
1279 if (center_set) {
1280 SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone);
1281 if (clone_object && SP_IS_ITEM(clone_object)) {
1282 clone_object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
1283 SP_ITEM(clone_object)->setCenter(desktop->doc2dt(new_center));
1284 clone_object->updateRepr();
1285 }
1286 }
1288 Inkscape::GC::release(clone);
1289 }
1290 cur[NR::Y] = 0;
1291 }
1293 if (dotrace) {
1294 clonetiler_trace_finish ();
1295 }
1297 clonetiler_change_selection (NULL, selection, dlg);
1299 sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
1300 /* TODO: annotate */ "clonetiler.cpp:1300");
1301 }
1303 static GtkWidget *
1304 clonetiler_new_tab (GtkWidget *nb, const gchar *label)
1305 {
1306 GtkWidget *l = gtk_label_new_with_mnemonic (label);
1307 GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN);
1308 gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN);
1309 gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l);
1310 return vb;
1311 }
1313 static void
1314 clonetiler_checkbox_toggled (GtkToggleButton *tb, gpointer *data)
1315 {
1316 const gchar *attr = (const gchar *) data;
1317 prefs_set_int_attribute (prefs_path, attr, gtk_toggle_button_get_active (tb));
1318 }
1320 static GtkWidget *
1321 clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr)
1322 {
1323 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
1325 GtkWidget *b = gtk_check_button_new ();
1326 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL);
1328 int value = prefs_get_int_attribute (prefs_path, attr, 0);
1329 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value);
1331 gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0);
1332 gtk_signal_connect ( GTK_OBJECT (b), "clicked",
1333 GTK_SIGNAL_FUNC (clonetiler_checkbox_toggled), (gpointer) attr);
1335 g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
1337 return hb;
1338 }
1341 static void
1342 clonetiler_value_changed (GtkAdjustment *adj, gpointer data)
1343 {
1344 const gchar *pref = (const gchar *) data;
1345 prefs_set_double_attribute (prefs_path, pref, adj->value);
1346 }
1348 static GtkWidget *
1349 clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false)
1350 {
1351 GtkWidget *hb = gtk_hbox_new(FALSE, 0);
1353 {
1354 GtkObject *a;
1355 if (exponent)
1356 a = gtk_adjustment_new(1.0, lower, upper, 0.01, 0.05, 0.1);
1357 else
1358 a = gtk_adjustment_new(0.0, lower, upper, 0.1, 0.5, 2);
1360 GtkWidget *sb;
1361 if (exponent)
1362 sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.01, 2);
1363 else
1364 sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.1, 1);
1366 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, tip, NULL);
1367 gtk_entry_set_width_chars (GTK_ENTRY (sb), 4);
1368 gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, SB_MARGIN);
1370 double value = prefs_get_double_attribute_limited (prefs_path, attr, exponent? 1 : 0, lower, upper);
1371 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
1372 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
1373 GTK_SIGNAL_FUNC(clonetiler_value_changed), (gpointer) attr);
1375 if (exponent)
1376 g_object_set_data (G_OBJECT(sb), "oneable", GINT_TO_POINTER(TRUE));
1377 else
1378 g_object_set_data (G_OBJECT(sb), "zeroable", GINT_TO_POINTER(TRUE));
1379 }
1381 {
1382 GtkWidget *l = gtk_label_new ("");
1383 gtk_label_set_markup (GTK_LABEL(l), suffix);
1384 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0);
1385 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
1386 }
1388 return hb;
1389 }
1391 static void
1392 clonetiler_symgroup_changed (GtkMenuItem *item, gpointer data)
1393 {
1394 gint group_new = GPOINTER_TO_INT (data);
1395 prefs_set_int_attribute ( prefs_path, "symmetrygroup", group_new );
1396 }
1398 static void
1399 clonetiler_xy_changed (GtkAdjustment *adj, gpointer data)
1400 {
1401 const gchar *pref = (const gchar *) data;
1402 prefs_set_int_attribute (prefs_path, pref, (int) floor(adj->value + 0.5));
1403 }
1405 static void
1406 clonetiler_keep_bbox_toggled (GtkToggleButton *tb, gpointer data)
1407 {
1408 prefs_set_int_attribute (prefs_path, "keepbbox", gtk_toggle_button_get_active (tb));
1409 }
1411 static void
1412 clonetiler_pick_to (GtkToggleButton *tb, gpointer data)
1413 {
1414 const gchar *pref = (const gchar *) data;
1415 prefs_set_int_attribute (prefs_path, pref, gtk_toggle_button_get_active (tb));
1416 }
1419 static void
1420 clonetiler_reset_recursive (GtkWidget *w)
1421 {
1422 if (w && GTK_IS_OBJECT(w)) {
1423 {
1424 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "zeroable"));
1425 if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton
1426 GtkAdjustment *a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(w));
1427 gtk_adjustment_set_value (a, 0);
1428 }
1429 }
1430 {
1431 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "oneable"));
1432 if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton
1433 GtkAdjustment *a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(w));
1434 gtk_adjustment_set_value (a, 1);
1435 }
1436 }
1437 {
1438 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "uncheckable"));
1439 if (r && GTK_IS_TOGGLE_BUTTON(w)) { // checkbox
1440 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(w), FALSE);
1441 }
1442 }
1443 }
1445 if (GTK_IS_CONTAINER(w)) {
1446 GList *ch = gtk_container_get_children (GTK_CONTAINER(w));
1447 for (GList *i = ch; i != NULL; i = i->next) {
1448 clonetiler_reset_recursive (GTK_WIDGET(i->data));
1449 }
1450 g_list_free (ch);
1451 }
1452 }
1454 static void
1455 clonetiler_reset (GtkWidget *widget, void *)
1456 {
1457 clonetiler_reset_recursive (dlg);
1458 }
1460 static void
1461 clonetiler_table_attach (GtkWidget *table, GtkWidget *widget, float align, int row, int col)
1462 {
1463 GtkWidget *a = gtk_alignment_new (align, 0, 0, 0);
1464 gtk_container_add(GTK_CONTAINER(a), widget);
1465 gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 );
1466 }
1468 static GtkWidget *
1469 clonetiler_table_x_y_rand (int values)
1470 {
1471 GtkWidget *table = gtk_table_new (values + 2, 5, FALSE);
1472 gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
1473 gtk_table_set_row_spacings (GTK_TABLE (table), 6);
1474 gtk_table_set_col_spacings (GTK_TABLE (table), 8);
1476 {
1477 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
1479 GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "clonetiler_per_row");
1480 gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
1482 GtkWidget *l = gtk_label_new ("");
1483 gtk_label_set_markup (GTK_LABEL(l), _("<small>Per row:</small>"));
1484 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2);
1486 clonetiler_table_attach (table, hb, 0, 1, 2);
1487 }
1489 {
1490 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
1492 GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "clonetiler_per_column");
1493 gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
1495 GtkWidget *l = gtk_label_new ("");
1496 gtk_label_set_markup (GTK_LABEL(l), _("<small>Per column:</small>"));
1497 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2);
1499 clonetiler_table_attach (table, hb, 0, 1, 3);
1500 }
1502 {
1503 GtkWidget *l = gtk_label_new ("");
1504 gtk_label_set_markup (GTK_LABEL(l), _("<small>Randomize:</small>"));
1505 clonetiler_table_attach (table, l, 0, 1, 4);
1506 }
1508 return table;
1509 }
1511 static void
1512 clonetiler_pick_switched (GtkToggleButton *tb, gpointer data)
1513 {
1514 guint v = GPOINTER_TO_INT (data);
1515 prefs_set_int_attribute (prefs_path, "pick", v);
1516 }
1519 static void
1520 clonetiler_switch_to_create (GtkToggleButton *tb, GtkWidget *dlg)
1521 {
1522 GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
1523 GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
1525 if (rowscols) {
1526 gtk_widget_set_sensitive (rowscols, TRUE);
1527 }
1528 if (widthheight) {
1529 gtk_widget_set_sensitive (widthheight, FALSE);
1530 }
1532 prefs_set_int_attribute (prefs_path, "fillrect", 0);
1533 }
1536 static void
1537 clonetiler_switch_to_fill (GtkToggleButton *tb, GtkWidget *dlg)
1538 {
1539 GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
1540 GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
1542 if (rowscols) {
1543 gtk_widget_set_sensitive (rowscols, FALSE);
1544 }
1545 if (widthheight) {
1546 gtk_widget_set_sensitive (widthheight, TRUE);
1547 }
1549 prefs_set_int_attribute (prefs_path, "fillrect", 1);
1550 }
1555 static void
1556 clonetiler_fill_width_changed (GtkAdjustment *adj, GtkWidget *u)
1557 {
1558 gdouble const raw_dist = adj->value;
1559 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
1560 gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
1562 prefs_set_double_attribute (prefs_path, "fillwidth", pixels);
1563 }
1565 static void
1566 clonetiler_fill_height_changed (GtkAdjustment *adj, GtkWidget *u)
1567 {
1568 gdouble const raw_dist = adj->value;
1569 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
1570 gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
1572 prefs_set_double_attribute (prefs_path, "fillheight", pixels);
1573 }
1576 static void
1577 clonetiler_do_pick_toggled (GtkToggleButton *tb, gpointer data)
1578 {
1579 GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace");
1581 prefs_set_int_attribute (prefs_path, "dotrace", gtk_toggle_button_get_active (tb));
1583 if (vvb)
1584 gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb));
1585 }
1590 void
1591 clonetiler_dialog (void)
1592 {
1593 if (!dlg)
1594 {
1595 gchar title[500];
1596 sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_CLONETILER), title);
1598 dlg = sp_window_new (title, TRUE);
1599 if (x == -1000 || y == -1000) {
1600 x = prefs_get_int_attribute (prefs_path, "x", 0);
1601 y = prefs_get_int_attribute (prefs_path, "y", 0);
1602 }
1604 if (w ==0 || h == 0) {
1605 w = prefs_get_int_attribute (prefs_path, "w", 0);
1606 h = prefs_get_int_attribute (prefs_path, "h", 0);
1607 }
1609 if (x<0) x=0;
1610 if (y<0) y=0;
1612 if (x != 0 || y != 0) {
1613 gtk_window_move ((GtkWindow *) dlg, x, y);
1615 } else {
1616 gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
1617 }
1619 if (w && h) {
1620 gtk_window_resize ((GtkWindow *) dlg, w, h);
1621 }
1623 sp_transientize (dlg);
1624 wd.win = dlg;
1625 wd.stop = 0;
1628 gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg);
1630 gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg);
1631 gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg);
1633 if (Inkscape::NSApplication::Application::getNewGui())
1634 {
1635 _shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (&on_delete);
1636 _dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::bind (&on_dialog_hide, dlg));
1637 _dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::bind (&on_dialog_unhide, dlg));
1638 _desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::bind (&on_transientize, &wd));
1639 } else {
1640 g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
1641 g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
1642 g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
1643 g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
1644 }
1646 GtkTooltips *tt = gtk_tooltips_new();
1648 GtkWidget *mainbox = gtk_vbox_new(FALSE, 4);
1649 gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6);
1650 gtk_container_add (GTK_CONTAINER (dlg), mainbox);
1652 GtkWidget *nb = gtk_notebook_new ();
1653 gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0);
1656 // Symmetry
1657 {
1658 GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry"));
1660 GtkWidget *om = gtk_option_menu_new ();
1661 /* TRANSLATORS: For the following 17 symmetry groups, see
1662 * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples);
1663 * http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or
1664 * http://membres.lycos.fr/villemingerard/Geometri/Sym1D.htm (French vocabulary).
1665 */
1666 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), om, _("Select one of the 17 symmetry groups for the tiling"), NULL);
1667 gtk_box_pack_start (GTK_BOX (vb), om, FALSE, FALSE, SB_MARGIN);
1669 GtkWidget *m = gtk_menu_new ();
1670 int current = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
1672 struct SymGroups {
1673 int group;
1674 gchar const *label;
1675 } const sym_groups[] = {
1676 // TRANSLATORS: "translation" means "shift" / "displacement" here.
1677 {TILE_P1, _("<b>P1</b>: simple translation")},
1678 {TILE_P2, _("<b>P2</b>: 180° rotation")},
1679 {TILE_PM, _("<b>PM</b>: reflection")},
1680 // TRANSLATORS: "glide reflection" is a reflection and a translation combined.
1681 // For more info, see http://mathforum.org/sum95/suzanne/symsusan.html
1682 {TILE_PG, _("<b>PG</b>: glide reflection")},
1683 {TILE_CM, _("<b>CM</b>: reflection + glide reflection")},
1684 {TILE_PMM, _("<b>PMM</b>: reflection + reflection")},
1685 {TILE_PMG, _("<b>PMG</b>: reflection + 180° rotation")},
1686 {TILE_PGG, _("<b>PGG</b>: glide reflection + 180° rotation")},
1687 {TILE_CMM, _("<b>CMM</b>: reflection + reflection + 180° rotation")},
1688 {TILE_P4, _("<b>P4</b>: 90° rotation")},
1689 {TILE_P4M, _("<b>P4M</b>: 90° rotation + 45° reflection")},
1690 {TILE_P4G, _("<b>P4G</b>: 90° rotation + 90° reflection")},
1691 {TILE_P3, _("<b>P3</b>: 120° rotation")},
1692 {TILE_P31M, _("<b>P31M</b>: reflection + 120° rotation, dense")},
1693 {TILE_P3M1, _("<b>P3M1</b>: reflection + 120° rotation, sparse")},
1694 {TILE_P6, _("<b>P6</b>: 60° rotation")},
1695 {TILE_P6M, _("<b>P6M</b>: reflection + 60° rotation")},
1696 };
1698 for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) {
1699 SymGroups const &sg = sym_groups[j];
1701 GtkWidget *l = gtk_label_new ("");
1702 gtk_label_set_markup (GTK_LABEL(l), sg.label);
1703 gtk_misc_set_alignment (GTK_MISC(l), 0, 0.5);
1705 GtkWidget *item = gtk_menu_item_new ();
1706 gtk_container_add (GTK_CONTAINER (item), l);
1708 gtk_signal_connect ( GTK_OBJECT (item), "activate",
1709 GTK_SIGNAL_FUNC (clonetiler_symgroup_changed),
1710 GINT_TO_POINTER (sg.group) );
1712 gtk_menu_append (GTK_MENU (m), item);
1713 }
1715 gtk_option_menu_set_menu (GTK_OPTION_MENU (om), m);
1716 gtk_option_menu_set_history ( GTK_OPTION_MENU (om), current);
1717 }
1719 table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1721 // Shift
1722 {
1723 GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift"));
1725 GtkWidget *table = clonetiler_table_x_y_rand (3);
1726 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1728 // X
1729 {
1730 GtkWidget *l = gtk_label_new ("");
1731 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount
1732 // xgettext:no-c-format
1733 gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift X:</b>"));
1734 gtk_size_group_add_widget(table_row_labels, l);
1735 clonetiler_table_attach (table, l, 1, 2, 1);
1736 }
1738 {
1739 GtkWidget *l = clonetiler_spinbox (tt,
1740 // xgettext:no-c-format
1741 _("Horizontal shift per row (in % of tile width)"), "d_x_per_y",
1742 -100, 1000, "%");
1743 clonetiler_table_attach (table, l, 0, 2, 2);
1744 }
1746 {
1747 GtkWidget *l = clonetiler_spinbox (tt,
1748 // xgettext:no-c-format
1749 _("Horizontal shift per column (in % of tile width)"), "d_x_per_x",
1750 -100, 1000, "%");
1751 clonetiler_table_attach (table, l, 0, 2, 3);
1752 }
1754 {
1755 GtkWidget *l = clonetiler_spinbox (tt,
1756 _("Randomize the horizontal shift by this percentage"), "rand_x",
1757 0, 1000, "%");
1758 clonetiler_table_attach (table, l, 0, 2, 4);
1759 }
1761 // Y
1762 {
1763 GtkWidget *l = gtk_label_new ("");
1764 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) vertically by this amount
1765 // xgettext:no-c-format
1766 gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>"));
1767 gtk_size_group_add_widget(table_row_labels, l);
1768 clonetiler_table_attach (table, l, 1, 3, 1);
1769 }
1771 {
1772 GtkWidget *l = clonetiler_spinbox (tt,
1773 // xgettext:no-c-format
1774 _("Vertical shift per row (in % of tile height)"), "d_y_per_y",
1775 -100, 1000, "%");
1776 clonetiler_table_attach (table, l, 0, 3, 2);
1777 }
1779 {
1780 GtkWidget *l = clonetiler_spinbox (tt,
1781 // xgettext:no-c-format
1782 _("Vertical shift per column (in % of tile height)"), "d_y_per_x",
1783 -100, 1000, "%");
1784 clonetiler_table_attach (table, l, 0, 3, 3);
1785 }
1787 {
1788 GtkWidget *l = clonetiler_spinbox (tt,
1789 _("Randomize the vertical shift by this percentage"), "rand_y",
1790 0, 1000, "%");
1791 clonetiler_table_attach (table, l, 0, 3, 4);
1792 }
1794 // Exponent
1795 {
1796 GtkWidget *l = gtk_label_new ("");
1797 gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));
1798 gtk_size_group_add_widget(table_row_labels, l);
1799 clonetiler_table_attach (table, l, 1, 4, 1);
1800 }
1802 {
1803 GtkWidget *l = clonetiler_spinbox (tt,
1804 _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_y_exp",
1805 0, 10, "", true);
1806 clonetiler_table_attach (table, l, 0, 4, 2);
1807 }
1809 {
1810 GtkWidget *l = clonetiler_spinbox (tt,
1811 _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_x_exp",
1812 0, 10, "", true);
1813 clonetiler_table_attach (table, l, 0, 4, 3);
1814 }
1816 { // alternates
1817 GtkWidget *l = gtk_label_new ("");
1818 // TRANSLATORS: "Alternate" is a verb here
1819 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1820 gtk_size_group_add_widget(table_row_labels, l);
1821 clonetiler_table_attach (table, l, 1, 5, 1);
1822 }
1824 {
1825 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each row"), "alternate_y");
1826 clonetiler_table_attach (table, l, 0, 5, 2);
1827 }
1829 {
1830 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each column"), "alternate_x");
1831 clonetiler_table_attach (table, l, 0, 5, 3);
1832 }
1834 }
1837 // Scale
1838 {
1839 GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale"));
1841 GtkWidget *table = clonetiler_table_x_y_rand (2);
1842 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1844 // X
1845 {
1846 GtkWidget *l = gtk_label_new ("");
1847 gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale X:</b>"));
1848 gtk_size_group_add_widget(table_row_labels, l);
1849 clonetiler_table_attach (table, l, 1, 2, 1);
1850 }
1852 {
1853 GtkWidget *l = clonetiler_spinbox (tt,
1854 // xgettext:no-c-format
1855 _("Horizontal scale per row (in % of tile width)"), "d_scalex_per_y",
1856 -100, 1000, "%");
1857 clonetiler_table_attach (table, l, 0, 2, 2);
1858 }
1860 {
1861 GtkWidget *l = clonetiler_spinbox (tt,
1862 // xgettext:no-c-format
1863 _("Horizontal scale per column (in % of tile width)"), "d_scalex_per_x",
1864 -100, 1000, "%");
1865 clonetiler_table_attach (table, l, 0, 2, 3);
1866 }
1868 {
1869 GtkWidget *l = clonetiler_spinbox (tt,
1870 _("Randomize the horizontal scale by this percentage"), "rand_scalex",
1871 0, 1000, "%");
1872 clonetiler_table_attach (table, l, 0, 2, 4);
1873 }
1875 // Y
1876 {
1877 GtkWidget *l = gtk_label_new ("");
1878 gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale Y:</b>"));
1879 gtk_size_group_add_widget(table_row_labels, l);
1880 clonetiler_table_attach (table, l, 1, 3, 1);
1881 }
1883 {
1884 GtkWidget *l = clonetiler_spinbox (tt,
1885 // xgettext:no-c-format
1886 _("Vertical scale per row (in % of tile height)"), "d_scaley_per_y",
1887 -100, 1000, "%");
1888 clonetiler_table_attach (table, l, 0, 3, 2);
1889 }
1891 {
1892 GtkWidget *l = clonetiler_spinbox (tt,
1893 // xgettext:no-c-format
1894 _("Vertical scale per column (in % of tile height)"), "d_scaley_per_x",
1895 -100, 1000, "%");
1896 clonetiler_table_attach (table, l, 0, 3, 3);
1897 }
1899 {
1900 GtkWidget *l = clonetiler_spinbox (tt,
1901 _("Randomize the vertical scale by this percentage"), "rand_scaley",
1902 0, 1000, "%");
1903 clonetiler_table_attach (table, l, 0, 3, 4);
1904 }
1906 { // alternates
1907 GtkWidget *l = gtk_label_new ("");
1908 // TRANSLATORS: "Alternate" is a verb here
1909 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1910 gtk_size_group_add_widget(table_row_labels, l);
1911 clonetiler_table_attach (table, l, 1, 4, 1);
1912 }
1914 {
1915 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each row"), "alternate_scaley");
1916 clonetiler_table_attach (table, l, 0, 4, 2);
1917 }
1919 {
1920 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each column"), "alternate_scalex");
1921 clonetiler_table_attach (table, l, 0, 4, 3);
1922 }
1924 }
1927 // Rotation
1928 {
1929 GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation"));
1931 GtkWidget *table = clonetiler_table_x_y_rand (1);
1932 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1934 // Angle
1935 {
1936 GtkWidget *l = gtk_label_new ("");
1937 gtk_label_set_markup (GTK_LABEL(l), _("<b>Angle:</b>"));
1938 gtk_size_group_add_widget(table_row_labels, l);
1939 clonetiler_table_attach (table, l, 1, 2, 1);
1940 }
1942 {
1943 GtkWidget *l = clonetiler_spinbox (tt,
1944 // xgettext:no-c-format
1945 _("Rotate tiles by this angle for each row"), "d_rot_per_y",
1946 -180, 180, "°");
1947 clonetiler_table_attach (table, l, 0, 2, 2);
1948 }
1950 {
1951 GtkWidget *l = clonetiler_spinbox (tt,
1952 // xgettext:no-c-format
1953 _("Rotate tiles by this angle for each column"), "d_rot_per_x",
1954 -180, 180, "°");
1955 clonetiler_table_attach (table, l, 0, 2, 3);
1956 }
1958 {
1959 GtkWidget *l = clonetiler_spinbox (tt,
1960 _("Randomize the rotation angle by this percentage"), "rand_rot",
1961 0, 100, "%");
1962 clonetiler_table_attach (table, l, 0, 2, 4);
1963 }
1965 { // alternates
1966 GtkWidget *l = gtk_label_new ("");
1967 // TRANSLATORS: "Alternate" is a verb here
1968 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1969 gtk_size_group_add_widget(table_row_labels, l);
1970 clonetiler_table_attach (table, l, 1, 3, 1);
1971 }
1973 {
1974 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each row"), "alternate_roty");
1975 clonetiler_table_attach (table, l, 0, 3, 2);
1976 }
1978 {
1979 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each column"), "alternate_rotx");
1980 clonetiler_table_attach (table, l, 0, 3, 3);
1981 }
1982 }
1985 // Opacity
1986 {
1987 GtkWidget *vb = clonetiler_new_tab (nb, _("_Opacity"));
1989 GtkWidget *table = clonetiler_table_x_y_rand (1);
1990 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1992 // Dissolve
1993 {
1994 GtkWidget *l = gtk_label_new ("");
1995 gtk_label_set_markup (GTK_LABEL(l), _("<b>Fade out:</b>"));
1996 gtk_size_group_add_widget(table_row_labels, l);
1997 clonetiler_table_attach (table, l, 1, 2, 1);
1998 }
2000 {
2001 GtkWidget *l = clonetiler_spinbox (tt,
2002 _("Decrease tile opacity by this percentage for each row"), "d_opacity_per_y",
2003 0, 100, "%");
2004 clonetiler_table_attach (table, l, 0, 2, 2);
2005 }
2007 {
2008 GtkWidget *l = clonetiler_spinbox (tt,
2009 _("Decrease tile opacity by this percentage for each column"), "d_opacity_per_x",
2010 0, 100, "%");
2011 clonetiler_table_attach (table, l, 0, 2, 3);
2012 }
2014 {
2015 GtkWidget *l = clonetiler_spinbox (tt,
2016 _("Randomize the tile opacity by this percentage"), "rand_opacity",
2017 0, 100, "%");
2018 clonetiler_table_attach (table, l, 0, 2, 4);
2019 }
2021 { // alternates
2022 GtkWidget *l = gtk_label_new ("");
2023 // TRANSLATORS: "Alternate" is a verb here
2024 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
2025 gtk_size_group_add_widget(table_row_labels, l);
2026 clonetiler_table_attach (table, l, 1, 3, 1);
2027 }
2029 {
2030 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "alternate_opacityy");
2031 clonetiler_table_attach (table, l, 0, 3, 2);
2032 }
2034 {
2035 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each column"), "alternate_opacityx");
2036 clonetiler_table_attach (table, l, 0, 3, 3);
2037 }
2038 }
2041 // Color
2042 {
2043 GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor"));
2045 {
2046 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
2048 GtkWidget *l = gtk_label_new (_("Initial color: "));
2049 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
2051 guint32 rgba = 0x000000ff | sp_svg_read_color (prefs_get_string_attribute(prefs_path, "initial_color"), 0x000000ff);
2052 color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke)")), rgba, false);
2053 _color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));
2055 gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0);
2057 gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
2058 }
2061 GtkWidget *table = clonetiler_table_x_y_rand (3);
2062 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
2064 // Hue
2065 {
2066 GtkWidget *l = gtk_label_new ("");
2067 gtk_label_set_markup (GTK_LABEL(l), _("<b>H:</b>"));
2068 gtk_size_group_add_widget(table_row_labels, l);
2069 clonetiler_table_attach (table, l, 1, 2, 1);
2070 }
2072 {
2073 GtkWidget *l = clonetiler_spinbox (tt,
2074 _("Change the tile hue by this percentage for each row"), "d_hue_per_y",
2075 -100, 100, "%");
2076 clonetiler_table_attach (table, l, 0, 2, 2);
2077 }
2079 {
2080 GtkWidget *l = clonetiler_spinbox (tt,
2081 _("Change the tile hue by this percentage for each column"), "d_hue_per_x",
2082 -100, 100, "%");
2083 clonetiler_table_attach (table, l, 0, 2, 3);
2084 }
2086 {
2087 GtkWidget *l = clonetiler_spinbox (tt,
2088 _("Randomize the tile hue by this percentage"), "rand_hue",
2089 0, 100, "%");
2090 clonetiler_table_attach (table, l, 0, 2, 4);
2091 }
2094 // Saturation
2095 {
2096 GtkWidget *l = gtk_label_new ("");
2097 gtk_label_set_markup (GTK_LABEL(l), _("<b>S:</b>"));
2098 gtk_size_group_add_widget(table_row_labels, l);
2099 clonetiler_table_attach (table, l, 1, 3, 1);
2100 }
2102 {
2103 GtkWidget *l = clonetiler_spinbox (tt,
2104 _("Change the color saturation by this percentage for each row"), "d_saturation_per_y",
2105 -100, 100, "%");
2106 clonetiler_table_attach (table, l, 0, 3, 2);
2107 }
2109 {
2110 GtkWidget *l = clonetiler_spinbox (tt,
2111 _("Change the color saturation by this percentage for each column"), "d_saturation_per_x",
2112 -100, 100, "%");
2113 clonetiler_table_attach (table, l, 0, 3, 3);
2114 }
2116 {
2117 GtkWidget *l = clonetiler_spinbox (tt,
2118 _("Randomize the color saturation by this percentage"), "rand_saturation",
2119 0, 100, "%");
2120 clonetiler_table_attach (table, l, 0, 3, 4);
2121 }
2123 // Lightness
2124 {
2125 GtkWidget *l = gtk_label_new ("");
2126 gtk_label_set_markup (GTK_LABEL(l), _("<b>L:</b>"));
2127 gtk_size_group_add_widget(table_row_labels, l);
2128 clonetiler_table_attach (table, l, 1, 4, 1);
2129 }
2131 {
2132 GtkWidget *l = clonetiler_spinbox (tt,
2133 _("Change the color lightness by this percentage for each row"), "d_lightness_per_y",
2134 -100, 100, "%");
2135 clonetiler_table_attach (table, l, 0, 4, 2);
2136 }
2138 {
2139 GtkWidget *l = clonetiler_spinbox (tt,
2140 _("Change the color lightness by this percentage for each column"), "d_lightness_per_x",
2141 -100, 100, "%");
2142 clonetiler_table_attach (table, l, 0, 4, 3);
2143 }
2145 {
2146 GtkWidget *l = clonetiler_spinbox (tt,
2147 _("Randomize the color lightness by this percentage"), "rand_lightness",
2148 0, 100, "%");
2149 clonetiler_table_attach (table, l, 0, 4, 4);
2150 }
2153 { // alternates
2154 GtkWidget *l = gtk_label_new ("");
2155 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
2156 gtk_size_group_add_widget(table_row_labels, l);
2157 clonetiler_table_attach (table, l, 1, 5, 1);
2158 }
2160 {
2161 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each row"), "alternate_color_y");
2162 clonetiler_table_attach (table, l, 0, 5, 2);
2163 }
2165 {
2166 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each column"), "alternate_color_x");
2167 clonetiler_table_attach (table, l, 0, 5, 3);
2168 }
2170 }
2172 // Trace
2173 {
2174 GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace"));
2177 {
2178 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2179 gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
2181 GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles"));
2182 g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
2183 gint old = prefs_get_int_attribute (prefs_path, "dotrace", 0);
2184 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2185 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone"), NULL);
2186 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2188 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2189 GTK_SIGNAL_FUNC(clonetiler_do_pick_toggled), dlg);
2190 }
2192 {
2193 GtkWidget *vvb = gtk_vbox_new (FALSE, 0);
2194 gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0);
2195 g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb);
2198 {
2199 GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:"));
2200 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0);
2202 GtkWidget *table = gtk_table_new (3, 3, FALSE);
2203 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2204 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2205 gtk_container_add(GTK_CONTAINER(frame), table);
2208 GtkWidget* radio;
2209 {
2210 radio = gtk_radio_button_new_with_label (NULL, _("Color"));
2211 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the visible color and opacity"), NULL);
2212 clonetiler_table_attach (table, radio, 0.0, 1, 1);
2213 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2214 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR));
2215 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_COLOR);
2216 }
2217 {
2218 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity"));
2219 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the total accumulated opacity"), NULL);
2220 clonetiler_table_attach (table, radio, 0.0, 2, 1);
2221 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2222 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY));
2223 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_OPACITY);
2224 }
2225 {
2226 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R"));
2227 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Red component of the color"), NULL);
2228 clonetiler_table_attach (table, radio, 0.0, 1, 2);
2229 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2230 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R));
2231 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_R);
2232 }
2233 {
2234 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G"));
2235 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Green component of the color"), NULL);
2236 clonetiler_table_attach (table, radio, 0.0, 2, 2);
2237 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2238 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G));
2239 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_G);
2240 }
2241 {
2242 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B"));
2243 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Blue component of the color"), NULL);
2244 clonetiler_table_attach (table, radio, 0.0, 3, 2);
2245 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2246 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B));
2247 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_B);
2248 }
2249 {
2250 //TRANSLATORS: only translate "string" in "context|string".
2251 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2252 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|H"));
2253 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the hue of the color"), NULL);
2254 clonetiler_table_attach (table, radio, 0.0, 1, 3);
2255 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2256 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H));
2257 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_H);
2258 }
2259 {
2260 //TRANSLATORS: only translate "string" in "context|string".
2261 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2262 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|S"));
2263 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the saturation of the color"), NULL);
2264 clonetiler_table_attach (table, radio, 0.0, 2, 3);
2265 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2266 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S));
2267 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_S);
2268 }
2269 {
2270 //TRANSLATORS: only translate "string" in "context|string".
2271 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2272 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|L"));
2273 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the lightness of the color"), NULL);
2274 clonetiler_table_attach (table, radio, 0.0, 3, 3);
2275 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2276 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L));
2277 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_L);
2278 }
2280 }
2282 {
2283 GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:"));
2284 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN);
2286 GtkWidget *table = gtk_table_new (4, 2, FALSE);
2287 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2288 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2289 gtk_container_add(GTK_CONTAINER(frame), table);
2291 {
2292 GtkWidget *l = gtk_label_new ("");
2293 gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:"));
2294 clonetiler_table_attach (table, l, 1.0, 1, 1);
2295 }
2296 {
2297 GtkWidget *l = clonetiler_spinbox (tt,
2298 _("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked",
2299 -10, 10, "");
2300 clonetiler_table_attach (table, l, 0.0, 1, 2);
2301 }
2303 {
2304 GtkWidget *l = gtk_label_new ("");
2305 gtk_label_set_markup (GTK_LABEL(l), _("Randomize:"));
2306 clonetiler_table_attach (table, l, 1.0, 1, 3);
2307 }
2308 {
2309 GtkWidget *l = clonetiler_spinbox (tt,
2310 _("Randomize the picked value by this percentage"), "rand_picked",
2311 0, 100, "%");
2312 clonetiler_table_attach (table, l, 0.0, 1, 4);
2313 }
2315 {
2316 GtkWidget *l = gtk_label_new ("");
2317 gtk_label_set_markup (GTK_LABEL(l), _("Invert:"));
2318 clonetiler_table_attach (table, l, 1.0, 2, 1);
2319 }
2320 {
2321 GtkWidget *l = clonetiler_checkbox (tt, _("Invert the picked value"), "invert_picked");
2322 clonetiler_table_attach (table, l, 0.0, 2, 2);
2323 }
2324 }
2326 {
2327 GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':"));
2328 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0);
2331 GtkWidget *table = gtk_table_new (2, 2, FALSE);
2332 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2333 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2334 gtk_container_add(GTK_CONTAINER(frame), table);
2336 {
2337 GtkWidget *b = gtk_check_button_new_with_label (_("Presence"));
2338 gint old = prefs_get_int_attribute (prefs_path, "pick_to_presence", 1);
2339 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2340 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is created with the probability determined by the picked value in that point"), NULL);
2341 clonetiler_table_attach (table, b, 0.0, 1, 1);
2342 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2343 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_presence");
2344 }
2346 {
2347 GtkWidget *b = gtk_check_button_new_with_label (_("Size"));
2348 gint old = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
2349 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2350 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's size is determined by the picked value in that point"), NULL);
2351 clonetiler_table_attach (table, b, 0.0, 2, 1);
2352 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2353 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_size");
2354 }
2356 {
2357 GtkWidget *b = gtk_check_button_new_with_label (_("Color"));
2358 gint old = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
2359 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2360 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)"), NULL);
2361 clonetiler_table_attach (table, b, 0.0, 1, 2);
2362 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2363 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_color");
2364 }
2366 {
2367 GtkWidget *b = gtk_check_button_new_with_label (_("Opacity"));
2368 gint old = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
2369 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2370 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's opacity is determined by the picked value in that point"), NULL);
2371 clonetiler_table_attach (table, b, 0.0, 2, 2);
2372 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2373 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_opacity");
2374 }
2375 }
2376 gtk_widget_set_sensitive (vvb, prefs_get_int_attribute (prefs_path, "dotrace", 0));
2377 }
2378 }
2380 // Rows/columns, width/height
2381 {
2382 GtkWidget *table = gtk_table_new (2, 2, FALSE);
2383 gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
2384 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2385 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2386 gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0);
2388 {
2389 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2390 g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb);
2392 {
2393 GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
2394 int value = prefs_get_int_attribute (prefs_path, "ymax", 2);
2395 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
2396 GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
2397 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many rows in the tiling"), NULL);
2398 gtk_entry_set_width_chars (GTK_ENTRY (sb), 5);
2399 gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0);
2401 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2402 GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "ymax");
2403 }
2405 {
2406 GtkWidget *l = gtk_label_new ("");
2407 gtk_label_set_markup (GTK_LABEL(l), "×");
2408 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
2409 gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
2410 }
2412 {
2413 GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
2414 int value = prefs_get_int_attribute (prefs_path, "xmax", 2);
2415 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
2416 GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
2417 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many columns in the tiling"), NULL);
2418 gtk_entry_set_width_chars (GTK_ENTRY (sb), 5);
2419 gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0);
2421 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2422 GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "xmax");
2423 }
2425 clonetiler_table_attach (table, hb, 0.0, 1, 2);
2426 }
2428 {
2429 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2430 g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb);
2432 // unitmenu
2433 GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
2434 sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units);
2436 {
2437 // Width spinbutton
2438 GtkObject *a = gtk_adjustment_new (0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0);
2439 sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
2441 double value = prefs_get_double_attribute (prefs_path, "fillwidth", 50);
2442 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
2443 gdouble const units = sp_pixels_get_units (value, unit);
2444 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
2446 GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2);
2447 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), e, _("Width of the rectangle to be filled"), NULL);
2448 gtk_entry_set_width_chars (GTK_ENTRY (e), 5);
2449 gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0);
2450 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2451 GTK_SIGNAL_FUNC(clonetiler_fill_width_changed), u);
2452 }
2453 {
2454 GtkWidget *l = gtk_label_new ("");
2455 gtk_label_set_markup (GTK_LABEL(l), "×");
2456 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
2457 gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
2458 }
2460 {
2461 // Height spinbutton
2462 GtkObject *a = gtk_adjustment_new (0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0);
2463 sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
2465 double value = prefs_get_double_attribute (prefs_path, "fillheight", 50);
2466 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
2467 gdouble const units = sp_pixels_get_units (value, unit);
2468 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
2471 GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2);
2472 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), e, _("Height of the rectangle to be filled"), NULL);
2473 gtk_entry_set_width_chars (GTK_ENTRY (e), 5);
2474 gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0);
2475 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2476 GTK_SIGNAL_FUNC(clonetiler_fill_height_changed), u);
2477 }
2479 gtk_box_pack_start (GTK_BOX (hb), u, TRUE, TRUE, 0);
2480 clonetiler_table_attach (table, hb, 0.0, 2, 2);
2482 }
2484 // Switch
2485 GtkWidget* radio;
2486 {
2487 radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: "));
2488 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Create the specified number of rows and columns"), NULL);
2489 clonetiler_table_attach (table, radio, 0.0, 1, 1);
2490 gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg);
2491 }
2492 if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 0) {
2493 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
2494 gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
2495 }
2496 {
2497 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Width, height: "));
2498 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Fill the specified width and height with the tiling"), NULL);
2499 clonetiler_table_attach (table, radio, 0.0, 2, 1);
2500 gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg);
2501 }
2502 if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 1) {
2503 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
2504 gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
2505 }
2506 }
2509 // Use saved pos
2510 {
2511 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2512 gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2514 GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile"));
2515 gint keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
2516 gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox != 0);
2517 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size"), NULL);
2518 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2520 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2521 GTK_SIGNAL_FUNC(clonetiler_keep_bbox_toggled), NULL);
2522 }
2524 // Statusbar
2525 {
2526 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2527 gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2528 GtkWidget *l = gtk_label_new("");
2529 g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l);
2530 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
2531 }
2533 // Buttons
2534 {
2535 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2536 gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2538 {
2539 GtkWidget *b = gtk_button_new ();
2540 GtkWidget *l = gtk_label_new ("");
2541 gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> "));
2542 gtk_container_add (GTK_CONTAINER(b), l);
2543 gtk_tooltips_set_tip (tt, b, _("Create and tile the clones of the selection"), NULL);
2544 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_apply), NULL);
2545 gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0);
2546 }
2548 { // buttons which are enabled only when there are tiled clones
2549 GtkWidget *sb = gtk_hbox_new(FALSE, 0);
2550 gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0);
2551 g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb);
2552 {
2553 // TRANSLATORS: if a group of objects are "clumped" together, then they
2554 // are unevenly spread in the given amount of space - as shown in the
2555 // diagrams on the left in the following screenshot:
2556 // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png
2557 // So unclumping is the process of spreading a number of objects out more evenly.
2558 GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump "));
2559 gtk_tooltips_set_tip (tt, b, _("Spread out clones to reduce clumping; can be applied repeatedly"), NULL);
2560 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_unclump), NULL);
2561 gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0);
2562 }
2564 {
2565 GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move "));
2566 gtk_tooltips_set_tip (tt, b, _("Remove existing tiled clones of the selected object (siblings only)"), NULL);
2567 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_remove), NULL);
2568 gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0);
2569 }
2571 // connect to global selection changed signal (so we can change desktops) and
2572 // external_change (so we're not fooled by undo)
2573 g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg);
2574 g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg);
2575 g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE));
2577 // update now
2578 clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
2579 }
2581 {
2582 GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset "));
2583 // TRANSLATORS: "change" is a noun here
2584 gtk_tooltips_set_tip (tt, b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero"), NULL);
2585 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_reset), NULL);
2586 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2587 }
2588 }
2590 gtk_widget_show_all (mainbox);
2592 } // end of if (!dlg)
2594 gtk_window_present ((GtkWindow *) dlg);
2595 }
2598 /*
2599 Local Variables:
2600 mode:c++
2601 c-file-style:"stroustrup"
2602 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2603 indent-tabs-mode:nil
2604 fill-column:99
2605 End:
2606 */
2607 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :