index 324a3d94ba8ae5145f9b8dce5125d60ed2446419..00fcac48e8ac1d8706bf1f66957386620e66359d 100644 (file)
* Clone tiling dialog
*
* Authors:
- * bulia byak <buliabyak@users.sf.net>
+ * bulia byak <buliabyak@users.sf.net>
+ * Johan Engelen <goejendaagh@zonnet.nl>
*
- * Copyright (C) 2004-2005 Authors
+ * Copyright (C) 2004-2006 Authors
* Released under GNU GPL
*/
#include "../sp-filter.h"
#include "../filter-chemistry.h"
+#define MIN_ONSCREEN_DISTANCE 50
+
static GtkWidget *dlg = NULL;
static win_data wd;
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);
w = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-w", 0);
h = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-h", 0);
} else {
- NR::Rect const r = SP_ITEM(obj)->invokeBbox(sp_item_i2doc_affine(SP_ITEM(obj)));
+ NR::Rect const r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj)));
c = r.midpoint();
w = r.dimensions()[NR::X];
h = r.dimensions()[NR::Y];
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));
- double diag_original = sqrt(w*w + h*h);
+ double perimeter_original = (w + h)/4;
for (int x = 0;
fillrect?
}
// 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);
if (blur > 0.0) {
SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone);
- double diag = diag_original * t.expansion();
- double radius = blur * diag;
- SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius);
+ 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);
}
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) {
h = prefs_get_int_attribute (prefs_path, "h", 0);
}
- if (x<0) x=0;
- if (y<0) y=0;
+// if (x<0) x=0;
+// if (y<0) y=0;
- if (x != 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;
{
// 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);
{
// Height 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, "fillheight", 50);