diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-03-24 05:24:22 +0000 |
|---|---|---|
| committer | John Smith <removethis.john.q.public@bigmail.com> | 2012-03-24 05:24:22 +0000 |
| commit | da7fae5bb65071a4f90505799d74ef937cb275f1 (patch) | |
| tree | 1dd96b64106b0228fa88ab0c489d5807d2b6b8f4 /src | |
| parent | final cleanup of spiro? (diff) | |
| download | inkscape-da7fae5bb65071a4f90505799d74ef937cb275f1.tar.gz inkscape-da7fae5bb65071a4f90505799d74ef937cb275f1.zip | |
Fix for 251674 and 592323 : Make CloneTiler dialog dockable
(bzr r11125)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dialogs/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/dialogs/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/dialogs/clonetiler.h | 30 | ||||
| -rw-r--r-- | src/ui/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/ui/dialog/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/ui/dialog/clonetiler.cpp (renamed from src/dialogs/clonetiler.cpp) | 2455 | ||||
| -rw-r--r-- | src/ui/dialog/clonetiler.h | 183 | ||||
| -rw-r--r-- | src/ui/dialog/dialog-manager.cpp | 3 | ||||
| -rw-r--r-- | src/verbs.cpp | 5 |
9 files changed, 1379 insertions, 1305 deletions
diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index 7af6f2ede..1cd230a08 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -1,12 +1,10 @@ set(dialogs_SRC - clonetiler.cpp dialog-events.cpp find.cpp # ------- # Headers - clonetiler.h dialog-events.h find.h ) diff --git a/src/dialogs/Makefile_insert b/src/dialogs/Makefile_insert index ac0792a73..62641ecb9 100644 --- a/src/dialogs/Makefile_insert +++ b/src/dialogs/Makefile_insert @@ -1,8 +1,6 @@ ## Makefile.am fragment sourced by src/Makefile.am. ink_common_sources += \ - dialogs/clonetiler.cpp \ - dialogs/clonetiler.h \ dialogs/dialog-events.cpp \ dialogs/dialog-events.h \ dialogs/find.cpp \ diff --git a/src/dialogs/clonetiler.h b/src/dialogs/clonetiler.h deleted file mode 100644 index 899181346..000000000 --- a/src/dialogs/clonetiler.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - * @brief Clone tiling dialog - */ -/* Authors: - * bulia byak <buliabyak@users.sf.net> - * - * Copyright (C) 2004 Authors - * Released under the GNU GPL, read the file 'COPYING' for more information - */ -#ifndef __SP_CLONE_TILER_H__ -#define __SP_CLONE_TILER_H__ - -#include <glib.h> - -#include <gtk/gtk.h> - -void clonetiler_dialog ( void ); - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 484edc6e2..35840e0c4 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -25,6 +25,7 @@ set(ui_SRC dialog/align-and-distribute.cpp dialog/calligraphic-profile-rename.cpp dialog/color-item.cpp + dialog/clonetiler.cpp dialog/debug.cpp dialog/desktop-tracker.cpp dialog/dialog-manager.cpp @@ -134,6 +135,7 @@ set(ui_SRC dialog/behavior.h dialog/calligraphic-profile-rename.h dialog/color-item.h + dialog/clonetiler.h dialog/debug.h dialog/desktop-tracker.h dialog/dialog-manager.h diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 91b1ccaf6..f8b95247a 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -8,6 +8,8 @@ ink_common_sources += \ ui/dialog/behavior.h \ ui/dialog/calligraphic-profile-rename.h \ ui/dialog/calligraphic-profile-rename.cpp \ + ui/dialog/clonetiler.cpp \ + ui/dialog/clonetiler.h \ ui/dialog/color-item.cpp \ ui/dialog/color-item.h \ ui/dialog/debug.cpp \ diff --git a/src/dialogs/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index c56abc21a..36e79a682 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1,3 +1,4 @@ + /** @file * Clone tiling dialog */ @@ -16,9 +17,9 @@ # include "config.h" #endif -#include <climits> +#include "clonetiler.h" -#include "ui/widget/color-picker.h" +#include <climits> #include <glib.h> #include <glibmm/i18n.h> @@ -27,7 +28,6 @@ #include "desktop.h" #include "desktop-handles.h" -#include "dialog-events.h" #include "display/cairo-utils.h" #include "display/drawing.h" #include "display/drawing-context.h" @@ -58,81 +58,1175 @@ #include "xml/repr.h" #include "sp-root.h" -#include <gtk/gtk.h> - using Inkscape::DocumentUndo; -#define MIN_ONSCREEN_DISTANCE 50 +namespace Inkscape { +namespace UI { +namespace Dialog { -static GtkWidget *dlg = NULL; -static win_data wd; +#define SB_MARGIN 1 +#define VB_MARGIN 4 -// impossible original values to make sure they are read from prefs -static gint x = -1000, y = -1000, w = 0, h = 0; static Glib::ustring const prefs_path = "/dialogs/clonetiler/"; -#define SB_MARGIN 1 -#define VB_MARGIN 4 +static Inkscape::Drawing *trace_drawing = NULL; +static unsigned trace_visionkey; +static gdouble trace_zoom; +static SPDocument *trace_doc = NULL; -enum { - PICK_COLOR, - PICK_OPACITY, - PICK_R, - PICK_G, - PICK_B, - PICK_H, - PICK_S, - PICK_L -}; -static GtkSizeGroup* table_row_labels = NULL; +CloneTiler::CloneTiler (void) : + UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER), + dlg(NULL), + desktop(NULL), + deskTrack(), + table_row_labels(NULL), + selectChangedConn(), + subselChangedConn(), + selectModifiedConn() +{ + Gtk::Box *contents = _getContents(); + contents->set_spacing(0); -static sigc::connection _shutdown_connection; -static sigc::connection _dialogs_hidden_connection; -static sigc::connection _dialogs_unhidden_connection; -static sigc::connection _desktop_activated_connection; -static sigc::connection _color_changed_connection; + { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); -static Inkscape::UI::Widget::ColorPicker *color_picker; + dlg = GTK_WIDGET(gobj()); -static void clonetiler_dialog_destroy(GtkObject */*object*/, gpointer /*data*/) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt(prefs_path + "visible", 0); + GtkWidget *mainbox = gtk_vbox_new(FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6); - sp_signal_disconnect_by_data (INKSCAPE, dlg); - _color_changed_connection.disconnect(); + contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0); - delete color_picker; + GtkWidget *nb = gtk_notebook_new (); + gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0); - wd.win = dlg = NULL; - wd.stop = 0; -} + // Symmetry + { + GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry")); -static gboolean clonetiler_dialog_delete(GtkObject */*object*/, GdkEvent * /*event*/, gpointer /*data*/) -{ - gtk_window_get_position ((GtkWindow *) dlg, &x, &y); - gtk_window_get_size ((GtkWindow *) dlg, &w, &h); + /* TRANSLATORS: For the following 17 symmetry groups, see + * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples); + * http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or + * http://membres.lycos.fr/villemingerard/Geometri/Sym1D.htm (French vocabulary). + */ + struct SymGroups { + gint group; + gchar const *label; + } const sym_groups[] = { + // TRANSLATORS: "translation" means "shift" / "displacement" here. + {TILE_P1, _("<b>P1</b>: simple translation")}, + {TILE_P2, _("<b>P2</b>: 180° rotation")}, + {TILE_PM, _("<b>PM</b>: reflection")}, + // TRANSLATORS: "glide reflection" is a reflection and a translation combined. + // For more info, see http://mathforum.org/sum95/suzanne/symsusan.html + {TILE_PG, _("<b>PG</b>: glide reflection")}, + {TILE_CM, _("<b>CM</b>: reflection + glide reflection")}, + {TILE_PMM, _("<b>PMM</b>: reflection + reflection")}, + {TILE_PMG, _("<b>PMG</b>: reflection + 180° rotation")}, + {TILE_PGG, _("<b>PGG</b>: glide reflection + 180° rotation")}, + {TILE_CMM, _("<b>CMM</b>: reflection + reflection + 180° rotation")}, + {TILE_P4, _("<b>P4</b>: 90° rotation")}, + {TILE_P4M, _("<b>P4M</b>: 90° rotation + 45° reflection")}, + {TILE_P4G, _("<b>P4G</b>: 90° rotation + 90° reflection")}, + {TILE_P3, _("<b>P3</b>: 120° rotation")}, + {TILE_P31M, _("<b>P31M</b>: reflection + 120° rotation, dense")}, + {TILE_P3M1, _("<b>P3M1</b>: reflection + 120° rotation, sparse")}, + {TILE_P6, _("<b>P6</b>: 60° rotation")}, + {TILE_P6M, _("<b>P6M</b>: reflection + 60° rotation")}, + }; + + gint current = prefs->getInt(prefs_path + "symmetrygroup", 0); + + // Create a list structure containing all the data to be displayed in + // the symmetry group combo box. + GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING); + GtkTreeIter iter; + + for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { + SymGroups const &sg = sym_groups[j]; + + // Add the description of the symgroup to a new row + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, sg.label, -1); + } + + // Add a new combo box widget with the list of symmetry groups to the vbox + GtkWidget *combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); + gtk_widget_set_tooltip_text (combo, _("Select one of the 17 symmetry groups for the tiling")); + gtk_box_pack_start (GTK_BOX (vb), combo, FALSE, FALSE, SB_MARGIN); + + // Specify the rendering of data from the list in a combo box cell + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "markup", 0, NULL); + + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current); + + g_signal_connect(G_OBJECT(combo), "changed", + G_CALLBACK(clonetiler_symgroup_changed), NULL); + } + + table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + + // Shift + { + GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift")); + + GtkWidget *table = clonetiler_table_x_y_rand (3); + gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); + + // X + { + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount + // xgettext:no-c-format + gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift X:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 2, 1); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j", + -10000, 10000, "%"); + clonetiler_table_attach (table, l, 0, 2, 2); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i", + -10000, 10000, "%"); + clonetiler_table_attach (table, l, 0, 2, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", + 0, 1000, "%"); + clonetiler_table_attach (table, l, 0, 2, 4); + } + + // Y + { + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "shift" means: the tiles will be shifted (offset) vertically by this amount + // xgettext:no-c-format + gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 3, 1); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Vertical shift per row (in % of tile height)"), "shifty_per_j", + -10000, 10000, "%"); + clonetiler_table_attach (table, l, 0, 3, 2); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Vertical shift per column (in % of tile height)"), "shifty_per_i", + -10000, 10000, "%"); + clonetiler_table_attach (table, l, 0, 3, 3); + } + + { + GtkWidget *l = clonetiler_spinbox ( + _("Randomize the vertical shift by this percentage"), "shifty_rand", + 0, 1000, "%"); + clonetiler_table_attach (table, l, 0, 3, 4); + } + + // Exponent + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 4, 1); + } + + { + GtkWidget *l = clonetiler_spinbox ( + _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp", + 0, 10, "", true); + clonetiler_table_attach (table, l, 0, 4, 2); + } + + { + GtkWidget *l = clonetiler_spinbox ( + _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp", + 0, 10, "", true); + clonetiler_table_attach (table, l, 0, 4, 3); + } + + { // alternates + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Alternate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 5, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); + clonetiler_table_attach (table, l, 0, 5, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); + clonetiler_table_attach (table, l, 0, 5, 3); + } + + { // Cumulate + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Cumulate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 6, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); + clonetiler_table_attach (table, l, 0, 6, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); + clonetiler_table_attach (table, l, 0, 6, 3); + } + + { // Exclude tile width and height in shift + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Cumulate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Exclude tile:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 7, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); + clonetiler_table_attach (table, l, 0, 7, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); + clonetiler_table_attach (table, l, 0, 7, 3); + } + + } + + + // Scale + { + GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale")); + + GtkWidget *table = clonetiler_table_x_y_rand (2); + gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); + + // X + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale X:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 2, 1); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Horizontal scale per row (in % of tile width)"), "scalex_per_j", + -100, 1000, "%"); + clonetiler_table_attach (table, l, 0, 2, 2); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Horizontal scale per column (in % of tile width)"), "scalex_per_i", + -100, 1000, "%"); + clonetiler_table_attach (table, l, 0, 2, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", + 0, 1000, "%"); + clonetiler_table_attach (table, l, 0, 2, 4); + } + + // Y + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale Y:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 3, 1); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Vertical scale per row (in % of tile height)"), "scaley_per_j", + -100, 1000, "%"); + clonetiler_table_attach (table, l, 0, 3, 2); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Vertical scale per column (in % of tile height)"), "scaley_per_i", + -100, 1000, "%"); + clonetiler_table_attach (table, l, 0, 3, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", + 0, 1000, "%"); + clonetiler_table_attach (table, l, 0, 3, 4); + } + + // Exponent + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 4, 1); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", + 0, 10, "", true); + clonetiler_table_attach (table, l, 0, 4, 2); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", + 0, 10, "", true); + clonetiler_table_attach (table, l, 0, 4, 3); + } + + // Logarithmic (as in logarithmic spiral) + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>Base:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 5, 1); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", + 0, 10, "", false); + clonetiler_table_attach (table, l, 0, 5, 2); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", + 0, 10, "", false); + clonetiler_table_attach (table, l, 0, 5, 3); + } + + { // alternates + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Alternate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 6, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); + clonetiler_table_attach (table, l, 0, 6, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); + clonetiler_table_attach (table, l, 0, 6, 3); + } + + { // Cumulate + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Cumulate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 7, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); + clonetiler_table_attach (table, l, 0, 7, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); + clonetiler_table_attach (table, l, 0, 7, 3); + } + + } + + + // Rotation + { + GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation")); + + GtkWidget *table = clonetiler_table_x_y_rand (1); + gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); + + // Angle + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>Angle:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 2, 1); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Rotate tiles by this angle for each row"), "rotate_per_j", + -180, 180, "°"); + clonetiler_table_attach (table, l, 0, 2, 2); + } + + { + GtkWidget *l = clonetiler_spinbox ( + // xgettext:no-c-format + _("Rotate tiles by this angle for each column"), "rotate_per_i", + -180, 180, "°"); + clonetiler_table_attach (table, l, 0, 2, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 2, 4); + } + + { // alternates + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Alternate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 3, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); + clonetiler_table_attach (table, l, 0, 3, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); + clonetiler_table_attach (table, l, 0, 3, 3); + } + + { // Cumulate + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Cumulate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 4, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); + clonetiler_table_attach (table, l, 0, 4, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); + clonetiler_table_attach (table, l, 0, 4, 3); + } + + } + + + // Blur and opacity + { + GtkWidget *vb = clonetiler_new_tab (nb, _("_Blur & opacity")); + + GtkWidget *table = clonetiler_table_x_y_rand (1); + gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); + + + // Blur + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>Blur:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 2, 1); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 2, 2); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 2, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 2, 4); + } + + { // alternates + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Alternate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 3, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); + clonetiler_table_attach (table, l, 0, 3, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); + clonetiler_table_attach (table, l, 0, 3, 3); + } + + + + // Dissolve + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>Opacity:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 4, 1); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 4, 2); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 4, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 4, 4); + } + + { // alternates + GtkWidget *l = gtk_label_new (""); + // TRANSLATORS: "Alternate" is a verb here + gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 5, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); + clonetiler_table_attach (table, l, 0, 5, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); + clonetiler_table_attach (table, l, 0, 5, 3); + } + } + + + // Color + { + GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor")); + + { + GtkWidget *hb = gtk_hbox_new (FALSE, 0); + + GtkWidget *l = gtk_label_new (_("Initial color: ")); + gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); + + guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff); + 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); + color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed)); + + gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); + } + + + GtkWidget *table = clonetiler_table_x_y_rand (3); + gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); + + // Hue + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>H:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 2, 1); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", + -100, 100, "%"); + clonetiler_table_attach (table, l, 0, 2, 2); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", + -100, 100, "%"); + clonetiler_table_attach (table, l, 0, 2, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 2, 4); + } + + + // Saturation + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>S:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 3, 1); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", + -100, 100, "%"); + clonetiler_table_attach (table, l, 0, 3, 2); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", + -100, 100, "%"); + clonetiler_table_attach (table, l, 0, 3, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 3, 4); + } + + // Lightness + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<b>L:</b>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 4, 1); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", + -100, 100, "%"); + clonetiler_table_attach (table, l, 0, 4, 2); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", + -100, 100, "%"); + clonetiler_table_attach (table, l, 0, 4, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 4, 4); + } + + + { // alternates + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 5, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); + clonetiler_table_attach (table, l, 0, 5, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); + clonetiler_table_attach (table, l, 0, 5, 3); + } + + } + + // Trace + { + GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); + + + { + GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); + gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); + + GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles")); + g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); + bool old = prefs->getBool(prefs_path + "dotrace"); + gtk_toggle_button_set_active ((GtkToggleButton *) b, old); + gtk_widget_set_tooltip_text (b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone")); + gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); + + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)dlg); + } + + { + GtkWidget *vvb = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0); + g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb); + + + { + GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:")); + gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); + + GtkWidget *table = gtk_table_new (3, 3, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_table_set_col_spacings (GTK_TABLE (table), 6); + gtk_container_add(GTK_CONTAINER(frame), table); + + + GtkWidget* radio; + { + radio = gtk_radio_button_new_with_label (NULL, _("Color")); + gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); + clonetiler_table_attach (table, radio, 0.0, 1, 1); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); + } + { + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); + gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); + clonetiler_table_attach (table, radio, 0.0, 2, 1); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); + } + { + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R")); + gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); + clonetiler_table_attach (table, radio, 0.0, 1, 2); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); + } + { + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G")); + gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); + clonetiler_table_attach (table, radio, 0.0, 2, 2); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); + } + { + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B")); + gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); + clonetiler_table_attach (table, radio, 0.0, 3, 2); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); + } + { + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); + gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); + clonetiler_table_attach (table, radio, 0.0, 1, 3); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); + } + { + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); + gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); + clonetiler_table_attach (table, radio, 0.0, 2, 3); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); + } + { + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); + gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); + clonetiler_table_attach (table, radio, 0.0, 3, 3); + g_signal_connect (G_OBJECT (radio), "toggled", + G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L); + } + + } + + { + GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:")); + gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN); + + GtkWidget *table = gtk_table_new (4, 2, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_table_set_col_spacings (GTK_TABLE (table), 6); + gtk_container_add(GTK_CONTAINER(frame), table); + + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:")); + clonetiler_table_attach (table, l, 1.0, 1, 1); + } + { + GtkWidget *l = clonetiler_spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", + -10, 10, ""); + clonetiler_table_attach (table, l, 0.0, 1, 2); + } + + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("Randomize:")); + clonetiler_table_attach (table, l, 1.0, 1, 3); + } + { + GtkWidget *l = clonetiler_spinbox (_("Randomize the picked value by this percentage"), "rand_picked", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0.0, 1, 4); + } + + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("Invert:")); + clonetiler_table_attach (table, l, 1.0, 2, 1); + } + { + GtkWidget *l = clonetiler_checkbox (_("Invert the picked value"), "invert_picked"); + clonetiler_table_attach (table, l, 0.0, 2, 2); + } + } + + { + GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':")); + gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); + + + GtkWidget *table = gtk_table_new (2, 2, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_table_set_col_spacings (GTK_TABLE (table), 6); + gtk_container_add(GTK_CONTAINER(frame), table); + + { + GtkWidget *b = gtk_check_button_new_with_label (_("Presence")); + bool old = prefs->getBool(prefs_path + "pick_to_presence", true); + gtk_toggle_button_set_active ((GtkToggleButton *) b, old); + gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); + clonetiler_table_attach (table, b, 0.0, 1, 1); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_presence"); + } + + { + GtkWidget *b = gtk_check_button_new_with_label (_("Size")); + bool old = prefs->getBool(prefs_path + "pick_to_size"); + gtk_toggle_button_set_active ((GtkToggleButton *) b, old); + gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); + clonetiler_table_attach (table, b, 0.0, 2, 1); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_size"); + } + + { + GtkWidget *b = gtk_check_button_new_with_label (_("Color")); + bool old = prefs->getBool(prefs_path + "pick_to_color", 0); + gtk_toggle_button_set_active ((GtkToggleButton *) b, old); + gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); + clonetiler_table_attach (table, b, 0.0, 1, 2); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_color"); + } + + { + GtkWidget *b = gtk_check_button_new_with_label (_("Opacity")); + bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0); + gtk_toggle_button_set_active ((GtkToggleButton *) b, old); + gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); + clonetiler_table_attach (table, b, 0.0, 2, 2); + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_opacity"); + } + } + gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace")); + } + } + + // Rows/columns, width/height + { + GtkWidget *table = gtk_table_new (2, 2, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_table_set_col_spacings (GTK_TABLE (table), 6); + gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); + + { + GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); + g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); + + { + Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); + int value = prefs->getInt(prefs_path + "jmax", 2); + a->set_value (value); + + Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); + sb->set_tooltip_text (_("How many rows in the tiling")); + sb->set_width_chars (7); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); + + // TODO: C++ification + g_signal_connect(G_OBJECT(a->gobj()), "value_changed", + G_CALLBACK(clonetiler_xy_changed), (gpointer) "jmax"); + } + + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), "×"); + gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); + gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); + } + + { + Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); + int value = prefs->getInt(prefs_path + "imax", 2); + a->set_value (value); + + Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); + sb->set_tooltip_text (_("How many columns in the tiling")); + sb->set_width_chars (7); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); + + // TODO: C++ification + g_signal_connect(G_OBJECT(a->gobj()), "value_changed", + G_CALLBACK(clonetiler_xy_changed), (gpointer) "imax"); + } + + clonetiler_table_attach (table, hb, 0.0, 1, 2); + } + + { + GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); + g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); + + // unitmenu + GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); + sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units); + + { + // Width spinbutton + Gtk::Adjustment *a = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); + sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a->gobj())); + + double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); + SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); + gdouble const units = sp_pixels_get_units (value, unit); + a->set_value (units); + + Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 2); + e->set_tooltip_text (_("Width of the rectangle to be filled")); + e->set_width_chars (7); + e->set_digits (4); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); + // TODO: C++ification + g_signal_connect(G_OBJECT(a->gobj()), "value_changed", + G_CALLBACK(clonetiler_fill_width_changed), u); + } + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), "×"); + gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); + gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); + } + + { + // Height spinbutton + Gtk::Adjustment *a = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); + sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a->gobj())); + + double value = prefs->getDouble(prefs_path + "fillheight", 50.0); + SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); + gdouble const units = sp_pixels_get_units (value, unit); + a->set_value (units); + + Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 2); + e->set_tooltip_text (_("Height of the rectangle to be filled")); + e->set_width_chars (7); + e->set_digits (4); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); + // TODO: C++ification + g_signal_connect(G_OBJECT(a->gobj()), "value_changed", + G_CALLBACK(clonetiler_fill_height_changed), u); + } + + gtk_box_pack_start (GTK_BOX (hb), u, TRUE, TRUE, 0); + clonetiler_table_attach (table, hb, 0.0, 2, 2); + + } + + // Switch + GtkWidget* radio; + { + radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); + gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); + clonetiler_table_attach (table, radio, 0.0, 1, 1); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) dlg); + } + if (!prefs->getBool(prefs_path + "fillrect")) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); + gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); + } + { + radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); + gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); + clonetiler_table_attach (table, radio, 0.0, 2, 1); + g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg); + } + if (prefs->getBool(prefs_path + "fillrect")) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); + gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); + } + } + + + // Use saved pos + { + GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); + gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); + + GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); + bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true); + gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox); + gtk_widget_set_tooltip_text (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")); + gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); + + g_signal_connect(G_OBJECT(b), "toggled", + G_CALLBACK(clonetiler_keep_bbox_toggled), NULL); + } + + // Statusbar + { + GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); + gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); + GtkWidget *l = gtk_label_new(""); + g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l); + gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); + } + + // Buttons + { + GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); + gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); + + { + GtkWidget *b = gtk_button_new (); + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> ")); + gtk_container_add (GTK_CONTAINER(b), l); + gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection")); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_apply), dlg); + gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0); + } + + { // buttons which are enabled only when there are tiled clones + GtkWidget *sb = gtk_hbox_new(FALSE, 0); + gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0); + g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb); + { + // TRANSLATORS: if a group of objects are "clumped" together, then they + // are unevenly spread in the given amount of space - as shown in the + // diagrams on the left in the following screenshot: + // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png + // So unclumping is the process of spreading a number of objects out more evenly. + GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); + gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_unclump), NULL); + gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); + } + + { + GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move ")); + gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)")); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_remove), gpointer(dlg)); + gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); + } + + // connect to global selection changed signal (so we can change desktops) and + // external_change (so we're not fooled by undo) + g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg); + g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg); + g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE)); + + // update now + clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); + } + + { + GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); + // TRANSLATORS: "change" is a noun here + gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); + g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), dlg); + gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); + } + } + + gtk_widget_show_all (mainbox); - if (x < 0) { - x = 0; - } - if (y < 0) { - y = 0; } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt(prefs_path + "x", x); - prefs->setInt(prefs_path + "y", y); - prefs->setInt(prefs_path + "w", w); - prefs->setInt(prefs_path + "h", h); + show_all(); - return FALSE; // which means, go ahead and destroy it + desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &CloneTiler::setTargetDesktop) ); + deskTrack.connect(GTK_WIDGET(gobj())); } -static void on_picker_color_changed(guint rgba) +CloneTiler::~CloneTiler (void) +{ + //subselChangedConn.disconnect(); + //selectChangedConn.disconnect(); + //selectModifiedConn.disconnect(); + desktopChangeConn.disconnect(); + deskTrack.disconnect(); + color_changed_connection.disconnect(); +} + +void CloneTiler::setDesktop(SPDesktop *desktop) +{ + Panel::setDesktop(desktop); + deskTrack.setBase(desktop); +} + +void CloneTiler::setTargetDesktop(SPDesktop *desktop) +{ + if (this->desktop != desktop) { + if (this->desktop) { + //selectModifiedConn.disconnect(); + //subselChangedConn.disconnect(); + //selectChangedConn.disconnect(); + } + this->desktop = desktop; + if (desktop && desktop->selection) { + //selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); + //subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); + //selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); + } + } +} + +void CloneTiler::on_picker_color_changed(guint rgba) { static bool is_updating = false; if (is_updating || !SP_ACTIVE_DESKTOP) @@ -148,9 +1242,7 @@ static void on_picker_color_changed(guint rgba) is_updating = false; } -static guint clonetiler_number_of_clones(SPObject *obj); - -static void clonetiler_change_selection(Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg) +void CloneTiler::clonetiler_change_selection(Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg) { GtkWidget *buttons = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles"); GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status"); @@ -179,41 +1271,19 @@ static void clonetiler_change_selection(Inkscape::Application * /*inkscape*/, In } } -static void clonetiler_external_change(Inkscape::Application * /*inkscape*/, GtkWidget *dlg) +void CloneTiler::clonetiler_external_change(Inkscape::Application * /*inkscape*/, GtkWidget *dlg) { clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); } -static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source) +void CloneTiler::clonetiler_disconnect_gsignal(GObject *widget, gpointer source) { if (source && G_IS_OBJECT(source)) { sp_signal_disconnect_by_data (source, widget); } } - -enum { - TILE_P1, - TILE_P2, - TILE_PM, - TILE_PG, - TILE_CM, - TILE_PMM, - TILE_PMG, - TILE_PGG, - TILE_CMM, - TILE_P4, - TILE_P4M, - TILE_P4G, - TILE_P3, - TILE_P31M, - TILE_P3M1, - TILE_P6, - TILE_P6M -}; - - -static Geom::Affine clonetiler_get_transform( +Geom::Affine CloneTiler::clonetiler_get_transform( // symmetry group int type, @@ -815,7 +1885,7 @@ static Geom::Affine clonetiler_get_transform( return Geom::identity(); } -static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) +bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) { bool result = false; char *id_href = NULL; @@ -842,12 +1912,7 @@ static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) return result; } -static Inkscape::Drawing *trace_drawing = NULL; -static unsigned trace_visionkey; -static gdouble trace_zoom; -static SPDocument *trace_doc = NULL; - -static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) +void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) { if (!trace_drawing) return; @@ -859,7 +1924,7 @@ static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) } } -static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) +void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) { trace_drawing = new Inkscape::Drawing(); /* Create ArenaItem and set transform */ @@ -877,7 +1942,7 @@ static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *origin trace_zoom = zoom; } -static guint32 clonetiler_trace_pick(Geom::Rect box) +guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box) { if (!trace_drawing) { return 0; @@ -901,7 +1966,7 @@ static guint32 clonetiler_trace_pick(Geom::Rect box) return SP_RGBA32_F_COMPOSE (R, G, B, A); } -static void clonetiler_trace_finish() +void CloneTiler::clonetiler_trace_finish() { if (trace_doc) { trace_doc->getRoot()->invoke_hide(trace_visionkey); @@ -911,7 +1976,7 @@ static void clonetiler_trace_finish() } } -static void clonetiler_unclump(GtkWidget */*widget*/, void *) +void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -947,7 +2012,7 @@ static void clonetiler_unclump(GtkWidget */*widget*/, void *) _("Unclump tiled clones")); } -static guint clonetiler_number_of_clones(SPObject *obj) +guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) { SPObject *parent = obj->parent; @@ -962,7 +2027,7 @@ static guint clonetiler_number_of_clones(SPObject *obj) return n; } -static void clonetiler_remove(GtkWidget */*widget*/, void *, bool do_undo = true) +void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo/* = true*/) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -1000,7 +2065,7 @@ static void clonetiler_remove(GtkWidget */*widget*/, void *, bool do_undo = true } } -static Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m) +Geom::Rect CloneTiler::transform_rect(Geom::Rect const &r, Geom::Affine const &m) { using Geom::X; using Geom::Y; @@ -1021,7 +2086,7 @@ static Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m) Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same probability of being displaced. */ -static double randomize01(double val, double rand) +double CloneTiler::randomize01(double val, double rand) { double base = MIN (val - rand, 1 - 2*rand); if (base < 0) { @@ -1032,7 +2097,7 @@ static double randomize01(double val, double rand) } -static void clonetiler_apply(GtkWidget */*widget*/, void *) +void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -1068,7 +2133,7 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *) const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id")); SPObject *parent = obj->parent; - clonetiler_remove (NULL, NULL, false); + clonetiler_remove (NULL, dlg, false); double shiftx_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_i", 0, -10000, 10000); double shifty_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_i", 0, -10000, 10000); @@ -1466,7 +2531,7 @@ static void clonetiler_apply(GtkWidget */*widget*/, void *) _("Create tiled clones")); } -static GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label) +GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) { GtkWidget *l = gtk_label_new_with_mnemonic (label); GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN); @@ -1475,14 +2540,14 @@ static GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label) return vb; } -static void clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data) +void CloneTiler::clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data) { const gchar *attr = (const gchar *) data; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb)); } -static GtkWidget * clonetiler_checkbox(const char *tip, const char *attr) +GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) { GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); @@ -1502,14 +2567,14 @@ static GtkWidget * clonetiler_checkbox(const char *tip, const char *attr) return hb; } -static void clonetiler_value_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::clonetiler_value_changed(GtkAdjustment *adj, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; prefs->setDouble(prefs_path + pref, gtk_adjustment_get_value (adj)); } -static GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false) +GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) { GtkWidget *hb = gtk_hbox_new(FALSE, 0); @@ -1557,27 +2622,27 @@ static GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double return hb; } -static void clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/) +void CloneTiler::clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint group_new = gtk_combo_box_get_active (cb); prefs->setInt(prefs_path + "symmetrygroup", group_new); } -static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::clonetiler_xy_changed(GtkAdjustment *adj, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5)); } -static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) +void CloneTiler::clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb)); } -static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data) +void CloneTiler::clonetiler_pick_to(GtkToggleButton *tb, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); const gchar *pref = (const gchar *) data; @@ -1585,7 +2650,7 @@ static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data) } -static void clonetiler_reset_recursive(GtkWidget *w) +void CloneTiler::clonetiler_reset_recursive(GtkWidget *w) { if (w && GTK_IS_OBJECT(w)) { { @@ -1619,19 +2684,19 @@ static void clonetiler_reset_recursive(GtkWidget *w) } } -static void clonetiler_reset(GtkWidget */*widget*/, void *) +void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg) { clonetiler_reset_recursive (dlg); } -static void clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) +void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) { GtkWidget *a = gtk_alignment_new (align, 0, 0, 0); gtk_container_add(GTK_CONTAINER(a), widget); gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 ); } -static GtkWidget * clonetiler_table_x_y_rand(int values) +GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) { GtkWidget *table = gtk_table_new (values + 2, 5, FALSE); gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); @@ -1673,7 +2738,7 @@ static GtkWidget * clonetiler_table_x_y_rand(int values) return table; } -static void clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data) +void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint v = GPOINTER_TO_INT (data); @@ -1681,7 +2746,7 @@ static void clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data) } -static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg) +void CloneTiler::clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg) { GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols"); GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight"); @@ -1698,7 +2763,7 @@ static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg) } -static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg) +void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg) { GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols"); GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight"); @@ -1717,7 +2782,7 @@ static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg) -static void clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u) +void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); @@ -1727,7 +2792,7 @@ static void clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u) prefs->setDouble(prefs_path + "fillwidth", pixels); } -static void clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u) +void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); @@ -1738,7 +2803,7 @@ static void clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u) } -static void clonetiler_do_pick_toggled(GtkToggleButton *tb, gpointer /*data*/) +void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) { GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace"); @@ -1751,1156 +2816,8 @@ static void clonetiler_do_pick_toggled(GtkToggleButton *tb, gpointer /*data*/) } - - -void clonetiler_dialog(void) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (!dlg) - { - gchar title[500]; - sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_CLONETILER), title); - - dlg = sp_window_new (title, TRUE); - if (x == -1000 || y == -1000) { - x = prefs->getInt(prefs_path + "x", -1000); - y = prefs->getInt(prefs_path + "y", -1000); - } - - if (w ==0 || h == 0) { - w = prefs->getInt(prefs_path + "w", 0); - h = prefs->getInt(prefs_path + "h", 0); - } - - prefs->setInt(prefs_path + "visible", 1); - -// if (x<0) x=0; -// if (y<0) y=0; - - if (w && h) { - gtk_window_resize ((GtkWindow *) dlg, w, h); - } - if (x >= 0 && y >= 0 && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE))) { - gtk_window_move ((GtkWindow *) dlg, x, y); - - } else { - gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER); - } - - - sp_transientize (dlg); - wd.win = dlg; - wd.stop = 0; - - - g_signal_connect ( G_OBJECT (dlg), "event", G_CALLBACK (sp_dialog_event_handler), dlg); - - g_signal_connect ( G_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg); - g_signal_connect ( G_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg); - - g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); - - GtkWidget *mainbox = gtk_vbox_new(FALSE, 4); - gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6); - gtk_container_add (GTK_CONTAINER (dlg), mainbox); - - GtkWidget *nb = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0); - - -// Symmetry - { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry")); - - /* TRANSLATORS: For the following 17 symmetry groups, see - * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples); - * http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or - * http://membres.lycos.fr/villemingerard/Geometri/Sym1D.htm (French vocabulary). - */ - struct SymGroups { - gint group; - gchar const *label; - } const sym_groups[] = { - // TRANSLATORS: "translation" means "shift" / "displacement" here. - {TILE_P1, _("<b>P1</b>: simple translation")}, - {TILE_P2, _("<b>P2</b>: 180° rotation")}, - {TILE_PM, _("<b>PM</b>: reflection")}, - // TRANSLATORS: "glide reflection" is a reflection and a translation combined. - // For more info, see http://mathforum.org/sum95/suzanne/symsusan.html - {TILE_PG, _("<b>PG</b>: glide reflection")}, - {TILE_CM, _("<b>CM</b>: reflection + glide reflection")}, - {TILE_PMM, _("<b>PMM</b>: reflection + reflection")}, - {TILE_PMG, _("<b>PMG</b>: reflection + 180° rotation")}, - {TILE_PGG, _("<b>PGG</b>: glide reflection + 180° rotation")}, - {TILE_CMM, _("<b>CMM</b>: reflection + reflection + 180° rotation")}, - {TILE_P4, _("<b>P4</b>: 90° rotation")}, - {TILE_P4M, _("<b>P4M</b>: 90° rotation + 45° reflection")}, - {TILE_P4G, _("<b>P4G</b>: 90° rotation + 90° reflection")}, - {TILE_P3, _("<b>P3</b>: 120° rotation")}, - {TILE_P31M, _("<b>P31M</b>: reflection + 120° rotation, dense")}, - {TILE_P3M1, _("<b>P3M1</b>: reflection + 120° rotation, sparse")}, - {TILE_P6, _("<b>P6</b>: 60° rotation")}, - {TILE_P6M, _("<b>P6M</b>: reflection + 60° rotation")}, - }; - - gint current = prefs->getInt(prefs_path + "symmetrygroup", 0); - - // Create a list structure containing all the data to be displayed in - // the symmetry group combo box. - GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING); - GtkTreeIter iter; - - for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { - SymGroups const &sg = sym_groups[j]; - - // Add the description of the symgroup to a new row - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, sg.label, - -1); - } - - // Add a new combo box widget with the list of symmetry groups to the vbox - GtkWidget *combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); - gtk_widget_set_tooltip_text (combo, _("Select one of the 17 symmetry groups for the tiling")); - gtk_box_pack_start (GTK_BOX (vb), combo, FALSE, FALSE, SB_MARGIN); - - // Specify the rendering of data from the list in a combo box cell - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, - "markup", 0, - NULL); - - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current); - - g_signal_connect (G_OBJECT (combo), "changed", - G_CALLBACK (clonetiler_symgroup_changed), - NULL); - } - - table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - -// Shift - { - GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift")); - - GtkWidget *table = clonetiler_table_x_y_rand (3); - gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); - - // X - { - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount - // xgettext:no-c-format - gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift X:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j", - -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i", - -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", - 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); - } - - // Y - { - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "shift" means: the tiles will be shifted (offset) vertically by this amount - // xgettext:no-c-format - gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Vertical shift per row (in % of tile height)"), "shifty_per_j", - -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Vertical shift per column (in % of tile height)"), "shifty_per_i", - -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); - } - - { - GtkWidget *l = clonetiler_spinbox ( - _("Randomize the vertical shift by this percentage"), "shifty_rand", - 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); - } - - // Exponent - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); - } - - { - GtkWidget *l = clonetiler_spinbox ( - _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp", - 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 2); - } - - { - GtkWidget *l = clonetiler_spinbox ( - _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp", - 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 3); - } - - { // alternates - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Alternate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); - clonetiler_table_attach (table, l, 0, 5, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); - clonetiler_table_attach (table, l, 0, 5, 3); - } - - { // Cumulate - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Cumulate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 6, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); - clonetiler_table_attach (table, l, 0, 6, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); - clonetiler_table_attach (table, l, 0, 6, 3); - } - - { // Exclude tile width and height in shift - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Cumulate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Exclude tile:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 7, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); - clonetiler_table_attach (table, l, 0, 7, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); - clonetiler_table_attach (table, l, 0, 7, 3); - } - - } - - -// Scale - { - GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale")); - - GtkWidget *table = clonetiler_table_x_y_rand (2); - gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); - - // X - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale X:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Horizontal scale per row (in % of tile width)"), "scalex_per_j", - -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Horizontal scale per column (in % of tile width)"), "scalex_per_i", - -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", - 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); - } - - // Y - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale Y:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Vertical scale per row (in % of tile height)"), "scaley_per_j", - -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Vertical scale per column (in % of tile height)"), "scaley_per_i", - -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", - 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); - } - - // Exponent - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", - 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 2); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", - 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 3); - } - - // Logarithmic (as in logarithmic spiral) - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>Base:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", - 0, 10, "", false); - clonetiler_table_attach (table, l, 0, 5, 2); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", - 0, 10, "", false); - clonetiler_table_attach (table, l, 0, 5, 3); - } - - { // alternates - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Alternate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 6, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); - clonetiler_table_attach (table, l, 0, 6, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); - clonetiler_table_attach (table, l, 0, 6, 3); - } - - { // Cumulate - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Cumulate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 7, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); - clonetiler_table_attach (table, l, 0, 7, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); - clonetiler_table_attach (table, l, 0, 7, 3); - } - - } - - -// Rotation - { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation")); - - GtkWidget *table = clonetiler_table_x_y_rand (1); - gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); - - // Angle - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>Angle:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Rotate tiles by this angle for each row"), "rotate_per_j", - -180, 180, "°"); - clonetiler_table_attach (table, l, 0, 2, 2); - } - - { - GtkWidget *l = clonetiler_spinbox ( - // xgettext:no-c-format - _("Rotate tiles by this angle for each column"), "rotate_per_i", - -180, 180, "°"); - clonetiler_table_attach (table, l, 0, 2, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); - } - - { // alternates - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Alternate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); - clonetiler_table_attach (table, l, 0, 3, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); - clonetiler_table_attach (table, l, 0, 3, 3); - } - - { // Cumulate - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Cumulate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); - clonetiler_table_attach (table, l, 0, 4, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); - clonetiler_table_attach (table, l, 0, 4, 3); - } - - } - - -// Blur and opacity - { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Blur & opacity")); - - GtkWidget *table = clonetiler_table_x_y_rand (1); - gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); - - - // Blur - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>Blur:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); - } - - { // alternates - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Alternate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); - clonetiler_table_attach (table, l, 0, 3, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); - clonetiler_table_attach (table, l, 0, 3, 3); - } - - - - // Dissolve - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>Opacity:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 2); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 4); - } - - { // alternates - GtkWidget *l = gtk_label_new (""); - // TRANSLATORS: "Alternate" is a verb here - gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); - clonetiler_table_attach (table, l, 0, 5, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); - clonetiler_table_attach (table, l, 0, 5, 3); - } - } - - -// Color - { - GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor")); - - { - GtkWidget *hb = gtk_hbox_new (FALSE, 0); - - GtkWidget *l = gtk_label_new (_("Initial color: ")); - gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); - - guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff); - 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); - _color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed)); - - gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); - } - - - GtkWidget *table = clonetiler_table_x_y_rand (3); - gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); - - // Hue - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>H:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", - -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", - -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); - } - - - // Saturation - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>S:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", - -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", - -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); - } - - // Lightness - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<b>L:</b>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", - -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 2); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", - -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 3); - } - - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 4); - } - - - { // alternates - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); - gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); - clonetiler_table_attach (table, l, 0, 5, 2); - } - - { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); - clonetiler_table_attach (table, l, 0, 5, 3); - } - - } - -// Trace - { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); - - - { - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); - gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); - - GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles")); - g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); - bool old = prefs->getBool(prefs_path + "dotrace"); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone")); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_do_pick_toggled), dlg); - } - - { - GtkWidget *vvb = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb); - - - { - GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:")); - gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); - - GtkWidget *table = gtk_table_new (3, 3, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); - gtk_container_add(GTK_CONTAINER(frame), table); - - - GtkWidget* radio; - { - radio = gtk_radio_button_new_with_label (NULL, _("Color")); - gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); - clonetiler_table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); - } - { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); - gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); - clonetiler_table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); - } - { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R")); - gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); - clonetiler_table_attach (table, radio, 0.0, 1, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); - } - { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G")); - gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); - clonetiler_table_attach (table, radio, 0.0, 2, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); - } - { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B")); - gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); - clonetiler_table_attach (table, radio, 0.0, 3, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); - } - { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); - gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); - clonetiler_table_attach (table, radio, 0.0, 1, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); - } - { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); - gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); - clonetiler_table_attach (table, radio, 0.0, 2, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); - } - { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); - gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); - clonetiler_table_attach (table, radio, 0.0, 3, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L); - } - - } - - { - GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:")); - gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN); - - GtkWidget *table = gtk_table_new (4, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); - gtk_container_add(GTK_CONTAINER(frame), table); - - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:")); - clonetiler_table_attach (table, l, 1.0, 1, 1); - } - { - GtkWidget *l = clonetiler_spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", - -10, 10, ""); - clonetiler_table_attach (table, l, 0.0, 1, 2); - } - - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("Randomize:")); - clonetiler_table_attach (table, l, 1.0, 1, 3); - } - { - GtkWidget *l = clonetiler_spinbox (_("Randomize the picked value by this percentage"), "rand_picked", - 0, 100, "%"); - clonetiler_table_attach (table, l, 0.0, 1, 4); - } - - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("Invert:")); - clonetiler_table_attach (table, l, 1.0, 2, 1); - } - { - GtkWidget *l = clonetiler_checkbox (_("Invert the picked value"), "invert_picked"); - clonetiler_table_attach (table, l, 0.0, 2, 2); - } - } - - { - GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':")); - gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); - - - GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); - gtk_container_add(GTK_CONTAINER(frame), table); - - { - GtkWidget *b = gtk_check_button_new_with_label (_("Presence")); - bool old = prefs->getBool(prefs_path + "pick_to_presence", true); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 1, 1); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_presence"); - } - - { - GtkWidget *b = gtk_check_button_new_with_label (_("Size")); - bool old = prefs->getBool(prefs_path + "pick_to_size"); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 2, 1); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_size"); - } - - { - GtkWidget *b = gtk_check_button_new_with_label (_("Color")); - bool old = prefs->getBool(prefs_path + "pick_to_color", 0); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); - clonetiler_table_attach (table, b, 0.0, 1, 2); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_color"); - } - - { - GtkWidget *b = gtk_check_button_new_with_label (_("Opacity")); - bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 2, 2); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_opacity"); - } - } - gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace")); - } - } - -// Rows/columns, width/height - { - GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); - gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); - - { - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); - g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); - - { - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); - int value = prefs->getInt(prefs_path + "jmax", 2); - a->set_value (value); - - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); - sb->set_tooltip_text (_("How many rows in the tiling")); - sb->set_width_chars (7); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); - - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_xy_changed), (gpointer) "jmax"); - } - - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), "×"); - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); - } - - { - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); - int value = prefs->getInt(prefs_path + "imax", 2); - a->set_value (value); - - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); - sb->set_tooltip_text (_("How many columns in the tiling")); - sb->set_width_chars (7); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); - - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_xy_changed), (gpointer) "imax"); - } - - clonetiler_table_attach (table, hb, 0.0, 1, 2); - } - - { - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); - g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); - - // unitmenu - GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); - sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units); - - { - // Width spinbutton - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); - sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a->gobj())); - - double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); - gdouble const units = sp_pixels_get_units (value, unit); - a->set_value (units); - - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 2); - e->set_tooltip_text (_("Width of the rectangle to be filled")); - e->set_width_chars (7); - e->set_digits (4); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_width_changed), u); - } - { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), "×"); - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); - } - - { - // Height spinbutton - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); - sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a->gobj())); - - double value = prefs->getDouble(prefs_path + "fillheight", 50.0); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); - gdouble const units = sp_pixels_get_units (value, unit); - a->set_value (units); - - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 2); - e->set_tooltip_text (_("Height of the rectangle to be filled")); - e->set_width_chars (7); - e->set_digits (4); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_height_changed), u); - } - - gtk_box_pack_start (GTK_BOX (hb), u, TRUE, TRUE, 0); - clonetiler_table_attach (table, hb, 0.0, 2, 2); - - } - - // Switch - GtkWidget* radio; - { - radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); - gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); - clonetiler_table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) dlg); - } - if (!prefs->getBool(prefs_path + "fillrect")) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); - } - { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); - gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); - clonetiler_table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg); - } - if (prefs->getBool(prefs_path + "fillrect")) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); - } - } - - -// Use saved pos - { - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); - gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); - - GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); - bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true); - gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox); - gtk_widget_set_tooltip_text (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")); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_keep_bbox_toggled), NULL); - } - -// Statusbar - { - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); - gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); - GtkWidget *l = gtk_label_new(""); - g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l); - gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); - } - -// Buttons - { - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); - gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); - - { - GtkWidget *b = gtk_button_new (); - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> ")); - gtk_container_add (GTK_CONTAINER(b), l); - gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_apply), NULL); - gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0); - } - - { // buttons which are enabled only when there are tiled clones - GtkWidget *sb = gtk_hbox_new(FALSE, 0); - gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb); - { - // TRANSLATORS: if a group of objects are "clumped" together, then they - // are unevenly spread in the given amount of space - as shown in the - // diagrams on the left in the following screenshot: - // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png - // So unclumping is the process of spreading a number of objects out more evenly. - GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); - gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_unclump), NULL); - gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); - } - - { - GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move ")); - gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_remove), NULL); - gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); - } - - // connect to global selection changed signal (so we can change desktops) and - // external_change (so we're not fooled by undo) - g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg); - g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg); - g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE)); - - // update now - clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); - } - - { - GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); - // TRANSLATORS: "change" is a noun here - gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), NULL); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - } - } - - gtk_widget_show_all (mainbox); - - } // end of if (!dlg) - - gtk_window_present ((GtkWindow *) dlg); +} +} } diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h new file mode 100644 index 000000000..2cad30e9e --- /dev/null +++ b/src/ui/dialog/clonetiler.h @@ -0,0 +1,183 @@ +/** @file + * @brief Clone tiling dialog + */ +/* Authors: + * bulia byak <buliabyak@users.sf.net> + * + * Copyright (C) 2004 Authors + * Released under the GNU GPL, read the file 'COPYING' for more information + */ +#ifndef __SP_CLONE_TILER_H__ +#define __SP_CLONE_TILER_H__ + +#include "ui/widget/panel.h" +#include <glib.h> +#include <gtk/gtk.h> + +#include "ui/dialog/desktop-tracker.h" +#include "ui/widget/color-picker.h" +#include "sp-root.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class CloneTiler : public Widget::Panel { +public: + CloneTiler(); + virtual ~CloneTiler(); + + static CloneTiler &getInstance() { return *new CloneTiler(); } + +protected: + + GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label); + GtkWidget * clonetiler_table_x_y_rand(int values); + GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false); + GtkWidget * clonetiler_checkbox(const char *tip, const char *attr); + void clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col); + + static void clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/); + static void clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo = true); + static void on_picker_color_changed(guint rgba); + static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from); + static void clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data); + static void clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data); + static void clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg); + static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data); + static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data); + static void clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u); + static void clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u); + static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); + static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); + static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); + static void clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg); + static void clonetiler_unclump(GtkWidget */*widget*/, void *); + static void clonetiler_change_selection(Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg); + static void clonetiler_external_change(Inkscape::Application * /*inkscape*/, GtkWidget *dlg); + static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source); + static void clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg); + static guint clonetiler_number_of_clones(SPObject *obj); + static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); + static guint32 clonetiler_trace_pick(Geom::Rect box); + static void clonetiler_trace_finish(); + static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj); + static Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m); + static double randomize01(double val, double rand); + static void clonetiler_value_changed(GtkAdjustment *adj, gpointer data); + static void clonetiler_reset_recursive(GtkWidget *w); + + static Geom::Affine clonetiler_get_transform( // symmetry group + int type, + + // row, column + int i, int j, + + // center, width, height of the tile + double cx, double cy, + double w, double h, + + // values from the dialog: + // Shift + double shiftx_per_i, double shifty_per_i, + double shiftx_per_j, double shifty_per_j, + double shiftx_rand, double shifty_rand, + double shiftx_exp, double shifty_exp, + int shiftx_alternate, int shifty_alternate, + int shiftx_cumulate, int shifty_cumulate, + int shiftx_excludew, int shifty_excludeh, + + // Scale + double scalex_per_i, double scaley_per_i, + double scalex_per_j, double scaley_per_j, + double scalex_rand, double scaley_rand, + double scalex_exp, double scaley_exp, + double scalex_log, double scaley_log, + int scalex_alternate, int scaley_alternate, + int scalex_cumulate, int scaley_cumulate, + + // Rotation + double rotate_per_i, double rotate_per_j, + double rotate_rand, + int rotate_alternatei, int rotate_alternatej, + int rotate_cumulatei, int rotate_cumulatej + ); + + +private: + CloneTiler(CloneTiler const &d); + CloneTiler& operator=(CloneTiler const &d); + + GtkWidget *dlg; + SPDesktop *desktop; + DesktopTracker deskTrack; + Inkscape::UI::Widget::ColorPicker *color_picker; + GtkSizeGroup* table_row_labels; + + sigc::connection desktopChangeConn; + sigc::connection selectChangedConn; + sigc::connection subselChangedConn; + sigc::connection selectModifiedConn; + sigc::connection color_changed_connection; + + /** + * Can be invoked for setting the desktop. Currently not used. + */ + void setDesktop(SPDesktop *desktop); + + /** + * Is invoked by the desktop tracker when the desktop changes. + */ + void setTargetDesktop(SPDesktop *desktop); + +}; + + +enum { + PICK_COLOR, + PICK_OPACITY, + PICK_R, + PICK_G, + PICK_B, + PICK_H, + PICK_S, + PICK_L +}; + +enum { + TILE_P1, + TILE_P2, + TILE_PM, + TILE_PG, + TILE_CM, + TILE_PMM, + TILE_PMG, + TILE_PGG, + TILE_CMM, + TILE_P4, + TILE_P4M, + TILE_P4G, + TILE_P3, + TILE_P31M, + TILE_P3M1, + TILE_P6, + TILE_P6M +}; + +} // namespace Dialog +} // namespace UI +} // namespace Inkscape + + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 2e7ffa1c2..60011ca9d 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -51,6 +51,7 @@ #include "ui/dialog/spellcheck.h" #include "ui/dialog/export.h" #include "ui/dialog/xml-tree.h" +#include "ui/dialog/clonetiler.h" #ifdef ENABLE_SVG_FONTS #include "ui/dialog/svg-fonts-dialog.h" @@ -129,6 +130,7 @@ DialogManager::DialogManager() { registerFactory("SpellCheck", &create<SpellCheck, FloatingBehavior>); registerFactory("Export", &create<Export, FloatingBehavior>); registerFactory("XmlTree", &create<XmlTree, FloatingBehavior>); + registerFactory("CloneTiler", &create<CloneTiler, FloatingBehavior>); } else { @@ -163,6 +165,7 @@ DialogManager::DialogManager() { registerFactory("SpellCheck", &create<SpellCheck, DockBehavior>); registerFactory("Export", &create<Export, DockBehavior>); registerFactory("XmlTree", &create<XmlTree, DockBehavior>); + registerFactory("CloneTiler", &create<CloneTiler, DockBehavior>); } } diff --git a/src/verbs.cpp b/src/verbs.cpp index b890e64a5..9b750e123 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -39,7 +39,6 @@ #include "bind/javabind.h" #include "desktop.h" #include "desktop-handles.h" -#include "dialogs/clonetiler.h" #include "dialogs/find.h" #include "display/curve.h" #include "document.h" @@ -67,6 +66,7 @@ #include "sp-namedview.h" #include "text-chemistry.h" #include "tools-switch.h" +#include "ui/dialog/clonetiler.h" #include "ui/dialog/dialog-manager.h" #include "ui/dialog/document-properties.h" #include "ui/dialog/extensions.h" @@ -1844,7 +1844,8 @@ void DialogVerb::perform(SPAction *action, void *data) inkscape_dialogs_toggle(); break; case SP_VERB_DIALOG_CLONETILER: - clonetiler_dialog(); + //clonetiler_dialog(); + dt->_dlg_mgr->showDialog("CloneTiler"); break; case SP_VERB_DIALOG_ATTR: //sp_item_dialog(); |
