r23409 by jghali - Code style fixes and cleanups for CanvasMode_Normal
scribus-commit
scribus-commit at lists.scribus.net
Tue Dec 10 02:53:43 UTC 2019
Author: jghali
Date: Tue Dec 10 02:53:43 2019
New Revision: 23409
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23409
Log:
Code style fixes and cleanups for CanvasMode_Normal
Modified:
trunk/Scribus/scribus/canvasmode_normal.cpp
Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23409&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Tue Dec 10 02:53:43 2019
@@ -84,7 +84,7 @@
m_mousePressPoint.setXY(0, 0);
m_mouseCurrentPoint.setXY(0, 0);
m_mouseSavedPoint.setXY(0, 0);
- m_objectDeltaPos.setXY(0,0 );
+ m_objectDeltaPos.setXY(0, 0);
ySnap = 0;
xSnap = 0;
m_hoveredItem = nullptr;
@@ -626,7 +626,6 @@
{
double gx, gy, gh, gw;
m_doc->m_Selection->setGroupRect();
- // m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
int dX = qRound(newX - m_mousePressPoint.x()), dY = qRound(newY - m_mousePressPoint.y());
erf = true;
@@ -707,8 +706,8 @@
{
double gx, gy, gh, gw;
m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
- m_doc->adjustCanvas(FPoint(gx,gy), FPoint(gx+gw, gy+gh));
- QPoint selectionCenter = m_canvas->canvasToLocal(QPointF(gx+gw/2, gy+gh/2));
+ m_doc->adjustCanvas(FPoint(gx,gy), FPoint(gx + gw, gy + gh));
+ QPoint selectionCenter = m_canvas->canvasToLocal(QPointF(gx + gw / 2, gy + gh / 2));
QPoint localMousePos = m_canvas->canvasToLocal(mousePointDoc);
int localwidth = static_cast<int>(gw * m_canvas->scale());
int localheight = static_cast<int>(gh * m_canvas->scale());
@@ -722,7 +721,7 @@
localheight = 0;
selectionCenter.setY(localMousePos.y());
}
- m_view->ensureVisible(selectionCenter.x(), selectionCenter.y(), localwidth/2 + 20, localheight/2 + 20);
+ m_view->ensureVisible(selectionCenter.x(), selectionCenter.y(), localwidth / 2 + 20, localheight / 2 + 20);
m_canvas->repaint();
m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
m_canvas->displayCorrectedXYHUD(m->globalPos(), gx + m_objectDeltaPos.x(), gy + m_objectDeltaPos.y());
@@ -735,22 +734,15 @@
{
if (m_doc->m_Selection->isMultipleSelection())
{
-// QRect mpo = QRect(qRound(m->x()/m_canvas->scale())-m_doc->guidesPrefs().grabRad, qRound(m->y()/m_canvas->scale())-m_doc->guidesPrefs().grabRad, m_doc->guidesPrefs().grabRad*2, m_doc->guidesPrefs().grabRad*2);
-// mpo.moveBy(qRound(m_doc->minCanvasCoordinate.x()), qRound(m_doc->minCanvasCoordinate.y()));
double gx, gy, gh, gw;
m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
int how = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), QRectF(gx, gy, gw, gh));
-// if ((QRect(static_cast<int>(gx), static_cast<int>(gy), static_cast<int>(gw), static_cast<int>(gh)).intersects(mpo))
if (how >= 0)
{
if (how > 0)
- {
setResizeCursor(how);
- }
else
- {
m_view->setCursor(QCursor(Qt::OpenHandCursor));
- }
}
else
{
@@ -765,9 +757,8 @@
break;
QTransform p;
m_canvas->Transform(currItem, p);
- QRect mpo = QRect(m->x()-m_doc->guidesPrefs().grabRadius, m->y()-m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius*2, m_doc->guidesPrefs().grabRadius*2);
-// mpo.moveBy(qRound(m_doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(m_doc->minCanvasCoordinate.y() * m_canvas->scale()));
- if ((QRegion(p.map(QPolygon(QRect(-3, -3, static_cast<int>(currItem->width()+6), static_cast<int>(currItem->height()+6))))).contains(mpo)))
+ QRect mpo = QRect(m->x() - m_doc->guidesPrefs().grabRadius, m->y() - m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius * 2, m_doc->guidesPrefs().grabRadius * 2);
+ if ((QRegion(p.map(QPolygon(QRect(-3, -3, static_cast<int>(currItem->width() + 6), static_cast<int>(currItem->height() + 6))))).contains(mpo)))
{
QRect tx = p.mapRect(QRect(0, 0, static_cast<int>(currItem->width()), static_cast<int>(currItem->height())));
if ((tx.intersects(mpo)) && (!currItem->locked()))
@@ -788,8 +779,8 @@
m_view->setCursor(QCursor(Qt::SizeAllCursor));
else if (!currItem->locked() && !currItem->sizeLocked())
{
- if ((!currItem->sizeHLocked() && !currItem->sizeVLocked()) || (currItem->sizeHLocked() && (how == 5 || how == 8))
- || (currItem->sizeVLocked() && (how == 6 || how == 7)))
+ if ((!currItem->sizeHLocked() && !currItem->sizeVLocked()) || (currItem->sizeHLocked() && (how == Canvas::SOUTH || how == Canvas::NORTH))
+ || (currItem->sizeVLocked() && (how == Canvas::EAST || how == Canvas::WEST)))
setResizeCursor(how, currItem->rotation());
}
}
@@ -811,8 +802,8 @@
{
if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
{
- newX = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
- newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
+ newX = qRound(mousePointDoc.x());
+ newY = qRound(mousePointDoc.y());
m_mouseSavedPoint.setXY(newX, newY);
QPoint startP = m_canvas->canvasToGlobal(m_mousePressPoint);
m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
@@ -839,8 +830,6 @@
m_doc->leaveDrag = false;
m->accept();
m_view->registerMousePress(m->globalPos());
-// QRect mpo(m->x()-m_doc->guidesPrefs().grabRadius, m->y()-m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius*2, m_doc->guidesPrefs().grabRadius*2);
-// mpo.moveBy(qRound(m_doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(m_doc->minCanvasCoordinate.y() * m_canvas->scale()));
if (m->button() == Qt::MidButton)
{
@@ -1105,8 +1094,8 @@
{
double gx, gy, gh, gw;
m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
- FPoint maxSize(gx+gw+m_doc->scratch()->right(), gy+gh+m_doc->scratch()->bottom());
- FPoint minSize(gx-m_doc->scratch()->left(), gy-m_doc->scratch()->top());
+ FPoint maxSize(gx + gw + m_doc->scratch()->right(), gy + gh + m_doc->scratch()->bottom());
+ FPoint minSize(gx - m_doc->scratch()->left(), gy - m_doc->scratch()->top());
m_doc->adjustCanvas(minSize, maxSize);
}
m_doc->setRedrawBounding(currItem);
@@ -1139,8 +1128,8 @@
QRectF localSele = m_canvas->canvasToLocal(canvasSele).normalized();
if (!m_doc->masterPageMode())
{
- uint docPagesCount=m_doc->Pages->count();
- uint docCurrPageNo=m_doc->currentPageNumber();
+ uint docPagesCount = m_doc->Pages->count();
+ uint docCurrPageNo = m_doc->currentPageNumber();
for (uint i = 0; i < docPagesCount; ++i)
{
ScPage* page = m_doc->Pages->at(i);
@@ -1157,7 +1146,7 @@
}
m_view->setRulerPos(m_view->contentsX(), m_view->contentsY());
}
- int docItemCount=m_doc->Items->count();
+ int docItemCount = m_doc->Items->count();
if (docItemCount != 0)
{
m_doc->m_Selection->delaySignalsOn();
@@ -1597,7 +1586,7 @@
double gx(0.0), gy(0.0), gw(0.0), gh(0.0);
m_doc->m_Selection->setGroupRect();
m_doc->m_Selection->getVisualGroupRect(&gx, &gy, &gw, &gh);
- Canvas::FrameHandle frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), QRectF(gx, gy, gw, gh));
+ Canvas::FrameHandle frameResizeHandle = m_canvas->frameHitTest(QPointF(mousePointDoc.x(), mousePointDoc.y()), QRectF(gx, gy, gw, gh));
enableGuideGesture = (frameResizeHandle == Canvas::INSIDE);
}
if (enableGuideGesture)
@@ -1605,7 +1594,7 @@
if (!m_guideMoveGesture)
{
m_guideMoveGesture = new RulerGesture(m_view, RulerGesture::HORIZONTAL);
- connect(m_guideMoveGesture,SIGNAL(guideInfo(int,qreal)),m_ScMW->alignDistributePalette,SLOT(setGuide(int,qreal)));
+ connect(m_guideMoveGesture,SIGNAL(guideInfo(int,qreal)), m_ScMW->alignDistributePalette,SLOT(setGuide(int,qreal)));
}
if ( (!m_doc->GuideLock) && (m_guideMoveGesture->mouseHitsGuide(mousePointDoc)) )
{
@@ -1626,33 +1615,33 @@
if (!m_doc->masterPageMode())
{
int pgNum = -1;
- int docPageCount = static_cast<int>(m_doc->Pages->count() - 1);
+ int docPageCount = m_doc->Pages->count() - 1;
MarginStruct pageBleeds;
bool drawBleed = false;
if (!m_doc->bleeds()->isNull() && m_doc->guidesPrefs().showBleed)
drawBleed = true;
- for (int a = docPageCount; a > -1; a--)
+ for (int i = docPageCount; i > -1; i--)
{
if (drawBleed)
- m_doc->getBleeds(a, pageBleeds);
- int x = static_cast<int>(m_doc->Pages->at(a)->xOffset() - pageBleeds.left());
- int y = static_cast<int>(m_doc->Pages->at(a)->yOffset() - pageBleeds.top());
- int w = static_cast<int>(m_doc->Pages->at(a)->width() + pageBleeds.left() + pageBleeds.right());
- int h = static_cast<int>(m_doc->Pages->at(a)->height() + pageBleeds.bottom() + pageBleeds.top());
+ m_doc->getBleeds(i, pageBleeds);
+ int x = static_cast<int>(m_doc->Pages->at(i)->xOffset() - pageBleeds.left());
+ int y = static_cast<int>(m_doc->Pages->at(i)->yOffset() - pageBleeds.top());
+ int w = static_cast<int>(m_doc->Pages->at(i)->width() + pageBleeds.left() + pageBleeds.right());
+ int h = static_cast<int>(m_doc->Pages->at(i)->height() + pageBleeds.bottom() + pageBleeds.top());
if (QRect(x, y, w, h).contains(MxpS, MypS))
{
- pgNum = static_cast<int>(a);
+ pgNum = i;
if (drawBleed) // check again if its really on the correct page
{
- for (int a2 = docPageCount; a2 > -1; a2--)
+ for (int j = docPageCount; j > -1; j--)
{
- int xn = static_cast<int>(m_doc->Pages->at(a2)->xOffset());
- int yn = static_cast<int>(m_doc->Pages->at(a2)->yOffset());
- int wn = static_cast<int>(m_doc->Pages->at(a2)->width());
- int hn = static_cast<int>(m_doc->Pages->at(a2)->height());
+ int xn = static_cast<int>(m_doc->Pages->at(j)->xOffset());
+ int yn = static_cast<int>(m_doc->Pages->at(j)->yOffset());
+ int wn = static_cast<int>(m_doc->Pages->at(j)->width());
+ int hn = static_cast<int>(m_doc->Pages->at(j)->height());
if (QRect(xn, yn, wn, hn).contains(MxpS, MypS))
{
- pgNum = static_cast<int>(a2);
+ pgNum = j;
break;
}
}
@@ -1701,7 +1690,7 @@
{
//CB: If we have a selection but the user clicks with control on another item that is not below the current
//then clear and select the new item
- if ((m->modifiers() == SELECT_BENEATH) && m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem) >= 0)
+ if ((m->modifiers() == SELECT_BENEATH) && m_canvas->frameHitTest(QPointF(mousePointDoc.x(), mousePointDoc.y()), currItem) >= 0)
m_doc->m_Selection->clear();
//CB: #7186: This was prependItem, does not seem to need to be anymore with current select code
if (m_doc->drawAsPreview && !m_doc->editOnPreview)
More information about the scribus-commit
mailing list