[calligra] /: Revert "Fixed autoscrolling bug in Krita"
Dmitry Kazakov
dimula73 at gmail.com
Sun Apr 17 07:27:11 BST 2011
Git commit 044aa71e9fd5374044d2cb9d4baedeebe244cf6c by Dmitry Kazakov.
Committed on 17/04/2011 at 08:00.
Pushed by dkazakov into branch 'master'.
Revert "Fixed autoscrolling bug in Krita"
This reverts commit a1bc54466caf7066db145d8bab989c1d620084b6.
(Breaks Stage as reported by Thorsten Zachmann)
CCMAIL:calligra-devel at kde.org
M +0 -1 krita/ui/CMakeLists.txt
M +2 -2 krita/ui/canvas/kis_canvas2.cpp
D +0 -34 krita/ui/canvas/kis_tool_proxy.cpp
D +0 -33 krita/ui/canvas/kis_tool_proxy.h
M +9 -32 libs/flake/KoToolProxy.cpp
M +1 -5 libs/flake/KoToolProxy.h
M +1 -1 libs/flake/KoToolProxy_p.h
http://commits.kde.org/calligra/044aa71e9fd5374044d2cb9d4baedeebe244cf6c
diff --git a/krita/ui/CMakeLists.txt b/krita/ui/CMakeLists.txt
index fba4d34..c9bc763 100644
--- a/krita/ui/CMakeLists.txt
+++ b/krita/ui/CMakeLists.txt
@@ -20,7 +20,6 @@ set(kritaui_LIB_SRCS
canvas/kis_canvas_widget_base.cpp
canvas/kis_canvas2.cpp
canvas/kis_canvas_controller.cpp
- canvas/kis_tool_proxy.cpp
canvas/kis_canvas_decoration.cc
canvas/kis_coordinates_converter.cpp
canvas/kis_grid_manager.cpp
diff --git a/krita/ui/canvas/kis_canvas2.cpp b/krita/ui/canvas/kis_canvas2.cpp
index ce65d34..3e4dc6c 100644
--- a/krita/ui/canvas/kis_canvas2.cpp
+++ b/krita/ui/canvas/kis_canvas2.cpp
@@ -34,9 +34,9 @@
#include <KoColorSpaceRegistry.h>
#include <KoCanvasControllerWidget.h>
#include <KoDocument.h>
+#include <KoToolProxy.h>
#include <KoSelection.h>
-#include "kis_tool_proxy.h"
#include "kis_coordinates_converter.h"
#include "kis_prescaled_projection.h"
#include "kis_image.h"
@@ -78,7 +78,7 @@ public:
, monitorProfile(0)
, currentCanvasIsOpenGL(false)
, currentCanvasUsesOpenGLShaders(false)
- , toolProxy(new KisToolProxy(parent))
+ , toolProxy(new KoToolProxy(parent))
, favoriteResourceManager(0)
, vastScrolling(true) {
}
diff --git a/krita/ui/canvas/kis_tool_proxy.cpp b/krita/ui/canvas/kis_tool_proxy.cpp
deleted file mode 100644
index 17479dd..0000000
--- a/krita/ui/canvas/kis_tool_proxy.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011 Dmitry Kazakov <dimula73 at gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kis_tool_proxy.h"
-#include "kis_canvas2.h"
-
-KisToolProxy::KisToolProxy(KoCanvasBase *canvas, QObject *parent)
- : KoToolProxy(canvas, parent)
-{
-}
-
-QPointF KisToolProxy::widgetToDocument(const QPointF &widgetPoint) const
-{
- KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas());
- Q_ASSERT(kritaCanvas);
-
- return kritaCanvas->coordinatesConverter()->widgetToDocument(widgetPoint);
-}
-
diff --git a/krita/ui/canvas/kis_tool_proxy.h b/krita/ui/canvas/kis_tool_proxy.h
deleted file mode 100644
index d30924b..0000000
--- a/krita/ui/canvas/kis_tool_proxy.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2011 Dmitry Kazakov <dimula73 at gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef __KIS_TOOL_PROXY_H
-#define __KIS_TOOL_PROXY_H
-
-#include <KoToolProxy.h>
-
-class KisToolProxy : public KoToolProxy
-{
-public:
- KisToolProxy(KoCanvasBase *canvas, QObject *parent = 0);
-
-protected:
- QPointF widgetToDocument(const QPointF &widgetPoint) const;
-};
-
-#endif /* __KIS_TOOL_PROXY_H */
diff --git a/libs/flake/KoToolProxy.cpp b/libs/flake/KoToolProxy.cpp
index 8429dd8..4f1608e 100644
--- a/libs/flake/KoToolProxy.cpp
+++ b/libs/flake/KoToolProxy.cpp
@@ -48,27 +48,20 @@ KoToolProxyPrivate::KoToolProxyPrivate(KoToolProxy *p)
void KoToolProxyPrivate::timeout() // Auto scroll the canvas
{
Q_ASSERT(controller);
-
- QPoint offset = QPoint(controller->canvasOffsetX(), controller->canvasOffsetY());
- QPoint origin = controller->canvas()->documentOrigin();
- QPoint viewPoint = widgetScrollPoint + origin - offset;
-
- QRectF mouseArea(viewPoint, QSizeF(10, 10));
+ int offsetX = controller->canvasOffsetX();
+ int offsetY = controller->canvasOffsetY();
+ QRectF mouseArea(scrollEdgePoint, QSizeF(10, 10));
mouseArea.setTopLeft(mouseArea.center());
controller->ensureVisible(mouseArea, true);
- QPoint newOffset = QPoint(controller->canvasOffsetX(), controller->canvasOffsetY());
-
- QPoint moved = offset - newOffset;
- if (moved.isNull())
+ QPoint moved(offsetX - controller->canvasOffsetX(), offsetY - controller->canvasOffsetY());
+ if (moved.x() == 0 && moved.y() == 0)
return;
+ scrollEdgePoint += moved;
- widgetScrollPoint += moved;
-
- QPointF documentPoint = parent->widgetToDocument(widgetScrollPoint);
- QMouseEvent event(QEvent::MouseMove, widgetScrollPoint, Qt::LeftButton, Qt::LeftButton, 0);
- KoPointerEvent ev(&event, documentPoint);
+ QMouseEvent event(QEvent::MouseMove, scrollEdgePoint, Qt::LeftButton, Qt::LeftButton, 0);
+ KoPointerEvent ev(&event, controller->canvas()->viewConverter()->viewToDocument(scrollEdgePoint));
activeTool->mouseMoveEvent(&ev);
}
@@ -79,9 +72,7 @@ void KoToolProxyPrivate::checkAutoScroll(const KoPointerEvent &event)
if (!activeTool->wantsAutoScroll()) return;
if (!event.isAccepted()) return;
if (event.buttons() != Qt::LeftButton) return;
-
- widgetScrollPoint = event.pos();
-
+ scrollEdgePoint = controller->canvas()->viewConverter()->documentToView(event.point).toPoint();
if (! scrollTimer.isActive())
scrollTimer.start();
}
@@ -130,20 +121,6 @@ void KoToolProxy::repaintDecorations()
if (d->activeTool) d->activeTool->repaintDecorations();
}
-QPointF KoToolProxy::widgetToDocument(const QPointF &widgetPoint) const
-{
- QPoint offset = QPoint(d->controller->canvasOffsetX(), d->controller->canvasOffsetY());
- QPoint origin = d->controller->canvas()->documentOrigin();
- QPoint viewPoint = widgetPoint.toPoint() + origin - offset;
-
- return d->controller->canvas()->viewConverter()->viewToDocument(viewPoint);
-}
-
-KoCanvasBase* KoToolProxy::canvas() const
-{
- return d->controller->canvas();
-}
-
#include <KDebug>
void KoToolProxy::tabletEvent(QTabletEvent *event, const QPointF &point)
{
diff --git a/libs/flake/KoToolProxy.h b/libs/flake/KoToolProxy.h
index c36fd2c..c5393f2 100644
--- a/libs/flake/KoToolProxy.h
+++ b/libs/flake/KoToolProxy.h
@@ -61,7 +61,7 @@ public:
* @param parent a parent QObject for memory management purposes.
*/
explicit KoToolProxy(KoCanvasBase *canvas, QObject *parent = 0);
- virtual ~KoToolProxy();
+ ~KoToolProxy();
/// Forwarded to the current KoToolBase
void paint(QPainter &painter, const KoViewConverter &converter);
@@ -140,10 +140,6 @@ signals:
*/
void toolChanged(const QString &toolId);
-protected:
- virtual QPointF widgetToDocument(const QPointF &widgetPoint) const;
- KoCanvasBase* canvas() const;
-
private:
Q_PRIVATE_SLOT(d, void timeout())
Q_PRIVATE_SLOT(d, void selectionChanged(bool))
diff --git a/libs/flake/KoToolProxy_p.h b/libs/flake/KoToolProxy_p.h
index 937ebd1..8baf4ac 100644
--- a/libs/flake/KoToolProxy_p.h
+++ b/libs/flake/KoToolProxy_p.h
@@ -48,7 +48,7 @@ public:
bool tabletPressed;
bool hasSelection;
QTimer scrollTimer;
- QPoint widgetScrollPoint;
+ QPoint scrollEdgePoint;
KoCanvasController *controller;
KoToolProxy *parent;
More information about the calligra-devel
mailing list