Code

Fix ef spam when adjusting pattern on text - patch from Adonis Papaderos
[inkscape.git] / src / seltrans.cpp
index 7ea2a86c05bc356b2a6585f203a8072272ea27fa..cdfcee7420a3cf84017ca4708553bf43b96ff810 100644 (file)
@@ -401,21 +401,6 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
             g_warning("Checking number of snap sources failed; nothing serious, but please report to Diederik");
         }
 
-        // Optionally, show the snap source
-        if (!(_state == STATE_ROTATE && x != 0.5 && y != 0.5)) { // but not when we're dragging a rotation handle, because that won't snap
-            // Now either _bbox_points or _snap_points has a single element, the other one has zero..... or both have zero elements
-            if ((_snap_points.size() + _bbox_points.size() + _bbox_points_for_translating.size()) > 1) {
-                g_warning("too many snap sources to display, please fix this");
-            } else if (m.snapprefs.getSnapEnabledGlobally()) {
-                if (_bbox_points.size() == 1) {
-                    _desktop->snapindicator->set_new_snapsource(_bbox_points.at(0));
-                } else if (_bbox_points_for_translating.size() == 1) {
-                    _desktop->snapindicator->set_new_snapsource(_bbox_points_for_translating.at(0));
-                } else if (_snap_points.size() == 1){
-                    _desktop->snapindicator->set_new_snapsource(_snap_points.at(0));
-                }
-            }
-        }
     }
 
     if ((x != -1) && (y != -1)) {
@@ -1338,26 +1323,30 @@ gboolean Inkscape::SelTrans::rotateRequest(Geom::Point &pt, guint state)
 // Move the item's transformation center
 gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state)
 {
-    SnapManager &m = _desktop->namedview->snap_manager;
-    m.setup(_desktop);
-
     // When dragging the transformation center while multiple items have been selected, then those
     // items will share a single center. While dragging that single center, it should never snap to the
     // centers of any of the selected objects. Therefore we will have to pass the list of selected items
     // to the snapper, to avoid self-snapping of the rotation center
     GSList *items = (GSList *) const_cast<Selection *>(_selection)->itemList();
+    SnapManager &m = _desktop->namedview->snap_manager;
+    m.setup(_desktop);
     m.setRotationCenterSource(items);
-    m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER);
-    m.unSetup();
 
-    if (state & GDK_CONTROL_MASK) {
-        if ( fabs(_point[Geom::X] - pt[Geom::X]) > fabs(_point[Geom::Y] - pt[Geom::Y]) ) {
-            pt[Geom::Y] = _point[Geom::Y];
-        } else {
-            pt[Geom::X] = _point[Geom::X];
+    if (state & GDK_CONTROL_MASK) { // with Ctrl, constrain to axes
+        std::vector<Inkscape::Snapper::SnapConstraint> constraints;
+        constraints.push_back(Inkscape::Snapper::SnapConstraint(_point, Geom::Point(1, 0)));
+        constraints.push_back(Inkscape::Snapper::SnapConstraint(_point, Geom::Point(0, 1)));
+        Inkscape::SnappedPoint sp = m.multipleConstrainedSnaps(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER), constraints, state & GDK_SHIFT_MASK);
+        pt = sp.getPoint();
+    }
+    else {
+        if (!(state & GDK_SHIFT_MASK)) { // Shift disables snapping
+            m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER);
         }
     }
 
+    m.unSetup();
+
     // status text
     GString *xs = SP_PX_TO_METRIC_STRING(pt[Geom::X], _desktop->namedview->getDefaultMetric());
     GString *ys = SP_PX_TO_METRIC_STRING(pt[Geom::Y], _desktop->namedview->getDefaultMetric());
@@ -1670,4 +1659,4 @@ void Inkscape::SelTrans::_keepClosestPointOnly(std::vector<Inkscape::SnapCandida
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :