summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f9bae70)
raw | patch | inline | side by side (parent: f9bae70)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Tue, 17 Apr 2007 21:26:43 +0000 (21:26 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Tue, 17 Apr 2007 21:26:43 +0000 (21:26 +0000) |
diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp
index a05ecd3e6b4423c517710c83b21965540dd0d5f9..9fd13705c26cb2ff12ded4e823a534a69e3145fb 100644 (file)
--- a/src/guide-snapper.cpp
+++ b/src/guide-snapper.cpp
{
LineList s;
- if ( NULL == _named_view ) {
+ if ( NULL == _named_view || willSnapSomething() == false) {
return s;
}
return s;
}
+/**
+ * \return true if this Snapper will snap at least one kind of point.
+ */
+bool Inkscape::GuideSnapper::willSnapSomething() const
+{
+ return _named_view == NULL ? false : (_enabled && _snap_to != 0 && _named_view->showguides);
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/guide-snapper.h b/src/guide-snapper.h
index 37e3e3006d66c51c2c733fbefed5119b8026b595..37ea08701db1238316dbe13464fb3cf52aeb25cf 100644 (file)
--- a/src/guide-snapper.h
+++ b/src/guide-snapper.h
{
public:
GuideSnapper(SPNamedView const *nv, NR::Coord const d);
+
+ bool willSnapSomething() const;
private:
LineList _getSnapLines(NR::Point const &p) const;
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 5492fc439cac8465a1e07db5704d32147097c4c9..e39d398b1d80be7db5a8a203d15c5e93ae64db34 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
std::list<SPItem const *> const &it,
NR::Point const &p) const
{
- SPDesktop const *desktop = SP_ACTIVE_DESKTOP;
- for (SPObject* o = sp_object_first_child(r); o != NULL; o = SP_OBJECT_NEXT(o)) {
- if (SP_IS_ITEM(o) && !SP_ITEM(o)->isLocked() && !desktop->itemIsHidden(SP_ITEM(o))) {
-
- /* See if this item is on the ignore list */
- std::list<SPItem const *>::const_iterator i = it.begin();
- while (i != it.end() && *i != o) {
- i++;
- }
-
- if (i == it.end()) {
- /* See if the item is within range */
- if (SP_IS_GROUP(o)) {
- _findCandidates(c, o, it, p);
- } else {
- NR::Maybe<NR::Rect> b = sp_item_bbox_desktop(SP_ITEM(o));
- if ( b && NR::expand(*b, -getDistance()).contains(p) ) {
- c.push_back(SP_ITEM(o));
+ if (willSnapSomething()) {
+ SPDesktop const *desktop = SP_ACTIVE_DESKTOP;
+ for (SPObject* o = sp_object_first_child(r); o != NULL; o = SP_OBJECT_NEXT(o)) {
+ if (SP_IS_ITEM(o) && !SP_ITEM(o)->isLocked() && !desktop->itemIsHidden(SP_ITEM(o))) {
+
+ /* See if this item is on the ignore list */
+ std::list<SPItem const *>::const_iterator i = it.begin();
+ while (i != it.end() && *i != o) {
+ i++;
+ }
+
+ if (i == it.end()) {
+ /* See if the item is within range */
+ if (SP_IS_GROUP(o)) {
+ _findCandidates(c, o, it, p);
+ } else {
+ NR::Maybe<NR::Rect> b = sp_item_bbox_desktop(SP_ITEM(o));
+ if ( b && NR::expand(*b, -getDistance()).contains(p) ) {
+ c.push_back(SP_ITEM(o));
+ }
}
}
+
}
-
}
}
}
@@ -181,6 +183,15 @@ Inkscape::SnappedPoint Inkscape::ObjectSnapper::_doConstrainedSnap(NR::Point con
return _doFreeSnap(p, it);
}
+/**
+ * \return true if this Snapper will snap at least one kind of point.
+ */
+bool Inkscape::ObjectSnapper::willSnapSomething() const
+{
+ return (_enabled && _snap_to != 0 && (_snap_to_paths || _snap_to_nodes));
+}
+
+
/*
Local Variables:
mode:c++
diff --git a/src/object-snapper.h b/src/object-snapper.h
index 4e74b2f744b246a824bbf24fee146110901674e0..f9c7a9817b7a3d1064578cfd822f0905b358295f 100644 (file)
--- a/src/object-snapper.h
+++ b/src/object-snapper.h
return _snap_to_paths;
}
+ bool willSnapSomething() const;
+
private:
SnappedPoint _doFreeSnap(NR::Point const &p,
std::list<SPItem const *> const &it) const;
diff --git a/src/snap.cpp b/src/snap.cpp
index 1714b6b67b75b9010efacd5f0361fdfa457e7ef6..b03b3f89d9a335936388c54a399641de1da93b2f 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
i++;
}
+
return (i != s.end());
}
diff --git a/src/snapper.cpp b/src/snapper.cpp
index 105ec46316ed9d4f5604bf477498de1feb4c1cef..390e0957e983eab9f0b47b7a451d0b2b74bf17a8 100644 (file)
--- a/src/snapper.cpp
+++ b/src/snapper.cpp
* \param nv Named view.
* \param d Snap distance.
*/
-Inkscape::Snapper::Snapper(SPNamedView const *nv, NR::Coord const d) : _named_view(nv), _distance(d), _enabled(true)
+Inkscape::Snapper::Snapper(SPNamedView const *nv, NR::Coord const d) : _named_view(nv), _enabled(true), _distance(d)
{
g_assert(_named_view != NULL);
g_assert(SP_IS_NAMEDVIEW(_named_view));
return (_snap_to & t);
}
-/**
- * \return true if this Snapper will snap at least one kind of point.
- */
-bool Inkscape::Snapper::willSnapSomething() const
-{
- return (_enabled && _snap_to != 0);
-}
-
-
/**
* \param s true to enable this snapper, otherwise false.
*/
diff --git a/src/snapper.h b/src/snapper.h
index 89e4f9d7288e8197d0ad536e6e798b35e95e85d9..21e96b019e10820e87e25574c7a9ff5e4078f11d 100644 (file)
--- a/src/snapper.h
+++ b/src/snapper.h
bool getSnapTo(PointType t) const;
::NR::Coord getDistance() const;
- bool willSnapSomething() const;
+ /**
+ * \return true if this Snapper will snap at least one kind of point.
+ */
+ virtual bool willSnapSomething() const {return (_enabled && _snap_to != 0);} // will likely be overridden by derived classes
+
void setEnabled(bool s);
std::list<SPItem const *> const &it) const;
protected:
SPNamedView const *_named_view;
+ int _snap_to; ///< bitmap of point types that we will snap to
+ bool _enabled; ///< true if this snapper is enabled, otherwise false
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
- bool _enabled; ///< true if this snapper is enabled, otherwise false
};
}