From addb39f5f5b6743f7ab120eda1078cc0c2216b2b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Krzysztof=20Kosi=C5=84ski?= Date: Thu, 18 Nov 2010 19:10:22 +0100 Subject: [PATCH] Fix four minor node tool regressions: * 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 | 10 ++++++++-- src/ui/tool/node.cpp | 29 +++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 57e57b711..8008d79eb 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -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)) { diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 6460d9062..12d04dd2b 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -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 unselected; -- 2.30.2