Code

fix filter area clipping when blurring a squeezed object
[inkscape.git] / src / dialogs / clonetiler.cpp
index 7f8c65b09d6a847fe428001c05dd53e174bf2581..c0acea533a91be2e021f5b4f78e3833e95673cb4 100644 (file)
@@ -4,9 +4,10 @@
  * 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
  */
 
@@ -60,6 +61,8 @@
 #include "../sp-filter.h"
 #include "../filter-chemistry.h"
 
+#define MIN_ONSCREEN_DISTANCE 50
+
 static GtkWidget *dlg = NULL;
 static win_data wd;
 
@@ -867,7 +870,7 @@ clonetiler_unclump (GtkWidget *widget, void *)
     g_slist_free (to_unclump);
 
     sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, 
-                      /* TODO: annotate */ "clonetiler.cpp:867");
+                      _("Unclump tiled clones"));
 }
 
 static guint
@@ -920,7 +923,7 @@ clonetiler_remove (GtkWidget *widget, void *, bool do_undo = true)
 
     if (do_undo)
         sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, 
-                          /* TODO: annotate */ "clonetiler.cpp:920");
+                          _("Delete tiled clones"));
 }
 
 static NR::Rect
@@ -1090,7 +1093,7 @@ clonetiler_apply (GtkWidget *widget, void *)
 
     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?
@@ -1299,9 +1302,12 @@ clonetiler_apply (GtkWidget *widget, void *)
 
             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);
             }
 
@@ -1326,7 +1332,7 @@ clonetiler_apply (GtkWidget *widget, void *)
     clonetiler_change_selection (NULL, selection, dlg);
 
     sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, 
-                     /* TODO: annotate */ "clonetiler.cpp:1300");
+                     _("Create tiled clones"));
 }
 
 static GtkWidget *
@@ -1626,8 +1632,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) {
@@ -1635,19 +1641,19 @@ clonetiler_dialog (void)
             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;