]> git.tokkee.org Git - inkscape.git/commitdiff

Code

Re-enable link between grid visibility and grid snap.
authorcth103 <cth103@users.sourceforge.net>
Tue, 9 May 2006 11:16:07 +0000 (11:16 +0000)
committercth103 <cth103@users.sourceforge.net>
Tue, 9 May 2006 11:16:07 +0000 (11:16 +0000)
src/snapper.cpp
src/snapper.h
src/sp-namedview.cpp

index 963cf7c9d3ad16c56f2123da1ff2f1fb097f0b23..723213afe18643666fd611ca1994e6bb072e8f4b 100644 (file)
@@ -19,7 +19,7 @@ Inkscape::Snapper::PointType const Inkscape::Snapper::SNAP_POINT = 0x2;
  *  \param nv Named view.
  *  \param d Snap distance.
  */
-Inkscape::Snapper::Snapper(SPNamedView const *nv, NR::Coord const d) : _named_view(nv), _distance(d)
+Inkscape::Snapper::Snapper(SPNamedView const *nv, NR::Coord const d) : _named_view(nv), _distance(d), _enabled(true)
 {
     g_assert(_named_view != NULL);
     g_assert(SP_IS_NAMEDVIEW(_named_view));
@@ -72,10 +72,19 @@ bool Inkscape::Snapper::getSnapTo(PointType t) const
  */
 bool Inkscape::Snapper::willSnapSomething() const
 {
-    return (_snap_to != 0);
+    return (_enabled && _snap_to != 0);
 }
 
 
+/**
+ *  \param s true to enable this snapper, otherwise false.
+ */
+
+void Inkscape::Snapper::setEnabled(bool s)
+{
+    _enabled = s;
+}
+
 
 /**
  *  Try to snap a point to whatever this snapper is interested in.  Any
@@ -113,7 +122,7 @@ Inkscape::SnappedPoint Inkscape::Snapper::freeSnap(PointType t,
                                                    NR::Point const &p,
                                                    std::list<SPItem const *> const &it) const
 {
-    if (getSnapTo(t) == false) {
+    if (_enabled == false || getSnapTo(t) == false) {
         return SnappedPoint(p, NR_HUGE);
     }
 
@@ -161,7 +170,7 @@ Inkscape::SnappedPoint Inkscape::Snapper::constrainedSnap(PointType t,
                                                           ConstraintLine const &c,
                                                           std::list<SPItem const *> const &it) const
 {
-    if (getSnapTo(t) == false) {
+    if (_enabled == false || getSnapTo(t) == false) {
         return SnappedPoint(p, NR_HUGE);
     }
 
index 33a15bd04887d500e4a16c0dea0eb4bb30850a8f..89e4f9d7288e8197d0ad536e6e798b35e95e85d9 100644 (file)
@@ -46,6 +46,8 @@ public:
 
     bool willSnapSomething() const;
 
+    void setEnabled(bool s);
+
     SnappedPoint freeSnap(PointType t,
                           NR::Point const &p,
                           SPItem const *it) const;
@@ -120,7 +122,8 @@ private:
                                             std::list<SPItem const *> const &it) const = 0;
     
     ::NR::Coord _distance; ///< snap distance (desktop coordinates)
-    int _snap_to; ///< bitmap of point types that we will snap to 
+    int _snap_to; ///< bitmap of point types that we will snap to
+    bool _enabled; ///< true if this snapper is enabled, otherwise false
 };
 
 }
index 129ef2c8c9a0128faa73bb6487e14fbd725f031a..4f9e4e2881aafdb791a77e0f244b7b9908bbef33 100644 (file)
@@ -221,6 +221,8 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
        case SP_ATTR_SHOWGRID:
             nv->showgrid = sp_str_to_bool(value);
             sp_namedview_setup_grid(nv);
+            /* Disable grid snaps if the grid is turned off */
+            nv->snap_manager.grid.setEnabled(nv->showgrid);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
        case SP_ATTR_SHOWGUIDES: