Code

Fix four minor node tool regressions:
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Thu, 18 Nov 2010 18:10:22 +0000 (19:10 +0100)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Thu, 18 Nov 2010 18:10:22 +0000 (19:10 +0100)
* Inverted modifier for spatial/linear grow
* PgDn/PgUp keyboard shortcuts for grow
* Shift during drag disables snapping
* Clicking on the background deselects first the nodes and then the path

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

index 57e57b711d2e3388b2550cfa9de77f0a631fc548..8008d79eb35dac86b0d7d9b913b96a32c28baf19 100644 (file)
@@ -619,8 +619,14 @@ void ink_node_tool_select_point(InkNodeTool *nt, Geom::Point const &/*sel*/, Gdk
 
     if (item_clicked == NULL) { // nothing under cursor
         // if no Shift, deselect
-        if (!(event->state & GDK_SHIFT_MASK)) {
-            selection->clear();
+        // if there are nodes selected, the first click should deselect the nodes
+        // and the second should deselect the items
+        if (!state_held_shift(event->state)) {
+            if (nt->_selected_nodes->empty()) {
+                selection->clear();
+            } else {
+                nt->_selected_nodes->clear();
+            }
         }
     } else {
         if (held_shift(*event)) {
index 6460d90622d9129ccd1c1377618633e7977abdc5..12d04dd2b74541e3e4b804c73e600000f4ae16a2 100644 (file)
@@ -728,8 +728,7 @@ NodeType Node::parse_nodetype(char x)
 /** Customized event handler to catch scroll events needed for selection grow/shrink. */
 bool Node::_eventHandler(GdkEvent *event)
 {
-    static NodeList::iterator origin;
-    static int dir;
+    int dir = 0;
 
     switch (event->type)
     {
@@ -740,14 +739,34 @@ bool Node::_eventHandler(GdkEvent *event)
             dir = -1;
         } else break;
         if (held_control(event->scroll)) {
-            _selection.spatialGrow(this, dir);
+            _linearGrow(dir);
         } else {
+            _selection.spatialGrow(this, dir);
+        }
+        return true;
+    case GDK_KEY_PRESS:
+        switch (shortcut_key(event->key))
+        {
+        case GDK_Page_Up:
+            dir = 1;
+            break;
+        case GDK_Page_Down:
+            dir = -1;
+            break;
+        default: goto bail_out;
+        }
+
+        if (held_control(event->key)) {
             _linearGrow(dir);
+        } else {
+            _selection.spatialGrow(this, dir);
         }
         return true;
     default:
         break;
     }
+    
+    bail_out:
     return ControlPoint::_eventHandler(event);
 }
 
@@ -946,7 +965,9 @@ void Node::dragged(Geom::Point &new_pos, GdkEventMotion *event)
     // constrainedSnap() methods to enforce the constraints, so we need
     // to setup the snapmanager anyway; this is also required for someSnapperMightSnap()
     sm.setup(_desktop);
-    bool snap = sm.someSnapperMightSnap();
+
+    // do not snap when Shift is pressed
+    bool snap = !held_shift(*event) && sm.someSnapperMightSnap();
 
     Inkscape::SnappedPoint sp;
     std::vector<Inkscape::SnapCandidatePoint> unselected;