Code

now that selection description includes style (filtered, clipped), we need to update...
[inkscape.git] / src / seltrans.cpp
index 1055e55ef6f76146fa2ed5f2b3c84c2807996c60..e55c25d797a2ce1fc643394a87b06f7a0e21c62a 100644 (file)
@@ -285,16 +285,20 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
 
     // Next, get all points to consider for snapping
     SnapManager const &m = _desktop->namedview->snap_manager;
+       Inkscape::SnapPreferences local_snapprefs = m.snapprefs;
+       local_snapprefs.setSnapToItemNode(true); // We should get at least the cusp nodes here. This might
+       // have been turned off because (for example) the user only want paths as a snap target, not nodes
+       // but as a snap source we still need some nodes though!
     _snap_points.clear();
-    _snap_points = selection->getSnapPoints(&m.snapprefs);
-    std::vector<Geom::Point> snap_points_hull = selection->getSnapPointsConvexHull(&m.snapprefs);
-    if (_snap_points.size() > 100) {
-        /* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes
-        An average user would rarely ever try to snap such a large number of nodes anyway, because
-        (s)he could hardly discern which node would be snapping */
-        _snap_points = snap_points_hull;
-        // Unfortunately, by now we will have lost the font-baseline snappoints :-(
-    }
+       _snap_points = selection->getSnapPoints(&local_snapprefs);
+       std::vector<Geom::Point> snap_points_hull = selection->getSnapPointsConvexHull(&local_snapprefs);
+       if (_snap_points.size() > 100) {
+               /* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes
+               An average user would rarely ever try to snap such a large number of nodes anyway, because
+               (s)he could hardly discern which node would be snapping */
+               _snap_points = snap_points_hull;
+               // Unfortunately, by now we will have lost the font-baseline snappoints :-(
+       }
 
     // Find bbox hulling all special points, which excludes stroke width. Here we need to include the
     // path nodes, for example because a rectangle which has been converted to a path doesn't have
@@ -312,7 +316,9 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
 
     _bbox_points.clear();
     if (_bbox) {
-       getBBoxPoints(_bbox, &_bbox_points, m.snapprefs.getSnapMidpoints());
+       if (m.snapprefs.getSnapModeBBox()) {
+               getBBoxPoints(_bbox, &_bbox_points, true, m.snapprefs.getSnapBBoxEdgeMidpoints(), m.snapprefs.getSnapBBoxMidpoints());
+       }
        // There are two separate "opposites" (i.e. opposite w.r.t. the handle being dragged):
         //  - one for snapping the boundingbox, which can be either visual or geometric
         //  - one for snapping the special points
@@ -353,13 +359,17 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
 
        // Now either _bbox_points or _snap_points has a single element, the other one has zero..... or both have zero elements
        g_assert((_bbox_points.size() + _snap_points.size()) < 2);
-       if (_bbox_points.size() == 1) {
-               _desktop->snapindicator->set_new_snapsource(_bbox_points.at(0));
-       } else if (_snap_points.size() == 1){
-               _desktop->snapindicator->set_new_snapsource(_snap_points.at(0));
+       if (m.snapprefs.getSnapEnabledGlobally()) {
+                       if (_bbox_points.size() == 1) {
+                               _desktop->snapindicator->set_new_snapsource(_bbox_points.at(0));
+                       } else if (_snap_points.size() == 1){
+                               _desktop->snapindicator->set_new_snapsource(_snap_points.at(0));
+                       }
        }
     }
 
+       sp_canvas_set_snap_delay_active(_desktop->canvas, true);
+
     // The lines below are useful for debugging any snapping issues, as they'll spit out all points that are considered for snapping
 
     /*std::cout << "Number of snap points:  " << _snap_points.size() << std::endl;
@@ -426,6 +436,10 @@ void Inkscape::SelTrans::ungrab()
     _grabbed = false;
     _show_handles = true;
 
+    sp_canvas_set_snap_delay_active(_desktop->canvas, false);
+
+    _desktop->snapindicator->remove_snapsource();
+
     Inkscape::Selection *selection = sp_desktop_selection(_desktop);
     _updateVolatileState();