summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2011-08-23 19:17:19 +0000
committerDiederik van Lierop <mail@diedenrezi.nl>2011-08-23 19:17:19 +0000
commitbc41980c93b8627b286daeb51bc29806a6c2b0f0 (patch)
treeea9d915ced405201cea4a8ac2a68de4a60bd6610
parentFilters. Filters clean-up again. (diff)
downloadinkscape-bc41980c93b8627b286daeb51bc29806a6c2b0f0.tar.gz
inkscape-bc41980c93b8627b286daeb51bc29806a6c2b0f0.zip
1) Use the "snap guides" button both for guides being snap sources, as well as for guides being snap targets
2) Remove some redundant guide-snapping code from the object snapper, (bzr r10576)
-rw-r--r--src/attributes.cpp2
-rw-r--r--src/attributes.h2
-rw-r--r--src/object-snapper.cpp38
-rw-r--r--src/object-snapper.h11
-rw-r--r--src/snap.cpp42
-rw-r--r--src/sp-namedview.cpp2
-rw-r--r--src/widgets/toolbox.cpp6
7 files changed, 13 insertions, 90 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp
index df27a578f..4552adb63 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -97,7 +97,7 @@ static SPStyleProp const props[] = {
{SP_ATTR_INKSCAPE_SNAP_OTHERS, "inkscape:snap-others"},
{SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER, "inkscape:snap-center"},
{SP_ATTR_INKSCAPE_SNAP_GRID, "inkscape:snap-grids"},
- {SP_ATTR_INKSCAPE_SNAP_TO_GUIDE, "inkscape:snap-to-guides"},
+ {SP_ATTR_INKSCAPE_SNAP_GUIDE, "inkscape:snap-to-guides"},
{SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH, "inkscape:snap-smooth-nodes"},
{SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT, "inkscape:snap-midpoints"},
{SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT, "inkscape:snap-object-midpoints"},
diff --git a/src/attributes.h b/src/attributes.h
index 237ad60d1..261871482 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -98,7 +98,7 @@ enum SPAttributeEnum {
//SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE,
SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER,
SP_ATTR_INKSCAPE_SNAP_GRID,
- SP_ATTR_INKSCAPE_SNAP_TO_GUIDE,
+ SP_ATTR_INKSCAPE_SNAP_GUIDE,
SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH,
SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT,
SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT,
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index da6eca027..82114e2c4 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -742,44 +742,6 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc,
}
}
-
-// This method is used to snap a guide to nodes, while dragging the guide around
-void Inkscape::ObjectSnapper::guideFreeSnap(SnappedConstraints &sc,
- Geom::Point const &p,
- Geom::Point const &guide_normal) const
-{
- if (!_snapmanager->snapprefs.getSnapModeOthers()) {
- return;
- }
-
-
- //std::vector<SPItem const *> const it; //just an empty list
-
- freeSnap(sc, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), Geom::Rect(p, p), NULL, NULL);
- //_findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity());
- //_snapTranslatingGuide(sc, p, guide_normal);
-
-}
-
-// This method is used to snap the origin of a guide to nodes/paths, while dragging the origin along the guide
-void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc,
- Geom::Point const &p,
- Geom::Point const &guide_normal,
- SnapConstraint const &/*c*/) const
-{
- /* Get a list of all the SPItems that we will try to snap to */
- std::vector<SPItem*> cand;
- std::vector<SPItem const *> const it; //just an empty list
-
- std::cout << "guideConstrainedSnap" << std::endl;
-
- if (_snapmanager->snapprefs.getSnapModeOthers()) {
- _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity());
- _snapTranslatingGuide(sc, p, guide_normal);
- }
-
-}
-
/**
* \return true if this Snapper will snap at least one kind of point.
*/
diff --git a/src/object-snapper.h b/src/object-snapper.h
index 00fb18923..b97ab827c 100644
--- a/src/object-snapper.h
+++ b/src/object-snapper.h
@@ -9,7 +9,7 @@
* Carl Hetherington <inkscape@carlh.net>
* Diederik van Lierop <mail@diedenrezi.nl>
*
- * Copyright (C) 2005 - 2008 Authors
+ * Copyright (C) 2005 - 2011 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -33,15 +33,6 @@ public:
ObjectSnapper(SnapManager *sm, Geom::Coord const d);
~ObjectSnapper();
- void guideFreeSnap(SnappedConstraints &sc,
- Geom::Point const &p,
- Geom::Point const &guide_normal) const;
-
- void guideConstrainedSnap(SnappedConstraints &sc,
- Geom::Point const &p,
- Geom::Point const &guide_normal,
- SnapConstraint const &c) const;
-
bool ThisSnapperMightSnap() const;
Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
diff --git a/src/snap.cpp b/src/snap.cpp
index 8c96cdfa1..c4ca32364 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -560,11 +560,7 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida
}
/**
- * \brief Try to snap a point of a guide to another guide or to a node
- *
- * Try to snap a point of a guide to another guide or to a node in two degrees-
- * of-freedom, i.e. snap in any direction on the two dimensional canvas to the
- * nearest snap target. This method is used when dragging or rotating a guide
+ * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code)
*
* PS: SnapManager::setup() must have been called before calling this method,
*
@@ -573,11 +569,7 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida
*/
void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, SPGuideDragType drag_type) const
{
- if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) {
- return;
- }
-
- if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) {
+ if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) {
return;
}
@@ -586,15 +578,8 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal,
candidate = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_GUIDE);
}
- // Snap to nodes
SnappedConstraints sc;
- if (object.ThisSnapperMightSnap()) {
- object.guideFreeSnap(sc, p, guide_normal);
- }
-
- // Snap to guides & grid lines
- SnapperList snappers = getGridSnappers();
- snappers.push_back(&guide);
+ SnapperList snappers = getSnappers();
for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
(*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL);
}
@@ -605,12 +590,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal,
}
/**
- * \brief Try to snap a point on a guide to the intersection with another guide or a path
- *
- * Try to snap a point on a guide to the intersection of that guide with another
- * guide or with a path. The snapped point will lie somewhere on the guide-line,
- * making this is a constrained snap, i.e. in only one degree-of-freedom.
- * This method is used when dragging the origin of the guide along the guide itself.
+ * \brief Wrapper method to make snapping of the guide origin a bit easier (i.e. simplifies the calling code)
*
* PS: SnapManager::setup() must have been called before calling this method,
*
@@ -620,26 +600,16 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal,
void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const
{
- if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) {
- return;
- }
-
- if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) {
+ if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) {
return;
}
Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, Inkscape::SNAPTARGET_UNDEFINED);
- // Snap to nodes or paths
SnappedConstraints sc;
Inkscape::Snapper::SnapConstraint cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line));
- if (object.ThisSnapperMightSnap()) {
- object.constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL, NULL);
- }
- // Snap to guides & grid lines
- SnapperList snappers = getGridSnappers();
- snappers.push_back(&guide);
+ SnapperList snappers = getSnappers();
for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
(*i)->constrainedSnap(sc, candidate, Geom::OptRect(), cl, NULL, NULL);
}
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index fd0dbdd42..71ee8298b 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -479,7 +479,7 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
- case SP_ATTR_INKSCAPE_SNAP_TO_GUIDE:
+ case SP_ATTR_INKSCAPE_SNAP_GUIDE:
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 780495819..26947979d 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -2188,7 +2188,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GRID);
sp_repr_set_boolean(repr, "inkscape:snap-grids", !v);
break;
- case SP_ATTR_INKSCAPE_SNAP_TO_GUIDE:
+ case SP_ATTR_INKSCAPE_SNAP_GUIDE:
v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GUIDE);
sp_repr_set_boolean(repr, "inkscape:snap-to-guides", !v);
break;
@@ -2432,8 +2432,8 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGuides",
- _("Guides"), _("Snap to guides"), INKSCAPE_ICON("guides"), secondarySize,
- SP_ATTR_INKSCAPE_SNAP_TO_GUIDE);
+ _("Guides"), _("Snap guides"), INKSCAPE_ICON("guides"), secondarySize,
+ SP_ATTR_INKSCAPE_SNAP_GUIDE);
gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );