View Issue Details

IDProjectCategoryView StatusLast Update
0015228ScribusGeneralpublic2018-09-27 07:12
Reporterale Assigned Toale  
PrioritynormalSeverityfeatureReproducibilityN/A
Status assignedResolutionopen 
Product Version1.5.4.svn 
Target VersionFixed in Version 
Summary0015228: [PATCH] pressing shift should temporary enable the snap to items
Descriptionboth when moving items and guides around, pressing the shift key should enable the snapping to items (while the shift key is down)
TagsNo tags attached.
PatchYes

Relationships

related to 0015230 new remove the snap to items modus (and only keep the newer shift snapping) 

Activities

ale

2018-03-29 12:17

manager   ~0045120

here is a diff...

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 */
shift-snap.diff (4,461 bytes)

ale

2018-03-29 12:17

manager  

shift-snap.gif (134,102 bytes)
shift-snap.gif (134,102 bytes)

Issue History

Date Modified Username Field Change
2018-03-29 09:33 ale New Issue
2018-03-29 09:35 jghali Category - => General
2018-03-29 09:35 jghali Severity minor => feature
2018-03-29 12:17 ale File Added: shift-snap.diff
2018-03-29 12:17 ale Note Added: 0045120
2018-03-29 12:17 ale File Added: shift-snap.gif
2018-03-29 12:19 ale Summary pressing shift should temporary enable the snap to items => [PATCH] pressing shift should temporary enable the snap to items
2018-03-29 12:19 ale Patch No => Yes
2018-09-27 07:11 ale Assigned To => ale
2018-09-27 07:11 ale Status new => assigned
2018-09-27 07:12 ale Relationship added related to 0015230