summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/attributes-test.h1
-rw-r--r--src/attributes.cpp1
-rw-r--r--src/attributes.h1
-rw-r--r--src/display/snap-indicator.cpp29
-rw-r--r--src/display/snap-indicator.h6
-rw-r--r--src/gradient-drag.cpp4
-rw-r--r--src/line-snapper.cpp4
-rw-r--r--src/object-snapper.cpp8
-rw-r--r--src/snap.cpp15
-rw-r--r--src/snapped-line.cpp24
-rw-r--r--src/snapped-line.h14
-rw-r--r--src/snapped-point.cpp9
-rw-r--r--src/snapped-point.h27
-rw-r--r--src/sp-namedview.cpp8
-rw-r--r--src/sp-namedview.h1
-rw-r--r--src/ui/dialog/document-properties.cpp12
-rw-r--r--src/ui/dialog/document-properties.h2
17 files changed, 107 insertions, 59 deletions
diff --git a/src/attributes-test.h b/src/attributes-test.h
index b5c05e988..c8287f769 100644
--- a/src/attributes-test.h
+++ b/src/attributes-test.h
@@ -347,6 +347,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"inkscape:bbox-nodes", true},
{"inkscape:snap-page", true},
{"inkscape:snap-global", true},
+ {"inkscape:snap-indicator", true},
{"inkscape:snap-bbox", true},
{"inkscape:snap-nodes", true},
{"inkscape:snap-guide", true},
diff --git a/src/attributes.cpp b/src/attributes.cpp
index a8ecb872b..de505236f 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -86,6 +86,7 @@ static SPStyleProp const props[] = {
{SP_ATTR_INKSCAPE_WINDOW_X, "inkscape:window-x"},
{SP_ATTR_INKSCAPE_WINDOW_Y, "inkscape:window-y"},
{SP_ATTR_INKSCAPE_SNAP_GLOBAL, "inkscape:snap-global"},
+ {SP_ATTR_INKSCAPE_SNAP_INDICATOR, "inkscape:snap-indicator"},
{SP_ATTR_INKSCAPE_SNAP_BBOX, "inkscape:snap-bbox"},
{SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"},
{SP_ATTR_INKSCAPE_SNAP_GUIDE, "inkscape:snap-guide"},
diff --git a/src/attributes.h b/src/attributes.h
index 8591258fe..52694eda2 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -86,6 +86,7 @@ enum SPAttributeEnum {
SP_ATTR_INKSCAPE_WINDOW_X,
SP_ATTR_INKSCAPE_WINDOW_Y,
SP_ATTR_INKSCAPE_SNAP_GLOBAL,
+ SP_ATTR_INKSCAPE_SNAP_INDICATOR,
SP_ATTR_INKSCAPE_SNAP_BBOX,
SP_ATTR_INKSCAPE_SNAP_NODES,
SP_ATTR_INKSCAPE_SNAP_GUIDE,
diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp
index 3ee00c9d1..e08fc06d6 100644
--- a/src/display/snap-indicator.cpp
+++ b/src/display/snap-indicator.cpp
@@ -15,6 +15,7 @@
#include "desktop.h"
#include "desktop-handles.h"
+#include "sp-namedview.h"
#include "display/sodipodi-ctrl.h"
#include "knot.h"
@@ -22,8 +23,8 @@ namespace Inkscape {
namespace Display {
SnapIndicator::SnapIndicator(SPDesktop * desktop)
- : tempitem(NULL),
- desktop(desktop)
+ : _tempitem(NULL),
+ _desktop(desktop)
{
}
@@ -37,11 +38,16 @@ void
SnapIndicator::set_new_snappoint(Inkscape::SnappedPoint const p)
{
remove_snappoint();
-
- bool enabled = true; // TODO add preference for snap indicator.
- if (enabled) {
+
+ g_assert(_desktop != NULL);
+ SPNamedView *nv = sp_desktop_namedview(_desktop);
+
+ if (nv->snapindicator) {
// TODO add many different kinds of snap indicator :-)
- SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (desktop),
+ // For this we should use p->getTarget() to find out what has snapped
+ // and adjust the shape of the snapindicator accordingly, e.g. a cross
+ // when snapping to an intersection, a circle when snapping to a node, etc.
+ SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (_desktop),
SP_TYPE_CTRL,
"anchor", GTK_ANCHOR_CENTER,
"size", 10.0,
@@ -49,20 +55,19 @@ SnapIndicator::set_new_snappoint(Inkscape::SnappedPoint const p)
"stroke_color", 0xf000f0ff,
"mode", SP_KNOT_MODE_XOR,
"shape", SP_KNOT_SHAPE_CROSS,
- NULL );
-
+ NULL );
SP_CTRL(canvasitem)->moveto(p.getPoint());
- tempitem = desktop->add_temporary_canvasitem(canvasitem, 1000); // TODO add preference for snap indicator timeout
+ _tempitem = _desktop->add_temporary_canvasitem(canvasitem, 1000); // TODO add preference for snap indicator timeout
}
}
void
SnapIndicator::remove_snappoint()
{
- if (tempitem) {
- desktop->remove_temporary_canvasitem(tempitem);
- tempitem = NULL;
+ if (_tempitem) {
+ _desktop->remove_temporary_canvasitem(_tempitem);
+ _tempitem = NULL;
}
}
diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h
index 1e93e36df..1d291bcdf 100644
--- a/src/display/snap-indicator.h
+++ b/src/display/snap-indicator.h
@@ -28,10 +28,10 @@ public:
void set_new_snappoint(Inkscape::SnappedPoint const p);
void remove_snappoint();
-
+
protected:
- TemporaryItem * tempitem;
- SPDesktop *desktop;
+ TemporaryItem *_tempitem;
+ SPDesktop *_desktop;
private:
SnapIndicator(const SnapIndicator&);
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index ee9ff657b..7489f9451 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -593,7 +593,7 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi
dist = fabs(p[NR::Y] - dragger->parent->hor_levels[i]);
if (dist < snap_dist) {
p[NR::Y] = dragger->parent->hor_levels[i];
- s = Inkscape::SnappedPoint(p, dist, snap_dist, false);
+ s = Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_GRADIENT, dist, snap_dist, false);
was_snapped = true;
sp_knot_moveto (knot, &p);
}
@@ -602,7 +602,7 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi
dist = fabs(p[NR::X] - dragger->parent->vert_levels[i]);
if (dist < snap_dist) {
p[NR::X] = dragger->parent->vert_levels[i];
- s = Inkscape::SnappedPoint(p, dist, snap_dist, false);
+ s = Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_GRADIENT, dist, snap_dist, false);
was_snapped = true;
sp_knot_moveto (knot, &p);
}
diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp
index efa6762b2..8fdf936ed 100644
--- a/src/line-snapper.cpp
+++ b/src/line-snapper.cpp
@@ -97,7 +97,9 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
// This snappoint is therefore fully constrained, so there's no need
// to look for additional intersections; just return the snapped point
// and forget about the line
- sc.points.push_back(SnappedPoint(t, dist, getSnapperTolerance(), getSnapperAlwaysSnap()));
+ sc.points.push_back(SnappedPoint(t, Inkscape::SNAPTARGET_UNDEFINED, dist, getSnapperTolerance(), getSnapperAlwaysSnap()));
+ // The type of the snap target is yet undefined, as we cannot tell whether
+ // we're snapping to grid or the guide lines; must be set by on a higher level
}
}
}
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 57ec1b347..915b9eb0b 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -193,7 +193,7 @@ void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc,
for (std::vector<NR::Point>::const_iterator k = _points_to_snap_to->begin(); k != _points_to_snap_to->end(); k++) {
NR::Coord dist = NR::L2(*k - p);
if (dist < getSnapperTolerance() && dist < s.getDistance()) {
- s = SnappedPoint(*k, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
+ s = SnappedPoint(*k, SNAPTARGET_NODE, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
success = true;
}
}
@@ -222,7 +222,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &s
NR::Coord dist = NR::L2(*k - p_proj); // distance from node to the guide
NR::Coord dist2 = NR::L2(p - p_proj); // distance from projection of node on the guide, to the mouse location
if ((dist < tol && dist2 < tol || getSnapperAlwaysSnap()) && dist < s.getDistance()) {
- s = SnappedPoint(*k, dist, tol, getSnapperAlwaysSnap());
+ s = SnappedPoint(*k, SNAPTARGET_NODE, dist, tol, getSnapperAlwaysSnap());
success = true;
}
}
@@ -435,7 +435,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
} else {
// for segments other than straight lines of a path, we'll return just the closest snapped point
if (dist < s.getDistance()) {
- s = SnappedPoint(o_dt, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
+ s = SnappedPoint(o_dt, SNAPTARGET_PATH, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
success = true;
}
}
@@ -529,7 +529,7 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
// (within snapping range == between p_min_on_cl and p_max_on_cl == 0 < tb < 1)
if ((*m).tb >= 0 && (*m).tb <= 1 ) {
NR::Coord dist = NR::L2(desktop->dt2doc(p_proj_on_cl) - p_inters);
- SnappedPoint s(desktop->doc2dt(p_inters), dist, getSnapperTolerance(), getSnapperAlwaysSnap());
+ SnappedPoint s(desktop->doc2dt(p_inters), SNAPTARGET_PATH, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
sc.points.push_back(s);
}
}
diff --git a/src/snap.cpp b/src/snap.cpp
index 3429dfd74..885147063 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -185,7 +185,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_
NR::Maybe<NR::Rect> const &bbox_to_snap) const
{
if (!SomeSnapperMightSnap()) {
- return Inkscape::SnappedPoint(p, NR_HUGE, 0, false);
+ return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false);
}
std::vector<SPItem const *> *items_to_ignore;
@@ -231,7 +231,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::Snapper::PointType
NR::Maybe<NR::Rect> const &bbox_to_snap) const
{
if (!SomeSnapperMightSnap()) {
- return Inkscape::SnappedPoint(p, NR_HUGE, 0, false);
+ return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false);
}
std::vector<SPItem const *> *items_to_ignore;
@@ -263,7 +263,7 @@ Inkscape::SnappedPoint SnapManager::guideSnap(NR::Point const &p,
// This method is used to snap a guide to nodes, while dragging the guide around
if (!(object.GuidesMightSnap() && _snap_enabled_globally)) {
- return Inkscape::SnappedPoint(p, NR_HUGE, 0, false);
+ return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false);
}
SnappedConstraints sc;
@@ -699,12 +699,14 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(NR::Point const &p, SnappedCons
// search for the closest snapped grid line
Inkscape::SnappedLine closestGridLine;
if (getClosestSL(sc.grid_lines, closestGridLine)) {
+ closestGridLine.setTarget(Inkscape::SNAPTARGET_GRID);
sp_list.push_back(Inkscape::SnappedPoint(closestGridLine));
}
// search for the closest snapped guide line
Inkscape::SnappedLine closestGuideLine;
if (getClosestSL(sc.guide_lines, closestGuideLine)) {
+ closestGuideLine.setTarget(Inkscape::SNAPTARGET_GUIDE);
sp_list.push_back(Inkscape::SnappedPoint(closestGuideLine));
}
@@ -718,12 +720,14 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(NR::Point const &p, SnappedCons
// search for the closest snapped intersection of grid lines
Inkscape::SnappedPoint closestGridPoint;
if (getClosestIntersectionSL(sc.grid_lines, closestGridPoint)) {
+ closestGridPoint.setTarget(Inkscape::SNAPTARGET_GRID_INTERSECTION);
sp_list.push_back(closestGridPoint);
}
// search for the closest snapped intersection of guide lines
Inkscape::SnappedPoint closestGuidePoint;
if (getClosestIntersectionSL(sc.guide_lines, closestGuidePoint)) {
+ closestGuidePoint.setTarget(Inkscape::SNAPTARGET_GUIDE_INTERSECTION);
sp_list.push_back(closestGuidePoint);
}
@@ -731,13 +735,14 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(NR::Point const &p, SnappedCons
if (_intersectionGG) {
Inkscape::SnappedPoint closestGridGuidePoint;
if (getClosestIntersectionSL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) {
- sp_list.push_back(closestGridGuidePoint);
+ closestGridGuidePoint.setTarget(Inkscape::SNAPTARGET_GRID_GUIDE_INTERSECTION);
+ sp_list.push_back(closestGridGuidePoint);
}
}
}
// now let's see which snapped point gets a thumbs up
- Inkscape::SnappedPoint bestSnappedPoint = Inkscape::SnappedPoint(p, NR_HUGE, 0, false);
+ Inkscape::SnappedPoint bestSnappedPoint = Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false);
for (std::list<Inkscape::SnappedPoint>::const_iterator i = sp_list.begin(); i != sp_list.end(); i++) {
// first find out if this snapped point is within snapping range
if ((*i).getDistance() <= (*i).getTolerance()) {
diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp
index b6a5c2f9f..be7b0e871 100644
--- a/src/snapped-line.cpp
+++ b/src/snapped-line.cpp
@@ -12,7 +12,7 @@
#include <2geom/geom.h>
#include "libnr/nr-values.h"
-Inkscape::SnappedLineSegment::SnappedLineSegment(NR::Point snapped_point, NR::Coord snapped_distance, NR::Coord snapped_tolerance, bool always_snap, NR::Point start_point_of_line, NR::Point end_point_of_line)
+Inkscape::SnappedLineSegment::SnappedLineSegment(NR::Point const &snapped_point, NR::Coord const &snapped_distance, NR::Coord const &snapped_tolerance, bool const &always_snap, NR::Point const &start_point_of_line, NR::Point const &end_point_of_line)
: _start_point_of_line(start_point_of_line), _end_point_of_line(end_point_of_line)
{
_point = snapped_point;
@@ -67,17 +67,17 @@ Inkscape::SnappedPoint Inkscape::SnappedLineSegment::intersect(SnappedLineSegmen
bool const use_this_as_primary = c1 || c2;
Inkscape::SnappedLineSegment const *primarySLS = use_this_as_primary ? this : &line;
Inkscape::SnappedLineSegment const *secondarySLS = use_this_as_primary ? &line : this;
- return SnappedPoint(intersection, primarySLS->getDistance(), primarySLS->getTolerance(), primarySLS->getAlwaysSnap(), true,
+ return SnappedPoint(intersection, SNAPTARGET_PATH_INTERSECTION, primarySLS->getDistance(), primarySLS->getTolerance(), primarySLS->getAlwaysSnap(), true,
secondarySLS->getDistance(), secondarySLS->getTolerance(), secondarySLS->getAlwaysSnap());
}
// No intersection
- return SnappedPoint(intersection, NR_HUGE, 0, false, false, NR_HUGE, 0, false);
+ return SnappedPoint(intersection, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, NR_HUGE, 0, false);
};
-Inkscape::SnappedLine::SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Coord snapped_tolerance, bool always_snap, NR::Point normal_to_line, NR::Point point_on_line)
+Inkscape::SnappedLine::SnappedLine(NR::Point const &snapped_point, NR::Coord const &snapped_distance, NR::Coord const &snapped_tolerance, bool const &always_snap, NR::Point const &normal_to_line, NR::Point const &point_on_line)
: _normal_to_line(normal_to_line), _point_on_line(point_on_line)
{
_distance = snapped_distance;
@@ -142,16 +142,18 @@ Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line)
bool const use_this_as_primary = c1 || c2;
Inkscape::SnappedLine const *primarySL = use_this_as_primary ? this : &line;
Inkscape::SnappedLine const *secondarySL = use_this_as_primary ? &line : this;
- return SnappedPoint(intersection, primarySL->getDistance(), primarySL->getTolerance(), primarySL->getAlwaysSnap(), true,
+ return SnappedPoint(intersection, Inkscape::SNAPTARGET_UNDEFINED, primarySL->getDistance(), primarySL->getTolerance(), primarySL->getAlwaysSnap(), true,
secondarySL->getDistance(), secondarySL->getTolerance(), secondarySL->getAlwaysSnap());
+ // The type of the snap target is yet undefined, as we cannot tell whether
+ // we're snapping to grid or the guide lines; must be set by on a higher level
}
// No intersection
- return SnappedPoint(intersection, NR_HUGE, 0, false, false, NR_HUGE, 0, false);
+ return SnappedPoint(intersection, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, NR_HUGE, 0, false);
}
// search for the closest snapped line segment
-bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> &list, Inkscape::SnappedLineSegment &result)
+bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedLineSegment &result)
{
bool success = false;
@@ -166,7 +168,7 @@ bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> &list, Inkscape::Snap
}
// search for the closest intersection of two snapped line segments, which are both member of the same collection
-bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> &list, Inkscape::SnappedPoint &result)
+bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedPoint &result)
{
bool success = false;
@@ -196,7 +198,7 @@ bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> &list, In
}
// search for the closest snapped line
-bool getClosestSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedLine &result)
+bool getClosestSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedLine &result)
{
bool success = false;
@@ -211,7 +213,7 @@ bool getClosestSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedLine
}
// search for the closest intersection of two snapped lines, which are both member of the same collection
-bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedPoint &result)
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedPoint &result)
{
bool success = false;
@@ -241,7 +243,7 @@ bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list, Inkscape::
}
// search for the closest intersection of two snapped lines, which are in two different collections
-bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list1, std::list<Inkscape::SnappedLine> &list2, Inkscape::SnappedPoint &result)
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list1, std::list<Inkscape::SnappedLine> const &list2, Inkscape::SnappedPoint &result)
{
bool success = false;
diff --git a/src/snapped-line.h b/src/snapped-line.h
index 3616058b0..4713d9626 100644
--- a/src/snapped-line.h
+++ b/src/snapped-line.h
@@ -26,7 +26,7 @@ class SnappedLineSegment : public SnappedPoint
{
public:
SnappedLineSegment();
- SnappedLineSegment(NR::Point snapped_point, NR::Coord snapped_distance, NR::Coord snapped_tolerance, bool always_snap, NR::Point start_point_of_line, NR::Point end_point_of_line);
+ SnappedLineSegment(NR::Point const &snapped_point, NR::Coord const &snapped_distance, NR::Coord const &snapped_tolerance, bool const &always_snap, NR::Point const &start_point_of_line, NR::Point const &end_point_of_line);
~SnappedLineSegment();
Inkscape::SnappedPoint intersect(SnappedLineSegment const &line) const; //intersect with another SnappedLineSegment
@@ -41,7 +41,7 @@ class SnappedLine : public SnappedPoint
{
public:
SnappedLine();
- SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Coord snapped_tolerance, bool always_snap, NR::Point normal_to_line, NR::Point point_on_line);
+ SnappedLine(NR::Point const &snapped_point, NR::Coord const &snapped_distance, NR::Coord const &snapped_tolerance, bool const &always_snap, NR::Point const &normal_to_line, NR::Point const &point_on_line);
~SnappedLine();
Inkscape::SnappedPoint intersect(SnappedLine const &line) const; //intersect with another SnappedLine
// This line is described by this equation:
@@ -57,11 +57,11 @@ private:
}
-bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> &list, Inkscape::SnappedLineSegment &result);
-bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> &list, Inkscape::SnappedPoint &result);
-bool getClosestSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedLine &result);
-bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedPoint &result);
-bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list1, std::list<Inkscape::SnappedLine> &list2, Inkscape::SnappedPoint &result);
+bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedLineSegment &result);
+bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedPoint &result);
+bool getClosestSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedLine &result);
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedPoint &result);
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list1, std::list<Inkscape::SnappedLine> const &list2, Inkscape::SnappedPoint &result);
#endif /* !SEEN_SNAPPEDLINE_H */
diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp
index ae380b365..4e5ca836d 100644
--- a/src/snapped-point.cpp
+++ b/src/snapped-point.cpp
@@ -12,8 +12,8 @@
#include "snapped-point.h"
// overloaded constructor
-Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool a)
- : _point(p), _distance(d), _tolerance(t), _always_snap(a)
+Inkscape::SnappedPoint::SnappedPoint(NR::Point const &p, SnapTargetType const &target, NR::Coord const &d, NR::Coord const &t, bool const &a)
+ : _point(p), _target(target), _distance(d), _tolerance(t), _always_snap(a)
{
_at_intersection = false;
_second_distance = NR_HUGE;
@@ -22,8 +22,8 @@ Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool
_transformation = NR::Point(1,1);
}
-Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool a, bool at_intersection, NR::Coord d2, NR::Coord t2, bool a2)
- : _point(p), _at_intersection(at_intersection), _distance(d), _tolerance(t), _always_snap(a),
+Inkscape::SnappedPoint::SnappedPoint(NR::Point const &p, SnapTargetType const &target, NR::Coord const &d, NR::Coord const &t, bool const &a, bool const &at_intersection, NR::Coord const &d2, NR::Coord const &t2, bool const &a2)
+ : _point(p), _target(target), _at_intersection(at_intersection), _distance(d), _tolerance(t), _always_snap(a),
_second_distance(d2), _second_tolerance(t2), _second_always_snap(a2)
{
_transformation = NR::Point(1,1);
@@ -32,6 +32,7 @@ Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool
Inkscape::SnappedPoint::SnappedPoint()
{
_point = NR::Point(0,0);
+ _target = SNAPTARGET_UNDEFINED,
_distance = NR_HUGE;
_tolerance = 0;
_always_snap = false;
diff --git a/src/snapped-point.h b/src/snapped-point.h
index 309e322a6..372031955 100644
--- a/src/snapped-point.h
+++ b/src/snapped-point.h
@@ -20,18 +20,34 @@
namespace Inkscape
{
+
+enum SnapTargetType {
+ SNAPTARGET_UNDEFINED,
+ SNAPTARGET_GRID,
+ SNAPTARGET_GRID_INTERSECTION,
+ SNAPTARGET_GUIDE,
+ SNAPTARGET_GUIDE_INTERSECTION,
+ SNAPTARGET_GRID_GUIDE_INTERSECTION,
+ SNAPTARGET_NODE,
+ SNAPTARGET_PATH,
+ SNAPTARGET_PATH_INTERSECTION,
+ SNAPTARGET_BBOX_CORNER,
+ SNAPTARGET_BBOX_EDGE,
+ SNAPTARGET_GRADIENT
+};
/// Class describing the result of an attempt to snap.
class SnappedPoint
{
+
public:
SnappedPoint();
- SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool a, bool at_intersection, NR::Coord d2, NR::Coord t2, bool a2);
- SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool a);
+ SnappedPoint(NR::Point const &p, SnapTargetType const &target, NR::Coord const &d, NR::Coord const &t, bool const &a, bool const &at_intersection, NR::Coord const &d2, NR::Coord const &t2, bool const &a2);
+ SnappedPoint(NR::Point const &p, SnapTargetType const &target, NR::Coord const &d, NR::Coord const &t, bool const &a);
~SnappedPoint();
NR::Coord getDistance() const;
- void setDistance(NR::Coord d) {_distance = d;}
+ void setDistance(NR::Coord const d) {_distance = d;}
NR::Coord getTolerance() const;
bool getAlwaysSnap() const;
NR::Coord getSecondDistance() const;
@@ -41,10 +57,13 @@ public:
bool getAtIntersection() const {return _at_intersection;}
bool getSnapped() const {return _distance < NR_HUGE;}
NR::Point getTransformation() const {return _transformation;}
- void setTransformation(NR::Point t) {_transformation = t;}
+ void setTransformation(NR::Point const t) {_transformation = t;}
+ void setTarget(SnapTargetType const target) {_target = target;}
+ SnapTargetType getTarget() {return _target;}
protected:
NR::Point _point; // Location of the snapped point
+ SnapTargetType _target; // Describes to what we've snapped to
bool _at_intersection; // If true, the snapped point is at an intersection
/* Distance from original point to snapped point. If the snapped point is at
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index ec0552653..a890f9754 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -8,7 +8,7 @@
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
- * Copyright (C) 1999-2005 Authors
+ * Copyright (C) 1999-2008 Authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -114,6 +114,7 @@ static void sp_namedview_init(SPNamedView *nv)
nv->guides = NULL;
nv->viewcount = 0;
nv->grids = NULL;
+ nv->snapindicator = false;
nv->default_layer_id = 0;
@@ -246,6 +247,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
sp_object_read_attr(object, "inkscape:window-x");
sp_object_read_attr(object, "inkscape:window-y");
sp_object_read_attr(object, "inkscape:snap-global");
+ sp_object_read_attr(object, "inkscape:snap-indicator");
sp_object_read_attr(object, "inkscape:snap-bbox");
sp_object_read_attr(object, "inkscape:snap-nodes");
sp_object_read_attr(object, "inkscape:snap-guide");
@@ -456,6 +458,10 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
nv->snap_manager.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
+ case SP_ATTR_INKSCAPE_SNAP_INDICATOR:
+ nv->snapindicator = (value) ? sp_str_to_bool (value) : FALSE;
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ break;
case SP_ATTR_INKSCAPE_SNAP_BBOX:
nv->snap_manager.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
diff --git a/src/sp-namedview.h b/src/sp-namedview.h
index f79a0fb42..6055f5c71 100644
--- a/src/sp-namedview.h
+++ b/src/sp-namedview.h
@@ -52,6 +52,7 @@ struct SPNamedView : public SPObjectGroup {
SnapManager snap_manager;
GSList * grids;
bool grids_visible;
+ bool snapindicator;
SPUnit const *doc_units;
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index 6396a6103..519f795db 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -100,7 +100,8 @@ DocumentProperties::DocumentProperties()
_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),
//---------------------------------------------------------------
- _rcbsg(_("_Enable snapping"), _("Toggle snapping on or off"), "inkscape:snap-global", _wr),
+ _rcbs(_("_Enable snapping"), _("Toggle snapping on or off"), "inkscape:snap-global", _wr),
+ _rcbsi(_("_Enable snap indicator"), _("After snapping, a symbol is drawn at the point that has snapped"), "inkscape:snap-indicator", _wr),
_rcbsnbb(_("_Bounding box corners"), _("Only available in the selector tool: snap bounding box corners to guides, to grids, and to other bounding boxes (but not to nodes or paths)"),
"inkscape:snap-bbox", _wr),
_rcbsnn(_("_Nodes"), _("Snap nodes (e.g. path nodes, special points in shapes, gradient handles, text base points, transformation origins, etc.) to guides, to grids, to paths and to other nodes"),
@@ -306,8 +307,9 @@ DocumentProperties::build_snap()
slaves.clear();
slaves.push_back(&_rcbsnn);
slaves.push_back(&_rcbsnbb);
+ slaves.push_back(&_rcbsi);
- _rcbsg.setSlaveWidgets(slaves);
+ _rcbs.setSlaveWidgets(slaves);
Gtk::Label *label_g = manage (new Gtk::Label);
label_g->set_markup (_("<b>Snapping</b>"));
@@ -323,7 +325,8 @@ DocumentProperties::build_snap()
Gtk::Widget *const array[] =
{
label_g, 0,
- 0, &_rcbsg,
+ 0, &_rcbs,
+ 0, &_rcbsi,
0, 0,
label_w, 0,
0, &_rcbsnn,
@@ -504,7 +507,8 @@ DocumentProperties::update()
_rsu_gusn.setValue (nv->guidetolerance);
- _rcbsg.setActive (nv->snap_manager.getSnapEnabledGlobally());
+ _rcbs.setActive (nv->snap_manager.getSnapEnabledGlobally());
+ _rcbsi.setActive (nv->snapindicator);
//-----------------------------------------------------------grids page
diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h
index 6d6b77e5d..a8750a32b 100644
--- a/src/ui/dialog/document-properties.h
+++ b/src/ui/dialog/document-properties.h
@@ -74,7 +74,7 @@ protected:
RegisteredCheckButton _rcb_sgui, _rcbsng;
RegisteredColorPicker _rcp_gui, _rcp_hgui;
//---------------------------------------------------------------
- RegisteredCheckButton _rcbsg, _rcbsnbb, _rcbsnn, _rcbsnop;
+ RegisteredCheckButton _rcbs, _rcbsi, _rcbsnbb, _rcbsnn, _rcbsnop;
RegisteredCheckButton _rcbsnon, _rcbsnbbp, _rcbsnbbn, _rcbsnpb;
ToleranceSlider _rsu_sno, _rsu_sn, _rsu_gusn;
//---------------------------------------------------------------