summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2010-07-25 20:29:45 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2010-07-25 20:29:45 +0000
commitb3725365a24e922e5bda09d7489c2ed17d94108f (patch)
tree59907c619c5f06bf502106aa8544e925eb0491e0 /src
parentMake icon preview seleciton stikcy by default. (diff)
downloadinkscape-b3725365a24e922e5bda09d7489c2ed17d94108f.tar.gz
inkscape-b3725365a24e922e5bda09d7489c2ed17d94108f.zip
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 (bzr r9648)
Diffstat (limited to 'src')
-rw-r--r--src/display/snap-indicator.cpp16
-rw-r--r--src/object-snapper.cpp11
-rw-r--r--src/snap-enums.h2
-rw-r--r--src/snap.cpp5
4 files changed, 19 insertions, 15 deletions
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 <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
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::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();