summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ae1633d)
raw | patch | inline | side by side (parent: ae1633d)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sun, 4 May 2008 16:27:08 +0000 (16:27 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sun, 4 May 2008 16:27:08 +0000 (16:27 +0000) |
17 files changed:
diff --git a/src/attributes-test.h b/src/attributes-test.h
index b5c05e988fb4483235b6c8e8b2ac3edaa53ed9e4..c8287f76935945f8c4a7b0f52fbeae00fe252b9d 100644 (file)
--- a/src/attributes-test.h
+++ b/src/attributes-test.h
{"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 a8ecb872bfe977901a54fc560671978c917968f2..de505236f9819a144408edf23ace2d0c649808ad 100644 (file)
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
{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 8591258fe92ffdc7fa43ac253ab1a19849924f12..52694eda286a9d00f476af5cd56ff44cbccd4d46 100644 (file)
--- a/src/attributes.h
+++ b/src/attributes.h
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,
index 3ee00c9d1067a54fb04f3665deb2717ac6d47ba8..e08fc06d65a6a682caf72ff5558288851904fcb8 100644 (file)
#include "desktop.h"
#include "desktop-handles.h"
+#include "sp-namedview.h"
#include "display/sodipodi-ctrl.h"
#include "knot.h"
namespace Display {
SnapIndicator::SnapIndicator(SPDesktop * desktop)
- : tempitem(NULL),
- desktop(desktop)
+ : _tempitem(NULL),
+ _desktop(desktop)
{
}
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,
"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;
}
}
index 1e93e36df090671d2de1dc5c878e173a3dd72f65..1d291bcdf62265877049489a70c7fe7da8f1926f 100644 (file)
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 ee9ff657b53247ee38e2c8c85dc072f41ef6ae33..7489f9451531f7a38a5dd11195607691391a9450 100644 (file)
--- 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 efa6762b2a3d659c2d8740f9c518c3dd2135ea68..8fdf936ed84dbd8fcceaff92196be28871b2ee9a 100644 (file)
--- a/src/line-snapper.cpp
+++ b/src/line-snapper.cpp
// 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 57ec1b3479f550a7edf3308916be10f925d041cc..915b9eb0bc4dbbf52e71c40f57cee9e43f1e8439 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
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;
}
}
} 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;
}
}
// (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 3429dfd74e72b50a15d673b03ce9abb0f05dc1c1..8851470634a04e1a51893bfefd0ae23b11e615cd 100644 (file)
--- 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;
// 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 b6a5c2f9f5986f5b71692a808fad6a525cf26a80..be7b0e8711109913342b1ff4cce57475da564035 100644 (file)
--- a/src/snapped-line.cpp
+++ b/src/snapped-line.cpp
#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;
}
// 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 3616058b0cb0d6e8a9195d68230fb501c998e953..4713d962693e202d80790fa0f10d3ca54ae70e66 100644 (file)
--- a/src/snapped-line.h
+++ b/src/snapped-line.h
{
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
{
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:
}
-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 ae380b365871e8c28b98b3214206759a6e391f38..4e5ca836daa957905e84852a3616b946b1a077f2 100644 (file)
--- a/src/snapped-point.cpp
+++ b/src/snapped-point.cpp
#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;
_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);
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 309e322a6ed9600253c05c18b70f4e2ba5d5c4bc..3720319558768b3b11eeec328b7f2a2f07dd0a02 100644 (file)
--- a/src/snapped-point.h
+++ b/src/snapped-point.h
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;
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 ec0552653b76c3106575eb7eb431d6800a9a6680..a890f9754254f23743b9b83c3f9c1f0423b2ba95 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
* 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
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 f79a0fb429ac0de0be08432a9409f5e20cd2d18f..6055f5c71e8c45f0e90dfcdb5445509327c20d00 100644 (file)
--- a/src/sp-namedview.h
+++ b/src/sp-namedview.h
SnapManager snap_manager;
GSList * grids;
bool grids_visible;
+ bool snapindicator;
SPUnit const *doc_units;
index 6396a61038bf865e13193dfa63bf7f29bbac2099..519f795db1527929601125d5eaded7ff16fb5e2f 100644 (file)
_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"),
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>"));
Gtk::Widget *const array[] =
{
label_g, 0,
- 0, &_rcbsg,
+ 0, &_rcbs,
+ 0, &_rcbsi,
0, 0,
label_w, 0,
0, &_rcbsnn,
_rsu_gusn.setValue (nv->guidetolerance);
- _rcbsg.setActive (nv->snap_manager.getSnapEnabledGlobally());
+ _rcbs.setActive (nv->snap_manager.getSnapEnabledGlobally());
+ _rcbsi.setActive (nv->snapindicator);
//-----------------------------------------------------------grids page
index 6d6b77e5d40c9836fd1a20c941c053336dc0dd0f..a8750a32bfad6f42f0b2de1fb2c1667910b1f79c 100644 (file)
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;
//---------------------------------------------------------------