Code

Fix pattern editing in the node editor. As a bonus, allow editing
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Sun, 31 Oct 2010 18:26:58 +0000 (19:26 +0100)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Sun, 31 Oct 2010 18:26:58 +0000 (19:26 +0100)
of more than one non-path shape at once.

src/ui/tool/node-tool.cpp
src/ui/tool/node-tool.h

index 450ca96f02115498674f6b16dfc12ab5034ecabf..f2b2426ae81527bcdacdc8775f0aad1d134f02cb 100644 (file)
@@ -164,6 +164,7 @@ void ink_node_tool_init(InkNodeTool *nt)
     new (&nt->_multipath) MultiPathPtr();
     new (&nt->_selector) SelectorPtr();
     new (&nt->_path_data) PathSharedDataPtr();
+    new (&nt->_shape_editors) ShapeEditors();
 }
 
 void ink_node_tool_dispose(GObject *object)
@@ -178,6 +179,7 @@ void ink_node_tool_dispose(GObject *object)
     nt->_multipath.~MultiPathPtr();
     nt->_selected_nodes.~CSelPtr();
     nt->_selector.~SelectorPtr();
+    nt->_shape_editors.~ShapeEditors();
     
     Inkscape::UI::PathSharedData &data = *nt->_path_data;
     destroy_group(data.node_data.node_group);
@@ -283,7 +285,7 @@ void ink_node_tool_setup(SPEventContext *ec)
     nt->_last_over = NULL;
     // TODO long term, fold ShapeEditor into MultiPathManipulator and rename MPM
     // to something better
-    nt->shape_editor = new ShapeEditor(nt->desktop);
+    //nt->shape_editor = new ShapeEditor(nt->desktop);
 
     // read prefs before adding items to selection to prevent momentarily showing the outline
     sp_event_context_read(nt, "show_handles");
@@ -403,22 +405,21 @@ void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel)
         }
     }
 
-    // ugly hack: set the first editable non-path item for knotholder
-    // maybe use multiple ShapeEditors for now, to allow editing many shapes at once?
-    bool something_set = false;
+    nt->_shape_editors.clear();
+
+    // use multiple ShapeEditors for now, to allow editing many shapes at once
+    // needs to be rethought
+
     for (std::set<ShapeRecord>::iterator i = shapes.begin(); i != shapes.end(); ++i) {
         ShapeRecord const &r = *i;
-        if (SP_IS_SHAPE(r.item) ||
-            (SP_IS_PATH(r.item) && r.item->repr->attribute("inkscape:original-d") != NULL))
+        if (SP_IS_SHAPE(r.item))
         {
-            nt->shape_editor->set_item(r.item, SH_KNOTHOLDER);
-            something_set = true;
-            break;
+            ShapeEditor *si = new ShapeEditor(nt->desktop);
+            si->set_item(r.item, SH_KNOTHOLDER);
+            nt->_shape_editors.push_back(si);
+            //nt->shape_editor->set_item(r.item, SH_KNOTHOLDER);
         }
     }
-    if (!something_set) {
-        nt->shape_editor->unset_item(SH_KNOTHOLDER);
-    }
 
     nt->_multipath->setItems(shapes);
     ink_node_tool_update_tip(nt, NULL);
index 641d064c19691c9696f1f32e1b1dfc4776747b6a..11652b535da74d641c7dddfd09e747d0875a2734 100644 (file)
@@ -12,6 +12,7 @@
 #define SEEN_UI_TOOL_NODE_TOOL_H
 
 #include <memory>
+#include <boost/ptr_container/ptr_vector.hpp>
 #include <glib.h>
 #include <sigc++/sigc++.h>
 #include "event-context.h"
@@ -41,6 +42,7 @@ typedef std::auto_ptr<Inkscape::UI::MultiPathManipulator> MultiPathPtr;
 typedef std::auto_ptr<Inkscape::UI::ControlPointSelection> CSelPtr;
 typedef std::auto_ptr<Inkscape::UI::Selector> SelectorPtr;
 typedef std::auto_ptr<Inkscape::UI::PathSharedData> PathSharedDataPtr;
+typedef boost::ptr_vector<ShapeEditor> ShapeEditors;
 
 struct InkNodeTool : public SPEventContext
 {
@@ -56,6 +58,7 @@ struct InkNodeTool : public SPEventContext
     PathSharedDataPtr _path_data;
     SPCanvasGroup *_transform_handle_group;
     SPItem *_last_over;
+    ShapeEditors _shape_editors;
 
     unsigned cursor_drag : 1;
     unsigned show_handles : 1;