Code

Fix handle for LPERotateCopies
[inkscape.git] / src / desktop.cpp
index 5796ed6386ba810fa01aef91ed359249c94f47d8..932d79ff2e7dadfe24d1c6e3cee85e5db55c0d79 100644 (file)
@@ -85,6 +85,7 @@
 #include "xml/repr.h"
 #include "message-context.h"
 #include "device-manager.h"
+#include "layer-fns.h"
 #include "layer-manager.h"
 #include "event-log.h"
 #include "display/canvas-grid.h"
@@ -394,11 +395,19 @@ SPDesktop::~SPDesktop() {}
 /* Public methods */
 
 
+/* These methods help for temporarily showing things on-canvas.
+ * The *only* valid use of the TemporaryItem* that you get from add_temporary_canvasitem
+ * is when you want to prematurely remove the item from the canvas, by calling
+ * desktop->remove_temporary_canvasitem(tempitem).
+ */
 /** Note that lifetime is measured in milliseconds
-* it is perfectly safe to ignore the returned pointer: the object is deleted by itself, so don't delete it elsewhere!
-* The return value should only be used as argument for SPDesktop::remove_temporary_canvasitem, because the object might be deleted already.
-* move_to_bottom = true by default so the item does not interfere with handling of other items on the canvas like nodes.
-*/
+ * One should *not* keep a reference to the SPCanvasItem, the temporary item code will
+ * delete the object for you and the reference will become invalid without you knowing it.
+ * It is perfectly safe to ignore the returned pointer: the object is deleted by itself, so don't delete it elsewhere!
+ * The *only* valid use of the returned TemporaryItem* is as argument for SPDesktop::remove_temporary_canvasitem,
+ * because the object might be deleted already without you knowing it.
+ * move_to_bottom = true by default so the item does not interfere with handling of other items on the canvas like nodes.
+ */
 Inkscape::Display::TemporaryItem *
 SPDesktop::add_temporary_canvasitem (SPCanvasItem *item, guint lifetime, bool move_to_bottom)
 {
@@ -467,6 +476,31 @@ void SPDesktop::setCurrentLayer(SPObject *object) {
     _layer_hierarchy->setBottom(object);
 }
 
+void SPDesktop::toggleLayerSolo(SPObject *object) {
+    g_return_if_fail(SP_IS_GROUP(object));
+    g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) );
+
+    bool othersShowing = false;
+    std::vector<SPObject*> layers;
+    for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) {
+        layers.push_back(obj);
+        othersShowing |= !SP_ITEM(obj)->isHidden();
+    }
+    for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) {
+        layers.push_back(obj);
+        othersShowing |= !SP_ITEM(obj)->isHidden();
+    }
+
+
+    if ( SP_ITEM(object)->isHidden() ) {
+        SP_ITEM(object)->setHidden(false);
+    }
+
+    for ( std::vector<SPObject*>::iterator it = layers.begin(); it != layers.end(); ++it ) {
+        SP_ITEM(*it)->setHidden(othersShowing);
+    }
+}
+
 /**
  * Return layer that contains \a object.
  */