Code

Fix behavior when loading a document
[inkscape.git] / src / desktop.cpp
index 69aec65e09dae14b8b5aa181d6d3a7de3d853c54..1953ae2a6e8db730bfff77ff61f52a8f398ba6dd 100644 (file)
@@ -158,7 +158,7 @@ SPDesktop::SPDesktop() :
     _active( false ),
     _w2d(),
     _d2w(),
-    _doc2dt( Geom::Scale(1, -1) ),
+    _doc2dt( Geom::identity() ),
     grids_visible( false )
 {
     _d2w.setIdentity();
@@ -272,7 +272,6 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
 
 
     /* Connect event for page resize */
-    _doc2dt[5] = sp_document_height (document);
     sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
 
     _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
@@ -793,8 +792,8 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double
     int clear = FALSE;
     if (!NR_DF_TEST_CLOSE (newscale, scale, 1e-4 * scale)) {
         // zoom changed - set new zoom factors
-        _d2w = Geom::Scale(newscale, -newscale);
-        _w2d = Geom::Scale(1/newscale, 1/-newscale);
+        _d2w = Geom::Scale(newscale);
+        _w2d = Geom::Scale(1/newscale);
         sp_canvas_item_affine_absolute(SP_CANVAS_ITEM(main), _d2w);
         clear = TRUE;
         signal_zoom_changed.emit(_d2w.descrim());
@@ -802,10 +801,10 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double
 
     /* Calculate top left corner (in document pixels) */
     x0 = cx - 0.5 * viewbox.dimensions()[Geom::X] / newscale;
-    y1 = cy + 0.5 * viewbox.dimensions()[Geom::Y] / newscale;
+    y0 = cy - 0.5 * viewbox.dimensions()[Geom::Y] / newscale;
 
     /* Scroll */
-    sp_canvas_scroll_to (canvas, x0 * newscale - border, y1 * -newscale - border, clear);
+    sp_canvas_scroll_to (canvas, x0 * newscale - border, y0 * newscale - border, clear);
 
     /*  update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
     sp_box3d_context_update_lines(event_context);
@@ -829,8 +828,7 @@ Geom::Rect SPDesktop::get_display_area() const
 
     double const scale = _d2w[0];
 
-    return Geom::Rect(Geom::Point(viewbox.min()[Geom::X] / scale, viewbox.max()[Geom::Y] / -scale),
-                      Geom::Point(viewbox.max()[Geom::X] / scale, viewbox.min()[Geom::Y] / -scale));
+    return viewbox * (1./scale);
 }
 
 /**
@@ -910,7 +908,7 @@ SPDesktop::zoom_quick (bool enable)
                 if (!Geom::are_near(area, 0) && area * 2.0 < _quick_zoom_stored_area.area()) {
                     set_display_area(nodes, true);
                     zoomed = true;
-               }
+                }
             }
         }
 
@@ -1545,7 +1543,6 @@ SPDesktop::onDocumentURISet (gchar const* uri)
 void
 SPDesktop::onDocumentResized (gdouble width, gdouble height)
 {
-    _doc2dt[5] = height;
     sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
     Geom::Rect const a(Geom::Point(0, 0), Geom::Point(width, height));
     SP_CTRLRECT(page)->setRectangle(a);
@@ -1635,7 +1632,7 @@ static void
 _reconstruction_start (SPDesktop * desktop)
 {
     // printf("Desktop, starting reconstruction\n");
-    desktop->_reconstruction_old_layer_id = g_strdup(SP_OBJECT_ID(desktop->currentLayer()));
+    desktop->_reconstruction_old_layer_id = g_strdup(desktop->currentLayer()->getId());
     desktop->_layer_hierarchy->setBottom(desktop->currentRoot());
 
     /*