summaryrefslogtreecommitdiffstats
path: root/src/desktop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/desktop.cpp')
-rw-r--r--src/desktop.cpp75
1 files changed, 64 insertions, 11 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index c46d6e2f6..c56c42267 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -40,7 +40,9 @@
#include "desktop-style.h"
#include "device-manager.h"
#include "display/canvas-arena.h"
+#include "display/canvas-debug.h"
#include "display/canvas-grid.h"
+#include "display/canvas-rotate.h"
#include "display/canvas-temporary-item-list.h"
#include "display/drawing-group.h"
#include "display/gnome-canvas-acetate.h"
@@ -129,7 +131,6 @@ SPDesktop::SPDesktop() :
layers->_layer_deactivated_signal.connect(sigc::bind(sigc::ptr_fun(_layer_deactivated), this));
layers->_layer_changed_signal.connect(sigc::bind(sigc::ptr_fun(_layer_hierarchy_changed), this));
selection = Inkscape::GC::release( new Inkscape::Selection(layers, this) );
- // _current_affine.setRotate(M_PI/4); // To test zooming with rotation
}
void
@@ -221,10 +222,10 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
// being selected? or does it intercept some of the events that should have gone to the
// node handler? see bug https://bugs.launchpad.net/inkscape/+bug/414142)
gridgroup = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
- guides = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
- sketch = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
+ guides = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
+ sketch = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
tempgroup = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
- controls = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
+ controls = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
// Set the select tool as the active tool.
set_event_context2("/tools/select");
@@ -252,7 +253,8 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
_doc2dt[5] = document->getHeight().value("px");
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
- _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
+ _modified_connection =
+ namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
Inkscape::DrawingItem *ai = document->getRoot()->invoke_show(
SP_CANVAS_ARENA (drawing)->drawing,
@@ -314,6 +316,10 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
temporary_item_list = new Inkscape::Display::TemporaryItemList( this );
snapindicator = new Inkscape::Display::SnapIndicator ( this );
+
+ canvas_rotate = sp_canvas_item_new (root, SP_TYPE_CANVAS_ROTATE, NULL);
+ sp_canvas_item_hide( canvas_rotate );
+ // canvas_debug = sp_canvas_item_new (main, SP_TYPE_CANVAS_DEBUG, NULL);
}
@@ -838,6 +844,7 @@ SPDesktop::set_display_area (bool log)
_widget->updateRulers();
_widget->updateScrollbars(_current_affine.getZoom());
_widget->updateZoom();
+ _widget->updateRotation();
signal_zoom_changed.emit(_current_affine.getZoom());
}
@@ -1128,6 +1135,48 @@ SPDesktop::rotate_relative_center_point (Geom::Point const &c, double rotate)
/**
+ * Flip keeping the point 'c' fixed in the desktop window.
+ */
+void
+SPDesktop::flip_absolute_keep_point (Geom::Point const &c, CanvasFlip flip)
+{
+ Geom::Point w = d2w( c ); // Must be before flip.
+ _current_affine.setFlip( flip );
+ set_display_area( c, w );
+}
+
+
+void
+SPDesktop::flip_relative_keep_point (Geom::Point const &c, CanvasFlip flip)
+{
+ Geom::Point w = d2w( c ); // Must be before flip.
+ _current_affine.addFlip( flip );
+ set_display_area( c, w );
+}
+
+
+/**
+ * Flip aligning the point 'c' to the center of desktop window.
+ */
+void
+SPDesktop::flip_absolute_center_point (Geom::Point const &c, CanvasFlip flip)
+{
+ _current_affine.setFlip( flip );
+ Geom::Rect viewbox = canvas->getViewbox();
+ set_display_area( c, viewbox.midpoint() );
+}
+
+
+void
+SPDesktop::flip_relative_center_point (Geom::Point const &c, CanvasFlip flip)
+{
+ _current_affine.addFlip( flip );
+ Geom::Rect viewbox = canvas->getViewbox();
+ set_display_area( c, viewbox.midpoint() );
+}
+
+
+/**
* Scroll canvas by to a particular point (window coordinates).
*/
void
@@ -1557,12 +1606,16 @@ SPDesktop::setDocument (SPDocument *doc)
layers->setDocument(doc);
selection->setDocument(doc);
- // remove old EventLog if it exists (see also: bug #1071082)
- if (event_log) {
- doc->removeUndoObserver(*event_log);
- delete event_log;
- event_log = 0;
- }
+ if (event_log) {
+ // Remove it from the replaced document. This prevents Inkscape from
+ // crashing since we access it in the replaced document's destructor
+ // which results in an undefined behavior. (See also: bug #1670688)
+ if (this->doc()) {
+ this->doc()->removeUndoObserver(*event_log);
+ }
+ delete event_log;
+ event_log = 0;
+ }
/* setup EventLog */
event_log = new Inkscape::EventLog(doc);