diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2016-03-13 23:50:24 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2016-03-13 23:50:24 +0000 |
| commit | d7b1e066fa7c7d9e6a83d688fe48c5f06620bf10 (patch) | |
| tree | 3a0c0d0d59acbfdf97735223c482df2b968a1026 /src/ui/tool/control-point-selection.cpp | |
| parent | Translations. Danish translation update. (diff) | |
| download | inkscape-d7b1e066fa7c7d9e6a83d688fe48c5f06620bf10.tar.gz inkscape-d7b1e066fa7c7d9e6a83d688fe48c5f06620bf10.zip | |
"Relative to" option for node alignment.
- Node tool has those new "relative to" alignment options : last
selected, first selected, current behaviour (middle), max
value(rightmost/topmost) or min value(leftmost/bottommost).
- Verbs:
--If the node tool is active and whole objects are selected (no
individual node is), works as usual for objects;
--Else, align horizontal/vertical (SP_VERB_ALIGN_HORIZONTAL_CENTER)
honor the "relative to" settings,
SP_VERB_ALIGN_HORIZONTAL_LEFT (ctrl+alt+pavnum4) aligns vertically on
the leftmost node (same behavior as SP_VERB_ALIGN_HORIZONTAL_LEFT when
the setting is "align relative to min value"), and so on with all
alignment verbs
Fixed bugs:
- https://launchpad.net/bugs/171287
(bzr r14703)
Diffstat (limited to 'src/ui/tool/control-point-selection.cpp')
| -rw-r--r-- | src/ui/tool/control-point-selection.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index 998f74ee0..f36ad7374 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -19,6 +19,8 @@ #include "ui/tool/transform-handle-set.h" #include "ui/tool/node.h" + + #include <gdk/gdkkeysyms.h> namespace Inkscape { @@ -82,6 +84,7 @@ std::pair<ControlPointSelection::iterator, bool> ControlPointSelection::insert(c } found = _points.insert(x).first; + _points_list.push_back(x); x->updateState(); _pointChanged(x, true); @@ -97,6 +100,7 @@ std::pair<ControlPointSelection::iterator, bool> ControlPointSelection::insert(c void ControlPointSelection::erase(iterator pos) { SelectableControlPoint *erased = *pos; + _points_list.remove(*pos); _points.erase(pos); erased->updateState(); _pointChanged(erased, false); @@ -219,8 +223,11 @@ void ControlPointSelection::transform(Geom::Affine const &m) /** Align control points on the specified axis. */ void ControlPointSelection::align(Geom::Dim2 axis) { + enum AlignTargetNode { LAST_NODE=0, FIRST_NODE, MID_NODE, MIN_NODE, MAX_NODE }; if (empty()) return; Geom::Dim2 d = static_cast<Geom::Dim2>((axis + 1) % 2); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Geom::OptInterval bound; for (iterator i = _points.begin(); i != _points.end(); ++i) { @@ -229,7 +236,27 @@ void ControlPointSelection::align(Geom::Dim2 axis) if (!bound) { return; } - double new_coord = bound->middle(); + double new_coord; + switch (AlignTargetNode(prefs->getInt("/dialogs/align/align-nodes-to", 2))){ + case FIRST_NODE: + new_coord=(_points_list.front())->position()[d]; + break; + case LAST_NODE: + new_coord=(_points_list.back())->position()[d]; + break; + case MID_NODE: + new_coord=bound->middle(); + break; + case MIN_NODE: + new_coord=bound->min(); + break; + case MAX_NODE: + new_coord=bound->max(); + break; + default: + return; + } + for (iterator i = _points.begin(); i != _points.end(); ++i) { Geom::Point pos = (*i)->position(); pos[d] = new_coord; |
