r22801 by jghali - Refactoring + fixes related to zooming and canvas positioning
scribus-commit
scribus-commit at lists.scribus.net
Sun Jan 13 13:11:19 UTC 2019
Author: jghali
Date: Sun Jan 13 13:11:19 2019
New Revision: 22801
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22801
Log:
Refactoring + fixes related to zooming and canvas positioning
Modified:
trunk/Scribus/scribus/canvasmode_create.cpp
trunk/Scribus/scribus/canvasmode_magnifier.cpp
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribusview.cpp
trunk/Scribus/scribus/scribusview.h
Modified: trunk/Scribus/scribus/canvasmode_create.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22801&path=/trunk/Scribus/scribus/canvasmode_create.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_create.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_create.cpp Sun Jan 13 13:11:19 2019
@@ -841,6 +841,7 @@
SetupDrawNoResize(z);
newObject = m_doc->Items->at(z);
newObject->ContourLine = newObject->PoLine.copy();
+ m_doc->setRedrawBounding(newObject);
}
return newObject;
}
Modified: trunk/Scribus/scribus/canvasmode_magnifier.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22801&path=/trunk/Scribus/scribus/canvasmode_magnifier.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_magnifier.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_magnifier.cpp Sun Jan 13 13:11:19 2019
@@ -214,7 +214,7 @@
{
int mx = qRound(mousePointDoc.x());
int my = qRound(mousePointDoc.y());
- m_view->Magnify ? m_view->slotZoomIn(mx, my) : m_view->slotZoomOut(mx, my);
+ m_view->Magnify ? m_view->slotZoomIn(mx, my, true) : m_view->slotZoomOut(mx, my, true);
if (sc == m_canvas->scale())
{
m_view->HaveSelRect = false;
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22801&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sun Jan 13 13:11:19 2019
@@ -6570,7 +6570,7 @@
}
QPointF point = itemTrans.map(QPointF(xOffset, yOffset));
- view->SetCCPo(point.x(), point.y());
+ view->setCanvasCenterPos(point.x(), point.y());
}
void ScribusMainWindow::selectItemFromOutlines(PageItem *ite, bool single, int cPos)
@@ -7696,8 +7696,8 @@
}
m_storedPageNum = doc->currentPageNumber();
- m_storedViewXCoor = view->contentsX();
- m_storedViewYCoor = view->contentsY();
+ m_storedViewXCoor = view->horizontalScrollBar()->value();
+ m_storedViewYCoor = view->verticalScrollBar()->value();
m_storedViewScale = view->scale();
doc->stored_minCanvasCoordinate = doc->minCanvasCoordinate;
doc->stored_maxCanvasCoordinate = doc->maxCanvasCoordinate;
@@ -7713,9 +7713,9 @@
void ScribusMainWindow::editMasterPagesEnd()
{
- view->setScale(m_storedViewScale);
doc->minCanvasCoordinate = doc->stored_minCanvasCoordinate;
doc->maxCanvasCoordinate = doc->stored_maxCanvasCoordinate;
+ view->setScale(m_storedViewScale);
view->hideMasterPage();
if (m_WasAutoSave)
{
@@ -7741,9 +7741,10 @@
doc->setCurrentPage(doc->DocPages.at(m_storedPageNum));
doc->minCanvasCoordinate = doc->stored_minCanvasCoordinate;
doc->maxCanvasCoordinate = doc->stored_maxCanvasCoordinate;
+
doc->setLoading(true);
view->reformPages(false);
- view->setContentsPos(static_cast<int>(m_storedViewXCoor * m_storedViewScale), static_cast<int>(m_storedViewYCoor * m_storedViewScale));
+ view->setContentsPos(m_storedViewXCoor, m_storedViewYCoor);
doc->setLoading(false);
view->DrawNew();
}
@@ -8247,7 +8248,7 @@
if (scriptIsRunning())
return;
slotSetCurrentPage(p0);
- doc->view()->SetCPo(doc->currentPage()->xOffset() - 10, doc->currentPage()->yOffset() - 10);
+ doc->view()->setCanvasPos(doc->currentPage()->xOffset() - 10, doc->currentPage()->yOffset() - 10);
HaveNewSel();
doc->view()->setFocus();
}
Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22801&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Sun Jan 13 13:11:19 2019
@@ -152,10 +152,9 @@
updateOn(true),
Magnify(false),
RCenter(-1,-1),
- Ready(false),
- oldX(0), oldY(0),
+ m_ready(false),
+ m_oldZoomX(0), m_oldZoomY(0),
m_groupTransactions(0),
- m_oldCanvasHeight(0), m_oldCanvasWidth(0),
_isGlobalMode(true),
linkAfterDraw(false),
ImageAfterDraw(false),
@@ -191,7 +190,7 @@
horizRuler->setGeometry(m_vhRulerHW, 1, width()-m_vhRulerHW-1, m_vhRulerHW);
vertRuler->setGeometry(1, m_vhRulerHW, m_vhRulerHW, height()-m_vhRulerHW-1);
rulerMover->setGeometry(1, 1, m_vhRulerHW, m_vhRulerHW);
- Ready = true;
+ m_ready = true;
m_canvas->setMouseTracking(true);
setAcceptDrops(true);
m_canvas->setAcceptDrops(true);
@@ -345,23 +344,21 @@
void ScribusView::changed(QRectF re, bool)
{
double scale = m_canvas->scale();
- int newCanvasWidth = qRound((Doc->maxCanvasCoordinate.x() - Doc->minCanvasCoordinate.x()) * scale);
+ int newCanvasWidth = qRound((Doc->maxCanvasCoordinate.x() - Doc->minCanvasCoordinate.x()) * scale);
int newCanvasHeight = qRound((Doc->maxCanvasCoordinate.y() - Doc->minCanvasCoordinate.y()) * scale);
- if (!re.isValid() && // don't check this all the time
- ( m_oldCanvasWidth != newCanvasWidth || m_oldCanvasHeight != newCanvasHeight))
+ QSize newCanvasSize(newCanvasWidth, newCanvasHeight);
+ if (!re.isValid() && /* don't check this all the time */
+ (m_oldCanvasSize != newCanvasSize))
{
QSize maxViewport = maximumViewportSize();
- horizontalScrollBar()->setRange(qRound(Doc->minCanvasCoordinate.x() * scale),
- qRound(Doc->maxCanvasCoordinate.x() * scale) - maxViewport.width());
- verticalScrollBar()->setRange(qRound(Doc->minCanvasCoordinate.y() * scale),
- qRound(Doc->maxCanvasCoordinate.y() * scale) - maxViewport.height());
- /* qDebug() << "adjustCanvas [" << m_oldCanvasWidth << m_oldCanvasHeight << " ] -> [" << newCanvasWidth << newCanvasHeight
+ horizontalScrollBar()->setRange(0, newCanvasWidth - maxViewport.width());
+ verticalScrollBar()->setRange(0, newCanvasHeight - maxViewport.height());
+ /* qDebug() << "adjustCanvas [" << m_oldCanvasSize.width() << m_oldCanvasSize.height() << " ] -> [" << newCanvasWidth << newCanvasHeight
<< "] (" << Doc->minCanvasCoordinate.x() << Doc->minCanvasCoordinate.y() << ") - ("
<< Doc->maxCanvasCoordinate.x() << Doc->maxCanvasCoordinate.y() << ") @" << scale << maxViewport;
*/
- widget()->resize(newCanvasWidth, newCanvasHeight);
- m_oldCanvasWidth = newCanvasWidth;
- m_oldCanvasHeight = newCanvasHeight;
+ widget()->resize(newCanvasWidth, newCanvasHeight);
+ m_oldCanvasSize = newCanvasSize;
}
if (!Doc->isLoading() && !m_ScMW->scriptIsRunning())
{
@@ -433,7 +430,7 @@
{
bool updateNecessary = false;
// qDebug() << "request mode:" << appMode;
- switch(appMode) // filter submodes
+ switch (appMode) // filter submodes
{
case submodePaintingDone: // return to normal mode
appMode = modeNormal;
@@ -1358,26 +1355,6 @@
}
}
-
-/*
-void ScribusView::normalizeSelectionRect() // unsused
-{
- if(Mxp > SeRx)
- {
- int tmp = SeRx;
- SeRx = Mxp;
- Mxp = tmp;
- }
- if(Myp > SeRy)
- {
- int tmp = SeRy;
- SeRy = Myp;
- Myp = tmp;
- }
-}
-*/
-
-
void ScribusView::getDragRectScreen(double *x, double *y, double *w, double *h)
{
QPoint in(qRound(dragX*m_canvas->scale()), qRound(dragY*m_canvas->scale()));
@@ -2022,14 +1999,14 @@
void ScribusView::setHBarGeometry(QScrollBar &bar, int x, int y, int w, int h)
{
bar.setGeometry(x, y, w, h);
- if (Ready)
+ if (m_ready)
horizRuler->setGeometry(m_vhRulerHW, 1, w-m_vhRulerHW-1, m_vhRulerHW);
}
void ScribusView::setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h)
{
bar.setGeometry(x, y, w, h);
- if (Ready)
+ if (m_ready)
{
vertRuler->setGeometry(1, m_vhRulerHW, m_vhRulerHW, h-m_vhRulerHW-1);
rulerMover->setGeometry(1, 1, m_vhRulerHW, m_vhRulerHW);
@@ -2122,8 +2099,8 @@
//CB find a new name
void ScribusView::rememberOldZoomLocation(int mx, int my)
{
- oldX = mx;
- oldY = my;
+ m_oldZoomX = mx;
+ m_oldZoomY = my;
}
void ScribusView::setRulerPos(int x, int y)
@@ -2256,10 +2233,10 @@
verticalScrollBar()->setValue(qRound(y * scale));
// fix ranges
QSize maxViewport = maximumViewportSize();
- horizontalScrollBar()->setRange(qRound(Doc->minCanvasCoordinate.x() * scale),
- qRound(Doc->maxCanvasCoordinate.x() * scale) - maxViewport.width());
- verticalScrollBar()->setRange(qRound(Doc->minCanvasCoordinate.y() * scale),
- qRound(Doc->maxCanvasCoordinate.y() * scale) - maxViewport.height());
+ int newCanvasWidth = qRound((Doc->maxCanvasCoordinate.x() - Doc->minCanvasCoordinate.x()) * scale);
+ int newCanvasHeight = qRound((Doc->maxCanvasCoordinate.y() - Doc->minCanvasCoordinate.y()) * scale);
+ horizontalScrollBar()->setRange(0, newCanvasWidth - maxViewport.width());
+ verticalScrollBar()->setRange(0, newCanvasHeight - maxViewport.height());
}
@@ -2309,26 +2286,47 @@
void ScribusView::setZoom()
{
- int x = qRound(qMax(contentsX() / m_canvas->scale(), 0.0));
- int y = qRound(qMax(contentsY() / m_canvas->scale(), 0.0));
- int w = qRound(qMin(visibleWidth() / m_canvas->scale(), Doc->currentPage()->width()));
- int h = qRound(qMin(visibleHeight() / m_canvas->scale(), Doc->currentPage()->height()));
- rememberOldZoomLocation(w / 2 + x,h / 2 + y);
- zoom(oldX, oldY, m_ScMW->zoomSpinBox->value() / 100.0 * Prefs->displayPrefs.displayScale, false);
+ double x = qMax(contentsX() / m_canvas->scale(), Doc->minCanvasCoordinate.x());
+ double y = qMax(contentsY() / m_canvas->scale(), Doc->minCanvasCoordinate.y());
+ double w = qMin(visibleWidth() / m_canvas->scale(), Doc->maxCanvasCoordinate.x() - Doc->minCanvasCoordinate.x());
+ double h = qMin(visibleHeight() / m_canvas->scale(), Doc->maxCanvasCoordinate.y() - Doc->minCanvasCoordinate.y());
+
+ int zoomX = qRound(x + w / 2);
+ int zoomY = qRound(y + h / 2);
+ rememberOldZoomLocation(zoomX, zoomY);
+
+ zoom(m_oldZoomX, m_oldZoomY, m_ScMW->zoomSpinBox->value() / 100.0 * Prefs->displayPrefs.displayScale, false);
setFocus();
}
void ScribusView::slotZoom100()
{
- int x = qRound(qMax(contentsX() / m_canvas->scale(), Doc->minCanvasCoordinate.x()));
- int y = qRound(qMax(contentsY() / m_canvas->scale(), Doc->minCanvasCoordinate.y()));
- int w = qRound(qMin(visibleWidth() / m_canvas->scale(), Doc->maxCanvasCoordinate.x() - Doc->minCanvasCoordinate.x()));
- int h = qRound(qMin(visibleHeight() / m_canvas->scale(), Doc->maxCanvasCoordinate.y() - Doc->minCanvasCoordinate.y()));
- rememberOldZoomLocation(w / 2 + x,h / 2 + y);
- zoom(oldX, oldY, Prefs->displayPrefs.displayScale, false);
-}
-
-void ScribusView::slotZoomIn(int mx, int my)
+ double x = qMax(contentsX() / m_canvas->scale(), Doc->minCanvasCoordinate.x());
+ double y = qMax(contentsY() / m_canvas->scale(), Doc->minCanvasCoordinate.y());
+ double w = qMin(visibleWidth() / m_canvas->scale(), Doc->maxCanvasCoordinate.x() - Doc->minCanvasCoordinate.x());
+ double h = qMin(visibleHeight() / m_canvas->scale(), Doc->maxCanvasCoordinate.y() - Doc->minCanvasCoordinate.y());
+
+ int zoomX = qRound(x + w / 2);
+ int zoomY = qRound(y + h / 2);
+ rememberOldZoomLocation(zoomX, zoomY);
+
+ int zoomPointX(m_oldZoomX), zoomPointY(m_oldZoomY);
+ if (Doc->m_Selection->count() != 0)
+ {
+ QRectF selRect = Doc->m_Selection->getVisualGroupRect();
+ zoomPointX = qRound(selRect.x() + selRect.width() / 2.0);
+ zoomPointY = qRound(selRect.y() + selRect.height() / 2.0);
+ }
+ else if (Doc->currentPage() != nullptr)
+ {
+ ScPage* currentPage = Doc->currentPage();
+ zoomPointX = qRound(currentPage->xOffset() + currentPage->width() / 2.0);
+ zoomPointY = qRound(currentPage->yOffset() + currentPage->height() / 2.0);
+ }
+ zoom(zoomPointX, zoomPointY, Prefs->displayPrefs.displayScale, false);
+}
+
+void ScribusView::slotZoomIn(int mx, int my, bool preservePoint)
{
// FIXME : mx and my should really be ScribusView local coordinates or global coordinates
int oldZoomX(mx), oldZoomY(my);
@@ -2347,18 +2345,27 @@
if (static_cast<int>(newScale * 100) > static_cast<int>(100 * static_cast<double>(Doc->opToolPrefs().magStep) * Prefs->displayPrefs.displayScale / 100))
newScale = m_canvas->scale() + static_cast<double>(Doc->opToolPrefs().magStep) * Prefs->displayPrefs.displayScale / 100;
- int zoomPointX(oldX), zoomPointY(oldY);
- if (Doc->m_Selection->count() != 0)
- {
- PageItem *currItem = Doc->m_Selection->itemAt(0);
- zoomPointX = qRound(currItem->xPos() + currItem->width() / 2.0);
- zoomPointY = qRound(currItem->yPos() + currItem->height() / 2.0);
- }
- zoom(zoomPointX, zoomPointY, newScale, (Doc->m_Selection->count() == 0));
+ int zoomPointX(m_oldZoomX), zoomPointY(m_oldZoomY);
+ if (!preservePoint)
+ {
+ if (Doc->m_Selection->count() != 0)
+ {
+ QRectF selRect = Doc->m_Selection->getVisualGroupRect();
+ zoomPointX = qRound(selRect.x() + selRect.width() / 2.0);
+ zoomPointY = qRound(selRect.y() + selRect.height() / 2.0);
+ }
+ else if (Doc->currentPage() != nullptr)
+ {
+ ScPage* currentPage = Doc->currentPage();
+ zoomPointX = qRound(currentPage->xOffset() + currentPage->width() / 2.0);
+ zoomPointY = qRound(currentPage->yOffset() + currentPage->height() / 2.0);
+ }
+ }
+ zoom(zoomPointX, zoomPointY, newScale, preservePoint);
}
/** Verkleinert die Ansicht */
-void ScribusView::slotZoomOut(int mx, int my)
+void ScribusView::slotZoomOut(int mx, int my, bool preservePoint)
{
// FIXME : mx and my should really be ScribusView local coordinates or global coordinates
int oldZoomX(mx), oldZoomY(my);
@@ -2379,14 +2386,23 @@
if (newScale <= Prefs->displayPrefs.displayScale / 100)
newScale = m_canvas->scale();
- int zoomPointX(oldX), zoomPointY(oldY);
- if (Doc->m_Selection->count() != 0)
- {
- PageItem *currItem = Doc->m_Selection->itemAt(0);
- zoomPointX = qRound(currItem->xPos() + currItem->width() / 2.0);
- zoomPointY = qRound(currItem->yPos() + currItem->height() / 2.0);
- }
- zoom(zoomPointX, zoomPointY, newScale, (Doc->m_Selection->count() == 0));
+ int zoomPointX(m_oldZoomX), zoomPointY(m_oldZoomY);
+ if (!preservePoint)
+ {
+ if (Doc->m_Selection->count() != 0)
+ {
+ QRectF selRect = Doc->m_Selection->getVisualGroupRect();
+ zoomPointX = qRound(selRect.x() + selRect.width() / 2.0);
+ zoomPointY = qRound(selRect.y() + selRect.height() / 2.0);
+ }
+ else if (Doc->currentPage() != nullptr)
+ {
+ ScPage* currentPage = Doc->currentPage();
+ zoomPointX = qRound(currentPage->xOffset() + currentPage->width() / 2.0);
+ zoomPointY = qRound(currentPage->yOffset() + currentPage->height() / 2.0);
+ }
+ }
+ zoom(zoomPointX, zoomPointY, newScale, preservePoint);
}
void ScribusView::DrawNew()
@@ -2405,7 +2421,7 @@
// connect(m_ScMW->zoomSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setZoom()));
}
-void ScribusView::SetCCPo(double x, double y)
+void ScribusView::setCanvasCenterPos(double x, double y)
{
if (m_ScMW->scriptIsRunning())
return;
@@ -2415,7 +2431,7 @@
setContentsPos(nx.x() - viewsize.width() / 2, nx.y() - viewsize.height() / 2);
}
-void ScribusView::SetCPo(double x, double y)
+void ScribusView::setCanvasPos(double x, double y)
{
if (m_ScMW->scriptIsRunning())
return;
@@ -2457,7 +2473,7 @@
if (m_ScMW->scriptIsRunning())
return;
m_ScMW->slotSetCurrentPage(Seite);
- SetCPo(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
+ setCanvasPos(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
m_ScMW->HaveNewSel();
}
@@ -2472,10 +2488,10 @@
Doc->setCurrentPage(Doc->Pages->at(nr));
m_ScMW->pageSelector->setEnabled(false);
updateOn = false;
- zoom();
- oldX = qRound(Doc->currentPage()->xOffset()- 10);
- oldY = qRound(Doc->currentPage()->yOffset()- 10);
- SetCPo(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
+ setZoom();
+ m_oldZoomX = qRound(Doc->currentPage()->xOffset()- 10);
+ m_oldZoomY = qRound(Doc->currentPage()->yOffset()- 10);
+ setCanvasPos(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
updateOn = true;
endEditButton->setVisible(true);
DrawNew();
@@ -2503,10 +2519,10 @@
m_ScMW->pageSelector->setEnabled(false);
m_ScMW->layerMenu->setEnabled(false);
updateOn = false;
- zoom();
- oldX = qRound(Doc->currentPage()->xOffset()- 10);
- oldY = qRound(Doc->currentPage()->yOffset()- 10);
- SetCPo(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
+ setZoom();
+ m_oldZoomX = qRound(Doc->currentPage()->xOffset()- 10);
+ m_oldZoomY = qRound(Doc->currentPage()->yOffset()- 10);
+ setCanvasPos(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
updateOn = true;
endEditButton->setVisible(true);
DrawNew();
@@ -2538,10 +2554,10 @@
m_ScMW->pageSelector->setEnabled(false);
m_ScMW->layerMenu->setEnabled(false);
updateOn = false;
- zoom();
- oldX = qRound(Doc->currentPage()->xOffset()- 10);
- oldY = qRound(Doc->currentPage()->yOffset()- 10);
- SetCPo(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
+ setZoom();
+ m_oldZoomX = qRound(Doc->currentPage()->xOffset()- 10);
+ m_oldZoomY = qRound(Doc->currentPage()->yOffset()- 10);
+ setCanvasPos(Doc->currentPage()->xOffset() - 10, Doc->currentPage()->yOffset() - 10);
updateOn = true;
endEditButton->setVisible(true);
DrawNew();
@@ -3140,7 +3156,7 @@
UndoTransaction trans(undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), Um::ToOutlines, "", nullptr));
int offset = 0;
- for(int i = 0; i < selectedItemCount; ++i)
+ for (int i = 0; i < selectedItemCount; ++i)
{
PageItem *currItem = tmpSelection.itemAt(offset);
bool cont = false;
@@ -3240,7 +3256,7 @@
if (toDeleteItemCount != 0)
{
tmpSelection.clear();
- for(int i = 0; i < toDeleteItemCount; ++i)
+ for (int i = 0; i < toDeleteItemCount; ++i)
tmpSelection.addItem(delItems.takeAt(0)); //yes, 0, remove the first
Doc->itemSelection_DeleteItem(&tmpSelection);
}
@@ -3267,7 +3283,7 @@
//qDebug() << "IME" << event->commitString() << event->preeditString() << "attributes:" << event->attributes().count();
// #9682 : Avoid parameter type ambiguity in QKeyEvent constructor with Qt3Support enabled Qt builds
Qt::KeyboardModifiers modifiers = Qt::NoModifier;
- for(int i = 0; i < event->commitString().length(); ++i)
+ for (int i = 0; i < event->commitString().length(); ++i)
{
QKeyEvent ev( QEvent::KeyPress, 0, modifiers, event->commitString().mid(i,1));
keyPressEvent(&ev);
@@ -3285,13 +3301,12 @@
if (w->modifiers() == Qt::ControlModifier)
{
FPoint mp = m_canvas->globalToCanvas(w->globalPos());
- w->delta() > 0 ? slotZoomIn(mp.x(), mp.y()) : slotZoomOut(mp.x(), mp.y());
-
+ w->delta() > 0 ? slotZoomIn(mp.x(), mp.y() , true) : slotZoomOut(mp.x(), mp.y(), true);
}
else
{
- int dX=0,dY=0;
- int moveBy=(w->delta() < 0) ? Prefs->uiPrefs.wheelJump : -Prefs->uiPrefs.wheelJump;
+ int dX = 0,dY = 0;
+ int moveBy = (w->delta() < 0) ? Prefs->uiPrefs.wheelJump : -Prefs->uiPrefs.wheelJump;
if ((w->orientation() != Qt::Vertical) || ( w->modifiers() == Qt::ShiftModifier ))
dX = moveBy;
else
@@ -3599,7 +3614,7 @@
void ScribusView::zoom(double scale)
{
- double zPointX = oldX, zPointY = oldY;
+ double zPointX = m_oldZoomX, zPointY = m_oldZoomY;
if (scale <= 0.0)
scale = m_canvas->scale();
if (Doc->m_Selection->count() != 0)
Modified: trunk/Scribus/scribus/scribusview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22801&path=/trunk/Scribus/scribus/scribusview.h
==============================================================================
--- trunk/Scribus/scribus/scribusview.h (original)
+++ trunk/Scribus/scribus/scribusview.h Sun Jan 13 13:11:19 2019
@@ -46,6 +46,7 @@
#include <QPoint>
#include <QRect>
#include <QRectF>
+#include <QSize>
#include <QTime>
#include <QTimer>
#include <QWheelEvent>
@@ -195,7 +196,6 @@
void updateCanvas(double x, double y, double width, double height) { updateCanvas(QRectF(x,y,width,height)); }
void setCanvasOrigin(double x, double y);
void setCanvasCenter(double x, double y);
- void scrollCanvasBy(double deltaX, double deltaY);
FPoint canvasOrigin() const;
QRectF visibleCanvas() const;
void setRedrawMarkerShown(bool shown);
@@ -208,16 +208,23 @@
void resizeContents(int w, int h);
QPoint contentsToViewport(QPoint p);
QPoint viewportToContents(QPoint p);
+
public: // for now
int contentsX();
int contentsY();
int contentsWidth();
int contentsHeight();
+ int visibleWidth() { return viewport()->size().width(); };
+ int visibleHeight() { return viewport()->size().height(); };
+
+ void setCanvasPos(double x, double y);
+ void setCanvasCenterPos(double x, double y);
void setContentsPos(int x, int y);
- int visibleWidth() { return viewport()->size().width(); } ;
- int visibleHeight() { return viewport()->size().height(); } ;
- void stopAllDrags();
+
void scrollBy(int x, int y);
+ void scrollCanvasBy(double deltaX, double deltaY);
+ void scrollContentsBy(int dx, int dy);
+
void zoom(double scale = 0.0);
void zoom(int canvasX, int canvasY, double scale, bool preservePoint);
@@ -232,8 +239,8 @@
/** Zooms in or out */
void slotZoom100();
/** Zooms in */
- void slotZoomIn(int mx=0,int my=0);
- void slotZoomOut(int mx=0,int my=0);
+ void slotZoomIn(int mx = 0, int my = 0, bool preservePoint = false);
+ void slotZoomOut(int mx = 0, int my = 0, bool preservePoint = false);
/** Redraws everything */
void DrawNew();
void GotoPa(int Seite);
@@ -241,8 +248,6 @@
void GotoPage(int Seite);
void ChgUnit(int art);
- void SetCPo(double x, double y);
- void SetCCPo(double x, double y);
void editExtendedImageProperties();
void RefreshGradient(PageItem *currItem, double dx = 8, double dy = 8);
void ToPicFrame();
@@ -266,15 +271,14 @@
QPoint m_pressLocation;
QTime m_moveTimer;
QTimer *m_dragTimer;
- bool m_dragTimerFired;
- bool Ready;
- int oldX;
- int oldY;
- int m_groupTransactions;
- int m_oldCanvasHeight;
- int m_oldCanvasWidth;
+ bool m_dragTimerFired;
+ bool m_ready;
+ int m_oldZoomX;
+ int m_oldZoomY;
+ QSize m_oldCanvasSize;
+ int m_groupTransactions;
UndoTransaction m_groupTransaction;
- bool _isGlobalMode;
+ bool _isGlobalMode;
bool linkAfterDraw;
bool ImageAfterDraw;
@@ -310,6 +314,7 @@
inline void stopDragTimer();
inline void resetDragTimer();
inline bool dragTimerElapsed();
+ void stopAllDrags();
bool handleObjectImport(QMimeData* mimeData, TransactionSettings* trSettings = nullptr);
@@ -326,7 +331,6 @@
virtual void contentsDropEvent(QDropEvent *e);
virtual void setHBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
virtual void setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
- void scrollContentsBy(int dx, int dy);
//The width of vertical ruler/height of horizontal ruler, set to 17 in scribusview.cpp
int m_vhRulerHW;
More information about the scribus-commit
mailing list