summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7c44e8c)
raw | patch | inline | side by side (parent: 7c44e8c)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Fri, 7 Sep 2007 19:22:55 +0000 (19:22 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Fri, 7 Sep 2007 19:22:55 +0000 (19:22 +0000) |
src/desktop-events.cpp | patch | blob | history | |
src/snap.cpp | patch | blob | history | |
src/snap.h | patch | blob | history |
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 7f9ce0b04158d08d3e5b96c86a93179de54dcf9e..90c02a7723b0fffc5d8d51748442de777a5d5000 100644 (file)
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -77,10 +77,15 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
case GDK_MOTION_NOTIFY:
if (dragging) {
NR::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
- NR::Point const event_dt(desktop->w2d(event_w));
+ NR::Point event_dt(desktop->w2d(event_w));
+
+ SnapManager const &m = desktop->namedview->snap_manager;
+ event_dt = m.guideSnap(event_dt, component_vectors[horiz ? NR::Y : NR::X]).getPoint();
+
double const guide_pos_dt = event_dt[ horiz
? NR::Y
: NR::X ];
+
sp_guideline_set_position(SP_GUIDELINE(guide), guide_pos_dt);
desktop->set_coordinate_status(event_dt);
desktop->setPosition (event_dt);
SPGuide *guide = SP_GUIDE(data);
SPDesktop *desktop = static_cast<SPDesktop*>(gtk_object_get_data(GTK_OBJECT(item->canvas), "SPDesktop"));
- switch (event->type) {
+ switch (event->type) {
case GDK_2BUTTON_PRESS:
if (event->button.button == 1) {
dragging = false;
event->motion.y);
NR::Point motion_dt(desktop->w2d(motion_w));
+ // This is for snapping while dragging existing guidelines. New guidelines,
+ // which are dragged off the ruler, are being snapped in sp_dt_ruler_event
SnapManager const &m = desktop->namedview->snap_manager;
- motion_dt = m.guideSnap(motion_dt, *guide).getPoint();
+ motion_dt = m.guideSnap(motion_dt, guide->normal).getPoint();
sp_guide_moveto(*guide, sp_guide_position_from_pt(guide, motion_dt), false);
moved = true;
//whereas it might have been at a snapped position a millisecond before.
//See GDK_MOTION_NOTIFY above. Why's that????
SnapManager const &m = desktop->namedview->snap_manager;
- event_dt = m.guideSnap(event_dt, *guide).getPoint();
+ event_dt = m.guideSnap(event_dt, guide->normal).getPoint();
if (sp_canvas_world_pt_inside_window(item->canvas, event_w)) {
sp_guide_moveto(*guide, sp_guide_position_from_pt(guide, event_dt), true);
diff --git a/src/snap.cpp b/src/snap.cpp
index 7a451f5d51a4d990abb39718390b8b687238dadd..886a1216ff30d94340fa9ca06afc0a9dfb90d782 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -352,12 +352,12 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::Snapper::PointType
}
Inkscape::SnappedPoint SnapManager::guideSnap(NR::Point const &p,
- SPGuide const &guide) const
+ NR::Point const &guide_normal) const
{
Inkscape::ObjectSnapper::DimensionToSnap snap_dim;
- if (guide.normal == component_vectors[NR::Y]) {
+ if (guide_normal == component_vectors[NR::Y]) {
snap_dim = Inkscape::ObjectSnapper::SNAP_Y;
- } else if (guide.normal == component_vectors[NR::X]) {
+ } else if (guide_normal == component_vectors[NR::X]) {
snap_dim = Inkscape::ObjectSnapper::SNAP_X;
} else {
g_warning("WARNING: snapping of angled guides is not supported yet!");
diff --git a/src/snap.h b/src/snap.h
index cdd707d01167238aa8a3828aa39cd6b42d8109f8..f44df8923f68c9651db6541d1bc299bd146a1aa2 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
std::list<SPItem const *> const &it) const;
Inkscape::SnappedPoint guideSnap(NR::Point const &p,
- SPGuide const &guide) const;
+ NR::Point const &guide_normal) const;
std::pair<NR::Point, bool> freeSnapTranslation(Inkscape::Snapper::PointType t,
std::vector<NR::Point> const &p,