r19546 by craig - #12373: Fix CanvasMode::drawSnapLine. It didnt know about the right page, just used the current page
scribus-commit
scribus-commit at lists.scribus.net
Thu Oct 2 20:12:00 UTC 2014
Author: craig
Date: Thu Oct 2 20:12:00 2014
New Revision: 19546
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19546
Log:
#12373: Fix CanvasMode::drawSnapLine. It didnt know about the right page, just used the current page
Modified:
trunk/Scribus/scribus/canvasmode.cpp
trunk/Scribus/scribus/canvasmode.h
Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19546&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Thu Oct 2 20:12:00 2014
@@ -101,6 +101,7 @@
m_keyRepeat = false;
m_arrowKeyDown = false;
+ m_mousePointDoc = FPoint(0,0);
}
CanvasMode::~CanvasMode()
@@ -918,29 +919,36 @@
void CanvasMode::drawSnapLine(QPainter* p)
{
- if (m_doc->SnapElement && (xSnap != 0.0 || ySnap != 0.0))
- {
- MarginStruct bleedValues;
- m_doc->getBleeds(m_doc->currentPage(), bleedValues);
- double xOffset = m_doc->currentPage()->xOffset() - bleedValues.Left;
- double yOffset = m_doc->currentPage()->yOffset() - bleedValues.Top;
- QPoint pageOrigin = m_canvas->canvasToLocal(QPointF(xOffset, yOffset));
- if (ySnap)
- {
- p->setPen(Qt::green);
- QPoint pt = m_canvas->canvasToLocal(QPointF(xOffset, ySnap));
- double w = (m_doc->currentPage()->width() + bleedValues.Left + bleedValues.Right) * m_canvas->scale();
- p->drawLine(pageOrigin.x(), pt.y(), pageOrigin.x() + w, pt.y());
- ySnap = 0;
- }
- if (xSnap)
- {
- p->setPen(Qt::green);
- QPoint pt = m_canvas->canvasToLocal(QPointF(xSnap, yOffset));
- double h = (m_doc->currentPage()->height() + bleedValues.Bottom + bleedValues.Top) * m_canvas->scale();
- p->drawLine(pt.x(), pageOrigin.y(), pt.x(), pageOrigin.y() + h);
- xSnap = 0;
- }
+ if (!m_doc->SnapElement)
+ return;
+ if (xSnap == 0.0 && ySnap == 0.0)
+ return;
+ int page = m_doc->OnPage(m_mousePointDoc.x(), m_mousePointDoc.y());
+ if (page == -1)
+ return;
+ MarginStruct bleedValues;
+ ScPage* dragToPage=m_doc->Pages->at(page);
+ if (!dragToPage)
+ return;
+ m_doc->getBleeds(dragToPage, bleedValues);
+ double xOffset = dragToPage->xOffset() - bleedValues.Left;
+ double yOffset = dragToPage->yOffset() - bleedValues.Top;
+ QPoint pageOrigin = m_canvas->canvasToLocal(QPointF(xOffset, yOffset));
+ if (ySnap)
+ {
+ p->setPen(Qt::green);
+ QPoint pt = m_canvas->canvasToLocal(QPointF(xOffset, ySnap));
+ double w = (dragToPage->width() + bleedValues.Left + bleedValues.Right) * m_canvas->scale();
+ p->drawLine(pageOrigin.x(), pt.y(), pageOrigin.x() + w, pt.y());
+ ySnap = 0;
+ }
+ if (xSnap)
+ {
+ p->setPen(Qt::green);
+ QPoint pt = m_canvas->canvasToLocal(QPointF(xSnap, yOffset));
+ double h = (dragToPage->height() + bleedValues.Bottom + bleedValues.Top) * m_canvas->scale();
+ p->drawLine(pt.x(), pageOrigin.y(), pt.x(), pageOrigin.y() + h);
+ xSnap = 0;
}
}
@@ -972,6 +980,7 @@
bool CanvasMode::commonMouseMove(QMouseEvent *m)
{
+ m_mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
if ((m_canvas->m_viewMode.m_MouseButtonPressed && (m->buttons() & Qt::RightButton) && (m->modifiers() & Qt::ControlModifier)) || ((!(m->modifiers() & Qt::ControlModifier)) && (m->buttons() & Qt::MidButton)))
{
if (!m_panGesture)
Modified: trunk/Scribus/scribus/canvasmode.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19546&path=/trunk/Scribus/scribus/canvasmode.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode.h (original)
+++ trunk/Scribus/scribus/canvasmode.h Thu Oct 2 20:12:00 2014
@@ -47,6 +47,8 @@
class PageItem;
class PageItemPreview;
class PageItem_TextFrame;
+
+#include "fpoint.h"
/** These aren't real appmodes but open a new window or override behaviour for a short time */
enum SubMode
@@ -167,6 +169,7 @@
bool m_keyRepeat;
bool m_arrowKeyDown;
+ FPoint m_mousePointDoc;
};
More information about the scribus-commit
mailing list