Code

1) Snap to transformation center even if it's outside of the bounding box of the...
authorDiederik van Lierop <mailat-signdiedenrezidotnl>
Sun, 25 Jul 2010 20:29:45 +0000 (22:29 +0200)
committerDiederik van Lierop <mailat-signdiedenrezidotnl>
Sun, 25 Jul 2010 20:29:45 +0000 (22:29 +0200)
2) In some cases the snap source indicator wasn't shown

src/display/snap-indicator.cpp
src/object-snapper.cpp
src/snap-enums.h
src/snap.cpp

index 776c56c15a64de7f3870db616876bac935fddd25..c3198cd37ea0392724a7b8174d7c4a4a7a6e463c 100644 (file)
@@ -229,14 +229,14 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap
         // Display the snap indicator (i.e. the cross)
         SPCanvasItem * canvasitem = NULL;
         canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop),
-                                                                               SP_TYPE_CTRL,
-                                                                               "anchor", GTK_ANCHOR_CENTER,
-                                                                               "size", 10.0,
-                                                                               "stroked", TRUE,
-                                                                               "stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff,
-                                                                               "mode", SP_KNOT_MODE_XOR,
-                                                                               "shape", SP_KNOT_SHAPE_CROSS,
-                                                                               NULL );
+                                        SP_TYPE_CTRL,
+                                        "anchor", GTK_ANCHOR_CENTER,
+                                        "size", 10.0,
+                                        "stroked", TRUE,
+                                        "stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff,
+                                        "mode", SP_KNOT_MODE_XOR,
+                                        "shape", SP_KNOT_SHAPE_CROSS,
+                                        NULL );
 
         const int timeout_val = 1200; // TODO add preference for snap indicator timeout?
 
index c1ed08f12f7610b7d0004001078ddcad98423f58..d84ee9c4f09db5009019d874be01dd4d9ab60b4e 100644 (file)
@@ -6,7 +6,7 @@
  *   Carl Hetherington <inkscape@carlh.net>
  *   Diederik van Lierop <mail@diedenrezi.nl>
  *
- * Copyright (C) 2005 - 2008 Authors
+ * Copyright (C) 2005 - 2010 Authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
@@ -148,7 +148,8 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
                     }
                     if (bbox_of_item) {
                         // See if the item is within range
-                        if (bbox_to_snap_incl.intersects(*bbox_of_item)) {
+                        if (bbox_to_snap_incl.intersects(*bbox_of_item)
+                                || (_snapmanager->snapprefs.getIncludeItemCenter() && bbox_to_snap_incl.contains(item->getCenter()))) { // rotation center might be outside of the bounding box
                             // This item is within snapping range, so record it as a candidate
                             _candidates->push_back(SnapCandidateItem(item, clip_or_mask, additional_affine));
                             // For debugging: print the id of the candidate to the console
@@ -626,9 +627,9 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc,
         _snapNodes(sc, p, unselected_nodes);
     }
 
-    if (_snapmanager->snapprefs.getSnapModeNode() && _snapmanager->snapprefs.getSnapToItemPath() ||
-        _snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxPath() ||
-        _snapmanager->snapprefs.getSnapModeBBoxOrNodes() && _snapmanager->snapprefs.getSnapToPageBorder()) {
+    if ((_snapmanager->snapprefs.getSnapModeNode() && _snapmanager->snapprefs.getSnapToItemPath()) ||
+        (_snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxPath()) ||
+        (_snapmanager->snapprefs.getSnapModeBBoxOrNodes() && _snapmanager->snapprefs.getSnapToPageBorder())) {
         unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size();
         if (n > 0) {
             /* While editing a path in the node tool, findCandidates must ignore that path because
index 64be3463719790a568e1abb9f678082899ba6b6f..aa5db9328115082d8efb6e8d226493af0fc6af63 100644 (file)
@@ -66,7 +66,7 @@ enum SnapSourceType {
     SNAPSOURCE_CONVEX_HULL_CORNER,
     SNAPSOURCE_ELLIPSE_QUADRANT_POINT,
     SNAPSOURCE_NODE_HANDLE, // eg. nodes in the path editor, handles of stars or rectangles, etc. (tied to a stroke)
-    SNAPSOURCE_OBJECT_MIDPOINT,
+    SNAPSOURCE_OBJECT_MIDPOINT, // midpoint of rectangles, polygon, etc.
     //-------------------------------------------------------------------
     // Other points (e.g. guides, gradient knots) will snap to both bounding boxes and nodes
     SNAPSOURCE_OTHER_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two
index fc8837c4315328c892a7b7c8e57a029d36b4e9d5..bac37737fc5589187da7b12b5fdf19425968a739 100644 (file)
@@ -763,6 +763,8 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vector<Inkscape::Snap
         _displaySnapsource(Inkscape::SnapCandidatePoint(pt, p.at(0).getSourceType()));
     }
 
+
+
     return _snapTransformed(p, pointer, false, Geom::Point(0,0), TRANSLATE, tr, Geom::Point(0,0), Geom::X, false);
 }
 
@@ -1209,8 +1211,9 @@ void SnapManager::_displaySnapsource(Inkscape::SnapCandidatePoint const &p) cons
     if (prefs->getBool("/options/snapclosestonly/value")) {
         bool p_is_a_node = p.getSourceType() & Inkscape::SNAPSOURCE_NODE_CATEGORY;
         bool p_is_a_bbox = p.getSourceType() & Inkscape::SNAPSOURCE_BBOX_CATEGORY;
+        bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHER_CATEGORY;
 
-        if (snapprefs.getSnapEnabledGlobally() && ((p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) {
+        if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) {
             _desktop->snapindicator->set_new_snapsource(p);
         } else {
             _desktop->snapindicator->remove_snapsource();