diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-03-15 21:57:03 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2016-03-15 21:57:03 +0000 |
| commit | 6bd1c2a30b66e15fe055b22bd47dadb771f7fae2 (patch) | |
| tree | 1b991cc2736f84fb069666802d485bd29cff6394 /src/ui/tool | |
| parent | Update to limit options to radius = 0, radious > 0 or both (diff) | |
| parent | fix-bug-1557192. paint-order crash with multiple items (diff) | |
| download | inkscape-6bd1c2a30b66e15fe055b22bd47dadb771f7fae2.tar.gz inkscape-6bd1c2a30b66e15fe055b22bd47dadb771f7fae2.zip | |
Update to trunk
(bzr r13645.1.119)
Diffstat (limited to 'src/ui/tool')
| -rw-r--r-- | src/ui/tool/control-point-selection.cpp | 29 | ||||
| -rw-r--r-- | src/ui/tool/control-point-selection.h | 3 | ||||
| -rw-r--r-- | src/ui/tool/node.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 4 | ||||
| -rw-r--r-- | src/ui/tool/selector.cpp | 1 | ||||
| -rw-r--r-- | src/ui/tool/transform-handle-set.cpp | 48 |
6 files changed, 64 insertions, 23 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; diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h index 2d812c0a3..f122a468d 100644 --- a/src/ui/tool/control-point-selection.h +++ b/src/ui/tool/control-point-selection.h @@ -12,6 +12,7 @@ #ifndef SEEN_UI_TOOL_CONTROL_POINT_SELECTION_H #define SEEN_UI_TOOL_CONTROL_POINT_SELECTION_H +#include <list> #include <memory> #include <boost/optional.hpp> #include <stddef.h> @@ -140,6 +141,8 @@ private: double _rotationRadius(Geom::Point const &); set_type _points; + //the purpose of this list is to keep track of first and last selected + std::list<SelectableControlPoint *> _points_list; set_type _all_points; INK_UNORDERED_MAP<SelectableControlPoint *, Geom::Point> _original_positions; INK_UNORDERED_MAP<SelectableControlPoint *, Geom::Affine> _last_trans; diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 06e49dc7f..d70147f80 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -61,7 +61,7 @@ namespace Inkscape { namespace UI { const double NO_POWER = 0.0; -const double DEFAULT_START_POWER = 0.333334; +const double DEFAULT_START_POWER = 1.0/3.0; ControlPoint::ColorSet Node::node_colors = { {0xbfbfbf00, 0x000000ff}, // normal fill, stroke diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 284932bb8..4d28594c1 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -58,7 +58,7 @@ enum PathChange { } // anonymous namespace const double HANDLE_CUBIC_GAP = 0.001; const double NO_POWER = 0.0; -const double DEFAULT_START_POWER = 0.333334; +const double DEFAULT_START_POWER = 1.0/3.0; /** @@ -1292,7 +1292,7 @@ double PathManipulator::_bsplineHandlePosition(Handle *h, bool check_other) line_inside_nodes->moveto(n->position()); line_inside_nodes->lineto(next_node->position()); if(!are_near(h->position(), n->position())){ - pos = Geom::nearest_time(Geom::Point(h->position()[X] - HANDLE_CUBIC_GAP, h->position()[Y] - HANDLE_CUBIC_GAP), *line_inside_nodes->first_segment()); + pos = Geom::nearest_time(Geom::Point(h->position()[X] - HANDLE_CUBIC_GAP, h->position()[Y] + HANDLE_CUBIC_GAP), *line_inside_nodes->first_segment()); } } if (pos == NO_POWER && check_other){ diff --git a/src/ui/tool/selector.cpp b/src/ui/tool/selector.cpp index 051cb41ae..9acf7de88 100644 --- a/src/ui/tool/selector.cpp +++ b/src/ui/tool/selector.cpp @@ -39,6 +39,7 @@ public: setVisible(false); _rubber = static_cast<CtrlRect*>(sp_canvas_item_new(_desktop->getControls(), SP_TYPE_CTRLRECT, NULL)); + _rubber->setShadow(1, 0xffffffff); sp_canvas_item_hide(_rubber); } diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index da2a54989..748b9d4cc 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -15,9 +15,11 @@ #include <glib/gi18n.h> #include <2geom/transforms.h> #include "desktop.h" +#include "sp-namedview.h" #include "display/sodipodi-ctrlrect.h" #include "preferences.h" +#include "pure-transform.h" #include "snap.h" #include "snap-candidate.h" #include "sp-namedview.h" @@ -93,6 +95,7 @@ TransformHandle::TransformHandle(TransformHandleSet &th, SPAnchorType anchor, Gl setVisible(false); } +// TODO: This code is duplicated in seltrans.cpp; fix this! void TransformHandle::getNextClosestPoint(bool reverse) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -113,6 +116,11 @@ void TransformHandle::getNextClosestPoint(bool reverse) _snap_points.clear(); _snap_points.push_back(*_all_snap_sources_iter); + // Show the updated snap source now; otherwise it won't be shown until the selection is being moved again + SnapManager &m = _desktop->namedview->snap_manager; + m.setup(_desktop); + m.displaySnapsource(*_all_snap_sources_iter); + m.unSetup(); } } } @@ -247,7 +255,7 @@ protected: if (Geom::are_near(vold[Geom::X], 0) || Geom::are_near(vold[Geom::Y], 0)) return Geom::identity(); - double scale[2] = { vnew[Geom::X] / vold[Geom::X], vnew[Geom::Y] / vold[Geom::Y] }; + Geom::Scale scale = Geom::Scale(vnew[Geom::X] / vold[Geom::X], vnew[Geom::Y] / vold[Geom::Y]); if (held_alt(*event)) { for (unsigned i = 0; i < 2; ++i) { @@ -261,20 +269,21 @@ protected: SnapManager &m = _th._desktop->namedview->snap_manager; m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); - Inkscape::SnappedPoint sp; + Inkscape::PureScale *ptr; if (held_control(*event)) { scale[0] = scale[1] = std::min(scale[0], scale[1]); - sp = m.constrainedSnapScale(_snap_points, _origin, Geom::Scale(scale[0], scale[1]), scc); + ptr = new Inkscape::PureScaleConstrained(Geom::Scale(scale[0], scale[1]), scc); } else { - sp = m.freeSnapScale(_snap_points, _origin, Geom::Scale(scale[0], scale[1]), scc); + ptr = new Inkscape::PureScale(Geom::Scale(scale[0], scale[1]), scc, false); } + m.snapTransformed(_snap_points, _origin, (*ptr)); m.unSetup(); - if (sp.getSnapped()) { - Geom::Point result = sp.getTransformation(); - scale[0] = result[0]; - scale[1] = result[1]; + if (ptr->best_snapped_point.getSnapped()) { + scale = ptr->getScaleSnapped(); } + + delete ptr; } _last_scale_x = scale[0]; @@ -349,11 +358,12 @@ protected: m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); bool uniform = held_control(*event); - Inkscape::SnappedPoint sp = m.constrainedSnapStretch(_snap_points, _origin, vs[d1], scc, d1, uniform); + Inkscape::PureStretchConstrained psc = Inkscape::PureStretchConstrained(vs[d1], scc, d1, uniform); + m.snapTransformed(_snap_points, _origin, psc); m.unSetup(); - if (sp.getSnapped()) { - Geom::Point result = sp.getTransformation(); + if (psc.best_snapped_point.getSnapped()) { + Geom::Point result = psc.getStretchSnapped().vector(); //best_snapped_point.getTransformation(); vs[d1] = result[d1]; vs[d2] = result[d2]; } else { @@ -414,11 +424,12 @@ protected: } else { SnapManager &m = _th._desktop->namedview->snap_manager; m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); - Inkscape::SnappedPoint sp = m.constrainedSnapRotate(_snap_points, _origin, angle, rotc); + Inkscape::PureRotateConstrained prc = Inkscape::PureRotateConstrained(angle, rotc); + m.snapTransformed(_snap_points, _origin, prc); m.unSetup(); - if (sp.getSnapped()) { - angle = sp.getTransformation()[0]; + if (prc.best_snapped_point.getSnapped()) { + angle = prc.getAngleSnapped(); //best_snapped_point.getTransformation()[0]; } } @@ -528,13 +539,12 @@ protected: SnapManager &m = _th._desktop->namedview->snap_manager; m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); - Geom::Point cvec; cvec[d2] = 1.0; - Inkscape::Snapper::SnapConstraint const constraint(cvec); - Inkscape::SnappedPoint sp = m.constrainedSnapSkew(_snap_points, _origin, constraint, Geom::Point(skew[d1], scale[d1]), scc, d2); + Inkscape::PureSkewConstrained psc = Inkscape::PureSkewConstrained(skew[d1], scale[d1], scc, d2); + m.snapTransformed(_snap_points, _origin, psc); m.unSetup(); - if (sp.getSnapped()) { - skew[d1] = sp.getTransformation()[0]; + if (psc.best_snapped_point.getSnapped()) { + skew[d1] = psc.getSkewSnapped(); //best_snapped_point.getTransformation()[0]; } } |
