From: Diederik van Lierop Date: Sun, 25 Jul 2010 20:29:45 +0000 (+0200) Subject: 1) Snap to transformation center even if it's outside of the bounding box of the... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5ee25de9ab2d1ebc0e9dfa81f6486b194b0fc731;p=inkscape.git 1) Snap to transformation center even if it's outside of the bounding box of the parent item 2) In some cases the snap source indicator wasn't shown --- diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 776c56c15..c3198cd37 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -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? diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index c1ed08f12..d84ee9c4f 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -6,7 +6,7 @@ * Carl Hetherington * Diederik van Lierop * - * 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 diff --git a/src/snap-enums.h b/src/snap-enums.h index 64be34637..aa5db9328 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -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 diff --git a/src/snap.cpp b/src/snap.cpp index fc8837c43..bac37737f 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -763,6 +763,8 @@ Inkscape::SnappedPoint SnapManager::freeSnapTranslate(std::vectorgetBool("/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();