Code

When changing document size, the origin (lower left corner) should be stationary...
authordvlierop2 <dvlierop2@users.sourceforge.net>
Sat, 9 May 2009 12:40:32 +0000 (12:40 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Sat, 9 May 2009 12:40:32 +0000 (12:40 +0000)
src/ui/widget/page-sizer.cpp

index cdb0feff30b68b52db7631c794ae6df6b77f2c52..02688a55e67ac6370c31ba744e2027915ec07596 100644 (file)
@@ -36,6 +36,7 @@
 #include "desktop.h"
 #include "page-sizer.h"
 #include "helper/action.h"
+#include "sp-root.h"
 
 using std::pair;
 
@@ -346,8 +347,13 @@ PageSizer::setDim (double w, double h, bool changeList)
 
     if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) {
         SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP);
+        double const old_height = sp_document_height(doc);
         sp_document_set_width (doc, w, &_px_unit);
         sp_document_set_height (doc, h, &_px_unit);
+        // The origin for the user is in the lower left corner; this point should remain stationary when
+        // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this
+        Geom::Translate const vert_offset(Geom::Point(0, (old_height - h)));
+               SP_GROUP(SP_ROOT(doc->root))->translateChildItems(vert_offset);
         sp_document_done (doc, SP_VERB_NONE, _("Set page size"));
     }