diff --git a/src/context-fns.cpp b/src/context-fns.cpp
index 42100d49a1a140c5fa390e1ad12f7c89ab7bea71..15138a10b6f9f188de86ce7b794526e33691b5bd 100644 (file)
--- a/src/context-fns.cpp
+++ b/src/context-fns.cpp
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <glibmm/i18n.h>
#include "sp-item.h"
#include "desktop.h"
#include <glibmm/i18n.h>
#include "sp-item.h"
#include "desktop.h"
#include "snap.h"
#include "desktop-affine.h"
#include "event-context.h"
#include "snap.h"
#include "desktop-affine.h"
#include "event-context.h"
+#include "sp-namedview.h"
/* FIXME: could probably use a template here */
/* FIXME: could probably use a template here */
bool Inkscape::have_viable_layer(SPDesktop *desktop, MessageContext *message)
{
SPItem const *layer = SP_ITEM(desktop->currentLayer());
bool Inkscape::have_viable_layer(SPDesktop *desktop, MessageContext *message)
{
SPItem const *layer = SP_ITEM(desktop->currentLayer());
-
+
if ( !layer || desktop->itemIsHidden(layer) ) {
message->flash(Inkscape::ERROR_MESSAGE,
_("<b>Current layer is hidden</b>. Unhide it to be able to draw on it."));
return false;
}
if ( !layer || desktop->itemIsHidden(layer) ) {
message->flash(Inkscape::ERROR_MESSAGE,
_("<b>Current layer is hidden</b>. Unhide it to be able to draw on it."));
return false;
}
-
+
if ( !layer || layer->isLocked() ) {
message->flash(Inkscape::ERROR_MESSAGE,
_("<b>Current layer is locked</b>. Unlock it to be able to draw on it."));
if ( !layer || layer->isLocked() ) {
message->flash(Inkscape::ERROR_MESSAGE,
_("<b>Current layer is locked</b>. Unlock it to be able to draw on it."));
bool Inkscape::have_viable_layer(SPDesktop *desktop, MessageStack *message)
{
SPItem const *layer = SP_ITEM(desktop->currentLayer());
bool Inkscape::have_viable_layer(SPDesktop *desktop, MessageStack *message)
{
SPItem const *layer = SP_ITEM(desktop->currentLayer());
-
+
if ( !layer || desktop->itemIsHidden(layer) ) {
message->flash(Inkscape::WARNING_MESSAGE,
_("<b>Current layer is hidden</b>. Unhide it to be able to draw on it."));
return false;
}
if ( !layer || desktop->itemIsHidden(layer) ) {
message->flash(Inkscape::WARNING_MESSAGE,
_("<b>Current layer is hidden</b>. Unhide it to be able to draw on it."));
return false;
}
-
+
if ( !layer || layer->isLocked() ) {
message->flash(Inkscape::WARNING_MESSAGE,
_("<b>Current layer is locked</b>. Unlock it to be able to draw on it."));
if ( !layer || layer->isLocked() ) {
message->flash(Inkscape::WARNING_MESSAGE,
_("<b>Current layer is locked</b>. Unlock it to be able to draw on it."));
bool const shift = state & GDK_SHIFT_MASK;
bool const control = state & GDK_CONTROL_MASK;
bool const shift = state & GDK_SHIFT_MASK;
bool const control = state & GDK_CONTROL_MASK;
- SnapManager const m(desktop->namedview);
+ SnapManager const &m = desktop->namedview->snap_manager;
if (control) {
if (control) {
/* p[1] is the dragged point with the integer-ratio constraint */
p[1] = center + delta;
/* p[1] is the dragged point with the integer-ratio constraint */
p[1] = center + delta;
-
+
if (shift) {
/* Shift is down, so our origin is the centre point rather than the corner
if (shift) {
/* Shift is down, so our origin is the centre point rather than the corner
@@ -103,16 +108,16 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
/* p[0] is the opposite corner of our box */
p[0] = center - delta;
/* p[0] is the opposite corner of our box */
p[0] = center - delta;
-
+
Inkscape::SnappedPoint s[2];
/* Try to snap p[0] (the opposite corner) along the constraint vector */
Inkscape::SnappedPoint s[2];
/* Try to snap p[0] (the opposite corner) along the constraint vector */
- s[0] = m.constrainedSnap(Inkscape::Snapper::SNAP_POINT,
- p[0], p[0] - p[1], item);
+ s[0] = m.constrainedSnap(Inkscape::Snapper::SNAP_POINT, p[0],
+ Inkscape::Snapper::ConstraintLine(p[0] - p[1]), item);
/* Try to snap p[1] (the dragged corner) along the constraint vector */
/* Try to snap p[1] (the dragged corner) along the constraint vector */
- s[1] = m.constrainedSnap(Inkscape::Snapper::SNAP_POINT,
- p[1], p[1] - p[0], item);
+ s[1] = m.constrainedSnap(Inkscape::Snapper::SNAP_POINT, p[1],
+ Inkscape::Snapper::ConstraintLine(p[1] - p[0]), item);
/* Choose the best snap and update points accordingly */
if (s[0].getDistance() < s[1].getDistance()) {
/* Choose the best snap and update points accordingly */
if (s[0].getDistance() < s[1].getDistance()) {
@@ -122,20 +127,21 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
p[0] = 2 * center - s[1].getPoint();
p[1] = s[1].getPoint();
}
p[0] = 2 * center - s[1].getPoint();
p[1] = s[1].getPoint();
}
-
+
} else {
/* Our origin is the opposite corner. Snap the drag point along the constraint vector */
p[0] = center;
} else {
/* Our origin is the opposite corner. Snap the drag point along the constraint vector */
p[0] = center;
- p[1] = m.constrainedSnap(Inkscape::Snapper::SNAP_POINT, p[1], p[1] - p[0], item).getPoint();
+ p[1] = m.constrainedSnap(Inkscape::Snapper::SNAP_POINT, p[1],
+ Inkscape::Snapper::ConstraintLine(p[1] - p[0]), item).getPoint();
}
}
-
+
} else if (shift) {
/* Shift is down, so our origin is the centre point rather than the corner point;
** this means that corner-point movements are bound to each other.
*/
} else if (shift) {
/* Shift is down, so our origin is the centre point rather than the corner point;
** this means that corner-point movements are bound to each other.
*/
-
+
p[1] = pt;
p[0] = 2 * center - p[1];
p[1] = pt;
p[0] = 2 * center - p[1];
p[0] = 2 * center - s[1].getPoint();
p[1] = s[1].getPoint();
}
p[0] = 2 * center - s[1].getPoint();
p[1] = s[1].getPoint();
}
-
+
} else {
} else {
-
+
/* There's no constraint on the corner point, so just snap it to anything */
p[0] = center;
p[1] = m.freeSnap(Inkscape::Snapper::SNAP_POINT, pt, item).getPoint();
/* There's no constraint on the corner point, so just snap it to anything */
p[0] = center;
p[1] = m.freeSnap(Inkscape::Snapper::SNAP_POINT, pt, item).getPoint();