summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2007-08-04 09:10:17 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2007-08-04 09:10:17 +0000
commit5753fd8392dbfa06c3c808b5248d008d008a02c8 (patch)
tree092333efec8e95ee0c3193c505eda87fdfca21c5 /src
parentsetting of attributes and default values for feColorMatrix. (diff)
downloadinkscape-5753fd8392dbfa06c3c808b5248d008d008a02c8.tar.gz
inkscape-5753fd8392dbfa06c3c808b5248d008d008a02c8.zip
Make snapping to the item's transformation center optional, but not yet available in the snapping preferences dialog
(bzr r3365)
Diffstat (limited to 'src')
-rw-r--r--src/selection.cpp6
-rw-r--r--src/selection.h2
-rw-r--r--src/seltrans.cpp3
-rw-r--r--src/snap.cpp3
-rw-r--r--src/snap.h10
5 files changed, 19 insertions, 5 deletions
diff --git a/src/selection.cpp b/src/selection.cpp
index 2b143dd5a..ca3de5927 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -371,7 +371,7 @@ NR::Maybe<NR::Point> Selection::center() const {
* Compute the list of points in the selection that are to be considered for snapping.
* This includes all special points of each item in the selection, except path nodes
*/
-std::vector<NR::Point> Selection::getSnapPoints() const {
+std::vector<NR::Point> Selection::getSnapPoints(bool includeItemCenter) const {
GSList const *items = const_cast<Selection *>(this)->itemList();
std::vector<NR::Point> p;
for (GSList const *iter = items; iter != NULL; iter = iter->next) {
@@ -385,7 +385,9 @@ std::vector<NR::Point> Selection::getSnapPoints() const {
}
//Include the transformation origin for snapping
//For a group only the group's origin is considered
- p.push_back(this_item->getCenter());
+ if (includeItemCenter) {
+ p.push_back(this_item->getCenter());
+ }
}
return p;
diff --git a/src/selection.h b/src/selection.h
index d8427108f..58204160b 100644
--- a/src/selection.h
+++ b/src/selection.h
@@ -259,7 +259,7 @@ public:
* @brief Gets the selection's snap points.
* @return Selection's snap points
*/
- std::vector<NR::Point> getSnapPoints() const;
+ std::vector<NR::Point> getSnapPoints(bool includeItemCenter) const;
/**
* @brief Gets the snap points of a selection that form a convex hull.
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 465813ae0..ad37e24cf 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -268,7 +268,8 @@ void Inkscape::SelTrans::grab(NR::Point const &p, gdouble x, gdouble y, bool sho
// Next, get all special points for snapping
- _snap_points = selection->getSnapPoints(); // Excludes path nodes
+ SnapManager const &m = _desktop->namedview->snap_manager;
+ _snap_points = selection->getSnapPoints(m.getIncludeItemCenter()); // Excludes path nodes
std::vector<NR::Point> snap_points_hull = selection->getSnapPointsConvexHull(); // Includes path nodes
if (_snap_points.size() > 100) {
/* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes
diff --git a/src/snap.cpp b/src/snap.cpp
index 3ef246447..f5c1c9589 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -36,7 +36,8 @@
SnapManager::SnapManager(SPNamedView const *v) :
guide(v, 0),
object(v, 0),
- _named_view(v)
+ _named_view(v),
+ _include_item_center(false)
{
}
diff --git a/src/snap.h b/src/snap.h
index 401fd60ba..c60d866ad 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -127,6 +127,14 @@ public:
bool getSnapModeBBox() const;
bool getSnapModeNode() const;
+ void setIncludeItemCenter(bool enabled) {
+ _include_item_center = enabled;
+ }
+
+ bool getIncludeItemCenter() const {
+ return _include_item_center;
+ }
+
protected:
SPNamedView const *_named_view;
@@ -139,6 +147,8 @@ private:
SKEW
};
+ bool _include_item_center; //If true, snapping nodes will also snap the item's center
+
std::pair<NR::Point, bool> _snapTransformed(Inkscape::Snapper::PointType type,
std::vector<NR::Point> const &points,
std::list<SPItem const *> const &ignore,