summaryrefslogtreecommitdiffstats
path: root/src/nodepath.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-01-14 08:13:09 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-01-14 08:13:09 +0000
commit7f7da4643d6909af5cd58b2f24846774e3af509b (patch)
tree1fec13b3616ecc90fb251bb9e643aefc43c80c43 /src/nodepath.cpp
parentSome additional docs (diff)
parentInitial cut of disabling floating windows on window managers with problems. (diff)
downloadinkscape-7f7da4643d6909af5cd58b2f24846774e3af509b.tar.gz
inkscape-7f7da4643d6909af5cd58b2f24846774e3af509b.zip
* Merge from trunk
* Update to new snapping API * Modify the join action slightly (bzr r8846.2.11)
Diffstat (limited to 'src/nodepath.cpp')
-rw-r--r--src/nodepath.cpp74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 36e4e0d8c..488642cb2 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -1367,13 +1367,13 @@ static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath,
* must provide that information. */
// Build a list of the unselected nodes to which the snapper should snap
- std::vector<std::pair<Geom::Point, int> > unselected_nodes;
+ std::vector<Inkscape::SnapCandidatePoint> unselected_nodes;
for (GList *spl = nodepath->subpaths; spl != NULL; spl = spl->next) {
Inkscape::NodePath::SubPath *subpath = (Inkscape::NodePath::SubPath *) spl->data;
for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) {
Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data;
if (!node->selected) {
- unselected_nodes.push_back(std::make_pair(to_2geom(node->pos), node->type == Inkscape::NodePath::NODE_SMOOTH ? Inkscape::SNAPTARGET_NODE_SMOOTH : Inkscape::SNAPTARGET_NODE_CUSP));
+ unselected_nodes.push_back(Inkscape::SnapCandidatePoint(node->pos, Inkscape::SNAPSOURCE_UNDEFINED, node->type == Inkscape::NodePath::NODE_SMOOTH ? Inkscape::SNAPTARGET_NODE_SMOOTH : Inkscape::SNAPTARGET_NODE_CUSP));
}
}
}
@@ -1388,39 +1388,39 @@ static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath,
Inkscape::NodePath::Node *closest_node = NULL;
Geom::Coord closest_dist = NR_HUGE;
- if (closest_only) {
- for (GList *l = nodepath->selected; l != NULL; l = l->next) {
- Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
- Geom::Coord dist = Geom::L2(nodepath->drag_origin_mouse - n->origin);
- if (dist < closest_dist) {
- closest_node = n;
- closest_dist = dist;
- }
- }
+ if (closest_only) {
+ for (GList *l = nodepath->selected; l != NULL; l = l->next) {
+ Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
+ Geom::Coord dist = Geom::L2(nodepath->drag_origin_mouse - n->origin);
+ if (dist < closest_dist) {
+ closest_node = n;
+ closest_dist = dist;
+ }
+ }
}
- // Iterate through all selected nodes
- m.setup(nodepath->desktop, false, nodepath->item, &unselected_nodes);
- for (GList *l = nodepath->selected; l != NULL; l = l->next) {
+ // Iterate through all selected nodes
+ m.setup(nodepath->desktop, false, nodepath->item, &unselected_nodes);
+ for (GList *l = nodepath->selected; l != NULL; l = l->next) {
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
if (!closest_only || n == closest_node) { //try to snap either all selected nodes or only the closest one
- Inkscape::SnappedPoint s;
- Inkscape::SnapSourceType source_type = (n->type == Inkscape::NodePath::NODE_SMOOTH ? Inkscape::SNAPSOURCE_NODE_SMOOTH : Inkscape::SNAPSOURCE_NODE_CUSP);
- if (constrained) {
- Inkscape::Snapper::ConstraintLine dedicated_constraint = constraint;
- dedicated_constraint.setPoint(n->pos);
- s = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(n->pos + delta), source_type, dedicated_constraint, false);
- } else {
- s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, to_2geom(n->pos + delta), source_type);
- }
-
- if (s.getSnapped()) {
- s.setPointerDistance(Geom::L2(nodepath->drag_origin_mouse - n->origin));
- if (!s.isOtherSnapBetter(best, true)) {
- best = s;
- best_pt = from_2geom(s.getPoint()) - n->pos;
- }
- }
+ Inkscape::SnappedPoint s;
+ Inkscape::SnapSourceType source_type = (n->type == Inkscape::NodePath::NODE_SMOOTH ? Inkscape::SNAPSOURCE_NODE_SMOOTH : Inkscape::SNAPSOURCE_NODE_CUSP);
+ if (constrained) {
+ Inkscape::Snapper::ConstraintLine dedicated_constraint = constraint;
+ dedicated_constraint.setPoint(n->pos);
+ s = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(n->pos + delta, source_type), dedicated_constraint);
+ } else {
+ s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(n->pos + delta, source_type));
+ }
+
+ if (s.getSnapped()) {
+ s.setPointerDistance(Geom::L2(nodepath->drag_origin_mouse - n->origin));
+ if (!s.isOtherSnapBetter(best, true)) {
+ best = s;
+ best_pt = from_2geom(s.getPoint()) - n->pos;
+ }
+ }
}
}
@@ -3955,9 +3955,9 @@ static gboolean node_handle_request(SPKnot *knot, Geom::Point &p, guint state, g
Inkscape::SnappedPoint s;
if ((state & GDK_SHIFT_MASK) != 0) {
- // We will not try to snap when the shift-key is pressed
- // so remove the old snap indicator and don't wait for it to time-out
- desktop->snapindicator->remove_snaptarget();
+ // We will not try to snap when the shift-key is pressed
+ // so remove the old snap indicator and don't wait for it to time-out
+ desktop->snapindicator->remove_snaptarget();
}
Inkscape::NodePath::Node *othernode = opposite->other;
@@ -3975,16 +3975,16 @@ static gboolean node_handle_request(SPKnot *knot, Geom::Point &p, guint state, g
p = n->pos + (scal / linelen) * ndelta;
}
if ((state & GDK_SHIFT_MASK) == 0) {
- s = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, source_type, Inkscape::Snapper::ConstraintLine(p, ndelta), false);
+ s = m.constrainedSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(p, source_type), Inkscape::Snapper::ConstraintLine(p, ndelta));
}
} else {
if ((state & GDK_SHIFT_MASK) == 0) {
- s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, source_type);
+ s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(p, source_type));
}
}
} else {
if ((state & GDK_SHIFT_MASK) == 0) {
- s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, source_type);
+ s = m.freeSnap(Inkscape::SnapPreferences::SNAPPOINT_NODE, Inkscape::SnapCandidatePoint(p, source_type));
}
}