summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-10-12 16:11:17 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-10-12 16:11:17 +0000
commit285f551658271fde028b389f7b1abe35e65c6659 (patch)
treee703eda0b82adf120db266ac05adf13561db7e91 /src
parentfix misunderstood path-closed-flag in LWPOLYLINE (Bug 656899) (diff)
downloadinkscape-285f551658271fde028b389f7b1abe35e65c6659.tar.gz
inkscape-285f551658271fde028b389f7b1abe35e65c6659.zip
Cherry pick node duplication from 0.48 stable
(bzr r9825)
Diffstat (limited to 'src')
-rw-r--r--src/ui/tool/multi-path-manipulator.cpp12
-rw-r--r--src/ui/tool/multi-path-manipulator.h1
-rw-r--r--src/ui/tool/path-manipulator.cpp33
-rw-r--r--src/ui/tool/path-manipulator.h1
4 files changed, 47 insertions, 0 deletions
diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp
index 2025a12d7..6101a3556 100644
--- a/src/ui/tool/multi-path-manipulator.cpp
+++ b/src/ui/tool/multi-path-manipulator.cpp
@@ -244,6 +244,12 @@ void MultiPathManipulator::insertNodes()
_done(_("Add nodes"));
}
+void MultiPathManipulator::duplicateNodes()
+{
+ invokeForAll(&PathManipulator::duplicateNodes);
+ _done(_("Duplicate nodes"));
+}
+
void MultiPathManipulator::joinNodes()
{
invokeForAll(&PathManipulator::hideDragPoint);
@@ -513,6 +519,12 @@ bool MultiPathManipulator::event(GdkEvent *event)
return true;
}
break;
+ case GDK_d:
+ case GDK_D:
+ if (held_only_shift(event->key)) {
+ duplicateNodes();
+ return true;
+ }
case GDK_j:
case GDK_J:
if (held_only_shift(event->key)) {
diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h
index 181ae6d1d..7a4cfdb5d 100644
--- a/src/ui/tool/multi-path-manipulator.h
+++ b/src/ui/tool/multi-path-manipulator.h
@@ -53,6 +53,7 @@ public:
void setSegmentType(SegmentType t);
void insertNodes();
+ void duplicateNodes();
void joinNodes();
void breakNodes();
void deleteNodes(bool keep_shape = true);
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index f5c27e1d6..81fc336ce 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -319,6 +319,39 @@ void PathManipulator::insertNodes()
}
}
+/** Insert new nodes exactly at the positions of selected nodes while preserving shape.
+ * This is equivalent to breaking, except that it doesn't split into subpaths. */
+void PathManipulator::duplicateNodes()
+{
+ if (_num_selected == 0) return;
+
+ for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) {
+ for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) {
+ if (j->selected()) {
+ NodeList::iterator k = j.next();
+ Node *n = new Node(_multi_path_manipulator._path_data.node_data, *j);
+
+ // Move the new node to the bottom of the Z-order. This way you can drag all
+ // nodes that were selected before this operation without deselecting
+ // everything because there is a new node above.
+ n->sink();
+
+ n->front()->setPosition(*j->front());
+ j->front()->retract();
+ j->setType(NODE_CUSP, false);
+ (*i)->insert(k, n);
+
+ // We need to manually call the selection change callback to refresh
+ // the handle display correctly.
+ // This call changes num_selected, but we call this once for a selected node
+ // and once for an unselected node, so in the end the number stays correct.
+ _selectionChanged(j.ptr(), true);
+ _selectionChanged(n, false);
+ }
+ }
+ }
+}
+
/** Replace contiguous selections of nodes in each subpath with one node. */
void PathManipulator::weldNodes(NodeList::iterator preserve_pos)
{
diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h
index a8f1c957e..c57b6497e 100644
--- a/src/ui/tool/path-manipulator.h
+++ b/src/ui/tool/path-manipulator.h
@@ -69,6 +69,7 @@ public:
void invertSelectionInSubpaths();
void insertNodes();
+ void duplicateNodes();
void weldNodes(NodeList::iterator preserve_pos = NodeList::iterator());
void weldSegments();
void breakNodes();