shift-snap.diff (4,461 bytes)
diff --git a/scribus/canvasmode.cpp b/scribus/canvasmode.cpp
index 07ff6ea70..6122201d2 100644
--- a/scribus/canvasmode.cpp
+++ b/scribus/canvasmode.cpp
@@ -947,8 +947,9 @@ void CanvasMode::clearPixmapCache()
void CanvasMode::drawSnapLine(QPainter* p)
{
- if (!m_doc->SnapElement)
+ if (!m_doc->SnapElement && !m_doc->snapLineVisible)
return;
+ m_doc->snapLineVisible = false;
if (xSnap == 0.0 && ySnap == 0.0)
return;
int page = m_doc->OnPage(m_view->m_mousePointDoc.x(), m_view->m_mousePointDoc.y());
diff --git a/scribus/canvasmode_normal.cpp b/scribus/canvasmode_normal.cpp
index 13ce61dd4..6218b0c9d 100644
--- a/scribus/canvasmode_normal.cpp
+++ b/scribus/canvasmode_normal.cpp
@@ -533,6 +533,11 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
}
else
{
+ bool onTheFlySnapToElement = false;
+ if ((m->modifiers() & Qt::ShiftModifier) && !(m->modifiers() & Qt::ControlModifier) && !(m->modifiers() & Qt::AltModifier)) {
+ onTheFlySnapToElement = true;
+ m_doc->snapLineVisible = true;
+ }
//Dragging orthogonally - Ctrl Drag
if ((m->modifiers() & Qt::ControlModifier) && !(m->modifiers() & Qt::ShiftModifier) && !(m->modifiers() & Qt::AltModifier))
{
@@ -580,7 +585,7 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
}
}
- if (m_doc->SnapElement)
+ if (onTheFlySnapToElement || m_doc->SnapElement)
{
xSnap = 0;
ySnap = 0;
@@ -595,9 +600,16 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
{
nx = gx + snapWidth[i] + m_objectDeltaPos.x();
ny = gy + snapHeight[i] + m_objectDeltaPos.y();
+ bool tmpSnapElement = m_doc->SnapElement;
+ if (onTheFlySnapToElement) {
+ m_doc->SnapElement = true;
+ }
nxo = nx, nyo = ny;
m_doc->ApplyGuides(&nx, &ny,true);
m_objectDeltaPos += FPoint(nx - nxo, ny - nyo);
+ if (onTheFlySnapToElement) {
+ m_doc->SnapElement = tmpSnapElement;
+ }
if (ny != nyo)
ySnap = ny;
if (nx != nxo)
@@ -629,6 +641,11 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
int dX=qRound(newX - m_mousePressPoint.x()), dY=qRound(newY - m_mousePressPoint.y());
erf = true;
+ bool onTheFlySnapToElement = false;
+ if ((m->modifiers() & Qt::ShiftModifier) && !(m->modifiers() & Qt::ControlModifier) && !(m->modifiers() & Qt::AltModifier)) {
+ onTheFlySnapToElement = true;
+ m_doc->snapLineVisible = true;
+ }
if (m->modifiers() & Qt::ControlModifier)
{
if (abs(dX)>abs(dY))
@@ -652,15 +669,8 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
ny = nyo = gy + gh + m_objectDeltaPos.y();
m_doc->ApplyGuides(&nx, &ny);
m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
- if (false)
- {
- nx = nxo = gx + gw/2 + m_objectDeltaPos.x();
- ny = nyo = gy + gh/2 + m_objectDeltaPos.y();
- m_doc->ApplyGuides(&nx, &ny);
- m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
- }
}
- if (m_doc->SnapElement)
+ if (onTheFlySnapToElement || m_doc->SnapElement)
{
xSnap = 0;
ySnap = 0;
@@ -670,6 +680,10 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
std::swap(snapWidth[0],snapWidth[2]);
if (m_objectDeltaPos.y() < 0)
std::swap(snapHeight[0],snapHeight[2]);
+ bool tmpSnapElement = m_doc->SnapElement;
+ if (onTheFlySnapToElement) {
+ m_doc->SnapElement = true;
+ }
double nx,ny,nyo,nxo;
for (int i = 0;i<3;i++)
{
@@ -683,6 +697,9 @@ void CanvasMode_Normal::mouseMoveEvent(QMouseEvent *m)
if (nx != nxo)
xSnap = nx;
}
+ if (onTheFlySnapToElement) {
+ m_doc->SnapElement = tmpSnapElement;
+ }
}
if (m_doc->SnapGrid)
{
diff --git a/scribus/scribusdoc.h b/scribus/scribusdoc.h
index e3ace25c1..f92b707b1 100644
--- a/scribus/scribusdoc.h
+++ b/scribus/scribusdoc.h
@@ -1237,6 +1237,7 @@ public: // Public attributes
bool SnapGrid;
bool SnapGuides;
bool SnapElement;
+ bool snapLineVisible = false;
bool GuideLock;
bool dontResize;
/** \brief Minimum and Maximum Points of Document */