summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8eb2b67)
raw | patch | inline | side by side (parent: 8eb2b67)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Thu, 28 Aug 2008 19:32:55 +0000 (19:32 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Thu, 28 Aug 2008 19:32:55 +0000 (19:32 +0000) |
14 files changed:
diff --git a/src/arc-context.cpp b/src/arc-context.cpp
index 3df9dc4b22d14e13597e5c9149210eea99358033..ae6ee88ade3348667528d8b6eec7b5248f64d9ac 100644 (file)
--- a/src/arc-context.cpp
+++ b/src/arc-context.cpp
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, NULL); //null, because we don't have an item yet
+ m.setup(desktop);
Geom::Point pt2g = to_2geom(ac->center);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
ac->center = from_2geom(pt2g);
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index 393340cc4b0822a1be162af9e721683913115678..0ea8b1dbdaed1679968874177f0147ca188c3c7e 100644 (file)
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -330,7 +330,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, bc->item);
+ m.setup(desktop, true, bc->item);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
bc->center = from_2geom(button_dt);
@@ -362,7 +362,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
Geom::Point motion_dt(to_2geom(desktop->w2d(motion_w)));
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, bc->item);
+ m.setup(desktop, true, bc->item);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
diff --git a/src/context-fns.cpp b/src/context-fns.cpp
index e584761472b73c3c43d77cf311995f9fe47d3f04..9acba28278013d710c5c44d55010c159f6722256 100644 (file)
--- a/src/context-fns.cpp
+++ b/src/context-fns.cpp
bool const control = state & GDK_CONTROL_MASK;
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(NULL, item);
+ m.setup(desktop, false, item);
Inkscape::SnappedPoint snappoint;
if (control) {
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index 7b40e7c95abf6b837e83edca53f72f0b97cbf066..6b98c17e5ece6fe3c51ab1890f2f4d663f2e882b 100644 (file)
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
@@ -504,7 +504,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N
//pressing CTRL
/* Snap it along best vector */
SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
- m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
+ m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
Geom::Point pt2g = to_2geom(p);
m.constrainedSnapReturnByRef( Inkscape::Snapper::SNAPPOINT_NODE, pt2g, Inkscape::Snapper::ConstraintLine(best));
p = from_2geom(pt2g);
@@ -516,7 +516,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N
void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guint const /*state*/)
{
SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
- m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
+ m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
Geom::Point pt2g = to_2geom(p);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
p = from_2geom(pt2g);
index 9d890e2fc42476ad403a92a3501d74b04941c0c4..46f21965b051e1b4400caa7199fc1271ce10a508 100644 (file)
Geom::Matrix const i2d (sp_item_i2d_affine(item));
Geom::Point s = p * i2d;
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, item);
+ m.setup(desktop, true, item);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, s);
return s * i2d.inverse();
}
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 3544b7441177398aa35529ee3898046ba7d366ed..7e46b2f10f9045b426c150110160cdf51b3971b3 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -1311,7 +1311,7 @@ static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath,
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
- m.setup(NULL, SP_PATH(n->subpath->nodepath->item), &unselected_nodes);
+ m.setup(nodepath->desktop, false, SP_PATH(n->subpath->nodepath->item), &unselected_nodes);
Inkscape::SnappedPoint s;
if (constrained) {
Inkscape::Snapper::ConstraintLine dedicated_constraint = constraint;
@@ -3778,7 +3778,7 @@ static gboolean node_handle_request(SPKnot *knot, NR::Point *p, guint state, gpo
SPDesktop *desktop = n->subpath->nodepath->desktop;
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, n->subpath->nodepath->item);
+ m.setup(desktop, true, n->subpath->nodepath->item);
Inkscape::SnappedPoint s;
if ((state & GDK_SHIFT_MASK) != 0) {
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index 69afdf614189fc320255d4803400f63210c83cac..cb1039119006983f3b3669cf02bced150d1c1f87 100644 (file)
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -350,7 +350,7 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
p = to_2geom(anchor->dp);
} else if ((mevent.state & GDK_SHIFT_MASK) == 0) {
SnapManager &m = dt->namedview->snap_manager;
- m.setup(dt, NULL);
+ m.setup(dt);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
}
if ( pc->npoints != 0 ) { // buttonpress may have happened before we entered draw context!
diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index 999aa03b82d5e34a4f8b8ac17f47e5d5f7ef84a1..bbb809ef2be416d0c383f921f96db0777972137d 100644 (file)
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
@@ -305,7 +305,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, NULL); //null, because we don't have an item yet
+ m.setup(desktop);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
rc->center = from_2geom(button_dt);
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 95c92ba6953a20be1ed2bdb6dd5c994aed5f895d..d5e6afd8acd26f67c172be5c6b01c9bd269b8af7 100644 (file)
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
} else {
// In all other cases we should try to snap now
SnapManager &m = _desktop->namedview->snap_manager;
- m.setup(NULL, _items_const);
+ m.setup(_desktop, false, _items_const);
Inkscape::SnappedPoint bb, sn;
NR::Coord bd(NR_HUGE);
@@ -1032,7 +1032,7 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, NR::
// In all other cases we should try to snap now
SnapManager &m = _desktop->namedview->snap_manager;
- m.setup(NULL, _items_const);
+ m.setup(_desktop, false, _items_const);
Inkscape::SnappedPoint bb, sn;
g_assert(bb.getSnapped() == false); // Check initialization to catch any regression
@@ -1156,7 +1156,7 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, NR::Poi
// Snap to objects, grids, guides
SnapManager &m = _desktop->namedview->snap_manager;
- m.setup(NULL, _items_const);
+ m.setup(_desktop, false, _items_const);
Inkscape::Snapper::ConstraintLine const constraint(component_vectors[dim_b]);
NR::Point const s(skew[dim_a], scale[dim_a]);
@@ -1364,7 +1364,7 @@ void sp_sel_trans_center(Inkscape::SelTrans *seltrans, SPSelTransHandle const &,
void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state)
{
SnapManager &m = _desktop->namedview->snap_manager;
- m.setup(_desktop, _items_const);
+ m.setup(_desktop, true, _items_const);
/* The amount that we've moved by during this drag */
Geom::Point dxy = to_2geom(xy - _point);
diff --git a/src/snap.cpp b/src/snap.cpp
index 9ae330b777591fb451a1e3b28b418c5051839294..15bc8658d4c56aa9dd0dfbc316a925004616d23a 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -871,11 +871,11 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, SnappedCo
// Update the snap indicator, if requested
- if (_desktop_for_snapindicator) {
+ if (_snapindicator) {
if (bestSnappedPoint.getSnapped()) {
- _desktop_for_snapindicator->snapindicator->set_new_snappoint(bestSnappedPoint);
+ _desktop->snapindicator->set_new_snappoint(bestSnappedPoint);
} else {
- _desktop_for_snapindicator->snapindicator->remove_snappoint();
+ _desktop->snapindicator->remove_snappoint();
}
}
@@ -883,19 +883,23 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, SnappedCo
return bestSnappedPoint;
}
-void SnapManager::setup(SPDesktop const *desktop_for_snapindicator, SPItem const *item_to_ignore, std::vector<Geom::Point> *unselected_nodes)
+void SnapManager::setup(SPDesktop const *desktop, bool snapindicator, SPItem const *item_to_ignore, std::vector<Geom::Point> *unselected_nodes)
{
- _item_to_ignore = item_to_ignore;
+ g_assert(desktop != NULL);
+ _item_to_ignore = item_to_ignore;
_items_to_ignore = NULL;
- _desktop_for_snapindicator = desktop_for_snapindicator;
+ _desktop = desktop;
+ _snapindicator = snapindicator;
_unselected_nodes = unselected_nodes;
}
-void SnapManager::setup(SPDesktop const *desktop_for_snapindicator, std::vector<SPItem const *> &items_to_ignore, std::vector<Geom::Point> *unselected_nodes)
+void SnapManager::setup(SPDesktop const *desktop, bool snapindicator, std::vector<SPItem const *> &items_to_ignore, std::vector<Geom::Point> *unselected_nodes)
{
- _item_to_ignore = NULL;
+ g_assert(desktop != NULL);
+ _item_to_ignore = NULL;
_items_to_ignore = &items_to_ignore;
- _desktop_for_snapindicator = desktop_for_snapindicator;
+ _desktop = desktop;
+ _snapindicator = snapindicator;
_unselected_nodes = unselected_nodes;
}
diff --git a/src/snap.h b/src/snap.h
index e4f9aaddf858612f8c2cc6a4637338955adba4ae..02cee70ca867068734ddb264bd8c6f844dbade0d 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
bool SomeSnapperMightSnap() const;
- void setup(SPDesktop const *desktop_for_snapindicator = NULL, SPItem const *item_to_ignore = NULL, std::vector<Geom::Point> *unselected_nodes = NULL);
- void setup(SPDesktop const *desktop_for_snapindicator, std::vector<SPItem const *> &items_to_ignore, std::vector<Geom::Point> *unselected_nodes = NULL);
+ void setup(SPDesktop const *desktop, bool snapindicator = true, SPItem const *item_to_ignore = NULL, std::vector<Geom::Point> *unselected_nodes = NULL);
+ void setup(SPDesktop const *desktop, bool snapindicator, std::vector<SPItem const *> &items_to_ignore, std::vector<Geom::Point> *unselected_nodes = NULL);
// freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a
// point if snapping has occured (by overwriting p); otherwise p is untouched
std::vector<SPItem const *> *_items_to_ignore;
SPItem const *_item_to_ignore;
- SPDesktop const *_desktop_for_snapindicator;
+ SPDesktop const *_desktop;
+ bool _snapindicator;
std::vector<Geom::Point> *_unselected_nodes;
Inkscape::SnappedPoint _snapTransformed(Inkscape::Snapper::PointType type,
diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp
index b42195c6069d873aaa84328d5dee89808b0c5808..dc2e99e07e01d0947ec2ac439784a1de2d8d8364 100644 (file)
--- a/src/spiral-context.cpp
+++ b/src/spiral-context.cpp
sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, NULL); //null, because we don't have an item yet
+ m.setup(desktop);
Geom::Point pt2g = to_2geom(sc->center);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
sc->center = from_2geom(pt2g);
Geom::Point motion_dt(to_2geom(event_context->desktop->w2d(motion_w)));
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, sc->item);
+ m.setup(desktop, true, sc->item);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
sp_spiral_drag(sc, from_2geom(motion_dt), event->motion.state);
Geom::Point const p0 = to_2geom(sp_desktop_dt2root_xy_point(desktop, sc->center));
Geom::Point p1 = to_2geom(sp_desktop_dt2root_xy_point(desktop, p));
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, sc->item);
+ m.setup(desktop, true, sc->item);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p1);
SPSpiral *spiral = SP_SPIRAL(sc->item);
diff --git a/src/star-context.cpp b/src/star-context.cpp
index 824fd53a4085e1badeb9133f2c41eee90dbb9fac..97577bcbae0b0bc053c790fa54a8952bc9eb7d79 100644 (file)
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -282,7 +282,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, NULL); //null, because we don't have an item yet
+ m.setup(desktop, true);
Geom::Point pt2g = to_2geom(sc->center);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
sc->center = from_2geom(pt2g);
/* Snap corner point with no constraints */
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, sc->item);
+ m.setup(desktop, true, sc->item);
Geom::Point pt2g = to_2geom(p);
m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, pt2g);
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index a3f1b9c0d0eca8e68d641313ec14f766cd1fd56d..ac35e7be6cd6ca278f3eb1ce3cf369fa5fb681df 100644 (file)
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
offset = rel_pos_original;
} else { // Stick to the grid if snapping is enabled, otherwise paste at mouse position;
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(NULL, NULL); //Don't display the snapindicator
+ m.setup(desktop, false); //Don't display the snapindicator
offset = rel_pos_original + m.multipleOfGridPitch(rel_pos_mouse - rel_pos_original);
}