f3cc9b4e094be2b66b78dca52ecbece446a0c06a
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 #include "../sp-filter.h"
61 #include "../filter-chemistry.h"
63 static GtkWidget *dlg = NULL;
64 static win_data wd;
66 // impossible original values to make sure they are read from prefs
67 static gint x = -1000, y = -1000, w = 0, h = 0;
68 static gchar *prefs_path = "dialogs.clonetiler";
70 #define SB_MARGIN 1
71 #define VB_MARGIN 4
73 enum {
74 PICK_COLOR,
75 PICK_OPACITY,
76 PICK_R,
77 PICK_G,
78 PICK_B,
79 PICK_H,
80 PICK_S,
81 PICK_L
82 };
84 static GtkSizeGroup* table_row_labels = NULL;
86 static sigc::connection _shutdown_connection;
87 static sigc::connection _dialogs_hidden_connection;
88 static sigc::connection _dialogs_unhidden_connection;
89 static sigc::connection _desktop_activated_connection;
90 static sigc::connection _color_changed_connection;
92 static Inkscape::UI::Widget::ColorPicker *color_picker;
94 static void
95 clonetiler_dialog_destroy (GtkObject *object, gpointer data)
96 {
97 if (Inkscape::NSApplication::Application::getNewGui())
98 {
99 _shutdown_connection.disconnect();
100 _dialogs_hidden_connection.disconnect();
101 _dialogs_unhidden_connection.disconnect();
102 _desktop_activated_connection.disconnect();
103 } else {
104 sp_signal_disconnect_by_data (INKSCAPE, dlg);
105 }
106 _color_changed_connection.disconnect();
108 delete color_picker;
110 wd.win = dlg = NULL;
111 wd.stop = 0;
113 }
115 static gboolean
116 clonetiler_dialog_delete (GtkObject *object, GdkEvent * /*event*/, gpointer data)
117 {
118 gtk_window_get_position ((GtkWindow *) dlg, &x, &y);
119 gtk_window_get_size ((GtkWindow *) dlg, &w, &h);
121 if (x<0) x=0;
122 if (y<0) y=0;
124 prefs_set_int_attribute (prefs_path, "x", x);
125 prefs_set_int_attribute (prefs_path, "y", y);
126 prefs_set_int_attribute (prefs_path, "w", w);
127 prefs_set_int_attribute (prefs_path, "h", h);
129 return FALSE; // which means, go ahead and destroy it
131 }
133 static void on_delete()
134 {
135 (void)clonetiler_dialog_delete (0, 0, NULL);
136 }
138 static void
139 on_picker_color_changed (guint rgba)
140 {
141 static bool is_updating = false;
142 if (is_updating || !SP_ACTIVE_DESKTOP)
143 return;
145 is_updating = true;
147 Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, prefs_path);
148 gchar c[32];
149 sp_svg_write_color(c, 32, rgba);
150 repr->setAttribute("initial_color", c);
152 is_updating = false;
153 }
155 static guint clonetiler_number_of_clones (SPObject *obj);
157 static void
158 clonetiler_change_selection (Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg)
159 {
160 GtkWidget *buttons = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles");
161 GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status");
163 if (selection->isEmpty()) {
164 gtk_widget_set_sensitive (buttons, FALSE);
165 gtk_label_set_markup (GTK_LABEL(status), _("<small>Nothing selected.</small>"));
166 return;
167 }
169 if (g_slist_length ((GSList *) selection->itemList()) > 1) {
170 gtk_widget_set_sensitive (buttons, FALSE);
171 gtk_label_set_markup (GTK_LABEL(status), _("<small>More than one object selected.</small>"));
172 return;
173 }
175 guint n = clonetiler_number_of_clones(selection->singleItem());
176 if (n > 0) {
177 gtk_widget_set_sensitive (buttons, TRUE);
178 gchar *sta = g_strdup_printf (_("<small>Object has <b>%d</b> tiled clones.</small>"), n);
179 gtk_label_set_markup (GTK_LABEL(status), sta);
180 g_free (sta);
181 } else {
182 gtk_widget_set_sensitive (buttons, FALSE);
183 gtk_label_set_markup (GTK_LABEL(status), _("<small>Object has no tiled clones.</small>"));
184 }
185 }
187 static void
188 clonetiler_external_change (Inkscape::Application * /*inkscape*/, GtkWidget *dlg)
189 {
190 clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
191 }
193 static void clonetiler_disconnect_gsignal (GObject *widget, gpointer source) {
194 if (source && G_IS_OBJECT(source))
195 sp_signal_disconnect_by_data (source, widget);
196 }
199 enum {
200 TILE_P1,
201 TILE_P2,
202 TILE_PM,
203 TILE_PG,
204 TILE_CM,
205 TILE_PMM,
206 TILE_PMG,
207 TILE_PGG,
208 TILE_CMM,
209 TILE_P4,
210 TILE_P4M,
211 TILE_P4G,
212 TILE_P3,
213 TILE_P31M,
214 TILE_P3M1,
215 TILE_P6,
216 TILE_P6M
217 };
220 static NR::Matrix
221 clonetiler_get_transform (
222 // symmetry group
223 int type,
224 // row, column
225 int x, int y,
226 // center, width, height of the tile
227 double cx, double cy,
228 double w, double h,
230 // values from the dialog:
231 double d_x_per_x, double d_y_per_x, double d_x_per_y, double d_y_per_y,
232 int alternate_x, int alternate_y, double rand_x, double rand_y,
233 double d_per_x_exp, double d_per_y_exp,
234 double d_rot_per_x, double d_rot_per_y, int alternate_rotx, int alternate_roty, double rand_rot,
235 double d_scalex_per_x, double d_scaley_per_x, double d_scalex_per_y, double d_scaley_per_y,
236 int alternate_scalex, int alternate_scaley, double rand_scalex, double rand_scaley
237 )
238 {
239 // in abs units
240 double eff_x = (alternate_x? (x%2) : pow ((double) x, d_per_x_exp));
241 double eff_y = (alternate_y? (y%2) : pow ((double) y, d_per_y_exp));
242 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);
243 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);
245 NR::Matrix rect_translate (NR::translate (w * pow ((double) x, d_per_x_exp) + dx, h * pow ((double) y, d_per_y_exp) + dy));
247 // in deg
248 double eff_x_rot = (alternate_rotx? (x%2) : (x));
249 double eff_y_rot = (alternate_roty? (y%2) : (y));
250 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);
252 // times the original
253 double eff_x_s = (alternate_scalex? (x%2) : (x));
254 double eff_y_s = (alternate_scaley? (y%2) : (y));
255 double rand_scale_x, rand_scale_y;
256 if (rand_scaley == rand_scalex) {
257 // if rands are equal, scale proportionally
258 rand_scale_x = rand_scale_y = rand_scalex * 1 * g_random_double_range (-1, 1);
259 } else {
260 rand_scale_x = rand_scalex * 1 * g_random_double_range (-1, 1);
261 rand_scale_y = rand_scaley * 1 * g_random_double_range (-1, 1);
262 }
263 double dscalex = 1 + d_scalex_per_x * eff_x_s + d_scalex_per_y * eff_y_s + rand_scale_x;
264 if (dscalex < 0) dscalex = 0;
265 double dscaley = 1 + d_scaley_per_x * eff_x_s + d_scaley_per_y * eff_y_s + rand_scale_y;
266 if (dscaley < 0) dscaley = 0;
268 NR::Matrix drot_c = NR::translate(-cx, -cy) * NR::rotate (M_PI*drot/180) * NR::translate(cx, cy);
270 NR::Matrix dscale_c = NR::translate(-cx, -cy) * NR::scale (dscalex, dscaley) * NR::translate(cx, cy);
272 NR::Matrix d_s_r = dscale_c * drot_c;
274 NR::Matrix rotate_180_c = NR::translate(-cx, -cy) * NR::rotate (M_PI) * NR::translate(cx, cy);
276 NR::Matrix rotate_90_c = NR::translate(-cx, -cy) * NR::rotate (-M_PI/2) * NR::translate(cx, cy);
277 NR::Matrix rotate_m90_c = NR::translate(-cx, -cy) * NR::rotate (M_PI/2) * NR::translate(cx, cy);
279 NR::Matrix rotate_120_c = NR::translate(-cx, -cy) * NR::rotate (-2*M_PI/3) * NR::translate(cx, cy);
280 NR::Matrix rotate_m120_c = NR::translate(-cx, -cy) * NR::rotate (2*M_PI/3) * NR::translate(cx, cy);
282 NR::Matrix rotate_60_c = NR::translate(-cx, -cy) * NR::rotate (-M_PI/3) * NR::translate(cx, cy);
283 NR::Matrix rotate_m60_c = NR::translate(-cx, -cy) * NR::rotate (M_PI/3) * NR::translate(cx, cy);
285 double cos60 = cos(M_PI/3);
286 double sin60 = sin(M_PI/3);
287 double cos30 = cos(M_PI/6);
288 double sin30 = sin(M_PI/6);
290 NR::Matrix flip_x = NR::translate(-cx, -cy) * NR::scale (-1, 1) * NR::translate(cx, cy);
291 NR::Matrix flip_y = NR::translate(-cx, -cy) * NR::scale (1, -1) * NR::translate(cx, cy);
293 x = (int) pow ((double) x, d_per_x_exp);
294 y = (int) pow ((double) y, d_per_y_exp);
296 switch (type) {
298 case TILE_P1:
299 return d_s_r * rect_translate;
300 break;
302 case TILE_P2:
303 if (x % 2 == 0) {
304 return d_s_r * rect_translate;
305 } else {
306 return d_s_r * rotate_180_c * rect_translate;
307 }
308 break;
310 case TILE_PM:
311 if (x % 2 == 0) {
312 return d_s_r * rect_translate;
313 } else {
314 return d_s_r * flip_x * rect_translate;
315 }
316 break;
318 case TILE_PG:
319 if (y % 2 == 0) {
320 return d_s_r * rect_translate;
321 } else {
322 return d_s_r * flip_x * rect_translate;
323 }
324 break;
326 case TILE_CM:
327 if ((x + y) % 2 == 0) {
328 return d_s_r * rect_translate;
329 } else {
330 return d_s_r * flip_x * rect_translate;
331 }
332 break;
334 case TILE_PMM:
335 if (y % 2 == 0) {
336 if (x % 2 == 0) {
337 return d_s_r * rect_translate;
338 } else {
339 return d_s_r * flip_x * rect_translate;
340 }
341 } else {
342 if (x % 2 == 0) {
343 return d_s_r * flip_y * rect_translate;
344 } else {
345 return d_s_r * flip_x * flip_y * rect_translate;
346 }
347 }
348 break;
350 case TILE_PMG:
351 if (y % 4 == 0) {
352 return d_s_r * rect_translate;
353 } else if (y % 4 == 1) {
354 return d_s_r * flip_y * rect_translate;
355 } else if (y % 4 == 2) {
356 return d_s_r * flip_x * rect_translate;
357 } else if (y % 4 == 3) {
358 return d_s_r * flip_x * flip_y * rect_translate;
359 }
360 break;
362 case TILE_PGG:
363 if (y % 2 == 0) {
364 if (x % 2 == 0) {
365 return d_s_r * rect_translate;
366 } else {
367 return d_s_r * flip_y * rect_translate;
368 }
369 } else {
370 if (x % 2 == 0) {
371 return d_s_r * rotate_180_c * rect_translate;
372 } else {
373 return d_s_r * rotate_180_c * flip_y * rect_translate;
374 }
375 }
376 break;
378 case TILE_CMM:
379 if (y % 4 == 0) {
380 if (x % 2 == 0) {
381 return d_s_r * rect_translate;
382 } else {
383 return d_s_r * flip_x * rect_translate;
384 }
385 } else if (y % 4 == 1) {
386 if (x % 2 == 0) {
387 return d_s_r * flip_y * rect_translate;
388 } else {
389 return d_s_r * flip_x * flip_y * rect_translate;
390 }
391 } else if (y % 4 == 2) {
392 if (x % 2 == 1) {
393 return d_s_r * rect_translate;
394 } else {
395 return d_s_r * flip_x * rect_translate;
396 }
397 } else {
398 if (x % 2 == 1) {
399 return d_s_r * flip_y * rect_translate;
400 } else {
401 return d_s_r * flip_x * flip_y * rect_translate;
402 }
403 }
404 break;
406 case TILE_P4:
407 {
408 NR::Matrix ori (NR::translate ((w + h) * (x/2) + dx, (h + w) * (y/2) + dy));
409 NR::Matrix dia1 (NR::translate (w/2 + h/2, -h/2 + w/2));
410 NR::Matrix dia2 (NR::translate (-w/2 + h/2, h/2 + w/2));
411 if (y % 2 == 0) {
412 if (x % 2 == 0) {
413 return d_s_r * ori;
414 } else {
415 return d_s_r * rotate_m90_c * dia1 * ori;
416 }
417 } else {
418 if (x % 2 == 0) {
419 return d_s_r * rotate_90_c * dia2 * ori;
420 } else {
421 return d_s_r * rotate_180_c * dia1 * dia2 * ori;
422 }
423 }
424 }
425 break;
427 case TILE_P4M:
428 {
429 double max = MAX(w, h);
430 NR::Matrix ori (NR::translate ((max + max) * (x/4) + dx, (max + max) * (y/2) + dy));
431 NR::Matrix dia1 (NR::translate (w/2 - h/2, h/2 - w/2));
432 NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 - h/2));
433 if (y % 2 == 0) {
434 if (x % 4 == 0) {
435 return d_s_r * ori;
436 } else if (x % 4 == 1) {
437 return d_s_r * flip_y * rotate_m90_c * dia1 * ori;
438 } else if (x % 4 == 2) {
439 return d_s_r * rotate_m90_c * dia1 * NR::translate (h, 0) * ori;
440 } else if (x % 4 == 3) {
441 return d_s_r * flip_x * NR::translate (w, 0) * ori;
442 }
443 } else {
444 if (x % 4 == 0) {
445 return d_s_r * flip_y * NR::translate(0, h) * ori;
446 } else if (x % 4 == 1) {
447 return d_s_r * rotate_90_c * dia2 * NR::translate(0, h) * ori;
448 } else if (x % 4 == 2) {
449 return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate(h, 0) * NR::translate(0, h) * ori;
450 } else if (x % 4 == 3) {
451 return d_s_r * flip_y * flip_x * NR::translate(w, 0) * NR::translate(0, h) * ori;
452 }
453 }
454 }
455 break;
457 case TILE_P4G:
458 {
459 double max = MAX(w, h);
460 NR::Matrix ori (NR::translate ((max + max) * (x/4) + dx, (max + max) * y + dy));
461 NR::Matrix dia1 (NR::translate (w/2 + h/2, h/2 - w/2));
462 NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 + h/2));
463 if (((x/4) + y) % 2 == 0) {
464 if (x % 4 == 0) {
465 return d_s_r * ori;
466 } else if (x % 4 == 1) {
467 return d_s_r * rotate_m90_c * dia1 * ori;
468 } else if (x % 4 == 2) {
469 return d_s_r * rotate_90_c * dia2 * ori;
470 } else if (x % 4 == 3) {
471 return d_s_r * rotate_180_c * dia1 * dia2 * ori;
472 }
473 } else {
474 if (x % 4 == 0) {
475 return d_s_r * flip_y * NR::translate (0, h) * ori;
476 } else if (x % 4 == 1) {
477 return d_s_r * flip_y * rotate_m90_c * dia1 * NR::translate (-h, 0) * ori;
478 } else if (x % 4 == 2) {
479 return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate (h, 0) * ori;
480 } else if (x % 4 == 3) {
481 return d_s_r * flip_x * NR::translate (w, 0) * ori;
482 }
483 }
484 }
485 break;
487 case TILE_P3:
488 {
489 double width;
490 double height;
491 NR::Matrix dia1;
492 NR::Matrix dia2;
493 if (w > h) {
494 width = w + w * cos60;
495 height = 2 * w * sin60;
496 dia1 = NR::Matrix (NR::translate (w/2 + w/2 * cos60, -(w/2 * sin60)));
497 dia2 = dia1 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60)));
498 } else {
499 width = h * cos (M_PI/6);
500 height = h;
501 dia1 = NR::Matrix (NR::translate (h/2 * cos30, -(h/2 * sin30)));
502 dia2 = dia1 * NR::Matrix (NR::translate (0, h/2));
503 }
504 NR::Matrix ori (NR::translate (width * (2*(x/3) + y%2) + dx, (height/2) * y + dy));
505 if (x % 3 == 0) {
506 return d_s_r * ori;
507 } else if (x % 3 == 1) {
508 return d_s_r * rotate_m120_c * dia1 * ori;
509 } else if (x % 3 == 2) {
510 return d_s_r * rotate_120_c * dia2 * ori;
511 }
512 }
513 break;
515 case TILE_P31M:
516 {
517 NR::Matrix ori;
518 NR::Matrix dia1;
519 NR::Matrix dia2;
520 NR::Matrix dia3;
521 NR::Matrix dia4;
522 if (w > h) {
523 ori = NR::Matrix(NR::translate (w * (x/6) + w/2 * (y%2) + dx, (w * cos30) * y + dy));
524 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) );
525 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
526 dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
527 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
528 } else {
529 ori = NR::Matrix (NR::translate (2*h * cos30 * (x/6 + 0.5*(y%2)) + dx, (2*h - h * sin30) * y + dy));
530 dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30));
531 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
532 dia3 = dia2 * NR::Matrix (NR::translate (0, h/2));
533 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
534 }
535 if (x % 6 == 0) {
536 return d_s_r * ori;
537 } else if (x % 6 == 1) {
538 return d_s_r * flip_y * rotate_m120_c * dia1 * ori;
539 } else if (x % 6 == 2) {
540 return d_s_r * rotate_m120_c * dia2 * ori;
541 } else if (x % 6 == 3) {
542 return d_s_r * flip_y * rotate_120_c * dia3 * ori;
543 } else if (x % 6 == 4) {
544 return d_s_r * rotate_120_c * dia4 * ori;
545 } else if (x % 6 == 5) {
546 return d_s_r * flip_y * NR::translate(0, h) * ori;
547 }
548 }
549 break;
551 case TILE_P3M1:
552 {
553 double width;
554 double height;
555 NR::Matrix dia1;
556 NR::Matrix dia2;
557 NR::Matrix dia3;
558 NR::Matrix dia4;
559 if (w > h) {
560 width = w + w * cos60;
561 height = 2 * w * sin60;
562 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) );
563 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
564 dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
565 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
566 } else {
567 width = 2 * h * cos (M_PI/6);
568 height = 2 * h;
569 dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30));
570 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
571 dia3 = dia2 * NR::Matrix (NR::translate (0, h/2));
572 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
573 }
574 NR::Matrix ori (NR::translate (width * (2*(x/6) + y%2) + dx, (height/2) * y + dy));
575 if (x % 6 == 0) {
576 return d_s_r * ori;
577 } else if (x % 6 == 1) {
578 return d_s_r * flip_y * rotate_m120_c * dia1 * ori;
579 } else if (x % 6 == 2) {
580 return d_s_r * rotate_m120_c * dia2 * ori;
581 } else if (x % 6 == 3) {
582 return d_s_r * flip_y * rotate_120_c * dia3 * ori;
583 } else if (x % 6 == 4) {
584 return d_s_r * rotate_120_c * dia4 * ori;
585 } else if (x % 6 == 5) {
586 return d_s_r * flip_y * NR::translate(0, h) * ori;
587 }
588 }
589 break;
591 case TILE_P6:
592 {
593 NR::Matrix ori;
594 NR::Matrix dia1;
595 NR::Matrix dia2;
596 NR::Matrix dia3;
597 NR::Matrix dia4;
598 NR::Matrix dia5;
599 if (w > h) {
600 ori = NR::Matrix(NR::translate (2*w * (x/6) + w * (y%2) + dx, (2*w * sin60) * y + dy));
601 dia1 = NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60));
602 dia2 = dia1 * NR::Matrix (NR::translate (w/2, 0));
603 dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, w/2 * sin60));
604 dia4 = dia3 * NR::Matrix (NR::translate (-w/2 * cos60, w/2 * sin60));
605 dia5 = dia4 * NR::Matrix (NR::translate (-w/2, 0));
606 } else {
607 ori = NR::Matrix(NR::translate (2*h * cos30 * (x/6 + 0.5*(y%2)) + dx, (h + h * sin30) * y + dy));
608 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));
609 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));
610 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));
611 dia4 = dia3 * dia1.inverse();
612 dia5 = dia3 * dia2.inverse();
613 }
614 if (x % 6 == 0) {
615 return d_s_r * ori;
616 } else if (x % 6 == 1) {
617 return d_s_r * rotate_m60_c * dia1 * ori;
618 } else if (x % 6 == 2) {
619 return d_s_r * rotate_m120_c * dia2 * ori;
620 } else if (x % 6 == 3) {
621 return d_s_r * rotate_180_c * dia3 * ori;
622 } else if (x % 6 == 4) {
623 return d_s_r * rotate_120_c * dia4 * ori;
624 } else if (x % 6 == 5) {
625 return d_s_r * rotate_60_c * dia5 * ori;
626 }
627 }
628 break;
630 case TILE_P6M:
631 {
633 NR::Matrix ori;
634 NR::Matrix dia1, dia2, dia3, dia4, dia5, dia6, dia7, dia8, dia9, dia10;
635 if (w > h) {
636 ori = NR::Matrix(NR::translate (2*w * (x/12) + w * (y%2) + dx, (2*w * sin60) * y + dy));
637 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));
638 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30));
639 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));
640 dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30));
641 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));
642 dia6 = dia5 * NR::Matrix (NR::translate (0, h));
643 dia7 = dia6 * dia1.inverse();
644 dia8 = dia6 * dia2.inverse();
645 dia9 = dia6 * dia3.inverse();
646 dia10 = dia6 * dia4.inverse();
647 } else {
648 ori = NR::Matrix(NR::translate (4*h * cos30 * (x/12 + 0.5*(y%2)) + dx, (2*h + 2*h * sin30) * y + dy));
649 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));
650 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30));
651 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));
652 dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30));
653 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));
654 dia6 = dia5 * NR::Matrix (NR::translate (0, h));
655 dia7 = dia6 * dia1.inverse();
656 dia8 = dia6 * dia2.inverse();
657 dia9 = dia6 * dia3.inverse();
658 dia10 = dia6 * dia4.inverse();
659 }
660 if (x % 12 == 0) {
661 return d_s_r * ori;
662 } else if (x % 12 == 1) {
663 return d_s_r * flip_y * rotate_m60_c * dia1 * ori;
664 } else if (x % 12 == 2) {
665 return d_s_r * rotate_m60_c * dia2 * ori;
666 } else if (x % 12 == 3) {
667 return d_s_r * flip_y * rotate_m120_c * dia3 * ori;
668 } else if (x % 12 == 4) {
669 return d_s_r * rotate_m120_c * dia4 * ori;
670 } else if (x % 12 == 5) {
671 return d_s_r * flip_x * dia5 * ori;
672 } else if (x % 12 == 6) {
673 return d_s_r * flip_x * flip_y * dia6 * ori;
674 } else if (x % 12 == 7) {
675 return d_s_r * flip_y * rotate_120_c * dia7 * ori;
676 } else if (x % 12 == 8) {
677 return d_s_r * rotate_120_c * dia8 * ori;
678 } else if (x % 12 == 9) {
679 return d_s_r * flip_y * rotate_60_c * dia9 * ori;
680 } else if (x % 12 == 10) {
681 return d_s_r * rotate_60_c * dia10 * ori;
682 } else if (x % 12 == 11) {
683 return d_s_r * flip_y * NR::translate (0, h) * ori;
684 }
685 }
686 break;
688 default:
689 break;
690 }
692 return NR::identity();
693 }
695 static bool
696 clonetiler_is_a_clone_of (SPObject *tile, SPObject *obj)
697 {
698 char *id_href = NULL;
700 if (obj) {
701 Inkscape::XML::Node *obj_repr = SP_OBJECT_REPR(obj);
702 id_href = g_strdup_printf("#%s", obj_repr->attribute("id"));
703 }
705 if (SP_IS_USE(tile) &&
706 SP_OBJECT_REPR(tile)->attribute("xlink:href") &&
707 (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("xlink:href"))) &&
708 SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of") &&
709 (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of"))))
710 {
711 if (id_href)
712 g_free (id_href);
713 return true;
714 } else {
715 if (id_href)
716 g_free (id_href);
717 return false;
718 }
719 }
721 static NRArena const *trace_arena = NULL;
722 static unsigned trace_visionkey;
723 static NRArenaItem *trace_root;
724 static gdouble trace_zoom;
726 static void
727 clonetiler_trace_hide_tiled_clones_recursively (SPObject *from)
728 {
729 if (!trace_arena)
730 return;
732 for (SPObject *o = sp_object_first_child(from); o != NULL; o = SP_OBJECT_NEXT(o)) {
733 if (SP_IS_ITEM(o) && clonetiler_is_a_clone_of (o, NULL))
734 sp_item_invoke_hide(SP_ITEM(o), trace_visionkey); // FIXME: hide each tiled clone's original too!
735 clonetiler_trace_hide_tiled_clones_recursively (o);
736 }
737 }
739 static void
740 clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original)
741 {
742 trace_arena = NRArena::create();
743 /* Create ArenaItem and set transform */
744 trace_visionkey = sp_item_display_key_new(1);
745 trace_root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT (doc)),
746 (NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY);
748 // hide the (current) original and any tiled clones, we only want to pick the background
749 sp_item_invoke_hide(original, trace_visionkey);
750 clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (doc)));
752 sp_document_root (doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
753 sp_document_ensure_up_to_date(doc);
755 trace_zoom = zoom;
756 }
758 static guint32
759 clonetiler_trace_pick (NR::Rect box)
760 {
761 if (!trace_arena)
762 return 0;
764 NRMatrix t;
765 nr_matrix_set_scale(&t, trace_zoom, trace_zoom);
766 nr_arena_item_set_transform(trace_root, &t);
767 NRGC gc(NULL);
768 nr_matrix_set_identity(&gc.transform);
769 nr_arena_item_invoke_update( trace_root, NULL, &gc,
770 NR_ARENA_ITEM_STATE_ALL,
771 NR_ARENA_ITEM_STATE_NONE );
773 /* Item integer bbox in points */
774 NRRectL ibox;
775 ibox.x0 = (int) floor(trace_zoom * box.min()[NR::X] + 0.5);
776 ibox.y0 = (int) floor(trace_zoom * box.min()[NR::Y] + 0.5);
777 ibox.x1 = (int) floor(trace_zoom * box.max()[NR::X] + 0.5);
778 ibox.y1 = (int) floor(trace_zoom * box.max()[NR::Y] + 0.5);
780 /* Find visible area */
781 int width = ibox.x1 - ibox.x0;
782 int height = ibox.y1 - ibox.y0;
784 /* Set up pixblock */
785 guchar *px = g_new(guchar, 4 * width * height);
786 memset(px, 0x00, 4 * width * height);
788 /* Render */
789 NRPixBlock pb;
790 nr_pixblock_setup_extern( &pb, NR_PIXBLOCK_MODE_R8G8B8A8N,
791 ibox.x0, ibox.y0, ibox.x1, ibox.y1,
792 px, 4 * width, FALSE, FALSE );
793 nr_arena_item_invoke_render( trace_root, &ibox, &pb,
794 NR_ARENA_ITEM_RENDER_NO_CACHE );
796 double R = 0, G = 0, B = 0, A = 0;
797 double count = 0;
798 double weight = 0;
800 for (int y = ibox.y0; y < ibox.y1; y++) {
801 const unsigned char *s = NR_PIXBLOCK_PX (&pb) + (y - ibox.y0) * pb.rs;
802 for (int x = ibox.x0; x < ibox.x1; x++) {
803 count += 1;
804 weight += s[3] / 255.0;
805 R += s[0] / 255.0;
806 G += s[1] / 255.0;
807 B += s[2] / 255.0;
808 A += s[3] / 255.0;
809 s += 4;
810 }
811 }
813 nr_pixblock_release(&pb);
815 R = R / weight;
816 G = G / weight;
817 B = B / weight;
818 A = A / count;
820 R = CLAMP (R, 0.0, 1.0);
821 G = CLAMP (G, 0.0, 1.0);
822 B = CLAMP (B, 0.0, 1.0);
823 A = CLAMP (A, 0.0, 1.0);
825 return SP_RGBA32_F_COMPOSE (R, G, B, A);
826 }
828 static void
829 clonetiler_trace_finish ()
830 {
831 if (trace_arena) {
832 ((NRObject *) trace_arena)->unreference();
833 trace_arena = NULL;
834 }
835 }
837 static void
838 clonetiler_unclump (GtkWidget *widget, void *)
839 {
840 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
841 if (desktop == NULL)
842 return;
844 Inkscape::Selection *selection = sp_desktop_selection(desktop);
846 // check if something is selected
847 if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
848 sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
849 return;
850 }
852 SPObject *obj = SP_OBJECT(selection->singleItem());
853 SPObject *parent = SP_OBJECT_PARENT (obj);
855 GSList *to_unclump = NULL; // not including the original
857 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
858 if (clonetiler_is_a_clone_of (child, obj)) {
859 to_unclump = g_slist_prepend (to_unclump, child);
860 }
861 }
863 sp_document_ensure_up_to_date(sp_desktop_document(desktop));
865 unclump (to_unclump);
867 g_slist_free (to_unclump);
869 sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER,
870 _("Unclump tiled clones"));
871 }
873 static guint
874 clonetiler_number_of_clones (SPObject *obj)
875 {
876 SPObject *parent = SP_OBJECT_PARENT (obj);
878 guint n = 0;
880 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
881 if (clonetiler_is_a_clone_of (child, obj)) {
882 n ++;
883 }
884 }
886 return n;
887 }
889 static void
890 clonetiler_remove (GtkWidget *widget, void *, bool do_undo = true)
891 {
892 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
893 if (desktop == NULL)
894 return;
896 Inkscape::Selection *selection = sp_desktop_selection(desktop);
898 // check if something is selected
899 if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
900 sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
901 return;
902 }
904 SPObject *obj = SP_OBJECT(selection->singleItem());
905 SPObject *parent = SP_OBJECT_PARENT (obj);
907 // remove old tiling
908 GSList *to_delete = NULL;
909 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
910 if (clonetiler_is_a_clone_of (child, obj)) {
911 to_delete = g_slist_prepend (to_delete, child);
912 }
913 }
914 for (GSList *i = to_delete; i; i = i->next) {
915 SP_OBJECT(i->data)->deleteObject();
916 }
917 g_slist_free (to_delete);
919 clonetiler_change_selection (NULL, selection, dlg);
921 if (do_undo)
922 sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER,
923 _("Delete tiled clones"));
924 }
926 static NR::Rect
927 transform_rect(NR::Rect const &r, NR::Matrix const &m)
928 {
929 using NR::X;
930 using NR::Y;
931 NR::Point const p1 = r.corner(1) * m;
932 NR::Point const p2 = r.corner(2) * m;
933 NR::Point const p3 = r.corner(3) * m;
934 NR::Point const p4 = r.corner(4) * m;
935 return NR::Rect(
936 NR::Point(
937 std::min(std::min(p1[X], p2[X]), std::min(p3[X], p4[X])),
938 std::min(std::min(p1[Y], p2[Y]), std::min(p3[Y], p4[Y]))),
939 NR::Point(
940 std::max(std::max(p1[X], p2[X]), std::max(p3[X], p4[X])),
941 std::max(std::max(p1[Y], p2[Y]), std::max(p3[Y], p4[Y]))));
942 }
944 /**
945 Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same
946 probability of being displaced.
947 */
948 static double
949 randomize01 (double val, double rand)
950 {
951 double base = MIN (val - rand, 1 - 2*rand);
952 if (base < 0) base = 0;
953 val = base + g_random_double_range (0, MIN (2 * rand, 1 - base));
954 return CLAMP(val, 0, 1); // this should be unnecessary with the above provisions, but just in case...
955 }
958 static void
959 clonetiler_apply (GtkWidget *widget, void *)
960 {
961 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
962 if (desktop == NULL)
963 return;
965 Inkscape::Selection *selection = sp_desktop_selection(desktop);
967 // check if something is selected
968 if (selection->isEmpty()) {
969 sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
970 return;
971 }
973 // Check if more than one object is selected.
974 if (g_slist_length((GSList *) selection->itemList()) > 1) {
975 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>."));
976 return;
977 }
979 SPObject *obj = SP_OBJECT(selection->singleItem());
980 Inkscape::XML::Node *obj_repr = SP_OBJECT_REPR(obj);
981 const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id"));
982 SPObject *parent = SP_OBJECT_PARENT (obj);
984 clonetiler_remove (NULL, NULL, false);
986 double d_x_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_x_per_x", 0, -100, 1000);
987 double d_y_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_y_per_x", 0, -100, 1000);
988 double d_per_x_exp = prefs_get_double_attribute_limited (prefs_path, "d_per_x_exp", 1, 0, 10);
989 double d_x_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_x_per_y", 0, -100, 1000);
990 double d_y_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_y_per_y", 0, -100, 1000);
991 double d_per_y_exp = prefs_get_double_attribute_limited (prefs_path, "d_per_y_exp", 1, 0, 10);
992 int alternate_x = prefs_get_int_attribute (prefs_path, "alternate_x", 0);
993 int alternate_y = prefs_get_int_attribute (prefs_path, "alternate_y", 0);
994 double rand_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_x", 0, 0, 1000);
995 double rand_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_y", 0, 0, 1000);
997 double d_scalex_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scalex_per_x", 0, -100, 1000);
998 double d_scaley_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scaley_per_x", 0, -100, 1000);
999 double d_scalex_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scalex_per_y", 0, -100, 1000);
1000 double d_scaley_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scaley_per_y", 0, -100, 1000);
1001 int alternate_scalex = prefs_get_int_attribute (prefs_path, "alternate_scalex", 0);
1002 int alternate_scaley = prefs_get_int_attribute (prefs_path, "alternate_scaley", 0);
1003 double rand_scalex = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scalex", 0, 0, 1000);
1004 double rand_scaley = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scaley", 0, 0, 1000);
1006 double d_rot_per_x = prefs_get_double_attribute_limited (prefs_path, "d_rot_per_x", 0, -180, 180);
1007 double d_rot_per_y = prefs_get_double_attribute_limited (prefs_path, "d_rot_per_y", 0, -180, 180);
1008 int alternate_rotx = prefs_get_int_attribute (prefs_path, "alternate_rotx", 0);
1009 int alternate_roty = prefs_get_int_attribute (prefs_path, "alternate_roty", 0);
1010 double rand_rot = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_rot", 0, 0, 100);
1012 double d_blur_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_blur_per_y", 0, 0, 100);
1013 double d_blur_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_blur_per_x", 0, 0, 100);
1014 int alternate_blury = prefs_get_int_attribute (prefs_path, "alternate_blury", 0);
1015 int alternate_blurx = prefs_get_int_attribute (prefs_path, "alternate_blurx", 0);
1016 double rand_blur = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_blur", 0, 0, 100);
1018 double d_opacity_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_y", 0, 0, 100);
1019 double d_opacity_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_x", 0, 0, 100);
1020 int alternate_opacityy = prefs_get_int_attribute (prefs_path, "alternate_opacityy", 0);
1021 int alternate_opacityx = prefs_get_int_attribute (prefs_path, "alternate_opacityx", 0);
1022 double rand_opacity = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_opacity", 0, 0, 100);
1024 const gchar *initial_color = prefs_get_string_attribute (prefs_path, "initial_color");
1025 double d_hue_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_hue_per_y", 0, -100, 100);
1026 double d_hue_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_hue_per_x", 0, -100, 100);
1027 double rand_hue = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_hue", 0, 0, 100);
1028 double d_saturation_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_saturation_per_y", 0, -100, 100);
1029 double d_saturation_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_saturation_per_x", 0, -100, 100);
1030 double rand_saturation = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_saturation", 0, 0, 100);
1031 double d_lightness_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_lightness_per_y", 0, -100, 100);
1032 double d_lightness_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_lightness_per_x", 0, -100, 100);
1033 double rand_lightness = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_lightness", 0, 0, 100);
1034 int alternate_color_y = prefs_get_int_attribute (prefs_path, "alternate_color_y", 0);
1035 int alternate_color_x = prefs_get_int_attribute (prefs_path, "alternate_color_x", 0);
1037 int type = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
1039 int keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
1041 int xmax = prefs_get_int_attribute (prefs_path, "xmax", 2);
1042 int ymax = prefs_get_int_attribute (prefs_path, "ymax", 2);
1044 int fillrect = prefs_get_int_attribute (prefs_path, "fillrect", 0);
1045 double fillwidth = prefs_get_double_attribute_limited (prefs_path, "fillwidth", 50, 0, 6000);
1046 double fillheight = prefs_get_double_attribute_limited (prefs_path, "fillheight", 50, 0, 6000);
1048 int dotrace = prefs_get_int_attribute (prefs_path, "dotrace", 0);
1049 int pick = prefs_get_int_attribute (prefs_path, "pick", 0);
1050 int pick_to_presence = prefs_get_int_attribute (prefs_path, "pick_to_presence", 0);
1051 int pick_to_size = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
1052 int pick_to_color = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
1053 int pick_to_opacity = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
1054 double rand_picked = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_picked", 0, 0, 100);
1055 int invert_picked = prefs_get_int_attribute (prefs_path, "invert_picked", 0);
1056 double gamma_picked = prefs_get_double_attribute_limited (prefs_path, "gamma_picked", 0, -10, 10);
1058 if (dotrace) {
1059 clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, SP_ITEM (obj));
1060 }
1062 NR::Point c;
1063 double w;
1064 double h;
1066 if (keepbbox &&
1067 obj_repr->attribute("inkscape:tile-w") &&
1068 obj_repr->attribute("inkscape:tile-h") &&
1069 obj_repr->attribute("inkscape:tile-cx") &&
1070 obj_repr->attribute("inkscape:tile-cy")) {
1072 double cx = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cx", 0);
1073 double cy = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cy", 0);
1075 c = NR::Point (cx, cy);
1077 w = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-w", 0);
1078 h = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-h", 0);
1079 } else {
1080 NR::Rect const r = SP_ITEM(obj)->invokeBbox(sp_item_i2doc_affine(SP_ITEM(obj)));
1081 c = r.midpoint();
1082 w = r.dimensions()[NR::X];
1083 h = r.dimensions()[NR::Y];
1085 sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w);
1086 sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h);
1087 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", c[NR::X]);
1088 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", c[NR::Y]);
1089 }
1091 NR::Point cur = NR::Point (0, 0);
1092 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));
1093 double diag_original = sqrt(w*w + h*h);
1095 for (int x = 0;
1096 fillrect?
1097 (fabs(cur[NR::X]) < fillwidth && x < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows
1098 : (x < xmax);
1099 x ++) {
1100 for (int y = 0;
1101 fillrect?
1102 (fabs(cur[NR::Y]) < fillheight && y < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols
1103 : (y < ymax);
1104 y ++) {
1106 // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored
1108 // Get transform from symmetry, shift, scale, rotation
1109 NR::Matrix t = clonetiler_get_transform (type, x, y, c[NR::X], c[NR::Y], w, h,
1110 d_x_per_x, d_y_per_x, d_x_per_y, d_y_per_y, alternate_x, alternate_y, rand_x, rand_y,
1111 d_per_x_exp, d_per_y_exp,
1112 d_rot_per_x, d_rot_per_y, alternate_rotx, alternate_roty, rand_rot,
1113 d_scalex_per_x, d_scaley_per_x, d_scalex_per_y, d_scaley_per_y,
1114 alternate_scalex, alternate_scaley, rand_scalex, rand_scaley);
1116 cur = c * t - c;
1117 if (fillrect) {
1118 if ((cur[NR::X] > fillwidth) || (cur[NR::Y] > fillheight)) { // off limits
1119 continue;
1120 }
1121 }
1123 gchar color_string[32]; *color_string = 0;
1125 // Color tab
1126 if (initial_color) {
1127 guint32 rgba = sp_svg_read_color (initial_color, 0x000000ff);
1128 float hsl[3];
1129 sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba));
1131 double eff_x = (alternate_color_x? (x%2) : (x));
1132 double eff_y = (alternate_color_y? (y%2) : (y));
1134 hsl[0] += d_hue_per_x * eff_x + d_hue_per_y * eff_y + rand_hue * g_random_double_range (-1, 1);
1135 if (hsl[0] < 0) hsl[0] += 1;
1136 if (hsl[0] > 1) hsl[0] -= 1;
1137 hsl[1] += d_saturation_per_x * eff_x + d_saturation_per_y * eff_y + rand_saturation * g_random_double_range (-1, 1);
1138 hsl[1] = CLAMP (hsl[1], 0, 1);
1139 hsl[2] += d_lightness_per_x * eff_x + d_lightness_per_y * eff_y + rand_lightness * g_random_double_range (-1, 1);
1140 hsl[2] = CLAMP (hsl[2], 0, 1);
1142 float rgb[3];
1143 sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]);
1144 sp_svg_write_color(color_string, 32, SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0));
1145 }
1147 // Blur
1148 double blur = 0.0;
1149 {
1150 int eff_x = (alternate_blurx? (x%2) : (x));
1151 int eff_y = (alternate_blury? (y%2) : (y));
1152 blur = (d_blur_per_x * eff_x + d_blur_per_y * eff_y + rand_blur * g_random_double_range (-1, 1));
1153 blur = CLAMP (blur, 0, 1);
1154 }
1156 // Opacity
1157 double opacity = 1.0;
1158 {
1159 int eff_x = (alternate_opacityx? (x%2) : (x));
1160 int eff_y = (alternate_opacityy? (y%2) : (y));
1161 opacity = 1 - (d_opacity_per_x * eff_x + d_opacity_per_y * eff_y + rand_opacity * g_random_double_range (-1, 1));
1162 opacity = CLAMP (opacity, 0, 1);
1163 }
1165 // Trace tab
1166 if (dotrace) {
1167 NR::Rect bbox_t = transform_rect (bbox_original, t);
1169 guint32 rgba = clonetiler_trace_pick (bbox_t);
1170 float r = SP_RGBA32_R_F(rgba);
1171 float g = SP_RGBA32_G_F(rgba);
1172 float b = SP_RGBA32_B_F(rgba);
1173 float a = SP_RGBA32_A_F(rgba);
1175 float hsl[3];
1176 sp_color_rgb_to_hsl_floatv (hsl, r, g, b);
1178 gdouble val = 0;
1179 switch (pick) {
1180 case PICK_COLOR:
1181 val = 1 - hsl[2]; // inverse lightness; to match other picks where black = max
1182 break;
1183 case PICK_OPACITY:
1184 val = a;
1185 break;
1186 case PICK_R:
1187 val = r;
1188 break;
1189 case PICK_G:
1190 val = g;
1191 break;
1192 case PICK_B:
1193 val = b;
1194 break;
1195 case PICK_H:
1196 val = hsl[0];
1197 break;
1198 case PICK_S:
1199 val = hsl[1];
1200 break;
1201 case PICK_L:
1202 val = 1 - hsl[2];
1203 break;
1204 default:
1205 break;
1206 }
1208 if (rand_picked > 0) {
1209 val = randomize01 (val, rand_picked);
1210 r = randomize01 (r, rand_picked);
1211 g = randomize01 (g, rand_picked);
1212 b = randomize01 (b, rand_picked);
1213 }
1215 if (gamma_picked != 0) {
1216 double power;
1217 if (gamma_picked < 0)
1218 power = 1/(1 + fabs(gamma_picked));
1219 else
1220 power = 1 + gamma_picked;
1222 val = pow (val, power);
1223 r = pow (r, power);
1224 g = pow (g, power);
1225 b = pow (b, power);
1226 }
1228 if (invert_picked) {
1229 val = 1 - val;
1230 r = 1 - r;
1231 g = 1 - g;
1232 b = 1 - b;
1233 }
1235 val = CLAMP (val, 0, 1);
1236 r = CLAMP (r, 0, 1);
1237 g = CLAMP (g, 0, 1);
1238 b = CLAMP (b, 0, 1);
1240 // recompose tweaked color
1241 rgba = SP_RGBA32_F_COMPOSE(r, g, b, a);
1243 if (pick_to_presence) {
1244 if (g_random_double_range (0, 1) > val) {
1245 continue; // skip!
1246 }
1247 }
1248 if (pick_to_size) {
1249 t = NR::translate(-c[NR::X], -c[NR::Y]) * NR::scale (val, val) * NR::translate(c[NR::X], c[NR::Y]) * t;
1250 }
1251 if (pick_to_opacity) {
1252 opacity *= val;
1253 }
1254 if (pick_to_color) {
1255 sp_svg_write_color(color_string, 32, rgba);
1256 }
1257 }
1259 if (opacity < 1e-6) { // invisibly transparent, skip
1260 continue;
1261 }
1263 if (fabs(t[0]) + fabs (t[1]) + fabs(t[2]) + fabs(t[3]) < 1e-6) { // too small, skip
1264 continue;
1265 }
1267 // Create the clone
1268 Inkscape::XML::Node *clone = sp_repr_new("svg:use");
1269 clone->setAttribute("x", "0");
1270 clone->setAttribute("y", "0");
1271 clone->setAttribute("inkscape:tiled-clone-of", id_href);
1272 clone->setAttribute("xlink:href", id_href);
1274 NR::Point new_center;
1275 bool center_set = false;
1276 if (obj_repr->attribute("inkscape:transform-center-x") || obj_repr->attribute("inkscape:transform-center-y")) {
1277 new_center = desktop->dt2doc(SP_ITEM(obj)->getCenter()) * t;
1278 center_set = true;
1279 }
1281 gchar affinestr[80];
1282 if (sp_svg_transform_write(affinestr, 79, t)) {
1283 clone->setAttribute("transform", affinestr);
1284 } else {
1285 clone->setAttribute("transform", NULL);
1286 }
1288 if (opacity < 1.0) {
1289 sp_repr_set_css_double(clone, "opacity", opacity);
1290 }
1292 if (*color_string) {
1293 clone->setAttribute("fill", color_string);
1294 clone->setAttribute("stroke", color_string);
1295 }
1297 // add the new clone to the top of the original's parent
1298 SP_OBJECT_REPR(parent)->appendChild(clone);
1300 if (blur > 0.0) {
1301 SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone);
1302 double diag = diag_original * t.expansion();
1303 double radius = blur * diag;
1304 // it's hard to figure out exact width/height of the tile without having an object
1305 // that we can take bbox of; however here we only need a lower bound so that blur
1306 // margins are not too small, and diag/2 should work
1307 SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, diag/2, diag/2);
1308 sp_style_set_property_url (clone_object, "filter", SP_OBJECT(constructed), false);
1309 }
1311 if (center_set) {
1312 SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone);
1313 if (clone_object && SP_IS_ITEM(clone_object)) {
1314 clone_object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
1315 SP_ITEM(clone_object)->setCenter(desktop->doc2dt(new_center));
1316 clone_object->updateRepr();
1317 }
1318 }
1320 Inkscape::GC::release(clone);
1321 }
1322 cur[NR::Y] = 0;
1323 }
1325 if (dotrace) {
1326 clonetiler_trace_finish ();
1327 }
1329 clonetiler_change_selection (NULL, selection, dlg);
1331 sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER,
1332 _("Create tiled clones"));
1333 }
1335 static GtkWidget *
1336 clonetiler_new_tab (GtkWidget *nb, const gchar *label)
1337 {
1338 GtkWidget *l = gtk_label_new_with_mnemonic (label);
1339 GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN);
1340 gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN);
1341 gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l);
1342 return vb;
1343 }
1345 static void
1346 clonetiler_checkbox_toggled (GtkToggleButton *tb, gpointer *data)
1347 {
1348 const gchar *attr = (const gchar *) data;
1349 prefs_set_int_attribute (prefs_path, attr, gtk_toggle_button_get_active (tb));
1350 }
1352 static GtkWidget *
1353 clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr)
1354 {
1355 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
1357 GtkWidget *b = gtk_check_button_new ();
1358 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL);
1360 int value = prefs_get_int_attribute (prefs_path, attr, 0);
1361 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value);
1363 gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0);
1364 gtk_signal_connect ( GTK_OBJECT (b), "clicked",
1365 GTK_SIGNAL_FUNC (clonetiler_checkbox_toggled), (gpointer) attr);
1367 g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
1369 return hb;
1370 }
1373 static void
1374 clonetiler_value_changed (GtkAdjustment *adj, gpointer data)
1375 {
1376 const gchar *pref = (const gchar *) data;
1377 prefs_set_double_attribute (prefs_path, pref, adj->value);
1378 }
1380 static GtkWidget *
1381 clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false)
1382 {
1383 GtkWidget *hb = gtk_hbox_new(FALSE, 0);
1385 {
1386 GtkObject *a;
1387 if (exponent)
1388 a = gtk_adjustment_new(1.0, lower, upper, 0.01, 0.05, 0.1);
1389 else
1390 a = gtk_adjustment_new(0.0, lower, upper, 0.1, 0.5, 2);
1392 GtkWidget *sb;
1393 if (exponent)
1394 sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.01, 2);
1395 else
1396 sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.1, 1);
1398 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, tip, NULL);
1399 gtk_entry_set_width_chars (GTK_ENTRY (sb), 4);
1400 gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, SB_MARGIN);
1402 double value = prefs_get_double_attribute_limited (prefs_path, attr, exponent? 1 : 0, lower, upper);
1403 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
1404 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
1405 GTK_SIGNAL_FUNC(clonetiler_value_changed), (gpointer) attr);
1407 if (exponent)
1408 g_object_set_data (G_OBJECT(sb), "oneable", GINT_TO_POINTER(TRUE));
1409 else
1410 g_object_set_data (G_OBJECT(sb), "zeroable", GINT_TO_POINTER(TRUE));
1411 }
1413 {
1414 GtkWidget *l = gtk_label_new ("");
1415 gtk_label_set_markup (GTK_LABEL(l), suffix);
1416 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0);
1417 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
1418 }
1420 return hb;
1421 }
1423 static void
1424 clonetiler_symgroup_changed (GtkMenuItem *item, gpointer data)
1425 {
1426 gint group_new = GPOINTER_TO_INT (data);
1427 prefs_set_int_attribute ( prefs_path, "symmetrygroup", group_new );
1428 }
1430 static void
1431 clonetiler_xy_changed (GtkAdjustment *adj, gpointer data)
1432 {
1433 const gchar *pref = (const gchar *) data;
1434 prefs_set_int_attribute (prefs_path, pref, (int) floor(adj->value + 0.5));
1435 }
1437 static void
1438 clonetiler_keep_bbox_toggled (GtkToggleButton *tb, gpointer data)
1439 {
1440 prefs_set_int_attribute (prefs_path, "keepbbox", gtk_toggle_button_get_active (tb));
1441 }
1443 static void
1444 clonetiler_pick_to (GtkToggleButton *tb, gpointer data)
1445 {
1446 const gchar *pref = (const gchar *) data;
1447 prefs_set_int_attribute (prefs_path, pref, gtk_toggle_button_get_active (tb));
1448 }
1451 static void
1452 clonetiler_reset_recursive (GtkWidget *w)
1453 {
1454 if (w && GTK_IS_OBJECT(w)) {
1455 {
1456 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "zeroable"));
1457 if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton
1458 GtkAdjustment *a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(w));
1459 gtk_adjustment_set_value (a, 0);
1460 }
1461 }
1462 {
1463 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "oneable"));
1464 if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton
1465 GtkAdjustment *a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(w));
1466 gtk_adjustment_set_value (a, 1);
1467 }
1468 }
1469 {
1470 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "uncheckable"));
1471 if (r && GTK_IS_TOGGLE_BUTTON(w)) { // checkbox
1472 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(w), FALSE);
1473 }
1474 }
1475 }
1477 if (GTK_IS_CONTAINER(w)) {
1478 GList *ch = gtk_container_get_children (GTK_CONTAINER(w));
1479 for (GList *i = ch; i != NULL; i = i->next) {
1480 clonetiler_reset_recursive (GTK_WIDGET(i->data));
1481 }
1482 g_list_free (ch);
1483 }
1484 }
1486 static void
1487 clonetiler_reset (GtkWidget *widget, void *)
1488 {
1489 clonetiler_reset_recursive (dlg);
1490 }
1492 static void
1493 clonetiler_table_attach (GtkWidget *table, GtkWidget *widget, float align, int row, int col)
1494 {
1495 GtkWidget *a = gtk_alignment_new (align, 0, 0, 0);
1496 gtk_container_add(GTK_CONTAINER(a), widget);
1497 gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 );
1498 }
1500 static GtkWidget *
1501 clonetiler_table_x_y_rand (int values)
1502 {
1503 GtkWidget *table = gtk_table_new (values + 2, 5, FALSE);
1504 gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
1505 gtk_table_set_row_spacings (GTK_TABLE (table), 6);
1506 gtk_table_set_col_spacings (GTK_TABLE (table), 8);
1508 {
1509 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
1511 GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "clonetiler_per_row");
1512 gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
1514 GtkWidget *l = gtk_label_new ("");
1515 gtk_label_set_markup (GTK_LABEL(l), _("<small>Per row:</small>"));
1516 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2);
1518 clonetiler_table_attach (table, hb, 0, 1, 2);
1519 }
1521 {
1522 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
1524 GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "clonetiler_per_column");
1525 gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
1527 GtkWidget *l = gtk_label_new ("");
1528 gtk_label_set_markup (GTK_LABEL(l), _("<small>Per column:</small>"));
1529 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2);
1531 clonetiler_table_attach (table, hb, 0, 1, 3);
1532 }
1534 {
1535 GtkWidget *l = gtk_label_new ("");
1536 gtk_label_set_markup (GTK_LABEL(l), _("<small>Randomize:</small>"));
1537 clonetiler_table_attach (table, l, 0, 1, 4);
1538 }
1540 return table;
1541 }
1543 static void
1544 clonetiler_pick_switched (GtkToggleButton *tb, gpointer data)
1545 {
1546 guint v = GPOINTER_TO_INT (data);
1547 prefs_set_int_attribute (prefs_path, "pick", v);
1548 }
1551 static void
1552 clonetiler_switch_to_create (GtkToggleButton *tb, GtkWidget *dlg)
1553 {
1554 GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
1555 GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
1557 if (rowscols) {
1558 gtk_widget_set_sensitive (rowscols, TRUE);
1559 }
1560 if (widthheight) {
1561 gtk_widget_set_sensitive (widthheight, FALSE);
1562 }
1564 prefs_set_int_attribute (prefs_path, "fillrect", 0);
1565 }
1568 static void
1569 clonetiler_switch_to_fill (GtkToggleButton *tb, GtkWidget *dlg)
1570 {
1571 GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
1572 GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
1574 if (rowscols) {
1575 gtk_widget_set_sensitive (rowscols, FALSE);
1576 }
1577 if (widthheight) {
1578 gtk_widget_set_sensitive (widthheight, TRUE);
1579 }
1581 prefs_set_int_attribute (prefs_path, "fillrect", 1);
1582 }
1587 static void
1588 clonetiler_fill_width_changed (GtkAdjustment *adj, GtkWidget *u)
1589 {
1590 gdouble const raw_dist = adj->value;
1591 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
1592 gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
1594 prefs_set_double_attribute (prefs_path, "fillwidth", pixels);
1595 }
1597 static void
1598 clonetiler_fill_height_changed (GtkAdjustment *adj, GtkWidget *u)
1599 {
1600 gdouble const raw_dist = adj->value;
1601 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
1602 gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
1604 prefs_set_double_attribute (prefs_path, "fillheight", pixels);
1605 }
1608 static void
1609 clonetiler_do_pick_toggled (GtkToggleButton *tb, gpointer data)
1610 {
1611 GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace");
1613 prefs_set_int_attribute (prefs_path, "dotrace", gtk_toggle_button_get_active (tb));
1615 if (vvb)
1616 gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb));
1617 }
1622 void
1623 clonetiler_dialog (void)
1624 {
1625 if (!dlg)
1626 {
1627 gchar title[500];
1628 sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_CLONETILER), title);
1630 dlg = sp_window_new (title, TRUE);
1631 if (x == -1000 || y == -1000) {
1632 x = prefs_get_int_attribute (prefs_path, "x", 0);
1633 y = prefs_get_int_attribute (prefs_path, "y", 0);
1634 }
1636 if (w ==0 || h == 0) {
1637 w = prefs_get_int_attribute (prefs_path, "w", 0);
1638 h = prefs_get_int_attribute (prefs_path, "h", 0);
1639 }
1641 if (x<0) x=0;
1642 if (y<0) y=0;
1644 if (x != 0 || y != 0) {
1645 gtk_window_move ((GtkWindow *) dlg, x, y);
1647 } else {
1648 gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
1649 }
1651 if (w && h) {
1652 gtk_window_resize ((GtkWindow *) dlg, w, h);
1653 }
1655 sp_transientize (dlg);
1656 wd.win = dlg;
1657 wd.stop = 0;
1660 gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg);
1662 gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg);
1663 gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg);
1665 if (Inkscape::NSApplication::Application::getNewGui())
1666 {
1667 _shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (&on_delete);
1668 _dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::bind (&on_dialog_hide, dlg));
1669 _dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::bind (&on_dialog_unhide, dlg));
1670 _desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::bind (&on_transientize, &wd));
1671 } else {
1672 g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
1673 g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
1674 g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
1675 g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
1676 }
1678 GtkTooltips *tt = gtk_tooltips_new();
1680 GtkWidget *mainbox = gtk_vbox_new(FALSE, 4);
1681 gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6);
1682 gtk_container_add (GTK_CONTAINER (dlg), mainbox);
1684 GtkWidget *nb = gtk_notebook_new ();
1685 gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0);
1688 // Symmetry
1689 {
1690 GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry"));
1692 GtkWidget *om = gtk_option_menu_new ();
1693 /* TRANSLATORS: For the following 17 symmetry groups, see
1694 * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples);
1695 * http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or
1696 * http://membres.lycos.fr/villemingerard/Geometri/Sym1D.htm (French vocabulary).
1697 */
1698 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), om, _("Select one of the 17 symmetry groups for the tiling"), NULL);
1699 gtk_box_pack_start (GTK_BOX (vb), om, FALSE, FALSE, SB_MARGIN);
1701 GtkWidget *m = gtk_menu_new ();
1702 int current = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
1704 struct SymGroups {
1705 int group;
1706 gchar const *label;
1707 } const sym_groups[] = {
1708 // TRANSLATORS: "translation" means "shift" / "displacement" here.
1709 {TILE_P1, _("<b>P1</b>: simple translation")},
1710 {TILE_P2, _("<b>P2</b>: 180° rotation")},
1711 {TILE_PM, _("<b>PM</b>: reflection")},
1712 // TRANSLATORS: "glide reflection" is a reflection and a translation combined.
1713 // For more info, see http://mathforum.org/sum95/suzanne/symsusan.html
1714 {TILE_PG, _("<b>PG</b>: glide reflection")},
1715 {TILE_CM, _("<b>CM</b>: reflection + glide reflection")},
1716 {TILE_PMM, _("<b>PMM</b>: reflection + reflection")},
1717 {TILE_PMG, _("<b>PMG</b>: reflection + 180° rotation")},
1718 {TILE_PGG, _("<b>PGG</b>: glide reflection + 180° rotation")},
1719 {TILE_CMM, _("<b>CMM</b>: reflection + reflection + 180° rotation")},
1720 {TILE_P4, _("<b>P4</b>: 90° rotation")},
1721 {TILE_P4M, _("<b>P4M</b>: 90° rotation + 45° reflection")},
1722 {TILE_P4G, _("<b>P4G</b>: 90° rotation + 90° reflection")},
1723 {TILE_P3, _("<b>P3</b>: 120° rotation")},
1724 {TILE_P31M, _("<b>P31M</b>: reflection + 120° rotation, dense")},
1725 {TILE_P3M1, _("<b>P3M1</b>: reflection + 120° rotation, sparse")},
1726 {TILE_P6, _("<b>P6</b>: 60° rotation")},
1727 {TILE_P6M, _("<b>P6M</b>: reflection + 60° rotation")},
1728 };
1730 for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) {
1731 SymGroups const &sg = sym_groups[j];
1733 GtkWidget *l = gtk_label_new ("");
1734 gtk_label_set_markup (GTK_LABEL(l), sg.label);
1735 gtk_misc_set_alignment (GTK_MISC(l), 0, 0.5);
1737 GtkWidget *item = gtk_menu_item_new ();
1738 gtk_container_add (GTK_CONTAINER (item), l);
1740 gtk_signal_connect ( GTK_OBJECT (item), "activate",
1741 GTK_SIGNAL_FUNC (clonetiler_symgroup_changed),
1742 GINT_TO_POINTER (sg.group) );
1744 gtk_menu_append (GTK_MENU (m), item);
1745 }
1747 gtk_option_menu_set_menu (GTK_OPTION_MENU (om), m);
1748 gtk_option_menu_set_history ( GTK_OPTION_MENU (om), current);
1749 }
1751 table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1753 // Shift
1754 {
1755 GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift"));
1757 GtkWidget *table = clonetiler_table_x_y_rand (3);
1758 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1760 // X
1761 {
1762 GtkWidget *l = gtk_label_new ("");
1763 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount
1764 // xgettext:no-c-format
1765 gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift X:</b>"));
1766 gtk_size_group_add_widget(table_row_labels, l);
1767 clonetiler_table_attach (table, l, 1, 2, 1);
1768 }
1770 {
1771 GtkWidget *l = clonetiler_spinbox (tt,
1772 // xgettext:no-c-format
1773 _("Horizontal shift per row (in % of tile width)"), "d_x_per_y",
1774 -100, 1000, "%");
1775 clonetiler_table_attach (table, l, 0, 2, 2);
1776 }
1778 {
1779 GtkWidget *l = clonetiler_spinbox (tt,
1780 // xgettext:no-c-format
1781 _("Horizontal shift per column (in % of tile width)"), "d_x_per_x",
1782 -100, 1000, "%");
1783 clonetiler_table_attach (table, l, 0, 2, 3);
1784 }
1786 {
1787 GtkWidget *l = clonetiler_spinbox (tt,
1788 _("Randomize the horizontal shift by this percentage"), "rand_x",
1789 0, 1000, "%");
1790 clonetiler_table_attach (table, l, 0, 2, 4);
1791 }
1793 // Y
1794 {
1795 GtkWidget *l = gtk_label_new ("");
1796 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) vertically by this amount
1797 // xgettext:no-c-format
1798 gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>"));
1799 gtk_size_group_add_widget(table_row_labels, l);
1800 clonetiler_table_attach (table, l, 1, 3, 1);
1801 }
1803 {
1804 GtkWidget *l = clonetiler_spinbox (tt,
1805 // xgettext:no-c-format
1806 _("Vertical shift per row (in % of tile height)"), "d_y_per_y",
1807 -100, 1000, "%");
1808 clonetiler_table_attach (table, l, 0, 3, 2);
1809 }
1811 {
1812 GtkWidget *l = clonetiler_spinbox (tt,
1813 // xgettext:no-c-format
1814 _("Vertical shift per column (in % of tile height)"), "d_y_per_x",
1815 -100, 1000, "%");
1816 clonetiler_table_attach (table, l, 0, 3, 3);
1817 }
1819 {
1820 GtkWidget *l = clonetiler_spinbox (tt,
1821 _("Randomize the vertical shift by this percentage"), "rand_y",
1822 0, 1000, "%");
1823 clonetiler_table_attach (table, l, 0, 3, 4);
1824 }
1826 // Exponent
1827 {
1828 GtkWidget *l = gtk_label_new ("");
1829 gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));
1830 gtk_size_group_add_widget(table_row_labels, l);
1831 clonetiler_table_attach (table, l, 1, 4, 1);
1832 }
1834 {
1835 GtkWidget *l = clonetiler_spinbox (tt,
1836 _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_y_exp",
1837 0, 10, "", true);
1838 clonetiler_table_attach (table, l, 0, 4, 2);
1839 }
1841 {
1842 GtkWidget *l = clonetiler_spinbox (tt,
1843 _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_x_exp",
1844 0, 10, "", true);
1845 clonetiler_table_attach (table, l, 0, 4, 3);
1846 }
1848 { // alternates
1849 GtkWidget *l = gtk_label_new ("");
1850 // TRANSLATORS: "Alternate" is a verb here
1851 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1852 gtk_size_group_add_widget(table_row_labels, l);
1853 clonetiler_table_attach (table, l, 1, 5, 1);
1854 }
1856 {
1857 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each row"), "alternate_y");
1858 clonetiler_table_attach (table, l, 0, 5, 2);
1859 }
1861 {
1862 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each column"), "alternate_x");
1863 clonetiler_table_attach (table, l, 0, 5, 3);
1864 }
1866 }
1869 // Scale
1870 {
1871 GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale"));
1873 GtkWidget *table = clonetiler_table_x_y_rand (2);
1874 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1876 // X
1877 {
1878 GtkWidget *l = gtk_label_new ("");
1879 gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale X:</b>"));
1880 gtk_size_group_add_widget(table_row_labels, l);
1881 clonetiler_table_attach (table, l, 1, 2, 1);
1882 }
1884 {
1885 GtkWidget *l = clonetiler_spinbox (tt,
1886 // xgettext:no-c-format
1887 _("Horizontal scale per row (in % of tile width)"), "d_scalex_per_y",
1888 -100, 1000, "%");
1889 clonetiler_table_attach (table, l, 0, 2, 2);
1890 }
1892 {
1893 GtkWidget *l = clonetiler_spinbox (tt,
1894 // xgettext:no-c-format
1895 _("Horizontal scale per column (in % of tile width)"), "d_scalex_per_x",
1896 -100, 1000, "%");
1897 clonetiler_table_attach (table, l, 0, 2, 3);
1898 }
1900 {
1901 GtkWidget *l = clonetiler_spinbox (tt,
1902 _("Randomize the horizontal scale by this percentage"), "rand_scalex",
1903 0, 1000, "%");
1904 clonetiler_table_attach (table, l, 0, 2, 4);
1905 }
1907 // Y
1908 {
1909 GtkWidget *l = gtk_label_new ("");
1910 gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale Y:</b>"));
1911 gtk_size_group_add_widget(table_row_labels, l);
1912 clonetiler_table_attach (table, l, 1, 3, 1);
1913 }
1915 {
1916 GtkWidget *l = clonetiler_spinbox (tt,
1917 // xgettext:no-c-format
1918 _("Vertical scale per row (in % of tile height)"), "d_scaley_per_y",
1919 -100, 1000, "%");
1920 clonetiler_table_attach (table, l, 0, 3, 2);
1921 }
1923 {
1924 GtkWidget *l = clonetiler_spinbox (tt,
1925 // xgettext:no-c-format
1926 _("Vertical scale per column (in % of tile height)"), "d_scaley_per_x",
1927 -100, 1000, "%");
1928 clonetiler_table_attach (table, l, 0, 3, 3);
1929 }
1931 {
1932 GtkWidget *l = clonetiler_spinbox (tt,
1933 _("Randomize the vertical scale by this percentage"), "rand_scaley",
1934 0, 1000, "%");
1935 clonetiler_table_attach (table, l, 0, 3, 4);
1936 }
1938 { // alternates
1939 GtkWidget *l = gtk_label_new ("");
1940 // TRANSLATORS: "Alternate" is a verb here
1941 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1942 gtk_size_group_add_widget(table_row_labels, l);
1943 clonetiler_table_attach (table, l, 1, 4, 1);
1944 }
1946 {
1947 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each row"), "alternate_scaley");
1948 clonetiler_table_attach (table, l, 0, 4, 2);
1949 }
1951 {
1952 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each column"), "alternate_scalex");
1953 clonetiler_table_attach (table, l, 0, 4, 3);
1954 }
1956 }
1959 // Rotation
1960 {
1961 GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation"));
1963 GtkWidget *table = clonetiler_table_x_y_rand (1);
1964 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1966 // Angle
1967 {
1968 GtkWidget *l = gtk_label_new ("");
1969 gtk_label_set_markup (GTK_LABEL(l), _("<b>Angle:</b>"));
1970 gtk_size_group_add_widget(table_row_labels, l);
1971 clonetiler_table_attach (table, l, 1, 2, 1);
1972 }
1974 {
1975 GtkWidget *l = clonetiler_spinbox (tt,
1976 // xgettext:no-c-format
1977 _("Rotate tiles by this angle for each row"), "d_rot_per_y",
1978 -180, 180, "°");
1979 clonetiler_table_attach (table, l, 0, 2, 2);
1980 }
1982 {
1983 GtkWidget *l = clonetiler_spinbox (tt,
1984 // xgettext:no-c-format
1985 _("Rotate tiles by this angle for each column"), "d_rot_per_x",
1986 -180, 180, "°");
1987 clonetiler_table_attach (table, l, 0, 2, 3);
1988 }
1990 {
1991 GtkWidget *l = clonetiler_spinbox (tt,
1992 _("Randomize the rotation angle by this percentage"), "rand_rot",
1993 0, 100, "%");
1994 clonetiler_table_attach (table, l, 0, 2, 4);
1995 }
1997 { // alternates
1998 GtkWidget *l = gtk_label_new ("");
1999 // TRANSLATORS: "Alternate" is a verb here
2000 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
2001 gtk_size_group_add_widget(table_row_labels, l);
2002 clonetiler_table_attach (table, l, 1, 3, 1);
2003 }
2005 {
2006 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each row"), "alternate_roty");
2007 clonetiler_table_attach (table, l, 0, 3, 2);
2008 }
2010 {
2011 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each column"), "alternate_rotx");
2012 clonetiler_table_attach (table, l, 0, 3, 3);
2013 }
2014 }
2017 // Blur and opacity
2018 {
2019 GtkWidget *vb = clonetiler_new_tab (nb, _("_Blur & opacity"));
2021 GtkWidget *table = clonetiler_table_x_y_rand (1);
2022 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
2025 // Blur
2026 {
2027 GtkWidget *l = gtk_label_new ("");
2028 gtk_label_set_markup (GTK_LABEL(l), _("<b>Blur:</b>"));
2029 gtk_size_group_add_widget(table_row_labels, l);
2030 clonetiler_table_attach (table, l, 1, 2, 1);
2031 }
2033 {
2034 GtkWidget *l = clonetiler_spinbox (tt,
2035 _("Blur tiles by this percentage for each row"), "d_blur_per_y",
2036 0, 100, "%");
2037 clonetiler_table_attach (table, l, 0, 2, 2);
2038 }
2040 {
2041 GtkWidget *l = clonetiler_spinbox (tt,
2042 _("Blur tiles by this percentage for each column"), "d_blur_per_x",
2043 0, 100, "%");
2044 clonetiler_table_attach (table, l, 0, 2, 3);
2045 }
2047 {
2048 GtkWidget *l = clonetiler_spinbox (tt,
2049 _("Randomize the tile blur by this percentage"), "rand_blur",
2050 0, 100, "%");
2051 clonetiler_table_attach (table, l, 0, 2, 4);
2052 }
2054 { // alternates
2055 GtkWidget *l = gtk_label_new ("");
2056 // TRANSLATORS: "Alternate" is a verb here
2057 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
2058 gtk_size_group_add_widget(table_row_labels, l);
2059 clonetiler_table_attach (table, l, 1, 3, 1);
2060 }
2062 {
2063 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each row"), "alternate_blury");
2064 clonetiler_table_attach (table, l, 0, 3, 2);
2065 }
2067 {
2068 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each column"), "alternate_blurx");
2069 clonetiler_table_attach (table, l, 0, 3, 3);
2070 }
2074 // Dissolve
2075 {
2076 GtkWidget *l = gtk_label_new ("");
2077 gtk_label_set_markup (GTK_LABEL(l), _("<b>Fade out:</b>"));
2078 gtk_size_group_add_widget(table_row_labels, l);
2079 clonetiler_table_attach (table, l, 1, 4, 1);
2080 }
2082 {
2083 GtkWidget *l = clonetiler_spinbox (tt,
2084 _("Decrease tile opacity by this percentage for each row"), "d_opacity_per_y",
2085 0, 100, "%");
2086 clonetiler_table_attach (table, l, 0, 4, 2);
2087 }
2089 {
2090 GtkWidget *l = clonetiler_spinbox (tt,
2091 _("Decrease tile opacity by this percentage for each column"), "d_opacity_per_x",
2092 0, 100, "%");
2093 clonetiler_table_attach (table, l, 0, 4, 3);
2094 }
2096 {
2097 GtkWidget *l = clonetiler_spinbox (tt,
2098 _("Randomize the tile opacity by this percentage"), "rand_opacity",
2099 0, 100, "%");
2100 clonetiler_table_attach (table, l, 0, 4, 4);
2101 }
2103 { // alternates
2104 GtkWidget *l = gtk_label_new ("");
2105 // TRANSLATORS: "Alternate" is a verb here
2106 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
2107 gtk_size_group_add_widget(table_row_labels, l);
2108 clonetiler_table_attach (table, l, 1, 5, 1);
2109 }
2111 {
2112 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "alternate_opacityy");
2113 clonetiler_table_attach (table, l, 0, 5, 2);
2114 }
2116 {
2117 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each column"), "alternate_opacityx");
2118 clonetiler_table_attach (table, l, 0, 5, 3);
2119 }
2120 }
2123 // Color
2124 {
2125 GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor"));
2127 {
2128 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
2130 GtkWidget *l = gtk_label_new (_("Initial color: "));
2131 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
2133 guint32 rgba = 0x000000ff | sp_svg_read_color (prefs_get_string_attribute(prefs_path, "initial_color"), 0x000000ff);
2134 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);
2135 _color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));
2137 gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0);
2139 gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
2140 }
2143 GtkWidget *table = clonetiler_table_x_y_rand (3);
2144 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
2146 // Hue
2147 {
2148 GtkWidget *l = gtk_label_new ("");
2149 gtk_label_set_markup (GTK_LABEL(l), _("<b>H:</b>"));
2150 gtk_size_group_add_widget(table_row_labels, l);
2151 clonetiler_table_attach (table, l, 1, 2, 1);
2152 }
2154 {
2155 GtkWidget *l = clonetiler_spinbox (tt,
2156 _("Change the tile hue by this percentage for each row"), "d_hue_per_y",
2157 -100, 100, "%");
2158 clonetiler_table_attach (table, l, 0, 2, 2);
2159 }
2161 {
2162 GtkWidget *l = clonetiler_spinbox (tt,
2163 _("Change the tile hue by this percentage for each column"), "d_hue_per_x",
2164 -100, 100, "%");
2165 clonetiler_table_attach (table, l, 0, 2, 3);
2166 }
2168 {
2169 GtkWidget *l = clonetiler_spinbox (tt,
2170 _("Randomize the tile hue by this percentage"), "rand_hue",
2171 0, 100, "%");
2172 clonetiler_table_attach (table, l, 0, 2, 4);
2173 }
2176 // Saturation
2177 {
2178 GtkWidget *l = gtk_label_new ("");
2179 gtk_label_set_markup (GTK_LABEL(l), _("<b>S:</b>"));
2180 gtk_size_group_add_widget(table_row_labels, l);
2181 clonetiler_table_attach (table, l, 1, 3, 1);
2182 }
2184 {
2185 GtkWidget *l = clonetiler_spinbox (tt,
2186 _("Change the color saturation by this percentage for each row"), "d_saturation_per_y",
2187 -100, 100, "%");
2188 clonetiler_table_attach (table, l, 0, 3, 2);
2189 }
2191 {
2192 GtkWidget *l = clonetiler_spinbox (tt,
2193 _("Change the color saturation by this percentage for each column"), "d_saturation_per_x",
2194 -100, 100, "%");
2195 clonetiler_table_attach (table, l, 0, 3, 3);
2196 }
2198 {
2199 GtkWidget *l = clonetiler_spinbox (tt,
2200 _("Randomize the color saturation by this percentage"), "rand_saturation",
2201 0, 100, "%");
2202 clonetiler_table_attach (table, l, 0, 3, 4);
2203 }
2205 // Lightness
2206 {
2207 GtkWidget *l = gtk_label_new ("");
2208 gtk_label_set_markup (GTK_LABEL(l), _("<b>L:</b>"));
2209 gtk_size_group_add_widget(table_row_labels, l);
2210 clonetiler_table_attach (table, l, 1, 4, 1);
2211 }
2213 {
2214 GtkWidget *l = clonetiler_spinbox (tt,
2215 _("Change the color lightness by this percentage for each row"), "d_lightness_per_y",
2216 -100, 100, "%");
2217 clonetiler_table_attach (table, l, 0, 4, 2);
2218 }
2220 {
2221 GtkWidget *l = clonetiler_spinbox (tt,
2222 _("Change the color lightness by this percentage for each column"), "d_lightness_per_x",
2223 -100, 100, "%");
2224 clonetiler_table_attach (table, l, 0, 4, 3);
2225 }
2227 {
2228 GtkWidget *l = clonetiler_spinbox (tt,
2229 _("Randomize the color lightness by this percentage"), "rand_lightness",
2230 0, 100, "%");
2231 clonetiler_table_attach (table, l, 0, 4, 4);
2232 }
2235 { // alternates
2236 GtkWidget *l = gtk_label_new ("");
2237 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
2238 gtk_size_group_add_widget(table_row_labels, l);
2239 clonetiler_table_attach (table, l, 1, 5, 1);
2240 }
2242 {
2243 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each row"), "alternate_color_y");
2244 clonetiler_table_attach (table, l, 0, 5, 2);
2245 }
2247 {
2248 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each column"), "alternate_color_x");
2249 clonetiler_table_attach (table, l, 0, 5, 3);
2250 }
2252 }
2254 // Trace
2255 {
2256 GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace"));
2259 {
2260 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2261 gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
2263 GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles"));
2264 g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
2265 gint old = prefs_get_int_attribute (prefs_path, "dotrace", 0);
2266 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2267 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);
2268 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2270 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2271 GTK_SIGNAL_FUNC(clonetiler_do_pick_toggled), dlg);
2272 }
2274 {
2275 GtkWidget *vvb = gtk_vbox_new (FALSE, 0);
2276 gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0);
2277 g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb);
2280 {
2281 GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:"));
2282 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0);
2284 GtkWidget *table = gtk_table_new (3, 3, FALSE);
2285 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2286 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2287 gtk_container_add(GTK_CONTAINER(frame), table);
2290 GtkWidget* radio;
2291 {
2292 radio = gtk_radio_button_new_with_label (NULL, _("Color"));
2293 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the visible color and opacity"), NULL);
2294 clonetiler_table_attach (table, radio, 0.0, 1, 1);
2295 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2296 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR));
2297 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_COLOR);
2298 }
2299 {
2300 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity"));
2301 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the total accumulated opacity"), NULL);
2302 clonetiler_table_attach (table, radio, 0.0, 2, 1);
2303 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2304 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY));
2305 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_OPACITY);
2306 }
2307 {
2308 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R"));
2309 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Red component of the color"), NULL);
2310 clonetiler_table_attach (table, radio, 0.0, 1, 2);
2311 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2312 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R));
2313 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_R);
2314 }
2315 {
2316 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G"));
2317 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Green component of the color"), NULL);
2318 clonetiler_table_attach (table, radio, 0.0, 2, 2);
2319 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2320 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G));
2321 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_G);
2322 }
2323 {
2324 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B"));
2325 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Blue component of the color"), NULL);
2326 clonetiler_table_attach (table, radio, 0.0, 3, 2);
2327 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2328 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B));
2329 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_B);
2330 }
2331 {
2332 //TRANSLATORS: only translate "string" in "context|string".
2333 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2334 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|H"));
2335 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the hue of the color"), NULL);
2336 clonetiler_table_attach (table, radio, 0.0, 1, 3);
2337 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2338 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H));
2339 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_H);
2340 }
2341 {
2342 //TRANSLATORS: only translate "string" in "context|string".
2343 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2344 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|S"));
2345 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the saturation of the color"), NULL);
2346 clonetiler_table_attach (table, radio, 0.0, 2, 3);
2347 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2348 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S));
2349 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_S);
2350 }
2351 {
2352 //TRANSLATORS: only translate "string" in "context|string".
2353 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2354 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|L"));
2355 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the lightness of the color"), NULL);
2356 clonetiler_table_attach (table, radio, 0.0, 3, 3);
2357 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2358 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L));
2359 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_L);
2360 }
2362 }
2364 {
2365 GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:"));
2366 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN);
2368 GtkWidget *table = gtk_table_new (4, 2, FALSE);
2369 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2370 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2371 gtk_container_add(GTK_CONTAINER(frame), table);
2373 {
2374 GtkWidget *l = gtk_label_new ("");
2375 gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:"));
2376 clonetiler_table_attach (table, l, 1.0, 1, 1);
2377 }
2378 {
2379 GtkWidget *l = clonetiler_spinbox (tt,
2380 _("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked",
2381 -10, 10, "");
2382 clonetiler_table_attach (table, l, 0.0, 1, 2);
2383 }
2385 {
2386 GtkWidget *l = gtk_label_new ("");
2387 gtk_label_set_markup (GTK_LABEL(l), _("Randomize:"));
2388 clonetiler_table_attach (table, l, 1.0, 1, 3);
2389 }
2390 {
2391 GtkWidget *l = clonetiler_spinbox (tt,
2392 _("Randomize the picked value by this percentage"), "rand_picked",
2393 0, 100, "%");
2394 clonetiler_table_attach (table, l, 0.0, 1, 4);
2395 }
2397 {
2398 GtkWidget *l = gtk_label_new ("");
2399 gtk_label_set_markup (GTK_LABEL(l), _("Invert:"));
2400 clonetiler_table_attach (table, l, 1.0, 2, 1);
2401 }
2402 {
2403 GtkWidget *l = clonetiler_checkbox (tt, _("Invert the picked value"), "invert_picked");
2404 clonetiler_table_attach (table, l, 0.0, 2, 2);
2405 }
2406 }
2408 {
2409 GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':"));
2410 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0);
2413 GtkWidget *table = gtk_table_new (2, 2, FALSE);
2414 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2415 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2416 gtk_container_add(GTK_CONTAINER(frame), table);
2418 {
2419 GtkWidget *b = gtk_check_button_new_with_label (_("Presence"));
2420 gint old = prefs_get_int_attribute (prefs_path, "pick_to_presence", 1);
2421 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2422 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is created with the probability determined by the picked value in that point"), NULL);
2423 clonetiler_table_attach (table, b, 0.0, 1, 1);
2424 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2425 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_presence");
2426 }
2428 {
2429 GtkWidget *b = gtk_check_button_new_with_label (_("Size"));
2430 gint old = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
2431 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2432 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's size is determined by the picked value in that point"), NULL);
2433 clonetiler_table_attach (table, b, 0.0, 2, 1);
2434 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2435 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_size");
2436 }
2438 {
2439 GtkWidget *b = gtk_check_button_new_with_label (_("Color"));
2440 gint old = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
2441 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2442 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);
2443 clonetiler_table_attach (table, b, 0.0, 1, 2);
2444 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2445 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_color");
2446 }
2448 {
2449 GtkWidget *b = gtk_check_button_new_with_label (_("Opacity"));
2450 gint old = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
2451 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2452 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's opacity is determined by the picked value in that point"), NULL);
2453 clonetiler_table_attach (table, b, 0.0, 2, 2);
2454 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2455 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_opacity");
2456 }
2457 }
2458 gtk_widget_set_sensitive (vvb, prefs_get_int_attribute (prefs_path, "dotrace", 0));
2459 }
2460 }
2462 // Rows/columns, width/height
2463 {
2464 GtkWidget *table = gtk_table_new (2, 2, FALSE);
2465 gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
2466 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2467 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2468 gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0);
2470 {
2471 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2472 g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb);
2474 {
2475 GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
2476 int value = prefs_get_int_attribute (prefs_path, "ymax", 2);
2477 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
2478 GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
2479 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many rows in the tiling"), NULL);
2480 gtk_entry_set_width_chars (GTK_ENTRY (sb), 5);
2481 gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0);
2483 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2484 GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "ymax");
2485 }
2487 {
2488 GtkWidget *l = gtk_label_new ("");
2489 gtk_label_set_markup (GTK_LABEL(l), "×");
2490 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
2491 gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
2492 }
2494 {
2495 GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
2496 int value = prefs_get_int_attribute (prefs_path, "xmax", 2);
2497 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
2498 GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
2499 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many columns in the tiling"), NULL);
2500 gtk_entry_set_width_chars (GTK_ENTRY (sb), 5);
2501 gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0);
2503 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2504 GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "xmax");
2505 }
2507 clonetiler_table_attach (table, hb, 0.0, 1, 2);
2508 }
2510 {
2511 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2512 g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb);
2514 // unitmenu
2515 GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
2516 sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units);
2518 {
2519 // Width spinbutton
2520 GtkObject *a = gtk_adjustment_new (0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0);
2521 sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
2523 double value = prefs_get_double_attribute (prefs_path, "fillwidth", 50);
2524 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
2525 gdouble const units = sp_pixels_get_units (value, unit);
2526 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
2528 GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2);
2529 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), e, _("Width of the rectangle to be filled"), NULL);
2530 gtk_entry_set_width_chars (GTK_ENTRY (e), 5);
2531 gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0);
2532 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2533 GTK_SIGNAL_FUNC(clonetiler_fill_width_changed), u);
2534 }
2535 {
2536 GtkWidget *l = gtk_label_new ("");
2537 gtk_label_set_markup (GTK_LABEL(l), "×");
2538 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
2539 gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
2540 }
2542 {
2543 // Height spinbutton
2544 GtkObject *a = gtk_adjustment_new (0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0);
2545 sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
2547 double value = prefs_get_double_attribute (prefs_path, "fillheight", 50);
2548 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
2549 gdouble const units = sp_pixels_get_units (value, unit);
2550 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
2553 GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2);
2554 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), e, _("Height of the rectangle to be filled"), NULL);
2555 gtk_entry_set_width_chars (GTK_ENTRY (e), 5);
2556 gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0);
2557 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2558 GTK_SIGNAL_FUNC(clonetiler_fill_height_changed), u);
2559 }
2561 gtk_box_pack_start (GTK_BOX (hb), u, TRUE, TRUE, 0);
2562 clonetiler_table_attach (table, hb, 0.0, 2, 2);
2564 }
2566 // Switch
2567 GtkWidget* radio;
2568 {
2569 radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: "));
2570 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Create the specified number of rows and columns"), NULL);
2571 clonetiler_table_attach (table, radio, 0.0, 1, 1);
2572 gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg);
2573 }
2574 if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 0) {
2575 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
2576 gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
2577 }
2578 {
2579 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Width, height: "));
2580 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Fill the specified width and height with the tiling"), NULL);
2581 clonetiler_table_attach (table, radio, 0.0, 2, 1);
2582 gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg);
2583 }
2584 if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 1) {
2585 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
2586 gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
2587 }
2588 }
2591 // Use saved pos
2592 {
2593 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2594 gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2596 GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile"));
2597 gint keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
2598 gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox != 0);
2599 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);
2600 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2602 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2603 GTK_SIGNAL_FUNC(clonetiler_keep_bbox_toggled), NULL);
2604 }
2606 // Statusbar
2607 {
2608 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2609 gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2610 GtkWidget *l = gtk_label_new("");
2611 g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l);
2612 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
2613 }
2615 // Buttons
2616 {
2617 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2618 gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2620 {
2621 GtkWidget *b = gtk_button_new ();
2622 GtkWidget *l = gtk_label_new ("");
2623 gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> "));
2624 gtk_container_add (GTK_CONTAINER(b), l);
2625 gtk_tooltips_set_tip (tt, b, _("Create and tile the clones of the selection"), NULL);
2626 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_apply), NULL);
2627 gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0);
2628 }
2630 { // buttons which are enabled only when there are tiled clones
2631 GtkWidget *sb = gtk_hbox_new(FALSE, 0);
2632 gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0);
2633 g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb);
2634 {
2635 // TRANSLATORS: if a group of objects are "clumped" together, then they
2636 // are unevenly spread in the given amount of space - as shown in the
2637 // diagrams on the left in the following screenshot:
2638 // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png
2639 // So unclumping is the process of spreading a number of objects out more evenly.
2640 GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump "));
2641 gtk_tooltips_set_tip (tt, b, _("Spread out clones to reduce clumping; can be applied repeatedly"), NULL);
2642 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_unclump), NULL);
2643 gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0);
2644 }
2646 {
2647 GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move "));
2648 gtk_tooltips_set_tip (tt, b, _("Remove existing tiled clones of the selected object (siblings only)"), NULL);
2649 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_remove), NULL);
2650 gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0);
2651 }
2653 // connect to global selection changed signal (so we can change desktops) and
2654 // external_change (so we're not fooled by undo)
2655 g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg);
2656 g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg);
2657 g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE));
2659 // update now
2660 clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg);
2661 }
2663 {
2664 GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset "));
2665 // TRANSLATORS: "change" is a noun here
2666 gtk_tooltips_set_tip (tt, b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero"), NULL);
2667 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_reset), NULL);
2668 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2669 }
2670 }
2672 gtk_widget_show_all (mainbox);
2674 } // end of if (!dlg)
2676 gtk_window_present ((GtkWindow *) dlg);
2677 }
2680 /*
2681 Local Variables:
2682 mode:c++
2683 c-file-style:"stroustrup"
2684 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2685 indent-tabs-mode:nil
2686 fill-column:99
2687 End:
2688 */
2689 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :