summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/2geom/sbasis-geometric.cpp2
-rw-r--r--src/attributes-test.h2
-rw-r--r--src/attributes.cpp2
-rw-r--r--src/attributes.h2
-rw-r--r--src/display/snap-indicator.cpp35
-rw-r--r--src/display/snap-indicator.h4
-rw-r--r--src/draw-context.cpp4
-rw-r--r--src/draw-context.h2
-rw-r--r--src/object-snapper.cpp28
-rw-r--r--src/pen-context.cpp6
-rw-r--r--src/pencil-context.cpp7
-rw-r--r--src/snap-candidate.h15
-rw-r--r--src/snap-enums.h2
-rw-r--r--src/snap-preferences.cpp5
-rw-r--r--src/snap.cpp24
-rw-r--r--src/snap.h8
-rw-r--r--src/sp-namedview.cpp10
-rw-r--r--src/ui/dialog/document-properties.cpp9
-rw-r--r--src/ui/dialog/document-properties.h2
-rw-r--r--src/widgets/toolbox.cpp8
20 files changed, 159 insertions, 18 deletions
diff --git a/src/2geom/sbasis-geometric.cpp b/src/2geom/sbasis-geometric.cpp
index f4b445faa..7d7ed23e4 100644
--- a/src/2geom/sbasis-geometric.cpp
+++ b/src/2geom/sbasis-geometric.cpp
@@ -749,7 +749,7 @@ Geom::cubics_with_prescribed_curvature(Point const &M0, Point const &M1,
* \brief returns all the parameter values of A whose tangent passes through P.
* \relates D2
*/
-std::vector<double> find_tangents(Point P, D2<SBasis> const &A) {
+std::vector<double> Geom::find_tangents(Point P, D2<SBasis> const &A) {
SBasis crs (cross(A - P, derivative(A)));
crs = shift(crs*Linear(-1, 0)*Linear(-1, 0), -2); // We know that there is a double root at t=0 so we divide out t^2
// JFB points out that this is equivalent to (t-1)^2 followed by a divide by s^2 (shift)
diff --git a/src/attributes-test.h b/src/attributes-test.h
index 02b53defc..ec2b0c6af 100644
--- a/src/attributes-test.h
+++ b/src/attributes-test.h
@@ -342,6 +342,8 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"sodipodi:version", false},
{"inkscape:version", true},
{"inkscape:object-paths", true},
+ {"inkscape:snap-path-clip", true},
+ {"inkscape:snap-path-mask", true},
{"inkscape:object-nodes", true},
{"inkscape:bbox-paths", true},
{"inkscape:bbox-nodes", true},
diff --git a/src/attributes.cpp b/src/attributes.cpp
index 4552adb63..34312ebe8 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -106,6 +106,8 @@ static SPStyleProp const props[] = {
{SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT, "inkscape:snap-bbox-midpoints"},
{SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION, "inkscape:snap-intersection-paths"},
{SP_ATTR_INKSCAPE_SNAP_PATH, "inkscape:object-paths"},
+ {SP_ATTR_INKSCAPE_SNAP_PATH_CLIP, "inkscape:snap-path-clip"},
+ {SP_ATTR_INKSCAPE_SNAP_PATH_MASK, "inkscape:snap-path-mask"},
{SP_ATTR_INKSCAPE_SNAP_NODE_CUSP, "inkscape:object-nodes"},
{SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE, "inkscape:bbox-paths"},
{SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER, "inkscape:bbox-nodes"},
diff --git a/src/attributes.h b/src/attributes.h
index 261871482..7a1dc559f 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -107,6 +107,8 @@ enum SPAttributeEnum {
SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT,
SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION,
SP_ATTR_INKSCAPE_SNAP_PATH,
+ SP_ATTR_INKSCAPE_SNAP_PATH_CLIP,
+ SP_ATTR_INKSCAPE_SNAP_PATH_MASK,
SP_ATTR_INKSCAPE_SNAP_NODE_CUSP,
SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE,
SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER,
diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp
index 0f31a24b9..72fdfbee7 100644
--- a/src/display/snap-indicator.cpp
+++ b/src/display/snap-indicator.cpp
@@ -105,6 +105,12 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap
case SNAPTARGET_PATH_GUIDE_INTERSECTION:
target_name = _("guide-path intersection");
break;
+ case SNAPTARGET_PATH_CLIP:
+ target_name = _("clip-path");
+ break;
+ case SNAPTARGET_PATH_MASK:
+ target_name = _("mask-path");
+ break;
case SNAPTARGET_BBOX_CORNER:
target_name = _("bounding box corner");
break;
@@ -326,6 +332,25 @@ SnapIndicator::set_new_snapsource(Inkscape::SnapCandidatePoint const &p)
}
void
+SnapIndicator::set_new_debugging_point(Geom::Point const &p)
+{
+ g_assert(_desktop != NULL);
+ SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (_desktop),
+ SP_TYPE_CTRL,
+ "anchor", GTK_ANCHOR_CENTER,
+ "size", 10.0,
+ "fill_color", 0x00ff00ff,
+ "stroked", FALSE,
+ "mode", SP_KNOT_MODE_XOR,
+ "shape", SP_KNOT_SHAPE_DIAMOND,
+ NULL );
+
+ SP_CTRL(canvasitem)->moveto(p);
+ _debugging_points.push_back(_desktop->add_temporary_canvasitem(canvasitem, 5000));
+
+}
+
+void
SnapIndicator::remove_snapsource()
{
if (_snapsource) {
@@ -334,6 +359,16 @@ SnapIndicator::remove_snapsource()
}
}
+void
+SnapIndicator::remove_debugging_points()
+{
+ for (std::list<TemporaryItem *>::const_iterator i = _debugging_points.begin(); i != _debugging_points.end(); i++) {
+ _desktop->remove_temporary_canvasitem(*i);
+ }
+ _debugging_points.clear();
+}
+
+
} //namespace Display
} /* namespace Inkscape */
diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h
index ff08a8a8c..da66d0033 100644
--- a/src/display/snap-indicator.h
+++ b/src/display/snap-indicator.h
@@ -34,11 +34,15 @@ public:
void set_new_snapsource(Inkscape::SnapCandidatePoint const &p);
void remove_snapsource();
+ void set_new_debugging_point(Geom::Point const &p);
+ void remove_debugging_points();
+
protected:
TemporaryItem *_snaptarget;
TemporaryItem *_snaptarget_tooltip;
TemporaryItem *_snaptarget_bbox;
TemporaryItem *_snapsource;
+ std::list<TemporaryItem *> _debugging_points;
bool _snaptarget_is_presnap;
SPDesktop *_desktop;
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index 5d324754f..ebc6e320f 100644
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
@@ -501,7 +501,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
}
-void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, guint const /*state*/)
+void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, boost::optional<Geom::Point> &start_point, guint const /*state*/)
{
SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(ec);
SnapManager &m = dt->namedview->snap_manager;
@@ -511,7 +511,7 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, gu
// TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment
m.setup(dt, true, selection->singleItem());
- m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
+ m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE, start_point);
m.unSetup();
}
diff --git a/src/draw-context.h b/src/draw-context.h
index 53114d820..a6762bed4 100644
--- a/src/draw-context.h
+++ b/src/draw-context.h
@@ -85,7 +85,7 @@ GType sp_draw_context_get_type(void);
SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p);
void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed);
void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o, guint state);
-void spdc_endpoint_snap_free(SPEventContext const *ec, Geom::Point &p, guint state);
+void spdc_endpoint_snap_free(SPEventContext const *ec, Geom::Point &p, boost::optional<Geom::Point> &start_point, guint state);
void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item);
void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state);
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 7e0961c95..b14415c47 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -78,6 +78,7 @@ bool Inkscape::ObjectSnapper::getSnapperAlwaysSnap() const
* \param parent Pointer to the document's root, or to a clipped path or mask object
* \param it List of items to ignore
* \param bbox_to_snap Bounding box hulling the whole bunch of points, all from the same selection and having the same transformation
+ * \param clip_or_mask The parent object being passed is either a clip or mask
*/
void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
@@ -88,7 +89,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
Geom::Affine const additional_affine) const // transformation of the item being clipped / masked
{
if (_snapmanager->getDesktop() == NULL) {
- g_warning("desktop == NULL, so we cannot snap; please inform the developpers of this bug");
+ g_warning("desktop == NULL, so we cannot snap; please inform the developers of this bug");
// Apparently the setup() method from the SnapManager class hasn't been called before trying to snap.
}
@@ -122,11 +123,11 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
// still be the subject of clipping or masking itself ; if so, then
// we should also consider that path or mask for snapping to
obj = SP_OBJECT(item->clip_ref->getObject());
- if (obj) {
+ if (obj && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_CLIP)) {
_findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine());
}
obj = SP_OBJECT(item->mask_ref->getObject());
- if (obj) {
+ if (obj && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_MASK)) {
_findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine());
}
}
@@ -506,6 +507,7 @@ void Inkscape::ObjectSnapper::_snapPaths(IntermSnapResults &isr,
bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping();
+ //_snapmanager->getDesktop()->snapindicator->remove_debugging_points();
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;
@@ -516,12 +518,14 @@ void Inkscape::ObjectSnapper::_snapPaths(IntermSnapResults &isr,
// n curves will return n time values with 0 <= t <= 1
std::vector<double> anp = (*it_pv).nearestPointPerCurve(p_doc);
+ //std::cout << "#nearest points = " << anp.size() << " | p = " << p.getPoint() << std::endl;
+ // Now we will examine each of the nearest points, and determine whether it's within snapping range and if we should snap to it
std::vector<double>::const_iterator np = anp.begin();
unsigned int index = 0;
for (; np != anp.end(); np++, index++) {
Geom::Curve const *curve = &((*it_pv).at_index(index));
Geom::Point const sp_doc = curve->pointAt(*np);
-
+ //_snapmanager->getDesktop()->snapindicator->set_new_debugging_point(sp_doc*_snapmanager->getDesktop()->doc2dt());
bool c1 = true;
bool c2 = true;
if (being_edited) {
@@ -546,9 +550,23 @@ void Inkscape::ObjectSnapper::_snapPaths(IntermSnapResults &isr,
Geom::Point const sp_dt = _snapmanager->getDesktop()->doc2dt(sp_doc);
if (!being_edited || (c1 && c2)) {
- Geom::Coord const dist = Geom::distance(sp_doc, p_doc);
+ Geom::Coord dist = Geom::distance(sp_doc, p_doc);
+ // std::cout << " dist -> " << dist << std::endl;
if (dist < getSnapperTolerance()) {
+ // Add the curve we have snapped to
isr.curves.push_back(SnappedCurve(sp_dt, num_path, index, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve, p.getSourceType(), p.getSourceNum(), it_p->target_type, it_p->target_bbox));
+ // Find all tangential points
+// boost::optional<Geom::Point> origin = p.getStartingPoint();
+// if (origin) {
+// Geom::Point origin_doc = _snapmanager->getDesktop()->dt2doc(*origin);
+// std::vector<double> atp = find_tangents(origin_doc, curve->toSBasis());
+// for (std::vector<double>::const_iterator t = atp.begin(); t != atp.end(); t++) {
+// Geom::Point const tp_doc = curve->pointAt(*t);
+// dist = Geom::distance(tp_doc, p_doc);
+// Geom::Point const tp_dt = _snapmanager->getDesktop()->doc2dt(tp_doc);
+// isr.points.push_back(SnappedPoint(tp_dt, p.getSourceType(), p.getSourceNum(), it_p->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, true, it_p->target_bbox));
+// }
+// }
}
}
}
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 19e0351a3..2be2fd87b 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -311,7 +311,8 @@ spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, guint const sta
pen_set_to_nearest_horiz_vert(pc, p, state, true);
} else {
// snap freely
- spdc_endpoint_snap_free(pc, p, state);
+ boost::optional<Geom::Point> origin = pc->npoints > 0 ? pc->p[0] : boost::optional<Geom::Point>();
+ spdc_endpoint_snap_free(pc, p, origin, state); // pass the origin, to allow for perpendicular / tangential snapping
}
}
}
@@ -329,7 +330,8 @@ spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint co
spdc_endpoint_snap_rotation(pc, p, pc->p[pc->npoints - 2], state);
} else {
if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
- spdc_endpoint_snap_free(pc, p, state);
+ boost::optional<Geom::Point> origin = pc->p[pc->npoints - 2];
+ spdc_endpoint_snap_free(pc, p, origin, state);
}
}
}
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index d823c1daa..d67833a91 100644
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -166,12 +166,15 @@ static void
spdc_endpoint_snap(SPPencilContext const *pc, Geom::Point &p, guint const state)
{
if ((state & GDK_CONTROL_MASK)) { //CTRL enables constrained snapping
- spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
+ if (pc->npoints > 0) {
+ spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
+ }
} else {
if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
//After all, the user explicitely asked for angular snapping by
//pressing CTRL
- spdc_endpoint_snap_free(pc, p, state);
+ boost::optional<Geom::Point> origin = pc->npoints > 0 ? pc->p[0] : boost::optional<Geom::Point>();
+ spdc_endpoint_snap_free(pc, p, origin, state);
}
}
}
diff --git a/src/snap-candidate.h b/src/snap-candidate.h
index 236f2497d..43082c010 100644
--- a/src/snap-candidate.h
+++ b/src/snap-candidate.h
@@ -31,6 +31,7 @@ public:
_source_num(source_num),
_target_bbox(bbox)
{
+ _line_starting_point = boost::optional<Geom::Point>();
};
SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, Inkscape::SnapTargetType const target)
@@ -40,6 +41,7 @@ public:
{
_source_num = -1;
_target_bbox = Geom::OptRect();
+ _line_starting_point = boost::optional<Geom::Point>();
}
SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source)
@@ -49,6 +51,17 @@ public:
_source_num(-1)
{
_target_bbox = Geom::OptRect();
+ _line_starting_point = boost::optional<Geom::Point>();
+ }
+
+ SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, boost::optional<Geom::Point> starting_point)
+ : _point(point),
+ _source_type(source),
+ _target_type(Inkscape::SNAPTARGET_UNDEFINED),
+ _source_num(-1)
+ {
+ _target_bbox = Geom::OptRect();
+ _line_starting_point = starting_point;
}
inline Geom::Point const & getPoint() const {return _point;}
@@ -58,10 +71,12 @@ public:
inline long getSourceNum() const {return _source_num;}
void setSourceNum(long num) {_source_num = num;}
inline Geom::OptRect const getTargetBBox() const {return _target_bbox;}
+ boost::optional<Geom::Point> const & getStartingPoint() const {return _line_starting_point;}
private:
// Coordinates of the point
Geom::Point _point;
+ boost::optional<Geom::Point> _line_starting_point; // For perpendicular or tangential snapping we need to know the starting point of a line
// If this SnapCandidatePoint is a snap source, then _source_type must be defined. If it
// is a snap target, then _target_type must be defined. If it's yet unknown whether it will
diff --git a/src/snap-enums.h b/src/snap-enums.h
index 5ade54354..d28f11314 100644
--- a/src/snap-enums.h
+++ b/src/snap-enums.h
@@ -70,6 +70,8 @@ enum SnapTargetType {
SNAPTARGET_PATH,
SNAPTARGET_PATH_INTERSECTION,
SNAPTARGET_PATH_GUIDE_INTERSECTION,
+ SNAPTARGET_PATH_CLIP,
+ SNAPTARGET_PATH_MASK,
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
//-------------------------------------------------------------------
diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp
index 250f38b90..b3a95877f 100644
--- a/src/snap-preferences.cpp
+++ b/src/snap-preferences.cpp
@@ -151,7 +151,6 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType
target = SNAPTARGET_PATH_INTERSECTION;
}
-
} else if (target & SNAPTARGET_DATUMS_CATEGORY) {
group_on = true; // These snap targets cannot be disabled as part of a disabled group;
switch (target) {
@@ -257,6 +256,8 @@ bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const
if (_active_snap_targets[index] == -1) {
// Catch coding errors
g_warning("Snap-preferences warning: Using an uninitialized snap target setting (#%i)", index);
+ // This happens if setTargetSnappable() has not been called for this parameter, e.g. from within sp_namedview_set,
+ // or if this target index doesn't exist at all
}
return _active_snap_targets[index];
}
@@ -292,6 +293,8 @@ bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType con
if (_active_snap_targets[index] == -1) {
// Catch coding errors
g_warning("Snap-preferences warning: Using an uninitialized snap target setting (#%i)", index);
+ // This happens if setTargetSnappable() has not been called for this parameter, e.g. from within sp_namedview_set,
+ // or if this target index doesn't exist at all
} 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];
diff --git a/src/snap.cpp b/src/snap.cpp
index fb6f120ec..56b48d507 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -180,6 +180,13 @@ void SnapManager::freeSnapReturnByRef(Geom::Point &p,
s.getPointIfSnapped(p);
}
+void SnapManager::freeSnapReturnByRef(Geom::Point &p,
+ Inkscape::SnapSourceType const source_type,
+ boost::optional<Geom::Point> &starting_point) const
+{
+ Inkscape::SnappedPoint const s = freeSnap(Inkscape::SnapCandidatePoint(p, source_type, starting_point), Geom::OptRect());
+ s.getPointIfSnapped(p);
+}
/**
* Try to snap a point to grids, guides or objects.
@@ -1136,6 +1143,23 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co
std::cout << " Curves : " << isr.curves.size()<< std::endl;
*/
+ /*
+ // Display all snap candidates on the canvas
+ _desktop->snapindicator->remove_debugging_points();
+ for (std::list<Inkscape::SnappedPoint>::const_iterator i = isr.points.begin(); i != isr.points.end(); i++) {
+ _desktop->snapindicator->set_new_debugging_point((*i).getPoint());
+ }
+ for (std::list<Inkscape::SnappedCurve>::const_iterator i = isr.curves.begin(); i != isr.curves.end(); i++) {
+ _desktop->snapindicator->set_new_debugging_point((*i).getPoint());
+ }
+ for (std::list<Inkscape::SnappedLine>::const_iterator i = isr.grid_lines.begin(); i != isr.grid_lines.end(); i++) {
+ _desktop->snapindicator->set_new_debugging_point((*i).getPoint());
+ }
+ for (std::list<Inkscape::SnappedLine>::const_iterator i = isr.guide_lines.begin(); i != isr.guide_lines.end(); i++) {
+ _desktop->snapindicator->set_new_debugging_point((*i).getPoint());
+ }
+ */
+
// Store all snappoints
std::list<Inkscape::SnappedPoint> sp_list;
diff --git a/src/snap.h b/src/snap.h
index 8fefa1cf2..41cbd0a02 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -114,8 +114,12 @@ public:
// freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a
// point if snapping has occurred (by overwriting p); otherwise p is untouched
void freeSnapReturnByRef(Geom::Point &p,
- Inkscape::SnapSourceType const source_type,
- Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const;
+ Inkscape::SnapSourceType const source_type,
+ Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const;
+
+ void freeSnapReturnByRef(Geom::Point &p,
+ Inkscape::SnapSourceType const source_type,
+ boost::optional<Geom::Point> &starting_point) const;
Inkscape::SnappedPoint freeSnap(Inkscape::SnapCandidatePoint const &p,
Geom::OptRect const &bbox_to_snap = Geom::OptRect() ) const;
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index e94a02265..c7d212d23 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -265,6 +265,8 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
object->readAttr( "inkscape:snap-grids" );
object->readAttr( "inkscape:snap-intersection-paths" );
object->readAttr( "inkscape:object-paths" );
+ object->readAttr( "inkscape:snap-path-clip" );
+ object->readAttr( "inkscape:snap-path-mask" );
object->readAttr( "inkscape:object-nodes" );
object->readAttr( "inkscape:bbox-paths" );
object->readAttr( "inkscape:bbox-nodes" );
@@ -515,6 +517,14 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
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_SNAP_PATH_CLIP:
+ nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_CLIP, value ? sp_str_to_bool(value) : FALSE);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_PATH_MASK:
+ nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_MASK, value ? sp_str_to_bool(value) : FALSE);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ break;
case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP:
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index d3123345b..9f8a99b1f 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -105,8 +105,10 @@ DocumentProperties::DocumentProperties()
_grids_label_crea("", Gtk::ALIGN_LEFT),
_grids_button_new(C_("Grid", "_New"), _("Create new grid.")),
_grids_button_remove(C_("Grid", "_Remove"), _("Remove selected grid.")),
- _grids_label_def("", Gtk::ALIGN_LEFT)
+ _grids_label_def("", Gtk::ALIGN_LEFT),
//---------------------------------------------------------------
+ _rcb_snclp(_("Snap to clip paths"), _("When snapping to paths, then also try snapping to clip paths"), "inkscape:snap-path-clip", _wr),
+ _rcb_snmsk(_("Snap to mask paths"), _("When snapping to paths, then also try snapping to mask paths"), "inkscape:snap-path-mask", _wr)
{
_tt.enable();
_getContents()->set_spacing (4);
@@ -292,6 +294,8 @@ DocumentProperties::build_snap()
{
label_o, 0,
0, _rsu_sno._vbox,
+ 0, &_rcb_snclp,
+ 0, &_rcb_snmsk,
0, 0,
label_gr, 0,
0, _rsu_sn._vbox,
@@ -1018,7 +1022,8 @@ void DocumentProperties::update()
_rsu_sno.setValue (nv->snap_manager.snapprefs.getObjectTolerance());
_rsu_sn.setValue (nv->snap_manager.snapprefs.getGridTolerance());
_rsu_gusn.setValue (nv->snap_manager.snapprefs.getGuideTolerance());
-
+ _rcb_snclp.setActive (nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_CLIP));
+ _rcb_snmsk.setActive (nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_MASK));
//-----------------------------------------------------------grids page
diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h
index 261287877..8f922d6fd 100644
--- a/src/ui/dialog/document-properties.h
+++ b/src/ui/dialog/document-properties.h
@@ -112,6 +112,8 @@ protected:
UI::Widget::ToleranceSlider _rsu_sno;
UI::Widget::ToleranceSlider _rsu_sn;
UI::Widget::ToleranceSlider _rsu_gusn;
+ UI::Widget::RegisteredCheckButton _rcb_snclp;
+ UI::Widget::RegisteredCheckButton _rcb_snmsk;
//---------------------------------------------------------------
Gtk::Menu _menu;
Gtk::OptionMenu _combo_avail;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 6ec393c2c..afd066b37 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -2153,6 +2153,14 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH);
sp_repr_set_boolean(repr, "inkscape:object-paths", !v);
break;
+ case SP_ATTR_INKSCAPE_SNAP_PATH_CLIP:
+ v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_CLIP);
+ sp_repr_set_boolean(repr, "inkscape:snap-path-clip", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_PATH_MASK:
+ v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_MASK);
+ sp_repr_set_boolean(repr, "inkscape:snap-path-mask", !v);
+ break;
case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP:
v = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP);
sp_repr_set_boolean(repr, "inkscape:object-nodes", !v);