Code

Fix path reverse action (Shift+R) in the node tool.
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Wed, 20 Jan 2010 15:31:22 +0000 (16:31 +0100)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Wed, 20 Jan 2010 15:31:22 +0000 (16:31 +0100)
src/ui/tool/multi-path-manipulator.cpp
src/ui/tool/path-manipulator.cpp
src/ui/tool/path-manipulator.h

index 818bdaedcf4c35940c18c6e033e3f29ada4389b6..c05b71cd4f3b3993437f3651d25be8dc255861e2 100644 (file)
@@ -368,8 +368,13 @@ void MultiPathManipulator::distributeNodes(Geom::Dim2 d)
 
 void MultiPathManipulator::reverseSubpaths()
 {
-    invokeForAll(&PathManipulator::reverseSubpaths);
-    _done("Reverse selected subpaths");
+    if (_selection.empty()) {
+        invokeForAll(&PathManipulator::reverseSubpaths, false);
+        _done("Reverse subpaths");
+    } else {
+        invokeForAll(&PathManipulator::reverseSubpaths, true);
+        _done("Reverse selected subpaths");
+    }
 }
 
 void MultiPathManipulator::move(Geom::Point const &delta)
@@ -413,11 +418,14 @@ bool MultiPathManipulator::event(GdkEvent *event)
         switch (shortcut_key(event->key)) {
         case GDK_Insert:
         case GDK_KP_Insert:
+            // Insert - insert nodes in the middle of selected segments
             insertNodes();
             return true;
         case GDK_i:
         case GDK_I:
             if (held_only_shift(event->key)) {
+                // Shift+I - insert nodes (alternate keybinding for Mac keyboards
+                //           that don't have the Insert key)
                 insertNodes();
                 return true;
             }
@@ -425,10 +433,12 @@ bool MultiPathManipulator::event(GdkEvent *event)
         case GDK_j:
         case GDK_J:
             if (held_only_shift(event->key)) {
+                // Shift+J - join nodes
                 joinNodes();
                 return true;
             }
             if (held_only_alt(event->key)) {
+                // Alt+J - join segments
                 joinSegments();
                 return true;
             }
@@ -436,6 +446,7 @@ bool MultiPathManipulator::event(GdkEvent *event)
         case GDK_b:
         case GDK_B:
             if (held_only_shift(event->key)) {
+                // Shift+B - break nodes
                 breakNodes();
                 return true;
             }
@@ -445,14 +456,18 @@ bool MultiPathManipulator::event(GdkEvent *event)
         case GDK_BackSpace:
             if (held_shift(event->key)) break;
             if (held_alt(event->key)) {
+                // Alt+Delete - delete segments
                 deleteSegments();
             } else {
+                // Control+Delete - delete nodes
+                // Delete - delete nodes preserving shape
                 deleteNodes(!held_control(event->key));
             }
             return true;
         case GDK_c:
         case GDK_C:
             if (held_only_shift(event->key)) {
+                // Shift+C - make nodes cusp
                 setNodeType(NODE_CUSP);
                 return true;
             }
@@ -460,6 +475,7 @@ bool MultiPathManipulator::event(GdkEvent *event)
         case GDK_s:
         case GDK_S:
             if (held_only_shift(event->key)) {
+                // Shift+S - make nodes smooth
                 setNodeType(NODE_SMOOTH);
                 return true;
             }
@@ -467,6 +483,7 @@ bool MultiPathManipulator::event(GdkEvent *event)
         case GDK_a:
         case GDK_A:
             if (held_only_shift(event->key)) {
+                // Shift+A - make nodes auto-smooth
                 setNodeType(NODE_AUTO);
                 return true;
             }
@@ -474,6 +491,7 @@ bool MultiPathManipulator::event(GdkEvent *event)
         case GDK_y:
         case GDK_Y:
             if (held_only_shift(event->key)) {
+                // Shift+Y - make nodes symmetric
                 setNodeType(NODE_SYMMETRIC);
                 return true;
             }
@@ -481,8 +499,8 @@ bool MultiPathManipulator::event(GdkEvent *event)
         case GDK_r:
         case GDK_R:
             if (held_only_shift(event->key)) {
+                // Shift+R - reverse subpaths
                 reverseSubpaths();
-                break;
             }
             break;
         default:
index 3be332b80a3a291cdf8a5a7ee541460cd2f7d6b4..e15349e06ea9f20c9900afdac44a6762cee267c8 100644 (file)
@@ -100,7 +100,6 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path,
     , _show_outline(false)
     , _lpe_key(lpe_key)
 {
-    /* Because curve drag point is always created first, it does not cover nodes */
     if (_lpe_key.empty()) {
         _i2d_transform = sp_item_i2d_affine(SP_ITEM(path));
     } else {
@@ -651,14 +650,18 @@ void PathManipulator::deleteSegments()
 }
 
 /** Reverse the subpaths that have anything selected. */
-void PathManipulator::reverseSubpaths()
+void PathManipulator::reverseSubpaths(bool selected_only)
 {
     for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) {
-        for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) {
-            if (j->selected()) {
-                (*i)->reverse();
-                break; // continue with the next subpath
+        if (selected_only) {
+            for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) {
+                if (j->selected()) {
+                    (*i)->reverse();
+                    break; // continue with the next subpath
+                }
             }
+        } else {
+            (*i)->reverse();
         }
     }
 }
index 99e183b4530c656ecca0c4ab9ec929394ab974e6..1b4711bbaccb10b5a7da7f883c533bbf9e24f3ea 100644 (file)
@@ -73,7 +73,7 @@ public:
     void breakNodes();
     void deleteNodes(bool keep_shape = true);
     void deleteSegments();
-    void reverseSubpaths();
+    void reverseSubpaths(bool selected_only);
     void setSegmentType(SegmentType);
 
     void showOutline(bool show);