Code

Calligraphy tool now draws in the last used color or tool style depending on the...
[inkscape.git] / src / selection.h
index 48d1112a80815c2ff2f8770026e286531e1a16ef..c78a1fdbb04fd09fa0219768b1addd85a55b062b 100644 (file)
@@ -25,6 +25,7 @@
 #include "gc-managed.h"
 #include "gc-finalized.h"
 #include "gc-anchored.h"
+#include "gc-soft-ptr.h"
 #include "util/list.h"
 
 class SPItem;
@@ -75,12 +76,19 @@ public:
      */
     SPDesktop *desktop() { return _desktop; }
 
+    /**
+     * @brief Returns active layer for selection (currentLayer or its parent)
+     *
+     * @return layer item the selection is bound to
+     */
+    SPObject *activeContext();
+
     /**
      * @brief Add an SPObject to the set of selected objects
      *
      * @param obj the SPObject to add
      */
-    void add(SPObject *obj);
+    void add(SPObject *obj, bool persist_selection_context = false);
 
     /**
      * @brief Add an XML node's SPObject to the set of selected objects
@@ -94,7 +102,7 @@ public:
      *
      * @param obj the object to select
      */
-    void set(SPObject *obj);
+    void set(SPObject *obj, bool persist_selection_context = false);
 
     /**
      * @brief Set the selection to an XML node's SPObject
@@ -218,10 +226,13 @@ public:
     /** @brief Returns the number of layers in which there are selected objects */
     guint numberOfLayers();
 
+    /** @brief Returns the number of parents to which the selected objects belong */
+    guint numberOfParents();
+
     /** @brief Returns the bounding rectangle of the selection */
     NRRect *bounds(NRRect *dest) const;
     /** @brief Returns the bounding rectangle of the selection */
-    NR::Rect bounds() const;
+    ::NR::Rect bounds() const;
 
     /**
      * @brief Returns the bounding rectangle of the selection
@@ -235,7 +246,12 @@ public:
      *
      * \todo how is this different from bounds()?
      */
-    NR::Rect boundsInDocument() const;
+    ::NR::Rect boundsInDocument() const;
+
+    /**
+     * @brief Returns the rotation/skew center of the selection
+     */
+    ::NR::Point center() const;
 
     /**
      * @brief Gets the selection's snap points.
@@ -299,11 +315,13 @@ private:
     static void _schedule_modified(SPObject *obj, guint flags, Selection *selection);
     /** @brief Releases a selected object that is being removed */
     static void _release(SPObject *obj, Selection *selection);
+    /** @brief Releases an active layer object that is being removed */
+    static void _releaseSelectionContext(SPObject *obj, Selection *selection);
 
     /** @brief Issues modified selection signal */
     void _emitModified(guint flags);
     /** @brief Issues changed selection signal */
-    void _emitChanged();
+    void _emitChanged(bool persist_selection_context = false);
 
     void _invalidateCachedLists();
 
@@ -319,12 +337,16 @@ private:
     void _remove(SPObject *obj);
     /** @brief returns the SPObject corresponding to an xml node (if any) */
     SPObject *_objectForXMLNode(XML::Node *repr) const;
+    /** @brief Releases an active layer object that is being removed */
+    void _releaseContext(SPObject *obj);
 
     mutable GSList *_objs;
     mutable GSList *_reprs;
     mutable GSList *_items;
 
-    SPDesktop *_desktop;
+    GC::soft_ptr<SPDesktop> _desktop;
+    SPObject* _selection_context;
+    gulong _context_release_handler_id;
     guint _flags;
     guint _idle;