diff --git a/src/snap.cpp b/src/snap.cpp
index ac2f1321cdc3293ef14a3450a7e436e535ece7a8..548741455704b51b510b052b2d9df4a608d0dd9f 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
*
* Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
* Copyrigth (C) 2004 Nathan Hurst
- * Copyright (C) 1999-2008 Authors
+ * Copyright (C) 1999-2009 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
SnapperList s;
//FIXME: this code should actually do this: add new grid snappers that are active for this desktop. now it just adds all gridsnappers
- SPDesktop* desktop = SP_ACTIVE_DESKTOP;
- if (desktop && desktop->gridsEnabled()) {
+ if (_desktop && _desktop->gridsEnabled() && snapprefs.getSnapToGrids()) {
for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) {
Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
s.push_back(grid->snapper);
return (i != s.end());
}
+/**
+ * \return true if one of the snappers will try to snap something.
+ */
+
+bool SnapManager::gridSnapperMightSnap() const
+{
+ if ( !snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() ) {
+ return false;
+ }
+
+ SnapperList const s = getGridSnappers();
+ SnapperList::const_iterator i = s.begin();
+ while (i != s.end() && (*i)->ThisSnapperMightSnap() == false) {
+ i++;
+ }
+
+ return (i != s.end());
+}
+
/**
* Try to snap a point to any of the specified snappers.
*
@@ -143,7 +161,12 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapPreferences::PointTyp
bool first_point,
Geom::OptRect const &bbox_to_snap) const
{
- if (!someSnapperMightSnap()) {
+ if (_desktop->canvas->context_snap_delay_active == false) {
+ g_warning("context_snap_delay_active has not been set to true by the current context. Please report this!");
+ // When the context goes into dragging-mode, then Inkscape should call this: sp_canvas_set_snap_delay_active(desktop->canvas, true);
+ }
+
+ if (!someSnapperMightSnap()) {
return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false);
}
return t;
//FIXME: this code should actually do this: add new grid snappers that are active for this desktop. now it just adds all gridsnappers
- SPDesktop* desktop = SP_ACTIVE_DESKTOP;
- if (desktop && desktop->gridsEnabled()) {
+ if (_desktop && _desktop->gridsEnabled()) {
bool success = false;
Geom::Point nearest_multiple;
Geom::Coord nearest_distance = NR_HUGE;
// this, so when using multiple grids one can get unexpected results
// Cannot use getGridSnappers() because we need both the grids AND their snappers
- // Therefor we iterate through all grids manually
+ // Therefore we iterate through all grids manually
for (GSList const *l = _named_view->grids; l != NULL; l = l->next) {
Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
const Inkscape::Snapper* snapper = grid->snapper;
// will use the grid snapper. Simply snapping the value t to the grid will do, but
// only if the origin of the grid is at (0,0). If it's not then compensate for this
// in the translation t
- Geom::Point const t_offset = from_2geom(t) + grid->origin;
+ Geom::Point const t_offset = t + grid->origin;
SnappedConstraints sc;
// Only the first three parameters are being used for grid snappers
snapper->freeSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_NODE, t_offset, TRUE, Geom::OptRect(), NULL, NULL);
@@ -267,7 +289,12 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::P
bool first_point,
Geom::OptRect const &bbox_to_snap) const
{
- if (!someSnapperMightSnap()) {
+ if (_desktop->canvas->context_snap_delay_active == false) {
+ g_warning("context_snap_delay_active has not been set to true by the current context. Please report this!");
+ // When the context goes into dragging-mode, then Inkscape should call this: sp_canvas_set_snap_delay_active(desktop->canvas, true);
+ }
+
+ if (!someSnapperMightSnap()) {
return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false);
}
@@ -298,6 +325,11 @@ void SnapManager::guideSnap(Geom::Point &p, Geom::Point const &guide_normal) con
{
// This method is used to snap a guide to nodes, while dragging the guide around
+ if (_desktop->canvas->context_snap_delay_active == false) {
+ g_warning("context_snap_delay_active has not been set to true by the current context. Please report this!");
+ // When the context goes into dragging-mode, then Inkscape should call this: sp_canvas_set_snap_delay_active(desktop->canvas, true);
+ }
+
if ( !(object.GuidesMightSnap() && snapprefs.getSnapEnabledGlobally()) || snapprefs.getSnapPostponedGlobally() ) {
return;
}
@@ -753,7 +785,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, SnappedCo
if (snapprefs.getSnapIntersectionCS()) {
// search for the closest snapped intersection of curves
Inkscape::SnappedPoint closestCurvesIntersection;
- if (getClosestIntersectionCS(sc.curves, p, closestCurvesIntersection)) {
+ if (getClosestIntersectionCS(sc.curves, p, closestCurvesIntersection, _desktop->dt2doc())) {
sp_list.push_back(closestCurvesIntersection);
}
}
@@ -905,7 +937,7 @@ void SnapManager::_displaySnapsource(Inkscape::SnapPreferences::PointType point_
if (prefs->getBool("/options/snapclosestonly/value")) {
bool p_is_a_node = point_type & Inkscape::SnapPreferences::SNAPPOINT_NODE;
bool p_is_a_bbox = point_type & Inkscape::SnapPreferences::SNAPPOINT_BBOX;
- if ((p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox())) {
+ if (snapprefs.getSnapEnabledGlobally() && ((p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) {
_desktop->snapindicator->set_new_snapsource(p);
} else {
_desktop->snapindicator->remove_snapsource();