From: Krzysztof KosiƄski Date: Thu, 18 Mar 2010 02:59:43 +0000 (+0100) Subject: Fix a few remaining oddities in handle scaling via keyboard X-Git-Url: https://git.tokkee.org/?p=inkscape.git;a=commitdiff_plain;h=e32639b3737f1dd3b882ebd4ad833133091880ba Fix a few remaining oddities in handle scaling via keyboard --- diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index fe97058c4..2025a12d7 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -464,6 +464,7 @@ bool MultiPathManipulator::event(GdkEvent *event) } if (which == 0) break; // no handle chosen bool one_pixel = _tracker.leftAlt() || _tracker.rightAlt(); + bool handled = true; switch (key) { // single handle functions @@ -485,8 +486,12 @@ bool MultiPathManipulator::event(GdkEvent *event) case GDK_less: pm.scaleHandle(n, which, -1, one_pixel); break; + default: + handled = false; + break; } - return true; + + if (handled) return true; } while(0); } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index f6d5bde37..66f72f379 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -747,6 +747,7 @@ void PathManipulator::scaleHandle(Node *n, int which, int dir, bool pixel) Geom::Point relpos; if (h->isDegenerate()) { + if (dir < 0) return; Node *nh = n->nodeToward(h); if (!nh) return; relpos = Geom::unit_vector(nh->position() - n->position()) * length_change; @@ -788,20 +789,24 @@ void PathManipulator::rotateHandle(Node *n, int which, int dir, bool pixel) Handle *PathManipulator::_chooseHandle(Node *n, int which) { - // Rationale for this choice: - // Imagine you have two handles pointing right, where one of them is only slighty higher - // than the other. Extending one of the handles could make its X coord larger than - // the second one, and keeping the shortcut pressed would result in two handles being - // extended alternately. This appears like extending both handles at once and is confusing. - // Using the unit vector avoids this problem and remains fairly intuitive. - Geom::Point f = Geom::unit_vector(n->front()->position()); - Geom::Point b = Geom::unit_vector(n->back()->position()); + NodeList::iterator i = NodeList::get_iterator(n); + Node *prev = i.prev().ptr(); + Node *next = i.next().ptr(); + + // on an endnode, the remaining handle automatically wins + if (!next) return n->back(); + if (!prev) return n->front(); + + // compare X coord ofline segments + Geom::Point npos = next->position(); + Geom::Point ppos = prev->position(); if (which < 0) { // pick left handle. // we just swap the handles and pick the right handle below. - std::swap(f, b); + std::swap(npos, ppos); } - if (f[Geom::X] >= b[Geom::X]) { + + if (npos[Geom::X] >= ppos[Geom::X]) { return n->front(); } else { return n->back();