X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdialogs%2Fclonetiler.cpp;h=f6d3b030958859530d3f96b19157a2ab91df44fd;hb=6d7d846dbf27d17b82110d99015a85cff809a789;hp=72cae3c47ab89e7f9df2e00fe3c9a470d76920c8;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 72cae3c47..f6d3b0309 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -4,15 +4,17 @@ * Clone tiling dialog * * Authors: - * bulia byak + * bulia byak + * Johan Engelen * - * Copyright (C) 2004-2005 Authors + * Copyright (C) 2004-2006 Authors * Released under GNU GPL */ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include #include #include @@ -30,6 +32,7 @@ #include "../interface.h" #include "../selection.h" #include "../style.h" +#include "../desktop.h" #include "../desktop-handles.h" #include "../sp-namedview.h" #include "../document.h" @@ -40,6 +43,7 @@ #include "xml/repr.h" #include "svg/svg.h" +#include "svg/svg-color.h" #include "libnr/nr-matrix-fns.h" #include "libnr/nr-matrix-ops.h" @@ -54,11 +58,16 @@ #include "ui/widget/color-picker.h" +#include "../sp-filter.h" +#include "../filter-chemistry.h" + +#define MIN_ONSCREEN_DISTANCE 50 + static GtkWidget *dlg = NULL; static win_data wd; // impossible original values to make sure they are read from prefs -static gint x = -1000, y = -1000, w = 0, h = 0; +static gint x = -1000, y = -1000, w = 0, h = 0; static gchar *prefs_path = "dialogs.clonetiler"; #define SB_MARGIN 1 @@ -103,7 +112,7 @@ clonetiler_dialog_destroy (GtkObject *object, gpointer data) wd.win = dlg = NULL; wd.stop = 0; - + } static gboolean @@ -112,6 +121,9 @@ 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); + if (x<0) x=0; + if (y<0) y=0; + prefs_set_int_attribute (prefs_path, "x", x); prefs_set_int_attribute (prefs_path, "y", y); prefs_set_int_attribute (prefs_path, "w", w); @@ -137,7 +149,7 @@ on_picker_color_changed (guint rgba) Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, prefs_path); gchar c[32]; - sp_svg_write_color(c, 32, rgba); + sp_svg_write_color(c, sizeof(c), rgba); repr->setAttribute("initial_color", c); is_updating = false; @@ -178,7 +190,7 @@ clonetiler_change_selection (Inkscape::Application * /*inkscape*/, Inkscape::Sel static void clonetiler_external_change (Inkscape::Application * /*inkscape*/, GtkWidget *dlg) { - clonetiler_change_selection (NULL, SP_DT_SELECTION(SP_ACTIVE_DESKTOP), dlg); + clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); } static void clonetiler_disconnect_gsignal (GObject *widget, gpointer source) { @@ -219,11 +231,11 @@ clonetiler_get_transform ( double w, double h, // values from the dialog: - double d_x_per_x, double d_y_per_x, double d_x_per_y, double d_y_per_y, + double d_x_per_x, double d_y_per_x, double d_x_per_y, double d_y_per_y, int alternate_x, int alternate_y, double rand_x, double rand_y, - double d_per_x_exp, double d_per_y_exp, + double d_per_x_exp, double d_per_y_exp, double d_rot_per_x, double d_rot_per_y, int alternate_rotx, int alternate_roty, double rand_rot, - double d_scalex_per_x, double d_scaley_per_x, double d_scalex_per_y, double d_scaley_per_y, + double d_scalex_per_x, double d_scaley_per_x, double d_scalex_per_y, double d_scaley_per_y, int alternate_scalex, int alternate_scaley, double rand_scalex, double rand_scaley ) { @@ -281,9 +293,6 @@ clonetiler_get_transform ( NR::Matrix flip_x = NR::translate(-cx, -cy) * NR::scale (-1, 1) * NR::translate(cx, cy); NR::Matrix flip_y = NR::translate(-cx, -cy) * NR::scale (1, -1) * NR::translate(cx, cy); - x = (int) pow ((double) x, d_per_x_exp); - y = (int) pow ((double) y, d_per_y_exp); - switch (type) { case TILE_P1: @@ -396,7 +405,7 @@ clonetiler_get_transform ( case TILE_P4: { - NR::Matrix ori (NR::translate ((w + h) * (x/2) + dx, (h + w) * (y/2) + dy)); + NR::Matrix ori (NR::translate ((w + h) * pow((x/2), d_per_x_exp) + dx, (h + w) * pow((y/2), d_per_y_exp) + dy)); NR::Matrix dia1 (NR::translate (w/2 + h/2, -h/2 + w/2)); NR::Matrix dia2 (NR::translate (-w/2 + h/2, h/2 + w/2)); if (y % 2 == 0) { @@ -418,7 +427,7 @@ clonetiler_get_transform ( case TILE_P4M: { double max = MAX(w, h); - NR::Matrix ori (NR::translate ((max + max) * (x/4) + dx, (max + max) * (y/2) + dy)); + NR::Matrix ori (NR::translate ((max + max) * pow((x/4), d_per_x_exp) + dx, (max + max) * pow((y/2), d_per_y_exp) + dy)); NR::Matrix dia1 (NR::translate (w/2 - h/2, h/2 - w/2)); NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 - h/2)); if (y % 2 == 0) { @@ -448,7 +457,7 @@ clonetiler_get_transform ( case TILE_P4G: { double max = MAX(w, h); - NR::Matrix ori (NR::translate ((max + max) * (x/4) + dx, (max + max) * y + dy)); + NR::Matrix ori (NR::translate ((max + max) * pow((x/4), d_per_x_exp) + dx, (max + max) * pow(y, d_per_y_exp) + dy)); NR::Matrix dia1 (NR::translate (w/2 + h/2, h/2 - w/2)); NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 + h/2)); if (((x/4) + y) % 2 == 0) { @@ -492,13 +501,13 @@ clonetiler_get_transform ( dia1 = NR::Matrix (NR::translate (h/2 * cos30, -(h/2 * sin30))); dia2 = dia1 * NR::Matrix (NR::translate (0, h/2)); } - NR::Matrix ori (NR::translate (width * (2*(x/3) + y%2) + dx, (height/2) * y + dy)); + NR::Matrix ori (NR::translate (width * pow((2*(x/3) + y%2), d_per_x_exp) + dx, (height/2) * pow(y, d_per_y_exp) + dy)); if (x % 3 == 0) { - return d_s_r * ori; + return d_s_r * ori; } else if (x % 3 == 1) { - return d_s_r * rotate_m120_c * dia1 * ori; + return d_s_r * rotate_m120_c * dia1 * ori; } else if (x % 3 == 2) { - return d_s_r * rotate_120_c * dia2 * ori; + return d_s_r * rotate_120_c * dia2 * ori; } } break; @@ -511,13 +520,13 @@ clonetiler_get_transform ( NR::Matrix dia3; NR::Matrix dia4; if (w > h) { - ori = NR::Matrix(NR::translate (w * (x/6) + w/2 * (y%2) + dx, (w * cos30) * y + dy)); + ori = NR::Matrix(NR::translate (w * pow((x/6) + 1/2 * (y%2), d_per_x_exp) + dx, (w * cos30) * pow(y, d_per_y_exp) + dy)); dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) ); dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30)); dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30))); dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30)); } else { - ori = NR::Matrix (NR::translate (2*h * cos30 * (x/6 + 0.5*(y%2)) + dx, (2*h - h * sin30) * y + dy)); + ori = NR::Matrix (NR::translate (2*h * cos30 * pow((x/6 + 0.5*(y%2)), d_per_x_exp) + dx, (2*h - h * sin30) * pow(y, d_per_y_exp) + dy)); dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30)); dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30)); dia3 = dia2 * NR::Matrix (NR::translate (0, h/2)); @@ -562,7 +571,7 @@ clonetiler_get_transform ( dia3 = dia2 * NR::Matrix (NR::translate (0, h/2)); dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30)); } - NR::Matrix ori (NR::translate (width * (2*(x/6) + y%2) + dx, (height/2) * y + dy)); + NR::Matrix ori (NR::translate (width * pow((2*(x/6) + y%2), d_per_x_exp) + dx, (height/2) * pow(y, d_per_y_exp) + dy)); if (x % 6 == 0) { return d_s_r * ori; } else if (x % 6 == 1) { @@ -588,14 +597,14 @@ clonetiler_get_transform ( NR::Matrix dia4; NR::Matrix dia5; if (w > h) { - ori = NR::Matrix(NR::translate (2*w * (x/6) + w * (y%2) + dx, (2*w * sin60) * y + dy)); + ori = NR::Matrix(NR::translate (w * pow((2*(x/6) + (y%2)), d_per_x_exp) + dx, (2*w * sin60) * pow(y, d_per_y_exp) + dy)); dia1 = NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60)); dia2 = dia1 * NR::Matrix (NR::translate (w/2, 0)); dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, w/2 * sin60)); dia4 = dia3 * NR::Matrix (NR::translate (-w/2 * cos60, w/2 * sin60)); dia5 = dia4 * NR::Matrix (NR::translate (-w/2, 0)); } else { - ori = NR::Matrix(NR::translate (2*h * cos30 * (x/6 + 0.5*(y%2)) + dx, (h + h * sin30) * y + dy)); + ori = NR::Matrix(NR::translate (2*h * cos30 * pow((x/6 + 0.5*(y%2)), d_per_x_exp) + dx, (h + h * sin30) * pow(y, d_per_y_exp) + dy)); dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60)); dia2 = dia1 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60)); dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2)); @@ -624,7 +633,7 @@ clonetiler_get_transform ( NR::Matrix ori; NR::Matrix dia1, dia2, dia3, dia4, dia5, dia6, dia7, dia8, dia9, dia10; if (w > h) { - ori = NR::Matrix(NR::translate (2*w * (x/12) + w * (y%2) + dx, (2*w * sin60) * y + dy)); + ori = NR::Matrix(NR::translate (w * pow((2*(x/12) + (y%2)), d_per_x_exp) + dx, (2*w * sin60) * pow(y, d_per_y_exp) + dy)); dia1 = NR::Matrix (NR::translate (w/2, h/2) * NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, h/2 * sin30)); dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30)); dia3 = dia2 * NR::Matrix (NR::translate (-h/2 * cos30, h/2 * sin30) * NR::translate (w * cos60, 0) * NR::translate (-h/2 * cos30, -h/2 * sin30)); @@ -636,7 +645,7 @@ clonetiler_get_transform ( dia9 = dia6 * dia3.inverse(); dia10 = dia6 * dia4.inverse(); } else { - ori = NR::Matrix(NR::translate (4*h * cos30 * (x/12 + 0.5*(y%2)) + dx, (2*h + 2*h * sin30) * y + dy)); + ori = NR::Matrix(NR::translate (4*h * cos30 * pow((x/12 + 0.5*(y%2)), d_per_x_exp) + dx, (2*h + 2*h * sin30) * pow(y, d_per_y_exp) + dy)); dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60)); dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30)); dia3 = dia2 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h * cos30, 0) * NR::translate (-w/2 * cos60, w/2 * sin60)); @@ -676,14 +685,14 @@ clonetiler_get_transform ( } break; - default: + default: break; } return NR::identity(); } -static bool +static bool clonetiler_is_a_clone_of (SPObject *tile, SPObject *obj) { char *id_href = NULL; @@ -693,11 +702,11 @@ clonetiler_is_a_clone_of (SPObject *tile, SPObject *obj) id_href = g_strdup_printf("#%s", obj_repr->attribute("id")); } - if (SP_IS_USE(tile) && + if (SP_IS_USE(tile) && SP_OBJECT_REPR(tile)->attribute("xlink:href") && - (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("xlink:href"))) && + (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("xlink:href"))) && SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of") && - (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of")))) + (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of")))) { if (id_href) g_free (id_href); @@ -773,7 +782,12 @@ clonetiler_trace_pick (NR::Rect box) int height = ibox.y1 - ibox.y0; /* Set up pixblock */ - guchar *px = nr_new(guchar, 4 * width * height); + guchar *px = g_new(guchar, 4 * width * height); + + if (px == NULL) { + return 0; // buffer is too big or too small, cannot pick, so return 0 + } + memset(px, 0x00, 4 * width * height); /* Render */ @@ -781,7 +795,7 @@ clonetiler_trace_pick (NR::Rect box) nr_pixblock_setup_extern( &pb, NR_PIXBLOCK_MODE_R8G8B8A8N, ibox.x0, ibox.y0, ibox.x1, ibox.y1, px, 4 * width, FALSE, FALSE ); - nr_arena_item_invoke_render( trace_root, &ibox, &pb, + nr_arena_item_invoke_render(NULL, trace_root, &ibox, &pb, NR_ARENA_ITEM_RENDER_NO_CACHE ); double R = 0, G = 0, B = 0, A = 0; @@ -832,11 +846,11 @@ clonetiler_unclump (GtkWidget *widget, void *) if (desktop == NULL) return; - Inkscape::Selection *selection = SP_DT_SELECTION(desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); // check if something is selected if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) { - SP_DT_MSGSTACK(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to unclump.")); + sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to unclump.")); return; } @@ -851,13 +865,14 @@ clonetiler_unclump (GtkWidget *widget, void *) } } - sp_document_ensure_up_to_date(SP_DT_DOCUMENT(desktop)); + sp_document_ensure_up_to_date(sp_desktop_document(desktop)); unclump (to_unclump); g_slist_free (to_unclump); - sp_document_done (SP_DT_DOCUMENT (desktop)); + sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, + _("Unclump tiled clones")); } static guint @@ -883,11 +898,11 @@ clonetiler_remove (GtkWidget *widget, void *, bool do_undo = true) if (desktop == NULL) return; - Inkscape::Selection *selection = SP_DT_SELECTION(desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); // check if something is selected if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) { - SP_DT_MSGSTACK(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to remove.")); + sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to remove.")); return; } @@ -909,7 +924,8 @@ clonetiler_remove (GtkWidget *widget, void *, bool do_undo = true) clonetiler_change_selection (NULL, selection, dlg); if (do_undo) - sp_document_done (SP_DT_DOCUMENT (desktop)); + sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, + _("Delete tiled clones")); } static NR::Rect @@ -951,17 +967,17 @@ clonetiler_apply (GtkWidget *widget, void *) if (desktop == NULL) return; - Inkscape::Selection *selection = SP_DT_SELECTION(desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); // check if something is selected if (selection->isEmpty()) { - SP_DT_MSGSTACK(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select an object to clone.")); + sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select an object to clone.")); return; } // Check if more than one object is selected. if (g_slist_length((GSList *) selection->itemList()) > 1) { - SP_DT_MSGSTACK(desktop)->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, group them and clone the group.")); + sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, group them and clone the group.")); return; } @@ -998,6 +1014,12 @@ clonetiler_apply (GtkWidget *widget, void *) int alternate_roty = prefs_get_int_attribute (prefs_path, "alternate_roty", 0); double rand_rot = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_rot", 0, 0, 100); + double d_blur_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_blur_per_y", 0, 0, 100); + double d_blur_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_blur_per_x", 0, 0, 100); + int alternate_blury = prefs_get_int_attribute (prefs_path, "alternate_blury", 0); + int alternate_blurx = prefs_get_int_attribute (prefs_path, "alternate_blurx", 0); + double rand_blur = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_blur", 0, 0, 100); + double d_opacity_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_y", 0, 0, 100); double d_opacity_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_x", 0, 0, 100); int alternate_opacityy = prefs_get_int_attribute (prefs_path, "alternate_opacityy", 0); @@ -1025,8 +1047,8 @@ clonetiler_apply (GtkWidget *widget, void *) int ymax = prefs_get_int_attribute (prefs_path, "ymax", 2); int fillrect = prefs_get_int_attribute (prefs_path, "fillrect", 0); - double fillwidth = prefs_get_double_attribute_limited (prefs_path, "fillwidth", 50, 0, 6000); - double fillheight = prefs_get_double_attribute_limited (prefs_path, "fillheight", 50, 0, 6000); + double fillwidth = prefs_get_double_attribute_limited (prefs_path, "fillwidth", 50, 0, 1e6); + double fillheight = prefs_get_double_attribute_limited (prefs_path, "fillheight", 50, 0, 1e6); int dotrace = prefs_get_int_attribute (prefs_path, "dotrace", 0); int pick = prefs_get_int_attribute (prefs_path, "pick", 0); @@ -1039,63 +1061,85 @@ clonetiler_apply (GtkWidget *widget, void *) double gamma_picked = prefs_get_double_attribute_limited (prefs_path, "gamma_picked", 0, -10, 10); if (dotrace) { - clonetiler_trace_setup (SP_DT_DOCUMENT(desktop), 1.0, SP_ITEM (obj)); + clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, SP_ITEM (obj)); } - NR::Point c; + NR::Point center; double w; double h; + double x0; + double y0; - if (keepbbox && + if (keepbbox && obj_repr->attribute("inkscape:tile-w") && obj_repr->attribute("inkscape:tile-h") && + obj_repr->attribute("inkscape:tile-x0") && + obj_repr->attribute("inkscape:tile-y0") && obj_repr->attribute("inkscape:tile-cx") && obj_repr->attribute("inkscape:tile-cy")) { double cx = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cx", 0); double cy = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cy", 0); - - c = NR::Point (cx, cy); + center = NR::Point (cx, cy); w = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-w", 0); h = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-h", 0); + x0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-x0", 0); + y0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-y0", 0); } else { - NR::Rect const r = SP_ITEM(obj)->invokeBbox(sp_item_i2doc_affine(SP_ITEM(obj))); - c = r.midpoint(); - w = r.dimensions()[NR::X]; - h = r.dimensions()[NR::Y]; - - sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w); - sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h); - sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", c[NR::X]); - sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", c[NR::Y]); + NR::Maybe r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj)), + SPItem::GEOMETRIC_BBOX); + /* impl: Use of GEOMETRIC_BBOX is so that the stroke of rectangles will be shared + * (overlapped) rather than effectively doubled in width. + * + * (If you wish to change this, then please consider discussing at bug #1722238.) */ + + if (r) { + w = r->dimensions()[NR::X]; + h = r->dimensions()[NR::Y]; + x0 = r->min()[NR::X]; + y0 = r->min()[NR::Y]; + center = desktop->dt2doc(SP_ITEM(obj)->getCenter()); + + sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", center[NR::X]); + sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", center[NR::Y]); + sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w); + sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h); + sp_repr_set_svg_double(obj_repr, "inkscape:tile-x0", x0); + sp_repr_set_svg_double(obj_repr, "inkscape:tile-y0", y0); + } else { + center = NR::Point(0, 0); + w = h = 0; + x0 = y0 = 0; + } } NR::Point cur = NR::Point (0, 0); - NR::Rect bbox_original = NR::Rect (NR::Point (c[NR::X] - w/2, c[NR::Y] - h/2), NR::Point (c[NR::X] + w/2, c[NR::Y] + h/2)); + NR::Rect bbox_original = NR::Rect (NR::Point (x0, y0), NR::Point (x0 + w, y0 + h)); + double perimeter_original = (w + h)/4; - for (int x = 0; - fillrect? + for (int x = 0; + fillrect? (fabs(cur[NR::X]) < fillwidth && x < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows - : (x < xmax); + : (x < xmax); x ++) { - for (int y = 0; + for (int y = 0; fillrect? - (fabs(cur[NR::Y]) < fillheight && y < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols + (fabs(cur[NR::Y]) < fillheight && y < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols : (y < ymax); y ++) { // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored // Get transform from symmetry, shift, scale, rotation - NR::Matrix t = clonetiler_get_transform (type, x, y, c[NR::X], c[NR::Y], w, h, + NR::Matrix t = clonetiler_get_transform (type, x, y, center[NR::X], center[NR::Y], w, h, d_x_per_x, d_y_per_x, d_x_per_y, d_y_per_y, alternate_x, alternate_y, rand_x, rand_y, - d_per_x_exp, d_per_y_exp, + d_per_x_exp, d_per_y_exp, d_rot_per_x, d_rot_per_y, alternate_rotx, alternate_roty, rand_rot, - d_scalex_per_x, d_scaley_per_x, d_scalex_per_y, d_scaley_per_y, + d_scalex_per_x, d_scaley_per_x, d_scalex_per_y, d_scaley_per_y, alternate_scalex, alternate_scaley, rand_scalex, rand_scaley); - cur = c * t - c; + cur = center * t - center; if (fillrect) { if ((cur[NR::X] > fillwidth) || (cur[NR::Y] > fillheight)) { // off limits continue; @@ -1123,15 +1167,26 @@ clonetiler_apply (GtkWidget *widget, void *) float rgb[3]; sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]); - sp_svg_write_color(color_string, 32, SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0)); - } + sp_svg_write_color(color_string, sizeof(color_string), SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0)); + } + + // Blur + double blur = 0.0; + { + int eff_x = (alternate_blurx? (x%2) : (x)); + int eff_y = (alternate_blury? (y%2) : (y)); + blur = (d_blur_per_x * eff_x + d_blur_per_y * eff_y + rand_blur * g_random_double_range (-1, 1)); + blur = CLAMP (blur, 0, 1); + } - // Opacity tab + // Opacity double opacity = 1.0; + { int eff_x = (alternate_opacityx? (x%2) : (x)); int eff_y = (alternate_opacityy? (y%2) : (y)); opacity = 1 - (d_opacity_per_x * eff_x + d_opacity_per_y * eff_y + rand_opacity * g_random_double_range (-1, 1)); opacity = CLAMP (opacity, 0, 1); + } // Trace tab if (dotrace) { @@ -1187,7 +1242,7 @@ clonetiler_apply (GtkWidget *widget, void *) double power; if (gamma_picked < 0) power = 1/(1 + fabs(gamma_picked)); - else + else power = 1 + gamma_picked; val = pow (val, power); @@ -1208,7 +1263,7 @@ clonetiler_apply (GtkWidget *widget, void *) g = CLAMP (g, 0, 1); b = CLAMP (b, 0, 1); - // recompose tweaked color + // recompose tweaked color rgba = SP_RGBA32_F_COMPOSE(r, g, b, a); if (pick_to_presence) { @@ -1217,13 +1272,13 @@ clonetiler_apply (GtkWidget *widget, void *) } } if (pick_to_size) { - t = NR::translate(-c[NR::X], -c[NR::Y]) * NR::scale (val, val) * NR::translate(c[NR::X], c[NR::Y]) * t; + t = NR::translate(-center[NR::X], -center[NR::Y]) * NR::scale (val, val) * NR::translate(center[NR::X], center[NR::Y]) * t; } if (pick_to_opacity) { opacity *= val; } if (pick_to_color) { - sp_svg_write_color(color_string, 32, rgba); + sp_svg_write_color(color_string, sizeof(color_string), rgba); } } @@ -1236,19 +1291,23 @@ clonetiler_apply (GtkWidget *widget, void *) } // Create the clone - Inkscape::XML::Node *clone = sp_repr_new("svg:use"); + Inkscape::XML::Node *clone = obj_repr->document()->createElement("svg:use"); clone->setAttribute("x", "0"); clone->setAttribute("y", "0"); clone->setAttribute("inkscape:tiled-clone-of", id_href); clone->setAttribute("xlink:href", id_href); - gchar affinestr[80]; - if (sp_svg_transform_write(affinestr, 79, t)) { - clone->setAttribute("transform", affinestr); - } else { - clone->setAttribute("transform", NULL); + NR::Point new_center; + bool center_set = false; + if (obj_repr->attribute("inkscape:transform-center-x") || obj_repr->attribute("inkscape:transform-center-y")) { + new_center = desktop->dt2doc(SP_ITEM(obj)->getCenter()) * t; + center_set = true; } + gchar *affinestr=sp_svg_transform_write(t); + clone->setAttribute("transform", affinestr); + g_free(affinestr); + if (opacity < 1.0) { sp_repr_set_css_double(clone, "opacity", opacity); } @@ -1260,6 +1319,27 @@ clonetiler_apply (GtkWidget *widget, void *) // add the new clone to the top of the original's parent SP_OBJECT_REPR(parent)->appendChild(clone); + + if (blur > 0.0) { + SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone); + double perimeter = perimeter_original * t.expansion(); + double radius = blur * perimeter; + // it's hard to figure out exact width/height of the tile without having an object + // that we can take bbox of; however here we only need a lower bound so that blur + // margins are not too small, and the perimeter should work + SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, t.expansion(), t.expansionX(), t.expansionY(), perimeter, perimeter); + sp_style_set_property_url (clone_object, "filter", SP_OBJECT(constructed), false); + } + + if (center_set) { + SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone); + if (clone_object && SP_IS_ITEM(clone_object)) { + clone_object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + SP_ITEM(clone_object)->setCenter(desktop->doc2dt(new_center)); + clone_object->updateRepr(); + } + } + Inkscape::GC::release(clone); } cur[NR::Y] = 0; @@ -1271,7 +1351,8 @@ clonetiler_apply (GtkWidget *widget, void *) clonetiler_change_selection (NULL, selection, dlg); - sp_document_done(SP_DT_DOCUMENT(desktop)); + sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, + _("Create tiled clones")); } static GtkWidget * @@ -1298,12 +1379,12 @@ clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr) GtkWidget *b = gtk_check_button_new (); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL); - + int value = prefs_get_int_attribute (prefs_path, attr, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value); gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0); - gtk_signal_connect ( GTK_OBJECT (b), "clicked", + gtk_signal_connect ( GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_checkbox_toggled), (gpointer) attr); g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); @@ -1328,13 +1409,13 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l GtkObject *a; if (exponent) a = gtk_adjustment_new(1.0, lower, upper, 0.01, 0.05, 0.1); - else + else a = gtk_adjustment_new(0.0, lower, upper, 0.1, 0.5, 2); GtkWidget *sb; if (exponent) sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.01, 2); - else + else sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.1, 1); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, tip, NULL); @@ -1348,7 +1429,7 @@ clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double l if (exponent) g_object_set_data (G_OBJECT(sb), "oneable", GINT_TO_POINTER(TRUE)); - else + else g_object_set_data (G_OBJECT(sb), "zeroable", GINT_TO_POINTER(TRUE)); } @@ -1367,7 +1448,7 @@ clonetiler_symgroup_changed (GtkMenuItem *item, gpointer data) { gint group_new = GPOINTER_TO_INT (data); prefs_set_int_attribute ( prefs_path, "symmetrygroup", group_new ); -} +} static void clonetiler_xy_changed (GtkAdjustment *adj, gpointer data) @@ -1415,7 +1496,7 @@ clonetiler_reset_recursive (GtkWidget *w) } } } - + if (GTK_IS_CONTAINER(w)) { GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); for (GList *i = ch; i != NULL; i = i->next) { @@ -1450,7 +1531,7 @@ clonetiler_table_x_y_rand (int values) { GtkWidget *hb = gtk_hbox_new (FALSE, 0); - GtkWidget *i = sp_icon_new (GTK_ICON_SIZE_MENU, "clonetiler_per_row"); + GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "clonetiler_per_row"); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); GtkWidget *l = gtk_label_new (""); @@ -1463,7 +1544,7 @@ clonetiler_table_x_y_rand (int values) { GtkWidget *hb = gtk_hbox_new (FALSE, 0); - GtkWidget *i = sp_icon_new (GTK_ICON_SIZE_MENU, "clonetiler_per_column"); + GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, "clonetiler_per_column"); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); GtkWidget *l = gtk_label_new (""); @@ -1571,8 +1652,8 @@ clonetiler_dialog (void) dlg = sp_window_new (title, TRUE); if (x == -1000 || y == -1000) { - x = prefs_get_int_attribute (prefs_path, "x", 0); - y = prefs_get_int_attribute (prefs_path, "y", 0); + x = prefs_get_int_attribute (prefs_path, "x", -1000); + y = prefs_get_int_attribute (prefs_path, "y", -1000); } if (w ==0 || h == 0) { @@ -1580,16 +1661,19 @@ clonetiler_dialog (void) h = prefs_get_int_attribute (prefs_path, "h", 0); } - if (x != 0 || y != 0) { +// 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); } - if (w && h) { - gtk_window_resize ((GtkWindow *) dlg, w, h); - } sp_transientize (dlg); wd.win = dlg; @@ -1619,7 +1703,7 @@ clonetiler_dialog (void) 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); @@ -1676,7 +1760,7 @@ clonetiler_dialog (void) GtkWidget *item = gtk_menu_item_new (); gtk_container_add (GTK_CONTAINER (item), l); - gtk_signal_connect ( GTK_OBJECT (item), "activate", + gtk_signal_connect ( GTK_OBJECT (item), "activate", GTK_SIGNAL_FUNC (clonetiler_symgroup_changed), GINT_TO_POINTER (sg.group) ); @@ -1707,7 +1791,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Horizontal shift per row (in % of tile width)"), "d_x_per_y", -100, 1000, "%"); @@ -1715,7 +1799,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Horizontal shift per column (in % of tile width)"), "d_x_per_x", -100, 1000, "%"); @@ -1723,7 +1807,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the horizontal shift by this percentage"), "rand_x", 0, 1000, "%"); clonetiler_table_attach (table, l, 0, 2, 4); @@ -1740,7 +1824,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Vertical shift per row (in % of tile height)"), "d_y_per_y", -100, 1000, "%"); @@ -1748,7 +1832,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Vertical shift per column (in % of tile height)"), "d_y_per_x", -100, 1000, "%"); @@ -1756,7 +1840,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the vertical shift by this percentage"), "rand_y", 0, 1000, "%"); clonetiler_table_attach (table, l, 0, 3, 4); @@ -1771,14 +1855,14 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_y_exp", 0, 10, "", true); clonetiler_table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_x_exp", 0, 10, "", true); clonetiler_table_attach (table, l, 0, 4, 3); @@ -1821,7 +1905,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Horizontal scale per row (in % of tile width)"), "d_scalex_per_y", -100, 1000, "%"); @@ -1829,7 +1913,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Horizontal scale per column (in % of tile width)"), "d_scalex_per_x", -100, 1000, "%"); @@ -1837,7 +1921,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the horizontal scale by this percentage"), "rand_scalex", 0, 1000, "%"); clonetiler_table_attach (table, l, 0, 2, 4); @@ -1852,7 +1936,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Vertical scale per row (in % of tile height)"), "d_scaley_per_y", -100, 1000, "%"); @@ -1860,7 +1944,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Vertical scale per column (in % of tile height)"), "d_scaley_per_x", -100, 1000, "%"); @@ -1868,7 +1952,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the vertical scale by this percentage"), "rand_scaley", 0, 1000, "%"); clonetiler_table_attach (table, l, 0, 3, 4); @@ -1911,7 +1995,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Rotate tiles by this angle for each row"), "d_rot_per_y", -180, 180, "°"); @@ -1919,7 +2003,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, // xgettext:no-c-format _("Rotate tiles by this angle for each column"), "d_rot_per_x", -180, 180, "°"); @@ -1927,7 +2011,7 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the rotation angle by this percentage"), "rand_rot", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 4); @@ -1953,38 +2037,39 @@ clonetiler_dialog (void) } -// Opacity +// Blur and opacity { - GtkWidget *vb = clonetiler_new_tab (nb, _("_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); - // Dissolve + + // Blur { GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), _("Fade out:")); + gtk_label_set_markup (GTK_LABEL(l), _("Blur:")); gtk_size_group_add_widget(table_row_labels, l); clonetiler_table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Decrease tile opacity by this percentage for each row"), "d_opacity_per_y", + GtkWidget *l = clonetiler_spinbox (tt, + _("Blur tiles by this percentage for each row"), "d_blur_per_y", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Decrease tile opacity by this percentage for each column"), "d_opacity_per_x", + GtkWidget *l = clonetiler_spinbox (tt, + _("Blur tiles by this percentage for each column"), "d_blur_per_x", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, - _("Randomize the tile opacity by this percentage"), "rand_opacity", + GtkWidget *l = clonetiler_spinbox (tt, + _("Randomize the tile blur by this percentage"), "rand_blur", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 4); } @@ -1998,14 +2083,63 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "alternate_opacityy"); + GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each row"), "alternate_blury"); clonetiler_table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each column"), "alternate_opacityx"); + GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each column"), "alternate_blurx"); clonetiler_table_attach (table, l, 0, 3, 3); } + + + + // Dissolve + { + GtkWidget *l = gtk_label_new (""); + gtk_label_set_markup (GTK_LABEL(l), _("Fade out:")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 4, 1); + } + + { + GtkWidget *l = clonetiler_spinbox (tt, + _("Decrease tile opacity by this percentage for each row"), "d_opacity_per_y", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 4, 2); + } + + { + GtkWidget *l = clonetiler_spinbox (tt, + _("Decrease tile opacity by this percentage for each column"), "d_opacity_per_x", + 0, 100, "%"); + clonetiler_table_attach (table, l, 0, 4, 3); + } + + { + GtkWidget *l = clonetiler_spinbox (tt, + _("Randomize the tile opacity by this percentage"), "rand_opacity", + 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), _("Alternate:")); + gtk_size_group_add_widget(table_row_labels, l); + clonetiler_table_attach (table, l, 1, 5, 1); + } + + { + GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "alternate_opacityy"); + clonetiler_table_attach (table, l, 0, 5, 2); + } + + { + GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each column"), "alternate_opacityx"); + clonetiler_table_attach (table, l, 0, 5, 3); + } } @@ -2041,21 +2175,21 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Change the tile hue by this percentage for each row"), "d_hue_per_y", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Change the tile hue by this percentage for each column"), "d_hue_per_x", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the tile hue by this percentage"), "rand_hue", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 2, 4); @@ -2071,21 +2205,21 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Change the color saturation by this percentage for each row"), "d_saturation_per_y", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Change the color saturation by this percentage for each column"), "d_saturation_per_x", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the color saturation by this percentage"), "rand_saturation", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 3, 4); @@ -2100,21 +2234,21 @@ clonetiler_dialog (void) } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Change the color lightness by this percentage for each row"), "d_lightness_per_y", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Change the color lightness by this percentage for each column"), "d_lightness_per_x", -100, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the color lightness by this percentage"), "rand_lightness", 0, 100, "%"); clonetiler_table_attach (table, l, 0, 4, 4); @@ -2145,7 +2279,7 @@ clonetiler_dialog (void) 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); @@ -2181,7 +2315,7 @@ clonetiler_dialog (void) radio = gtk_radio_button_new_with_label (NULL, _("Color")); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the visible color and opacity"), NULL); clonetiler_table_attach (table, radio, 0.0, 1, 1); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", + gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_COLOR); } @@ -2189,7 +2323,7 @@ clonetiler_dialog (void) radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the total accumulated opacity"), NULL); clonetiler_table_attach (table, radio, 0.0, 2, 1); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", + gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_OPACITY); } @@ -2197,7 +2331,7 @@ clonetiler_dialog (void) radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R")); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Red component of the color"), NULL); clonetiler_table_attach (table, radio, 0.0, 1, 2); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", + gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_R); } @@ -2205,7 +2339,7 @@ clonetiler_dialog (void) radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G")); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Green component of the color"), NULL); clonetiler_table_attach (table, radio, 0.0, 2, 2); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", + gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_G); } @@ -2213,7 +2347,7 @@ clonetiler_dialog (void) radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B")); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Blue component of the color"), NULL); clonetiler_table_attach (table, radio, 0.0, 3, 2); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", + gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_B); } @@ -2223,7 +2357,7 @@ clonetiler_dialog (void) radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|H")); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the hue of the color"), NULL); clonetiler_table_attach (table, radio, 0.0, 1, 3); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", + gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_H); } @@ -2233,7 +2367,7 @@ clonetiler_dialog (void) radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|S")); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the saturation of the color"), NULL); clonetiler_table_attach (table, radio, 0.0, 2, 3); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", + gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_S); } @@ -2243,7 +2377,7 @@ clonetiler_dialog (void) radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|L")); gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the lightness of the color"), NULL); clonetiler_table_attach (table, radio, 0.0, 3, 3); - gtk_signal_connect (GTK_OBJECT (radio), "toggled", + gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_L); } @@ -2265,7 +2399,7 @@ clonetiler_dialog (void) clonetiler_table_attach (table, l, 1.0, 1, 1); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("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); @@ -2277,7 +2411,7 @@ clonetiler_dialog (void) clonetiler_table_attach (table, l, 1.0, 1, 3); } { - GtkWidget *l = clonetiler_spinbox (tt, + GtkWidget *l = clonetiler_spinbox (tt, _("Randomize the picked value by this percentage"), "rand_picked", 0, 100, "%"); clonetiler_table_attach (table, l, 0.0, 1, 4); @@ -2402,11 +2536,11 @@ clonetiler_dialog (void) // unitmenu GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); - sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), SP_DT_NAMEDVIEW(SP_ACTIVE_DESKTOP)->doc_units); + sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units); { // Width spinbutton - GtkObject *a = gtk_adjustment_new (0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0); + GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0); sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a)); double value = prefs_get_double_attribute (prefs_path, "fillwidth", 50); @@ -2429,8 +2563,8 @@ clonetiler_dialog (void) } { - // Height spinbutton - GtkObject *a = gtk_adjustment_new (0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0); + // Height spinbutton + GtkObject *a = gtk_adjustment_new (0.0, -1e6, 1e6, 1.0, 10.0, 10.0); sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a)); double value = prefs_get_double_attribute (prefs_path, "fillheight", 50); @@ -2452,7 +2586,7 @@ clonetiler_dialog (void) } - // Switch + // Switch GtkWidget* radio; { radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); @@ -2478,7 +2612,7 @@ clonetiler_dialog (void) // Use saved pos - { + { GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); @@ -2546,7 +2680,7 @@ clonetiler_dialog (void) g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE)); // update now - clonetiler_change_selection (NULL, SP_DT_SELECTION(SP_ACTIVE_DESKTOP), dlg); + clonetiler_change_selection (NULL, sp_desktop_selection(SP_ACTIVE_DESKTOP), dlg); } { @@ -2561,7 +2695,7 @@ clonetiler_dialog (void) gtk_widget_show_all (mainbox); } // end of if (!dlg) - + gtk_window_present ((GtkWindow *) dlg); }