summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aa5927f)
raw | patch | inline | side by side (parent: aa5927f)
| author | johanengelen <johanengelen@users.sourceforge.net> | |
| Tue, 4 Mar 2008 21:33:35 +0000 (21:33 +0000) | ||
| committer | johanengelen <johanengelen@users.sourceforge.net> | |
| Tue, 4 Mar 2008 21:33:35 +0000 (21:33 +0000) |
| src/context-fns.cpp | patch | blob | history | |
| src/rect-context.cpp | patch | blob | history |
diff --git a/src/context-fns.cpp b/src/context-fns.cpp
index c845fd275bdc19b34e600231ebe91906ccf2ac83..32c7eef000cf194356f6e57000f6b8fc58c48235 100644 (file)
--- a/src/context-fns.cpp
+++ b/src/context-fns.cpp
#include "desktop-affine.h"
#include "event-context.h"
#include "sp-namedview.h"
+#include "display/snap-indicator.h"
static const double midpt_1_goldenratio = (1 + goldenratio) / 2;
static const double midpt_goldenratio_2 = (goldenratio + 2) / 2;
bool const control = state & GDK_CONTROL_MASK;
SnapManager const &m = desktop->namedview->snap_manager;
+ Inkscape::SnappedPoint snappoint;
if (control) {
@@ -140,17 +142,20 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
if (s[0].getDistance() < s[1].getDistance()) {
p[0] = s[0].getPoint();
p[1] = 2 * center - s[0].getPoint();
+ snappoint = s[0];
} else {
p[0] = 2 * center - s[1].getPoint();
p[1] = s[1].getPoint();
+ snappoint = s[1];
}
} else {
/* Our origin is the opposite corner. Snap the drag point along the constraint vector */
p[0] = center;
- p[1] = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, p[1],
- Inkscape::Snapper::ConstraintLine(p[1] - p[0]), item).getPoint();
+ snappoint = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, p[1],
+ Inkscape::Snapper::ConstraintLine(p[1] - p[0]), item);
+ p[1] = snappoint.getPoint();
}
} else if (shift) {
@@ -170,16 +175,24 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
if (s[0].getDistance() < s[1].getDistance()) {
p[0] = s[0].getPoint();
p[1] = 2 * center - s[0].getPoint();
+ snappoint = s[0];
} else {
p[0] = 2 * center - s[1].getPoint();
p[1] = s[1].getPoint();
+ snappoint = s[1];
}
} else {
/* There's no constraint on the corner point, so just snap it to anything */
p[0] = center;
- p[1] = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, pt, item).getPoint();
+ snappoint = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, pt, item);
+ p[1] = snappoint.getPoint();
+ }
+
+ if (snappoint.getDistance() < NR_HUGE) {
+ // this does not work well enough yet.
+// desktop->snapindicator->set_new_snappoint(snappoint.getPoint().to_2geom());
}
p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]);
diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index 6aa7d418c85499652b422e08431e9acd0ee05c0a..70d7b7721aff64baecde4972ce3fffd463e844de 100644 (file)
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
#include "macros.h"
#include "display/sp-canvas.h"
+#include "display/snap-indicator.h"
#include "sp-rect.h"
#include "document.h"
#include "sp-namedview.h"
@@ -283,6 +284,8 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+ desktop->snapindicator->remove_snappoint();
+
gint ret = FALSE;
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -305,8 +308,11 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
/* Snap center */
SnapManager const &m = desktop->namedview->snap_manager;
- rc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE,
- button_dt, rc->item).getPoint();
+ Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt, rc->item);
+ rc->center = s.getPoint();
+ if (s.getDistance() < NR_HUGE) {
+ desktop->snapindicator->set_new_snappoint(s.getPoint().to_2geom());
+ }
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
( GDK_KEY_PRESS_MASK |
@@ -336,8 +342,12 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
NR::Point motion_dt(desktop->w2d(motion_w));
SnapManager const &m = desktop->namedview->snap_manager;
- motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, rc->item).getPoint();
-
+ Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, rc->item);
+ motion_dt = s.getPoint();
+ if (s.getDistance() < NR_HUGE) {
+ desktop->snapindicator->set_new_snappoint(s.getPoint().to_2geom());
+ }
+
sp_rect_drag(*rc, motion_dt, event->motion.state);
gobble_motion_events(GDK_BUTTON1_MASK);
ret = TRUE;