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