From: Krzysztof KosiƄski Date: Sun, 31 Oct 2010 18:26:58 +0000 (+0100) Subject: Fix pattern editing in the node editor. As a bonus, allow editing X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=72a0785aba89fb5abee78c0d6c58e5941a9506d5;p=inkscape.git Fix pattern editing in the node editor. As a bonus, allow editing of more than one non-path shape at once. --- diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 450ca96f0..f2b2426ae 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -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::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); diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 641d064c1..11652b535 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -12,6 +12,7 @@ #define SEEN_UI_TOOL_NODE_TOOL_H #include +#include #include #include #include "event-context.h" @@ -41,6 +42,7 @@ typedef std::auto_ptr MultiPathPtr; typedef std::auto_ptr CSelPtr; typedef std::auto_ptr SelectorPtr; typedef std::auto_ptr PathSharedDataPtr; +typedef boost::ptr_vector 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;