summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Silver <sasilver@yahoo.com>2008-05-31 15:16:57 +0000
committersasilver <sasilver@users.sourceforge.net>2008-05-31 15:16:57 +0000
commitf709f7f377a37c2bec986965d5b0709675ef4538 (patch)
tree9f6461a79cfea499b1fd58e6b51c4930125dcae5 /src
parentCmake: added windows path to find modules. (diff)
downloadinkscape-f709f7f377a37c2bec986965d5b0709675ef4538.tar.gz
inkscape-f709f7f377a37c2bec986965d5b0709675ef4538.zip
wrtlprnft's patch for bug 234834 - keeps guidelines in same position relative to objects when doing "Fit page to selection", and also keeps the objects in the same position on the screen
(bzr r5771)
Diffstat (limited to 'src')
-rw-r--r--src/desktop.cpp10
-rw-r--r--src/desktop.h1
-rw-r--r--src/document.cpp10
-rw-r--r--src/sp-namedview.cpp17
-rw-r--r--src/sp-namedview.h3
5 files changed, 41 insertions, 0 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index eee0446db..5796ed638 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -976,6 +976,16 @@ SPDesktop::zoom_drawing()
}
/**
+ * Scroll canvas by specific coordinate amount in svg coordinates.
+ */
+void
+SPDesktop::scroll_world_in_svg_coords (double dx, double dy, bool is_scrolling)
+{
+ double scale = expansion(_d2w);
+ scroll_world(dx*scale, dy*scale, is_scrolling);
+}
+
+/**
* Scroll canvas by specific coordinate amount.
*/
void
diff --git a/src/desktop.h b/src/desktop.h
index df9848282..af0d41b2a 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -257,6 +257,7 @@ struct SPDesktop : public Inkscape::UI::View::View
using NR::Y;
scroll_world(scroll[X], scroll[Y], is_scrolling);
}
+ void scroll_world_in_svg_coords (double dx, double dy, bool is_scrolling = false);
void getWindowGeometry (gint &x, gint &y, gint &w, gint &h);
void setWindowPosition (NR::Point p);
diff --git a/src/document.cpp b/src/document.cpp
index d0792ab8a..bf5ef089e 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -48,6 +48,8 @@
#include "inkscape-private.h"
#include "inkscape_version.h"
#include "sp-object-repr.h"
+#include "sp-namedview.h"
+#include "desktop.h"
#include "document-private.h"
#include "dir-util.h"
#include "unit-constants.h"
@@ -557,6 +559,14 @@ void SPDocument::fitToRect(NR::Rect const &rect)
NR::translate const tr(NR::Point(0, (old_height - h))
- rect.min());
SP_GROUP(root)->translateChildItems(tr);
+ SPNamedView *nv = sp_document_namedview(this, 0);
+ if(nv) {
+ NR::translate tr2(-rect.min());
+ nv->translateGuides(tr2);
+
+ // update the viewport so the drawing appears to stay where it was
+ nv->scrollAllDesktops(-tr2[0], tr2[1], false);
+ }
}
void sp_document_set_uri(SPDocument *document, gchar const *uri)
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 3575ce6ae..3f52232cb 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -1063,6 +1063,23 @@ Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedvie
return NULL;
}
+void SPNamedView::translateGuides(NR::translate const &tr) {
+ for (GSList *l = guides; l != NULL; l = l->next) {
+ SPGuide &guide = *SP_GUIDE(l->data);
+ Geom::Point point_on_line = guide.point_on_line;
+ point_on_line[0] += tr[0];
+ point_on_line[1] += tr[1];
+ sp_guide_moveto(guide, point_on_line, true);
+ }
+}
+
+void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) {
+ for(GSList *l = views; l; l = l->next) {
+ SPDesktop *desktop = static_cast<SPDesktop *>(l->data);
+ desktop->scroll_world_in_svg_coords(dx, dy, is_scrolling);
+ }
+}
+
/*
Local Variables:
diff --git a/src/sp-namedview.h b/src/sp-namedview.h
index 6055f5c71..cfc57d1c4 100644
--- a/src/sp-namedview.h
+++ b/src/sp-namedview.h
@@ -87,6 +87,9 @@ struct SPNamedView : public SPObjectGroup {
guint getViewCount();
GSList const *getViewList() const;
SPMetric getDefaultMetric() const;
+
+ void translateGuides(NR::translate const &translation);
+ void scrollAllDesktops(double dx, double dy, bool is_scrolling);
};
struct SPNamedViewClass {