diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/attributes-test.h | 1 | ||||
| -rw-r--r-- | src/attributes.cpp | 2 | ||||
| -rw-r--r-- | src/attributes.h | 3 | ||||
| -rw-r--r-- | src/display/canvas-axonomgrid.cpp | 2 | ||||
| -rw-r--r-- | src/display/canvas-grid.cpp | 2 | ||||
| -rw-r--r-- | src/display/snap-indicator.cpp | 12 | ||||
| -rw-r--r-- | src/guide-snapper.cpp | 2 | ||||
| -rw-r--r-- | src/object-snapper.cpp | 231 | ||||
| -rw-r--r-- | src/selection.cpp | 12 | ||||
| -rw-r--r-- | src/seltrans.cpp | 9 | ||||
| -rw-r--r-- | src/snap-enums.h | 29 | ||||
| -rw-r--r-- | src/snap-preferences.cpp | 199 | ||||
| -rw-r--r-- | src/snap-preferences.h | 70 | ||||
| -rw-r--r-- | src/snap.cpp | 10 | ||||
| -rw-r--r-- | src/sp-ellipse.cpp | 20 | ||||
| -rw-r--r-- | src/sp-flowtext.cpp | 2 | ||||
| -rw-r--r-- | src/sp-image.cpp | 26 | ||||
| -rw-r--r-- | src/sp-item.cpp | 21 | ||||
| -rw-r--r-- | src/sp-namedview.cpp | 38 | ||||
| -rw-r--r-- | src/sp-rect.cpp | 19 | ||||
| -rw-r--r-- | src/sp-shape.cpp | 19 | ||||
| -rw-r--r-- | src/sp-spiral.cpp | 11 | ||||
| -rw-r--r-- | src/sp-star.cpp | 11 | ||||
| -rw-r--r-- | src/sp-text.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/document-properties.cpp | 6 | ||||
| -rw-r--r-- | src/ui/dialog/document-properties.h | 1 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 81 |
27 files changed, 425 insertions, 416 deletions
diff --git a/src/attributes-test.h b/src/attributes-test.h index dee29975e..02b53defc 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -358,7 +358,6 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"inkscape:snap-text-baseline", true}, {"inkscape:snap-bbox-edge-midpoints", true}, {"inkscape:snap-bbox-midpoints", true}, - //{"inkscape:snap-intersection-grid-guide", true}, {"inkscape:snap-grids", true}, {"inkscape:snap-to-guides", true}, {"inkscape:snap-intersection-paths", true}, diff --git a/src/attributes.cpp b/src/attributes.cpp index 47b261038..7e0a5e5d3 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -95,7 +95,7 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_SNAP_BBOX, "inkscape:snap-bbox"}, {SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"}, {SP_ATTR_INKSCAPE_SNAP_OTHERS, "inkscape:snap-others"}, - {SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, "inkscape:snap-from-guide"}, + //{SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, "inkscape:snap-from-guide"}, {SP_ATTR_INKSCAPE_SNAP_CENTER, "inkscape:snap-center"}, {SP_ATTR_INKSCAPE_SNAP_GRIDS, "inkscape:snap-grids"}, {SP_ATTR_INKSCAPE_SNAP_TO_GUIDES, "inkscape:snap-to-guides"}, diff --git a/src/attributes.h b/src/attributes.h index 2dec8b351..7d42dd357 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -95,7 +95,7 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_SNAP_BBOX, SP_ATTR_INKSCAPE_SNAP_NODES, SP_ATTR_INKSCAPE_SNAP_OTHERS, - SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, + //SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE, SP_ATTR_INKSCAPE_SNAP_CENTER, SP_ATTR_INKSCAPE_SNAP_GRIDS, SP_ATTR_INKSCAPE_SNAP_TO_GUIDES, @@ -105,7 +105,6 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE, SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS, - //SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE, SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS, SP_ATTR_INKSCAPE_OBJECT_PATHS, SP_ATTR_INKSCAPE_OBJECT_NODES, diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index ec2d35f69..3ed1fa5a9 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -770,7 +770,7 @@ void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Poi bool CanvasAxonomGridSnapper::ThisSnapperMightSnap() const { - return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeAny(); + return _snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID); } diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index aa38a14c9..b3ec73e78 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -1072,7 +1072,7 @@ void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point c */ bool CanvasXYGridSnapper::ThisSnapperMightSnap() const { - return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeAny(); + return _snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID); } } // namespace Inkscape diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index e351a1145..5b2314d51 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -120,9 +120,6 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_ROTATION_CENTER: target_name = _("object rotation center"); break; - case SNAPTARGET_HANDLE: - target_name = _("handle"); - break; case SNAPTARGET_BBOX_EDGE_MIDPOINT: target_name = _("bounding box side midpoint"); break; @@ -132,13 +129,11 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_PAGE_CORNER: target_name = _("page corner"); break; - case SNAPTARGET_CONVEX_HULL_CORNER: - target_name = _("convex hull corner"); - break; case SNAPTARGET_ELLIPSE_QUADRANT_POINT: target_name = _("quadrant point"); break; - case SNAPTARGET_CORNER: + case SNAPTARGET_RECT_CORNER: + case SNAPTARGET_IMG_CORNER: target_name = _("corner"); break; case SNAPTARGET_TEXT_ANCHOR: @@ -206,7 +201,8 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPSOURCE_ELLIPSE_QUADRANT_POINT: source_name = _("Quadrant point"); break; - case SNAPSOURCE_CORNER: + case SNAPSOURCE_RECT_CORNER: + case SNAPSOURCE_IMG_CORNER: source_name = _("Corner"); break; case SNAPSOURCE_TEXT_ANCHOR: diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp index 4f70521e0..2527ccb31 100644 --- a/src/guide-snapper.cpp +++ b/src/guide-snapper.cpp @@ -65,7 +65,7 @@ bool Inkscape::GuideSnapper::ThisSnapperMightSnap() const return false; } - return (_snap_enabled && _snapmanager->snapprefs.getSnapToGuides() && _snapmanager->getNamedView()->showguides); + return (_snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE) && _snapmanager->getNamedView()->showguides); } void Inkscape::GuideSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 389930b57..da6eca027 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -8,7 +8,7 @@ * Jon A. Cruz <jon@joncruz.org> * Abhishek Sharma * - * Copyright (C) 2005 - 2010 Authors + * Copyright (C) 2005 - 2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -42,8 +42,8 @@ Inkscape::ObjectSnapper::ObjectSnapper(SnapManager *sm, Geom::Coord const d) : Snapper(sm, d) { _candidates = new std::vector<SnapCandidateItem>; - _points_to_snap_to = new std::vector<Inkscape::SnapCandidatePoint>; - _paths_to_snap_to = new std::vector<Inkscape::SnapCandidatePath >; + _points_to_snap_to = new std::vector<SnapCandidatePoint>; + _paths_to_snap_to = new std::vector<SnapCandidatePath >; } Inkscape::ObjectSnapper::~ObjectSnapper() @@ -87,13 +87,9 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, bool const clip_or_mask, Geom::Affine const additional_affine) const // transformation of the item being clipped / masked { - if (!ThisSnapperMightSnap()) { - return; - } - if (_snapmanager->getDesktop() == NULL) { g_warning("desktop == NULL, so we cannot snap; please inform the developpers of this bug"); - // Apparently the etup() method from the SnapManager class hasn't been called before trying to snap. + // Apparently the setup() method from the SnapManager class hasn't been called before trying to snap. } if (first_point) { @@ -152,7 +148,7 @@ 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) - || (_snapmanager->snapprefs.getIncludeItemCenter() && bbox_to_snap_incl.contains(item->getCenter()))) { // rotation center might be outside of the bounding box + || (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER) && 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 @@ -167,7 +163,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, } -void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, +void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, bool const &first_point) const { // Now, let's first collect all points to snap to. If we have a whole bunch of points to snap, @@ -179,22 +175,24 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, // Determine the type of bounding box we should snap to SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX; - bool p_is_a_node = t & Inkscape::SNAPSOURCE_NODE_CATEGORY; - bool p_is_a_bbox = t & Inkscape::SNAPSOURCE_BBOX_CATEGORY; - bool p_is_other = t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; + bool p_is_a_node = t & SNAPSOURCE_NODE_CATEGORY; + bool p_is_a_bbox = t & SNAPSOURCE_BBOX_CATEGORY; + bool p_is_other = t & SNAPSOURCE_OTHERS_CATEGORY; // A point considered for snapping should be either a node, a bbox corner or a guide/other. Pick only ONE! - g_assert(!((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other))); + if (((p_is_a_node && p_is_a_bbox) || (p_is_a_bbox && p_is_other) || (p_is_a_node && p_is_other))) { + g_warning("Snap warning: node type is ambiguous"); + } - if (_snapmanager->snapprefs.getSnapToBBoxNode() || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints()) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER, SNAPTARGET_BBOX_EDGE_MIDPOINT, SNAPTARGET_BBOX_MIDPOINT)) { + Preferences *prefs = Preferences::get(); bool prefs_bbox = prefs->getBool("/tools/bounding_box"); bbox_type = !prefs_bbox ? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; } // Consider the page border for snapping to - if (_snapmanager->snapprefs.getSnapToPageBorder()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_CORNER)) { _getBorderNodes(_points_to_snap_to); } @@ -207,7 +205,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, g_return_if_fail(root_item); //Collect all nodes so we can snap to them - if (p_is_a_node || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_node) || p_is_other) { + if (p_is_a_node || p_is_other || (p_is_a_bbox && !_snapmanager->snapprefs.getStrictSnapping())) { // Note: there are two ways in which intersections are considered: // Method 1: Intersections are calculated for each shape individually, for both the // snap source and snap target (see sp_shape_snappoints) @@ -227,19 +225,19 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, // go hunting for intersections (but only when asked to in the prefs of course). In that case we can just // temporarily block the intersections in sp_item_snappoints, we don't need duplicates. If we're not snapping to // paths though but only to item nodes then we should still look for the intersections in sp_item_snappoints() - bool old_pref = _snapmanager->snapprefs.getSnapIntersectionCS(); - if (_snapmanager->snapprefs.getSnapToItemPath()) { - _snapmanager->snapprefs.setSnapIntersectionCS(false); + bool old_pref = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_INTERSECTION); + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH)) { + _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_PATH_INTERSECTION, false); } // We should not snap a transformation center to any of the centers of the items in the // current selection (see the comment in SelTrans::centerRequest()) - bool old_pref2 = _snapmanager->snapprefs.getIncludeItemCenter(); + bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); if (old_pref2) { for ( GSList const *itemlist = _snapmanager->getRotationCenterSource(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { if ((*i).item == reinterpret_cast<SPItem*>(itemlist->data)) { // don't snap to this item's rotation center - _snapmanager->snapprefs.setIncludeItemCenter(false); + _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); break; } } @@ -248,17 +246,20 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, root_item->getSnappoints(*_points_to_snap_to, &_snapmanager->snapprefs); // restore the original snap preferences - _snapmanager->snapprefs.setSnapIntersectionCS(old_pref); - _snapmanager->snapprefs.setIncludeItemCenter(old_pref2); + _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_PATH_INTERSECTION, old_pref); + _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, old_pref2); } //Collect the bounding box's corners so we can snap to them - if (p_is_a_bbox || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_bbox) || p_is_other) { + if (p_is_a_bbox || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node) || p_is_other) { // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time if (!(*i).clip_or_mask) { Geom::OptRect b = root_item->getBboxDesktop(bbox_type); - getBBoxPoints(b, _points_to_snap_to, true, _snapmanager->snapprefs.getSnapToBBoxNode(), _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints(), _snapmanager->snapprefs.getSnapBBoxMidpoints()); + getBBoxPoints(b, _points_to_snap_to, true, + _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER), + _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT), + _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT)); } } } @@ -266,7 +267,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, } void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, + SnapCandidatePoint const &p, std::vector<SnapCandidatePoint> *unselected_nodes, SnapConstraint const &c, Geom::Point const &p_proj_on_constraint) const @@ -321,9 +322,9 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, // Iterate through all nodes, find out which one is the closest to this guide, and snap to it! _collectNodes(SNAPSOURCE_GUIDE, true); - if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER)) { _collectPaths(p, SNAPSOURCE_GUIDE, true); - _snapPaths(sc, Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); + _snapPaths(sc, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); } SnappedPoint s; @@ -349,7 +350,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, */ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, - Inkscape::SnapSourceType const source_type, + SnapSourceType const source_type, bool const &first_point) const { // Now, let's first collect all paths to snap to. If we have a whole bunch of points to snap, @@ -361,21 +362,22 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, // Determine the type of bounding box we should snap to SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX; - bool p_is_a_node = source_type & Inkscape::SNAPSOURCE_NODE_CATEGORY; - bool p_is_other = source_type & Inkscape::SNAPSOURCE_OTHERS_CATEGORY; + bool p_is_a_node = source_type & SNAPSOURCE_NODE_CATEGORY; + bool p_is_a_bbox = source_type & SNAPSOURCE_BBOX_CATEGORY; + bool p_is_other = source_type & SNAPSOURCE_OTHERS_CATEGORY; - if (_snapmanager->snapprefs.getSnapToBBoxPath()) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE)) { + Preferences *prefs = Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box", 0); bbox_type = !prefs_bbox ? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; } // Consider the page border for snapping - if (_snapmanager->snapprefs.getSnapToPageBorder() && _snapmanager->snapprefs.getSnapModeAny()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_BORDER) && _snapmanager->snapprefs.getSnapModeAny()) { Geom::PathVector *border_path = _getBorderPathv(); if (border_path != NULL) { - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(border_path, SNAPTARGET_PAGE_BORDER, Geom::OptRect())); + _paths_to_snap_to->push_back(SnapCandidatePath(border_path, SNAPTARGET_PAGE_BORDER, Geom::OptRect())); } } @@ -397,17 +399,16 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, //Build a list of all paths considered for snapping to //Add the item's path to snap to - if ((_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapModeNode()) || - (_snapmanager->snapprefs.getSnapTextBaseline() && (_snapmanager->snapprefs.getSnapModeNode() || _snapmanager->snapprefs.getSnapToItemPath())) ) { - if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_node)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_TEXT_BASELINE)) { + if (p_is_other || p_is_a_node || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_bbox)) { if (SP_IS_TEXT(root_item) || SP_IS_FLOWTEXT(root_item)) { - if (_snapmanager->snapprefs.getSnapTextBaseline()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_TEXT_BASELINE)) { // Snap to the text baseline - Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) root_item); + Text::Layout const *layout = te_get_layout((SPItem *) root_item); if (layout != NULL && layout->outputExists()) { Geom::PathVector *pv = new Geom::PathVector(); pv->push_back(layout->baseline() * root_item->i2dt_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt()); - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_TEXT_BASELINE, Geom::OptRect())); + _paths_to_snap_to->push_back(SnapCandidatePath(pv, SNAPTARGET_TEXT_BASELINE, Geom::OptRect())); } } } else { @@ -419,7 +420,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, very_complex_path = sp_nodes_in_path(SP_PATH(root_item)) > 500; } - if (!very_complex_path && root_item && (_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapModeNode())) { + if (!very_complex_path && root_item && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH)) { SPCurve *curve = NULL; if (SP_IS_SHAPE(root_item)) { curve = SP_SHAPE(root_item)->getCurve(); @@ -434,7 +435,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, Geom::PathVector *pv = new Geom::PathVector(curve->get_pathvector()); (*pv) *= root_item->i2dt_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt(); // (_edit_transform * _i2d_transform); - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. + _paths_to_snap_to->push_back(SnapCandidatePath(pv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. curve->unref(); } } @@ -443,8 +444,8 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } //Add the item's bounding box to snap to - if (_snapmanager->snapprefs.getSnapToBBoxPath() && (_snapmanager->snapprefs.getSnapModeBBox() || _snapmanager->snapprefs.getSnapModeOthers())) { - if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node)) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE) && (_snapmanager->snapprefs.getSnapModeBBox() || _snapmanager->snapprefs.getSnapModeOthers())) { + if (p_is_other || p_is_a_bbox || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node)) { // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time if (!(*i).clip_or_mask) { @@ -453,7 +454,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, if (rect) { Geom::PathVector *path = _getPathvFromRect(*rect); rect = root_item->getBboxDesktop(bbox_type); - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(path, SNAPTARGET_BBOX_EDGE, rect)); + _paths_to_snap_to->push_back(SnapCandidatePath(path, SNAPTARGET_BBOX_EDGE, rect)); } } } @@ -463,8 +464,8 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, - std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes, + SnapCandidatePoint const &p, + std::vector<SnapCandidatePoint> *unselected_nodes, SPPath const *selected_path) const { _collectPaths(p.getPoint(), p.getSourceType(), p.getSourceNum() <= 0); @@ -473,7 +474,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, g_assert(_snapmanager->getDesktop() != NULL); Geom::Point const p_doc = _snapmanager->getDesktop()->dt2doc(p.getPoint()); - bool const node_tool_active = _snapmanager->snapprefs.getSnapToItemPath() && selected_path != NULL; + bool const node_tool_active = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH) && selected_path != NULL; if (p.getSourceNum() <= 0) { /* findCandidates() is used for snapping to both paths and nodes. It ignores the path that is @@ -492,7 +493,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, true, Geom::identity(), Geom::identity()); // We will get our own copy of the path, which must be freed at some point - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pathv, SNAPTARGET_PATH, Geom::OptRect(), true)); + _paths_to_snap_to->push_back(SnapCandidatePath(pathv, SNAPTARGET_PATH, Geom::OptRect(), true)); curve->unref(); } } @@ -503,7 +504,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping(); - for (std::vector<Inkscape::SnapCandidatePath >::const_iterator it_p = _paths_to_snap_to->begin(); it_p != _paths_to_snap_to->end(); it_p++) { + for (std::vector<SnapCandidatePath >::const_iterator it_p = _paths_to_snap_to->begin(); it_p != _paths_to_snap_to->end(); it_p++) { if (_allowSourceToSnapToTarget(p.getSourceType(), (*it_p).target_type, strict_snapping)) { bool const being_edited = node_tool_active && (*it_p).currently_being_edited; //if true then this pathvector it_pv is currently being edited in the node tool @@ -545,7 +546,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, if (!being_edited || (c1 && c2)) { Geom::Coord const dist = Geom::distance(sp_doc, p_doc); if (dist < getSnapperTolerance()) { - sc.curves.push_back(Inkscape::SnappedCurve(sp_dt, num_path, num_segm, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); + sc.curves.push_back(SnappedCurve(sp_dt, num_path, num_segm, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox)); } } } @@ -557,7 +558,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, } /* Returns true if point is coincident with one of the unselected nodes */ -bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::vector<Inkscape::SnapCandidatePoint> const *unselected_nodes) const +bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::vector<SnapCandidatePoint> const *unselected_nodes) const { if (unselected_nodes == NULL) { return false; @@ -567,7 +568,7 @@ bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::ve return false; } - for (std::vector<Inkscape::SnapCandidatePoint>::const_iterator i = unselected_nodes->begin(); i != unselected_nodes->end(); i++) { + for (std::vector<SnapCandidatePoint>::const_iterator i = unselected_nodes->begin(); i != unselected_nodes->end(); i++) { if (Geom::L2(point - (*i).getPoint()) < 1e-4) { return true; } @@ -577,7 +578,7 @@ bool Inkscape::ObjectSnapper::isUnselectedNode(Geom::Point const &point, std::ve } void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, + SnapCandidatePoint const &p, SnapConstraint const &c, Geom::Point const &p_proj_on_constraint) const { @@ -618,7 +619,7 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, // Find all intersections of the constrained path with the snap target candidates std::vector<Geom::Point> intersections; - for (std::vector<Inkscape::SnapCandidatePath >::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { + for (std::vector<SnapCandidatePath >::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { if (k->path_vector && _allowSourceToSnapToTarget(p.getSourceType(), (*k).target_type, strict_snapping)) { // Do the intersection math Geom::CrossingSet cs = Geom::crossings(constraint_path, *(k->path_vector)); @@ -671,12 +672,12 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc, void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, + SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, std::vector<SPItem const *> const *it, std::vector<SnapCandidatePoint> *unselected_nodes) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false ) { + if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { return; } @@ -686,29 +687,9 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, _findCandidates(_snapmanager->getDocument()->getRoot(), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity()); } - // TODO: Argh, UGLY! Get rid of this here, move this logic to the snap manager - bool snap_nodes = (_snapmanager->snapprefs.getSnapModeNode() && ( - _snapmanager->snapprefs.getSnapToItemNode() || - _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( - _snapmanager->snapprefs.getSnapToBBoxNode() || - _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || - _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeAny() && ( - _snapmanager->snapprefs.getIncludeItemCenter() || - _snapmanager->snapprefs.getSnapToPageBorder() || - _snapmanager->snapprefs.getSnapObjectMidpoints() || - _snapmanager->snapprefs.getSnapTextBaseline() - )) ; - - if (snap_nodes) { - _snapNodes(sc, p, unselected_nodes); - } + _snapNodes(sc, p, unselected_nodes); - if ((_snapmanager->snapprefs.getSnapModeNode() && _snapmanager->snapprefs.getSnapToItemPath()) || - (_snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxPath()) || - _snapmanager->snapprefs.getSnapModeAny()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { 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 @@ -731,13 +712,13 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc, } void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, - Inkscape::SnapCandidatePoint const &p, + SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, SnapConstraint const &c, std::vector<SPItem const *> const *it, std::vector<SnapCandidatePoint> *unselected_nodes) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) { + if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { return; } @@ -754,27 +735,9 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc, // This is useful for example when scaling an object while maintaining a fixed aspect ratio. It's // nodes are only allowed to move in one direction (i.e. in one degree of freedom). - // TODO: Argh, UGLY! Get rid of this here, move this logic to the snap manager - bool snap_nodes = (_snapmanager->snapprefs.getSnapModeNode() && ( - _snapmanager->snapprefs.getSnapToItemNode() || - _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( - _snapmanager->snapprefs.getSnapToBBoxNode() || - _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || - _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeAny() && ( - _snapmanager->snapprefs.getIncludeItemCenter() || - _snapmanager->snapprefs.getSnapObjectMidpoints() || - _snapmanager->snapprefs.getSnapToPageBorder() || - _snapmanager->snapprefs.getSnapTextBaseline() - )); - - if (snap_nodes) { - _snapNodes(sc, p, unselected_nodes, c, pp); - } + _snapNodes(sc, p, unselected_nodes, c, pp); - if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) { _snapPathsConstrained(sc, p, c, pp); } } @@ -785,12 +748,16 @@ void Inkscape::ObjectSnapper::guideFreeSnap(SnappedConstraints &sc, Geom::Point const &p, Geom::Point const &guide_normal) 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 + if (!_snapmanager->snapprefs.getSnapModeOthers()) { + return; + } + - _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); - _snapTranslatingGuide(sc, p, guide_normal); + //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); } @@ -804,8 +771,12 @@ void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc, std::vector<SPItem*> cand; std::vector<SPItem const *> const it; //just an empty list - _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); - _snapTranslatingGuide(sc, p, guide_normal); + 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); + } } @@ -814,29 +785,15 @@ void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc, */ bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const { - bool snap_to_something = (_snapmanager->snapprefs.getSnapModeNode() && ( - _snapmanager->snapprefs.getSnapToItemPath() || - _snapmanager->snapprefs.getSnapToItemNode() || - _snapmanager->snapprefs.getSnapSmoothNodes() || - _snapmanager->snapprefs.getSnapLineMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( - _snapmanager->snapprefs.getSnapToBBoxPath() || - _snapmanager->snapprefs.getSnapToBBoxNode() || - _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || - _snapmanager->snapprefs.getSnapBBoxMidpoints() - )) || (_snapmanager->snapprefs.getSnapModeAny() && ( - _snapmanager->snapprefs.getSnapToPageBorder() || - _snapmanager->snapprefs.getIncludeItemCenter() || - _snapmanager->snapprefs.getSnapObjectMidpoints() || - _snapmanager->snapprefs.getSnapTextBaseline() - )); - - return (_snap_enabled && snap_to_something); + return _snapmanager->snapprefs.getSnapModeBBox() + || _snapmanager->snapprefs.getSnapModeNode() + || _snapmanager->snapprefs.getSnapModeOthers() + || _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_CORNER); } void Inkscape::ObjectSnapper::_clear_paths() const { - for (std::vector<Inkscape::SnapCandidatePath >::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { + for (std::vector<SnapCandidatePath >::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) { delete k->path_vector; } _paths_to_snap_to->clear(); @@ -863,10 +820,10 @@ void Inkscape::ObjectSnapper::_getBorderNodes(std::vector<SnapCandidatePoint> *p { Geom::Coord w = (_snapmanager->getDocument())->getWidth(); Geom::Coord h = (_snapmanager->getDocument())->getHeight(); - points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(0,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); - points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(0,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); - points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(w,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); - points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(w,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); + points->push_back(SnapCandidatePoint(Geom::Point(0,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); + points->push_back(SnapCandidatePoint(Geom::Point(0,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); + points->push_back(SnapCandidatePoint(Geom::Point(w,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); + points->push_back(SnapCandidatePoint(Geom::Point(w,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); } void Inkscape::getBBoxPoints(Geom::OptRect const bbox, @@ -880,15 +837,15 @@ void Inkscape::getBBoxPoints(Geom::OptRect const bbox, // collect the corners of the bounding box for ( unsigned k = 0 ; k < 4 ; k++ ) { if (includeCorners) { - points->push_back(Inkscape::SnapCandidatePoint(bbox->corner(k), Inkscape::SNAPSOURCE_BBOX_CORNER, -1, Inkscape::SNAPTARGET_BBOX_CORNER, *bbox)); + points->push_back(SnapCandidatePoint(bbox->corner(k), SNAPSOURCE_BBOX_CORNER, -1, SNAPTARGET_BBOX_CORNER, *bbox)); } // optionally, collect the midpoints of the bounding box's edges too if (includeLineMidpoints) { - points->push_back(Inkscape::SnapCandidatePoint((bbox->corner(k) + bbox->corner((k+1) % 4))/2, Inkscape::SNAPSOURCE_BBOX_EDGE_MIDPOINT, -1, Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, *bbox)); + points->push_back(SnapCandidatePoint((bbox->corner(k) + bbox->corner((k+1) % 4))/2, SNAPSOURCE_BBOX_EDGE_MIDPOINT, -1, SNAPTARGET_BBOX_EDGE_MIDPOINT, *bbox)); } } if (includeObjectMidpoints) { - points->push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_BBOX_MIDPOINT, -1, Inkscape::SNAPTARGET_BBOX_MIDPOINT, *bbox)); + points->push_back(SnapCandidatePoint(bbox->midpoint(), SNAPSOURCE_BBOX_MIDPOINT, -1, SNAPTARGET_BBOX_MIDPOINT, *bbox)); } } } diff --git a/src/selection.cpp b/src/selection.cpp index 3007a3d1f..677e57d5f 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -433,9 +433,9 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc GSList const *items = const_cast<Selection *>(this)->itemList(); SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs - snapprefs_dummy.setIncludeItemCenter(false); // locally disable snapping to the item center - snapprefs_dummy.setSnapToItemNode(true); // consider any type of nodes as a snap source - snapprefs_dummy.setSnapSmoothNodes(true); // i.e. disregard the smooth / cusp node preference + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center + //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source + //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference std::vector<Inkscape::SnapCandidatePoint> p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { SPItem *this_item = SP_ITEM(iter->data); @@ -443,7 +443,7 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc //Include the transformation origin for snapping //For a selection or group only the overall origin is considered - if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) { + if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { p.push_back(Inkscape::SnapCandidatePoint(this_item->getCenter(), SNAPSOURCE_ROTATION_CENTER)); } } @@ -456,8 +456,8 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPointsConvexHull(Sna GSList const *items = const_cast<Selection *>(this)->itemList(); SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs - snapprefs_dummy.setSnapToItemNode(true); // consider any type of nodes as a snap source - snapprefs_dummy.setSnapSmoothNodes(true); // i.e. disregard the smooth / cusp node preference + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference std::vector<Inkscape::SnapCandidatePoint> p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { diff --git a/src/seltrans.cpp b/src/seltrans.cpp index bc8194d48..7538e15d9 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -324,18 +324,19 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s _bbox_points_for_translating.clear(); // Collect the bounding box's corners and midpoints for each selected item if (m.snapprefs.getSnapModeBBox()) { - bool mp = m.snapprefs.getSnapBBoxMidpoints(); - bool emp = m.snapprefs.getSnapBBoxEdgeMidpoints(); + bool c = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER); + bool mp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT); + bool emp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT); // Preferably we'd use the bbox of each selected item, instead of the bbox of the selection as a whole; for translations // this is easy to do, but when snapping the visual bbox while scaling we will have to compensate for the scaling of the // stroke width. (see get_scale_transform_with_stroke()). This however is currently only implemented for a single bbox. // That's why we have both _bbox_points_for_translating and _bbox_points. - getBBoxPoints(selection->bounds(_snap_bbox_type), &_bbox_points, false, true, emp, mp); + getBBoxPoints(selection->bounds(_snap_bbox_type), &_bbox_points, false, c, emp, mp); if (((_items.size() > 0) && (_items.size() < 50)) || prefs->getBool("/options/snapclosestonly/value", false)) { // More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole for (unsigned i = 0; i < _items.size(); i++) { - getBBoxPoints(_items[i]->getBboxDesktop(_snap_bbox_type), &_bbox_points_for_translating, false, true, emp, mp); + getBBoxPoints(_items[i]->getBboxDesktop(_snap_bbox_type), &_bbox_points_for_translating, false, c, emp, mp); } } else { _bbox_points_for_translating = _bbox_points; // use the bbox points of the selection as a whole diff --git a/src/snap-enums.h b/src/snap-enums.h index 6ef021fc0..fd28910a8 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -20,26 +20,28 @@ enum SnapSourceType { //------------------------------------------------------------------- // Bbox points can be located at the edge of the stroke (for visual bboxes); they will therefore not snap // to nodes because these are always located at the center of the stroke - SNAPSOURCE_BBOX_CATEGORY = 256, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_BBOX_CATEGORY = 32, // will be used as a flag and must therefore be a power of two. Also, + // must be larger than the largest number of targets in a single group SNAPSOURCE_BBOX_CORNER, SNAPSOURCE_BBOX_MIDPOINT, SNAPSOURCE_BBOX_EDGE_MIDPOINT, //------------------------------------------------------------------- // For the same reason, nodes will not snap to bbox points - SNAPSOURCE_NODE_CATEGORY = 512, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_NODE_CATEGORY = 64, // will be used as a flag and must therefore be a power of two SNAPSOURCE_NODE_SMOOTH, // Symmetrical nodes are also considered to be smooth; there's no dedicated type for symm. nodes SNAPSOURCE_NODE_CUSP, SNAPSOURCE_LINE_MIDPOINT, SNAPSOURCE_PATH_INTERSECTION, - SNAPSOURCE_CORNER, // of image or of rectangle + SNAPSOURCE_RECT_CORNER, // of a rectangle, so at the center of the stroke 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) //------------------------------------------------------------------- // Other points (e.g. guides, gradient knots) will snap to both bounding boxes and nodes - SNAPSOURCE_OTHERS_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two + SNAPSOURCE_OTHERS_CATEGORY = 128, // will be used as a flag and must therefore be a power of two SNAPSOURCE_ROTATION_CENTER, SNAPSOURCE_OBJECT_MIDPOINT, // midpoint of rectangles, ellipses, polygon, etc. + SNAPSOURCE_IMG_CORNER, SNAPSOURCE_GUIDE, SNAPSOURCE_GUIDE_ORIGIN, SNAPSOURCE_TEXT_ANCHOR, @@ -50,22 +52,24 @@ enum SnapSourceType { enum SnapTargetType { SNAPTARGET_UNDEFINED = 0, //------------------------------------------------------------------- - SNAPTARGET_BBOX_CATEGORY = 256, // will be used as a flag and must therefore be a power of two + SNAPTARGET_BBOX_CATEGORY = 32, // will be used as a flag and must therefore be a power of two. Also, + // must be larger than the largest number of targets in a single group + // i.e > 15 because that's the number of targets in the "others" group SNAPTARGET_BBOX_CORNER, SNAPTARGET_BBOX_EDGE, SNAPTARGET_BBOX_EDGE_MIDPOINT, SNAPTARGET_BBOX_MIDPOINT, //------------------------------------------------------------------- - SNAPTARGET_NODE_CATEGORY = 512, // will be used as a flag and must therefore be a power of two + SNAPTARGET_NODE_CATEGORY = 64, // will be used as a flag and must therefore be a power of two SNAPTARGET_NODE_SMOOTH, SNAPTARGET_NODE_CUSP, SNAPTARGET_LINE_MIDPOINT, SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, - SNAPTARGET_ELLIPSE_QUADRANT_POINT, - SNAPTARGET_CORNER, // of image or of rectangle + SNAPTARGET_ELLIPSE_QUADRANT_POINT, // this corner is at the center of the stroke + SNAPTARGET_RECT_CORNER, // of a rectangle, so this corner is at the center of the stroke //------------------------------------------------------------------- - SNAPTARGET_OTHERS_CATEGORY = 1024, // will be used as a flag and must therefore be a power of two + SNAPTARGET_OTHERS_CATEGORY = 128, // will be used as a flag and must therefore be a power of two SNAPTARGET_GRID, SNAPTARGET_GRID_INTERSECTION, SNAPTARGET_GUIDE, @@ -73,15 +77,16 @@ enum SnapTargetType { SNAPTARGET_GUIDE_ORIGIN, SNAPTARGET_GRID_GUIDE_INTERSECTION, SNAPTARGET_OBJECT_MIDPOINT, + SNAPTARGET_IMG_CORNER, SNAPTARGET_ROTATION_CENTER, - SNAPTARGET_HANDLE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_PAGE_CORNER, - SNAPTARGET_CONVEX_HULL_CORNER, SNAPTARGET_TEXT_ANCHOR, SNAPTARGET_TEXT_BASELINE, SNAPTARGET_CONSTRAINED_ANGLE, - SNAPTARGET_CONSTRAINT + SNAPTARGET_CONSTRAINT, + //------------------------------------------------------------------- + SNAPTARGET_MAX_ENUM_VALUE }; } diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index b98726a86..a02e4baba 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -12,20 +12,24 @@ #include "inkscape.h" #include "snap-preferences.h" +#include <glib.h> // g_assert() Inkscape::SnapPreferences::SnapPreferences() : - _include_item_center(false), - _intersectionGG(true), - _snap_to_grids(true), - _snap_to_guides(true), _snap_enabled_globally(true), _snap_postponed_globally(false), - _snap_to_itemnode(true), _snap_to_itempath(true), - _snap_to_bboxnode(true), _snap_to_bboxpath(true), - _snap_to_page_border(false), _strict_snapping(true) { + // Check for enough space to hold all snap target toggles in the "others" group; see the comments in snap-enums.h + g_assert(SNAPTARGET_MAX_ENUM_VALUE - SNAPTARGET_OTHERS_CATEGORY < SNAPTARGET_BBOX_CATEGORY); + // Check for powers of two; see the comments in snap-enums.h + g_assert((SNAPTARGET_BBOX_CATEGORY != 0) && !(SNAPTARGET_BBOX_CATEGORY & (SNAPTARGET_BBOX_CATEGORY - 1))); + g_assert((SNAPTARGET_NODE_CATEGORY != 0) && !(SNAPTARGET_NODE_CATEGORY & (SNAPTARGET_NODE_CATEGORY - 1))); + g_assert((SNAPTARGET_OTHERS_CATEGORY != 0) && !(SNAPTARGET_OTHERS_CATEGORY & (SNAPTARGET_OTHERS_CATEGORY - 1))); + setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab + for (int n = 0; n < Inkscape::SNAPTARGET_MAX_ENUM_VALUE; n++) { + _active_snap_targets[n] = -1; + } } /* @@ -46,6 +50,7 @@ void Inkscape::SnapPreferences::setSnapModeBBox(bool enabled) } else { _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_BBOX_CATEGORY); } + setTargetSnappable(SNAPTARGET_BBOX_CATEGORY, enabled); } bool Inkscape::SnapPreferences::getSnapModeBBox() const @@ -60,6 +65,7 @@ void Inkscape::SnapPreferences::setSnapModeNode(bool enabled) } else { _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_NODE_CATEGORY); } + setTargetSnappable(SNAPTARGET_NODE_CATEGORY, enabled); } bool Inkscape::SnapPreferences::getSnapModeNode() const @@ -74,6 +80,7 @@ void Inkscape::SnapPreferences::setSnapModeOthers(bool enabled) } else { _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } + setTargetSnappable(SNAPTARGET_OTHERS_CATEGORY, enabled); } bool Inkscape::SnapPreferences::getSnapModeOthers() const @@ -81,31 +88,11 @@ bool Inkscape::SnapPreferences::getSnapModeOthers() const return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); } - -//bool Inkscape::SnapPreferences::getSnapModeBBoxOrNodes() const -//{ -// return (_snap_from & (Inkscape::SNAPSOURCE_BBOX_CATEGORY | Inkscape::SNAPSOURCE_NODE_CATEGORY) ); -//} - bool Inkscape::SnapPreferences::getSnapModeAny() const { return (_snap_from != 0); } -void Inkscape::SnapPreferences::setSnapModeGuide(bool enabled) -{ - if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_OTHERS_CATEGORY); - } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHERS_CATEGORY); - } -} - -bool Inkscape::SnapPreferences::getSnapModeGuide() const -{ - return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); -} - /** * Turn on/off snapping of specific point types. * \param t Point type. @@ -129,6 +116,164 @@ bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const return (_snap_from & t); } +void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const +{ + if (target & SNAPTARGET_BBOX_CATEGORY) { + group_on = getSnapModeBBox(); // Only if the group with bbox sources/targets has been enabled, then we might snap to any of the bbox targets + } else if (target & SNAPTARGET_NODE_CATEGORY) { + group_on = getSnapModeNode(); // Only if the group with path/node sources/targets has been enabled, then we might snap to any of the nodes/paths + if (target == SNAPTARGET_RECT_CORNER || target == SNAPTARGET_ELLIPSE_QUADRANT_POINT) { // Don't have their own button; on when the group is on + target = SNAPTARGET_NODE_CATEGORY; + } + } else if (target & SNAPTARGET_OTHERS_CATEGORY) { + // Only if the group with "other" snap sources/targets has been enabled, then we might snap to any of those targets + // ... but this doesn't hold for the page border, grids, and guides + group_on = getSnapModeOthers(); + switch (target) { + // Some snap targets don't have their own toggle. These targets are called "secondary targets". We will re-map + // them to their cousin which does have a toggle, and which is called a "primary target" + case SNAPTARGET_GRID_INTERSECTION: + group_on = true; // cannot be disabled as part of a disabled group; + target = SNAPTARGET_GRID; + break; + case SNAPTARGET_GUIDE_INTERSECTION: + case SNAPTARGET_GUIDE_ORIGIN: + group_on = true; // cannot be disabled as part of a disabled group; + target = SNAPTARGET_GUIDE; + break; + case SNAPTARGET_PAGE_CORNER: + group_on = true; // cannot be disabled as part of a disabled group; + target = SNAPTARGET_PAGE_BORDER; + break; + case SNAPTARGET_TEXT_ANCHOR: + target = SNAPTARGET_TEXT_BASELINE; + break; + + case SNAPTARGET_IMG_CORNER: // Doesn't have its own button, on if the group is on + target = SNAPTARGET_OTHERS_CATEGORY; + break; + // Some snap targets cannot be toggled at all, and are therefore always enabled + case SNAPTARGET_GRID_GUIDE_INTERSECTION: + case SNAPTARGET_CONSTRAINED_ANGLE: + case SNAPTARGET_CONSTRAINT: + always_on = true; // Doesn't have it's own button + break; + case SNAPTARGET_GRID: + case SNAPTARGET_GUIDE: + case SNAPTARGET_PAGE_BORDER: + group_on = true; // cannot be disabled as part of a disabled group; + break; + + // These are only listed for completeness + case SNAPTARGET_OBJECT_MIDPOINT: + case SNAPTARGET_ROTATION_CENTER: + case SNAPTARGET_TEXT_BASELINE: + break; + + case SNAPTARGET_BBOX_CATEGORY: + case SNAPTARGET_NODE_CATEGORY: + case SNAPTARGET_OTHERS_CATEGORY: + break; + default: + g_warning("Snap-preferences warning: Undefined snap target (#%i)", target); + break; + } + } else if (target == SNAPTARGET_UNDEFINED ) { + g_warning("Snap-preferences warning: Undefined snaptarget (#%i)", target); + } +} + +void Inkscape::SnapPreferences::setTargetSnappable(Inkscape::SnapTargetType const target, bool enabled) +{ + bool always_on = false; + bool group_on = false; + Inkscape::SnapTargetType index = target; + + _mapTargetToArrayIndex(index, always_on, group_on); + + if (always_on) { + // Catch coding errors + g_warning("Snap-preferences warning: Trying to enable/disable a snap target (#%i) that's always on by definition", index); + } else { + if (index == target) { // I.e. if it has not been re-mapped, then we have a primary target at hand + _active_snap_targets[index] = enabled; + } else { // If it has been re-mapped though, then this target does not have its own toggle button and should therefore not be set + g_warning("Snap-preferences warning: Trying to enable/disable a secondary snap target (#%i); only primary targets can be set", index); + } + } +} + +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target) const +{ + bool always_on = false; + bool group_on = false; + Inkscape::SnapTargetType index = target; + + _mapTargetToArrayIndex(index, always_on, group_on); + + if (group_on) { + if (always_on) { + return true; + } else { + if (_active_snap_targets[index] == -1) { + // Catch coding errors + g_warning("Snap-preferences warning: Using an uninitialized snap target setting (#%i)", index); + } + return _active_snap_targets[index]; + } + } else { + return false; + } +} + +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2) const { + return isTargetSnappable(target1) || isTargetSnappable(target2); +} + +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3) const { + return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3); +} + +bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4) const { + return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3) || isTargetSnappable(target4); +} + + +//bool Inkscape::SnapPreferences::isAnyBBoxSnappable() const { +// return getSnapModeBBox() || getSnapModeOthers() || (getSnapModeNode() && !_strict_snapping); +//} + +//bool Inkscape::SnapPreferences::isAnyNodeOrPathSnappable() const { +// return getSnapModeNode() || getSnapModeOthers() || (getSnapModeBBox() && !_strict_snapping); +//} + +//bool Inkscape::SnapPreferences::isAnyOtherSnappable() const { +// return getSnapModeOthers(); +//} + +bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType const target) const +{ + bool always_on = false; + bool group_on = false; + Inkscape::SnapTargetType index = target; + + _mapTargetToArrayIndex(index, always_on, group_on); + + if (_active_snap_targets[index] == -1) { + // Catch coding errors + g_warning("Snap-preferences warning: Using an uninitialized snap target setting"); + } else { + if (index == target) { // I.e. if it has not been re-mapped, then we have a primary target at hand, which does have its own toggle button + return _active_snap_targets[index]; + } else { // If it has been re-mapped though, then this target does not have its own toggle button and therefore the button status cannot be read + g_warning("Snap-preferences warning: Trying to determine the button status of a secondary snap target; However, only primary targets have a button"); + } + } + + return false; +} + + /* Local Variables: mode:c++ diff --git a/src/snap-preferences.h b/src/snap-preferences.h index 35d05c40e..dac11b3aa 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -23,43 +23,23 @@ class SnapPreferences { public: SnapPreferences(); + void setTargetSnappable(Inkscape::SnapTargetType const target, bool enabled); + bool isTargetSnappable(Inkscape::SnapTargetType const target) const; + bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2) const; + bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3) const; + bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4) const; + //bool isAnyBBoxSnappable() const; + //bool isAnyNodeOrPathSnappable() const; + //bool isAnyOtherSnappable() const; + bool isSnapButtonEnabled(Inkscape::SnapTargetType const target) const; void setSnapModeBBox(bool enabled); void setSnapModeNode(bool enabled); void setSnapModeOthers(bool enabled); - void setSnapModeGuide(bool enabled); bool getSnapModeBBox() const; bool getSnapModeNode() const; bool getSnapModeOthers() const; - //bool getSnapModeBBoxOrNodes() const; bool getSnapModeAny() const; - bool getSnapModeGuide() const; - - void setSnapIntersectionGG(bool enabled) {_intersectionGG = enabled;} - void setSnapIntersectionCS(bool enabled) {_intersectionCS = enabled;} - void setSnapSmoothNodes(bool enabled) {_smoothNodes = enabled;} - void setSnapLineMidpoints(bool enabled) {_line_midpoints = enabled;} - void setSnapObjectMidpoints(bool enabled) {_object_midpoints = enabled;} - void setSnapTextBaseline(bool enabled) {_text_baseline = enabled;} - void setSnapBBoxEdgeMidpoints(bool enabled) {_bbox_edge_midpoints = enabled;} - void setSnapBBoxMidpoints(bool enabled) {_bbox_midpoints = enabled;} - bool getSnapIntersectionGG() const {return _intersectionGG;} - bool getSnapIntersectionCS() const {return _intersectionCS;} - bool getSnapSmoothNodes() const {return _smoothNodes;} - bool getSnapLineMidpoints() const {return _line_midpoints;} - bool getSnapObjectMidpoints() const {return _object_midpoints;} - bool getSnapTextBaseline() const {return _text_baseline;} - bool getSnapBBoxEdgeMidpoints() const {return _bbox_edge_midpoints;} - bool getSnapBBoxMidpoints() const {return _bbox_midpoints;} - - void setSnapToGrids(bool enabled) {_snap_to_grids = enabled;} - bool getSnapToGrids() const {return _snap_to_grids;} - - void setSnapToGuides(bool enabled) {_snap_to_guides = enabled;} - bool getSnapToGuides() const {return _snap_to_guides;} - - void setIncludeItemCenter(bool enabled) {_include_item_center = enabled;} - bool getIncludeItemCenter() const {return _include_item_center;} void setSnapEnabledGlobally(bool enabled) {_snap_enabled_globally = enabled;} bool getSnapEnabledGlobally() const {return _snap_enabled_globally;} @@ -70,17 +50,6 @@ public: void setSnapFrom(Inkscape::SnapSourceType t, bool s); bool getSnapFrom(Inkscape::SnapSourceType t) const; - // These will only be used for the object snapper - void setSnapToItemNode(bool s) {_snap_to_itemnode = s;} - bool getSnapToItemNode() const {return _snap_to_itemnode;} - void setSnapToItemPath(bool s) {_snap_to_itempath = s;} - bool getSnapToItemPath() const {return _snap_to_itempath;} - void setSnapToBBoxNode(bool s) {_snap_to_bboxnode = s;} - bool getSnapToBBoxNode() const {return _snap_to_bboxnode;} - void setSnapToBBoxPath(bool s) {_snap_to_bboxpath = s;} - bool getSnapToBBoxPath() const {return _snap_to_bboxpath;} - void setSnapToPageBorder(bool s) {_snap_to_page_border = s;} - bool getSnapToPageBorder() const {return _snap_to_page_border;} bool getStrictSnapping() const {return _strict_snapping;} gdouble getGridTolerance() const {return _grid_tolerance;} @@ -92,27 +61,14 @@ public: void setObjectTolerance(gdouble val) {_object_tolerance = val;} private: - bool _include_item_center; //If true, snapping nodes will also snap the item's center - bool _intersectionGG; //Consider snapping to intersections of grid and guides - bool _intersectionCS; //Consider snapping to intersections of curves - bool _smoothNodes; - bool _line_midpoints; - bool _object_midpoints; // the midpoint of shapes (e.g. a circle, rect, polygon) or of any other shape (at [h/2, w/2]) - bool _text_baseline; // both anchor point and baseline of the text - bool _bbox_edge_midpoints; - bool _bbox_midpoints; - bool _snap_to_grids; - bool _snap_to_guides; + void _mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const; + int _active_snap_targets[Inkscape::SNAPTARGET_MAX_ENUM_VALUE]; + bool _snap_enabled_globally; // Toggles ALL snapping bool _snap_postponed_globally; // Hold all snapping temporarily when the mouse is moving fast + SnapSourceType _snap_from; ///< bitmap of point types that we will snap from - // These will only be used for the object snapper - bool _snap_to_itemnode; - bool _snap_to_itempath; - bool _snap_to_bboxnode; - bool _snap_to_bboxpath; - bool _snap_to_page_border; //If enabled, then bbox corners will only snap to bboxes, //and nodes will only snap to nodes and paths. We will not //snap bbox corners to nodes, or nodes to bboxes. diff --git a/src/snap.cpp b/src/snap.cpp index a3015e576..8d3103122 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -97,7 +97,7 @@ SnapManager::getGridSnappers() const { SnapperList s; - if (_desktop && _desktop->gridsEnabled() && snapprefs.getSnapToGrids()) { + if (_desktop && _desktop->gridsEnabled() && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID)) { for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) { Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data; s.push_back(grid->snapper); @@ -577,7 +577,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, return; } - if (!(object.ThisSnapperMightSnap() || snapprefs.getSnapToGuides())) { + if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { return; } @@ -624,7 +624,7 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) return; } - if (!(object.ThisSnapperMightSnap() || snapprefs.getSnapToGuides())) { + if (!(object.ThisSnapperMightSnap() || snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE))) { return; } @@ -1202,7 +1202,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co } } - if (snapprefs.getSnapIntersectionCS()) { + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { // search for the closest snapped intersection of curves Inkscape::SnappedPoint closestCurvesIntersection; if (getClosestIntersectionCS(sc.curves, p.getPoint(), closestCurvesIntersection, _desktop->dt2doc())) { @@ -1247,7 +1247,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co } // search for the closest snapped intersection of grid with guide lines - if (snapprefs.getSnapIntersectionGG()) { + if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION)) { Inkscape::SnappedPoint closestGridGuidePoint; if (getClosestIntersectionSL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) { closestGridGuidePoint.setSource(p.getSourceType()); diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index d2ca2c445..99189da45 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -275,11 +275,6 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vector<Inkscap g_assert(item != NULL); g_assert(SP_IS_GENERICELLIPSE(item)); - // Help enforcing strict snapping, i.e. only return nodes when we're snapping nodes to nodes or a guide to nodes - if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - SPGenericEllipse *ellipse = SP_GENERICELLIPSE(item); sp_genericellipse_normalize(ellipse); Geom::Affine const i2dt = item->i2dt_affine(); @@ -304,7 +299,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vector<Inkscap // Snap to the 4 quadrant points of the ellipse, but only if the arc // spans far enough to include them - if (snapprefs->getSnapToItemNode()) { //TODO: Make a separate snap option toggle for this? + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)) { double angle = 0; for (angle = 0; angle < SP_2PI; angle += M_PI_2) { if (angle >= ellipse->start && angle <= ellipse->end) { @@ -315,13 +310,20 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vector<Inkscap } // Add the centre, if we have a closed slice or when explicitly asked for - if ((snapprefs->getSnapToItemNode() && slice && ellipse->closed) || snapprefs->getSnapObjectMidpoints()) { + bool c1 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice && ellipse->closed; + bool c2 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT); + if (c1 || c2) { pt = Geom::Point(cx, cy) * i2dt; - p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); + if (c1) { + p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); + } + if (c2) { + p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); + } } // And if we have a slice, also snap to the endpoints - if (snapprefs->getSnapToItemNode() && slice) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice) { // Add the start point, if it's not coincident with a quadrant point if (fmod(ellipse->start, M_PI_2) != 0.0 ) { pt = Geom::Point(cx + cos(ellipse->start)*rx, cy + sin(ellipse->start)*ry) * i2dt; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 87266464c..bb931a869 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -393,7 +393,7 @@ static gchar *sp_flowtext_description(SPItem *item) static void sp_flowtext_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { - if (snapprefs->getSnapTextBaseline()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { // Choose a point on the baseline for snapping from or to, with the horizontal position // of this point depending on the text alignment (left vs. right) Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index c9647c939..ea7d5089e 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1282,7 +1282,7 @@ static void sp_image_update_canvas_image(SPImage *image) } } -static void sp_image_snappoints( SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const */*snapprefs*/ ) +static void sp_image_snappoints( SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs ) { /* An image doesn't have any nodes to snap, but still we want to be able snap one image to another. Therefore we will create some snappoints at the corner, similar to a rect. If @@ -1297,17 +1297,19 @@ static void sp_image_snappoints( SPItem const *item, std::vector<Inkscape::SnapC //far far away from the visible part from the clipped image //TODO Do return snappoints, but only when within visual bounding box } else { - // The image has not been clipped: return its corners, which might be rotated for example - SPImage &image = *SP_IMAGE(item); - double const x0 = image.x.computed; - double const y0 = image.y.computed; - double const x1 = x0 + image.width.computed; - double const y1 = y0 + image.height.computed; - Geom::Affine const i2d (item->i2dt_affine ()); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y0) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y0) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_IMG_CORNER)) { + // The image has not been clipped: return its corners, which might be rotated for example + SPImage &image = *SP_IMAGE(item); + double const x0 = image.x.computed; + double const y0 = image.y.computed; + double const x1 = x0 + image.width.computed; + double const y1 = y0 + image.height.computed; + Geom::Affine const i2d (item->i2dt_affine ()); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y0) * i2d, Inkscape::SNAPSOURCE_IMG_CORNER, Inkscape::SNAPTARGET_IMG_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y1) * i2d, Inkscape::SNAPSOURCE_IMG_CORNER, Inkscape::SNAPTARGET_IMG_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y1) * i2d, Inkscape::SNAPSOURCE_IMG_CORNER, Inkscape::SNAPTARGET_IMG_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y0) * i2d, Inkscape::SNAPSOURCE_IMG_CORNER, Inkscape::SNAPTARGET_IMG_CORNER)); + } } } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9e3bc02ae..a4f2efa2c 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -900,27 +900,16 @@ Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type) return rect; } -void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const */*snapprefs*/) +void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { /* This will only be called if the derived class doesn't override this. * see for example sp_genericellipse_snappoints in sp-ellipse.cpp * We don't know what shape we could be dealing with here, so we'll just - * return the corners of the bounding box */ - - Geom::OptRect bbox = item->getBounds(item->i2dt_affine()); - - if (bbox) { - Geom::Point p1, p2; - p1 = bbox->min(); - p2 = bbox->max(); - p.push_back(Inkscape::SnapCandidatePoint(p1, Inkscape::SNAPSOURCE_BBOX_CORNER, Inkscape::SNAPTARGET_BBOX_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(p1[Geom::X], p2[Geom::Y]), Inkscape::SNAPSOURCE_BBOX_CORNER, Inkscape::SNAPTARGET_BBOX_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(p2, Inkscape::SNAPSOURCE_BBOX_CORNER, Inkscape::SNAPTARGET_BBOX_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(p2[Geom::X], p1[Geom::Y]), Inkscape::SNAPSOURCE_BBOX_CORNER, Inkscape::SNAPTARGET_BBOX_CORNER)); - } - + * do nothing + */ } + void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { // Get the snappoints of the item @@ -930,7 +919,7 @@ void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscap } // Get the snappoints at the item's center - if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) { + if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { p.push_back(Inkscape::SnapCandidatePoint(getCenter(), Inkscape::SNAPSOURCE_ROTATION_CENTER, Inkscape::SNAPTARGET_ROTATION_CENTER)); } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 5adc0dc74..7bafabba2 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -472,67 +472,67 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_CENTER: - nv->snap_manager.snapprefs.setIncludeItemCenter(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GRIDS: - nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE); + 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_GUIDES: - nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: - nv->snap_manager.snapprefs.setSnapSmoothNodes(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapLineMidpoints(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapObjectMidpoints(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: - nv->snap_manager.snapprefs.setSnapTextBaseline(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapBBoxEdgeMidpoints(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: - nv->snap_manager.snapprefs.setSnapBBoxMidpoints(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE: - nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; +// case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE: +// nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : TRUE); +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS: - nv->snap_manager.snapprefs.setSnapIntersectionCS(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_OBJECT_PATHS: - nv->snap_manager.snapprefs.setSnapToItemPath(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_OBJECT_NODES: - nv->snap_manager.snapprefs.setSnapToItemNode(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_BBOX_PATHS: - nv->snap_manager.snapprefs.setSnapToBBoxPath(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_BBOX_NODES: - nv->snap_manager.snapprefs.setSnapToBBoxNode(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CORNER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PAGE: - nv->snap_manager.snapprefs.setSnapToPageBorder(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PAGE_BORDER, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CURRENT_LAYER: diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 467b37d17..729e2a34c 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -566,11 +566,6 @@ static void sp_rect_snappoints(SPItem const *item, std::vector<Inkscape::SnapCan g_assert(item != NULL); g_assert(SP_IS_RECT(item)); - // Help enforcing strict snapping, i.e. only return nodes when we're snapping nodes to nodes or a guide to nodes - if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - SPRect *rect = SP_RECT(item); Geom::Affine const i2dt (item->i2dt_affine ()); @@ -580,21 +575,21 @@ static void sp_rect_snappoints(SPItem const *item, std::vector<Inkscape::SnapCan Geom::Point p2 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2dt; Geom::Point p3 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2dt; - if (snapprefs->getSnapToItemNode()) { - p.push_back(Inkscape::SnapCandidatePoint(p0, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(p1, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(p2, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); - p.push_back(Inkscape::SnapCandidatePoint(p3, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_RECT_CORNER)) { + p.push_back(Inkscape::SnapCandidatePoint(p0, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(p1, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(p2, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER)); + p.push_back(Inkscape::SnapCandidatePoint(p3, Inkscape::SNAPSOURCE_RECT_CORNER, Inkscape::SNAPTARGET_RECT_CORNER)); } - if (snapprefs->getSnapLineMidpoints()) { // only do this when we're snapping nodes (enforce strict snapping) + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT)) { p.push_back(Inkscape::SnapCandidatePoint((p0 + p1)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); p.push_back(Inkscape::SnapCandidatePoint((p1 + p2)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); p.push_back(Inkscape::SnapCandidatePoint((p2 + p3)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); p.push_back(Inkscape::SnapCandidatePoint((p3 + p0)/2, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); } - if (snapprefs->getSnapObjectMidpoints()) { // only do this when we're snapping nodes (enforce strict snapping) + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { p.push_back(Inkscape::SnapCandidatePoint((p0 + p2)/2, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index beec860be..7f24dd089 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1188,18 +1188,13 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::Snap return; } - // Help enforcing strict snapping, i.e. only return nodes when we're snapping nodes to nodes or a guide to nodes - if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - Geom::PathVector const &pathv = shape->curve->get_pathvector(); if (pathv.empty()) return; Geom::Affine const i2dt (item->i2dt_affine ()); - if (snapprefs->getSnapObjectMidpoints()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { Geom::OptRect bbox = item->getBounds(i2dt); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); @@ -1207,7 +1202,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::Snap } for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - if (snapprefs->getSnapToItemNode()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP)) { // Add the first point of the path p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } @@ -1217,14 +1212,14 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::Snap while (curve_it1 != path_it->end_default()) { // For each path: consider midpoints of line segments for snapping - if (snapprefs->getSnapLineMidpoints()) { // only do this when we're snapping nodes (enforces strict snapping) + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT)) { if (Geom::LineSegment const* line_segment = dynamic_cast<Geom::LineSegment const*>(&(*curve_it1))) { p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2dt, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); } } if (curve_it2 == path_it->end_default()) { // Test will only pass for the last iteration of the while loop - if (snapprefs->getSnapToItemNode() && !path_it->closed()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && !path_it->closed()) { // Add the last point of the path, but only for open paths // (for closed paths the first and last point will coincide) p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); @@ -1235,8 +1230,8 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::Snap Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, *curve_it2); - bool c1 = snapprefs->getSnapToItemNode() && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE); - bool c2 = snapprefs->getSnapSmoothNodes() && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM); + bool c1 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE); + bool c2 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH) && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM); if (c1 || c2) { Inkscape::SnapSourceType sst; @@ -1266,7 +1261,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::Snap // Find the internal intersections of each path and consider these for snapping // (using "Method 1" as described in Inkscape::ObjectSnapper::_collectNodes()) - if (snapprefs->getSnapIntersectionCS()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { Geom::Crossings cs; try { cs = self_crossings(*path_it); diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 3ba05adc6..298a4444a 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -520,20 +520,15 @@ sp_spiral_position_set (SPSpiral *spiral, static void sp_spiral_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { // We will determine the spiral's midpoint ourselves, instead of trusting on the base class - // Therefore setSnapObjectMidpoints() is set to false temporarily + // Therefore snapping to object midpoints is temporarily disabled Inkscape::SnapPreferences local_snapprefs = *snapprefs; - local_snapprefs.setSnapObjectMidpoints(false); + local_snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, false); if (((SPItemClass *) parent_class)->snappoints) { ((SPItemClass *) parent_class)->snappoints (item, p, &local_snapprefs); } - // Help enforcing strict snapping, i.e. only return nodes when we're snapping nodes to nodes or a guide to nodes - if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - - if (snapprefs->getSnapObjectMidpoints()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { Geom::Affine const i2dt (item->i2dt_affine ()); SPSpiral *spiral = SP_SPIRAL(item); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(spiral->cx, spiral->cy) * i2dt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); diff --git a/src/sp-star.cpp b/src/sp-star.cpp index c7c2c54ad..d224ff1ba 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -548,20 +548,15 @@ sp_star_position_set (SPStar *star, gint sides, Geom::Point center, gdouble r1, static void sp_star_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { // We will determine the star's midpoint ourselves, instead of trusting on the base class - // Therefore setSnapObjectMidpoints() is set to false temporarily + // Therefore snapping to object midpoints is temporarily disabled Inkscape::SnapPreferences local_snapprefs = *snapprefs; - local_snapprefs.setSnapObjectMidpoints(false); + local_snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, false); if (((SPItemClass *) parent_class)->snappoints) { ((SPItemClass *) parent_class)->snappoints (item, p, &local_snapprefs); } - // Help enforcing strict snapping, i.e. only return nodes when we're snapping nodes to nodes or a guide to nodes - if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - - if (snapprefs->getSnapObjectMidpoints()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { Geom::Affine const i2dt (item->i2dt_affine ()); p.push_back(Inkscape::SnapCandidatePoint(SP_STAR(item)->center * i2dt,Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 89ca4ace4..c56f2e91f 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -443,7 +443,7 @@ static char * sp_text_description(SPItem *item) static void sp_text_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { - if (snapprefs->getSnapTextBaseline()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE)) { // Choose a point on the baseline for snapping from or to, with the horizontal position // of this point depending on the text alignment (left vs. right) Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 5d32839cb..69d634e59 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -98,8 +98,6 @@ DocumentProperties::DocumentProperties() //--------------------------------------------------------------- //General snap options _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr), - _rcbsng(_("_Snap guides while dragging"), _("While dragging a guide, snap to object nodes or bounding box corners ('Snap to nodes' or 'snap to bounding box corners' must be enabled; only a small part of the guide near the cursor will snap)"), - "inkscape:snap-from-guide", _wr), _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr), _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr), //--------------------------------------------------------------- @@ -255,8 +253,7 @@ DocumentProperties::build_guides() label_gui, 0, 0, &_rcb_sgui, _rcp_gui._label, &_rcp_gui, - _rcp_hgui._label, &_rcp_hgui, - 0, &_rcbsng, + _rcp_hgui._label, &_rcp_hgui }; attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array)); @@ -1018,7 +1015,6 @@ DocumentProperties::update() _rcb_sgui.setActive (nv->showguides); _rcp_gui.setRgba32 (nv->guidecolor); _rcp_hgui.setRgba32 (nv->guidehicolor); - _rcbsng.setActive(nv->snap_manager.snapprefs.getSnapModeGuide()); //-----------------------------------------------------------snap page diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 69729f2da..261287877 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -106,7 +106,6 @@ protected: UI::Widget::PageSizer _page_sizer; //--------------------------------------------------------------- UI::Widget::RegisteredCheckButton _rcb_sgui; - UI::Widget::RegisteredCheckButton _rcbsng; UI::Widget::RegisteredColorPicker _rcp_gui; UI::Widget::RegisteredColorPicker _rcp_hgui; //--------------------------------------------------------------- diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index ea1811b92..90b299075 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2149,11 +2149,11 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:snap-bbox", !v); break; case SP_ATTR_INKSCAPE_BBOX_PATHS: - v = nv->snap_manager.snapprefs.getSnapToBBoxPath(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_EDGE); sp_repr_set_boolean(repr, "inkscape:bbox-paths", !v); break; case SP_ATTR_INKSCAPE_BBOX_NODES: - v = nv->snap_manager.snapprefs.getSnapToBBoxNode(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_CORNER); sp_repr_set_boolean(repr, "inkscape:bbox-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_NODES: @@ -2161,19 +2161,19 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:snap-nodes", !v); break; case SP_ATTR_INKSCAPE_OBJECT_PATHS: - v = nv->snap_manager.snapprefs.getSnapToItemPath(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH); sp_repr_set_boolean(repr, "inkscape:object-paths", !v); break; case SP_ATTR_INKSCAPE_OBJECT_NODES: - v = nv->snap_manager.snapprefs.getSnapToItemNode(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP); sp_repr_set_boolean(repr, "inkscape:object-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: - v = nv->snap_manager.snapprefs.getSnapSmoothNodes(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_SMOOTH); sp_repr_set_boolean(repr, "inkscape:snap-smooth-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS: - v = nv->snap_manager.snapprefs.getSnapIntersectionCS(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_INTERSECTION); sp_repr_set_boolean(repr, "inkscape:snap-intersection-paths", !v); break; case SP_ATTR_INKSCAPE_SNAP_OTHERS: @@ -2181,43 +2181,39 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:snap-others", !v); break; case SP_ATTR_INKSCAPE_SNAP_CENTER: - v = nv->snap_manager.snapprefs.getIncludeItemCenter(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_ROTATION_CENTER); sp_repr_set_boolean(repr, "inkscape:snap-center", !v); break; case SP_ATTR_INKSCAPE_SNAP_GRIDS: - v = nv->snap_manager.snapprefs.getSnapToGrids(); + 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_GUIDES: - v = nv->snap_manager.snapprefs.getSnapToGuides(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GUIDE); sp_repr_set_boolean(repr, "inkscape:snap-to-guides", !v); break; case SP_ATTR_INKSCAPE_SNAP_PAGE: - v = nv->snap_manager.snapprefs.getSnapToPageBorder(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PAGE_BORDER); sp_repr_set_boolean(repr, "inkscape:snap-page", !v); break; - /*case SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE: - v = nv->snap_manager.snapprefs.getSnapIntersectionGG(); - sp_repr_set_boolean(repr, "inkscape:snap-intersection-grid-guide", !v); - break;*/ case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapLineMidpoints(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_LINE_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-midpoints", !v); break; case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapObjectMidpoints(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_OBJECT_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-object-midpoints", !v); break; case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: - v = nv->snap_manager.snapprefs.getSnapTextBaseline(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_TEXT_BASELINE); sp_repr_set_boolean(repr, "inkscape:snap-text-baseline", !v); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-bbox-edge-midpoints", !v); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: - v = nv->snap_manager.snapprefs.getSnapBBoxMidpoints(); + v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_BBOX_MIDPOINT); sp_repr_set_boolean(repr, "inkscape:snap-bbox-midpoints", !v); break; default: @@ -2283,7 +2279,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromBBoxCorner", - _("Bounding box"), _("Snap bounding box corners"), INKSCAPE_ICON("snap-bounding-box"), + _("Bounding box"), _("Snap bounding boxes"), INKSCAPE_ICON("snap-bounding-box"), secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); @@ -2329,7 +2325,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromNode", - _("Nodes"), _("Snap nodes or handles"), INKSCAPE_ICON("snap-nodes"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODES); + _("Nodes"), _("Snap nodes, paths, and handles"), INKSCAPE_ICON("snap-nodes"), secondarySize, SP_ATTR_INKSCAPE_SNAP_NODES); gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); @@ -2443,16 +2439,6 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); } - /*{ - InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGridGuideIntersections", - _("Grid/guide intersections"), _("Snap to intersections of a grid with a guide"), - INKSCAPE_ICON("snap-grid-guide-intersections"), secondarySize, - SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE); - - gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) ); - g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); - }*/ - setupToolboxCommon( toolbox, desktop, descr, "/ui/SnapToolbar", "/toolbox/secondary" ); @@ -2510,7 +2496,6 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev Glib::RefPtr<Gtk::Action> act11 = mainActions->get_action("ToggleSnapToFromRotationCenter"); Glib::RefPtr<Gtk::Action> act11b = mainActions->get_action("ToggleSnapToFromTextBaseline"); Glib::RefPtr<Gtk::Action> act12 = mainActions->get_action("ToggleSnapToPageBorder"); - //Glib::RefPtr<Gtk::Action> act13 = mainActions->get_action("ToggleSnapToGridGuideIntersections"); Glib::RefPtr<Gtk::Action> act14 = mainActions->get_action("ToggleSnapToGrids"); Glib::RefPtr<Gtk::Action> act15 = mainActions->get_action("ToggleSnapToGuides"); @@ -2531,49 +2516,47 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act2->gobj()), c2); gtk_action_set_sensitive(GTK_ACTION(act2->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act3->gobj()), nv->snap_manager.snapprefs.getSnapToBBoxPath()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act3->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_EDGE)); gtk_action_set_sensitive(GTK_ACTION(act3->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4->gobj()), nv->snap_manager.snapprefs.getSnapToBBoxNode()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_CORNER)); gtk_action_set_sensitive(GTK_ACTION(act4->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4b->gobj()), nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_EDGE_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act4b->gobj()), c1 && c2); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.getSnapBBoxMidpoints()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act4c->gobj()), c1 && c2); bool const c3 = nv->snap_manager.snapprefs.getSnapModeNode(); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act5->gobj()), c3); gtk_action_set_sensitive(GTK_ACTION(act5->gobj()), c1); - bool const c4 = nv->snap_manager.snapprefs.getSnapToItemPath(); + bool const c4 = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), c4); gtk_action_set_sensitive(GTK_ACTION(act6->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionCS()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_INTERSECTION)); gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3 && c4); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.getSnapToItemNode()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP)); gtk_action_set_sensitive(GTK_ACTION(act7->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act8->gobj()), nv->snap_manager.snapprefs.getSnapSmoothNodes()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act8->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_SMOOTH)); gtk_action_set_sensitive(GTK_ACTION(act8->gobj()), c1 && c3); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act9->gobj()), nv->snap_manager.snapprefs.getSnapLineMidpoints()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act9->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_LINE_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act9->gobj()), c1 && c3); bool const c5 = nv->snap_manager.snapprefs.getSnapModeOthers(); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), c5); gtk_action_set_sensitive(GTK_ACTION(act10->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10b->gobj()), nv->snap_manager.snapprefs.getSnapObjectMidpoints()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act10b->gobj()), c1 && c5); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.getIncludeItemCenter()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_ROTATION_CENTER)); gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c5); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11b->gobj()), nv->snap_manager.snapprefs.getSnapTextBaseline()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_TEXT_BASELINE)); gtk_action_set_sensitive(GTK_ACTION(act11b->gobj()), c1 && c5); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.snapprefs.getSnapToPageBorder()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PAGE_BORDER)); gtk_action_set_sensitive(GTK_ACTION(act12->gobj()), c1); - //gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act13->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionGG()); - //gtk_action_set_sensitive(GTK_ACTION(act13->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act14->gobj()), nv->snap_manager.snapprefs.getSnapToGrids()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act14->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GRID)); gtk_action_set_sensitive(GTK_ACTION(act14->gobj()), c1); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act15->gobj()), nv->snap_manager.snapprefs.getSnapToGuides()); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act15->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_GUIDE)); gtk_action_set_sensitive(GTK_ACTION(act15->gobj()), c1); |
