[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/calligra/2.9] krita/plugins/tools/defaulttools: Remove the pan tool code
From: Boudewijn Rempt <boud () valdyas ! org>
Date: 2015-02-06 15:16:38
Message-ID: E1YJke6-00022b-7n () scm ! kde ! org
[Download RAW message or body]
Git commit ddcf49cd13bbee6657ce8446e050a88ec63fcab9 by Boudewijn Rempt.
Committed on 06/02/2015 at 13:53.
Pushed by rempt into branch 'calligra/2.9'.
Remove the pan tool code
This was already disabled from the build in
commit 2ceb7d39c8a6cc59367bebb0591ea2374bb4b526
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date: Fri Jun 22 14:17:20 2012 +0200
Disable pan and zoom tools.
So, let's remove the code and the icons as well.
D +0 -210 krita/plugins/tools/defaulttools/kis_tool_pan.cpp
D +0 -93 krita/plugins/tools/defaulttools/kis_tool_pan.h
D +- -- krita/plugins/tools/defaulttools/krita_tool_pan.png
http://commits.kde.org/calligra/ddcf49cd13bbee6657ce8446e050a88ec63fcab9
diff --git a/krita/plugins/tools/defaulttools/kis_tool_pan.cpp \
b/krita/plugins/tools/defaulttools/kis_tool_pan.cpp deleted file mode 100644
index 41db104..0000000
--- a/krita/plugins/tools/defaulttools/kis_tool_pan.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 2010 Dmitry Kazakov <dimula73@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_pan.h"
-
-#include <QScrollBar>
-#include <QPainter>
-
-#include <KoPointerEvent.h>
-#include <KoCanvasBase.h>
-#include <KoViewConverter.h>
-
-#include <kis_canvas2.h>
-#include "kis_canvas_controller.h"
-
-#include "kis_cursor.h"
-#include "kis_coordinates_converter.h"
-
-
-const qreal KisToolPan::m_checkerRadius = 50;
-
-KisToolPan::KisToolPan(KoCanvasBase * canvas)
- : KisTool(canvas, KisCursor::openHandCursor())
-{
- setObjectName("tool_pan");
- m_rotationMode = false;
- m_defaultCursor = KisCursor::openHandCursor();
-}
-
-KisToolPan::~KisToolPan()
-{
-}
-
-bool KisToolPan::wantsAutoScroll() const
-{
- return false;
-}
-
-void KisToolPan::paint(QPainter& gc, const KoViewConverter &converter)
-{
- Q_UNUSED(converter);
- if(m_rotationMode) {
- const KisCoordinatesConverter *converter = \
kritaCanvas()->coordinatesConverter();
- QPointF centerPoint = converter->flakeCenterPoint();
-
- QBrush fillBrush(QColor(0,0,0,100));
- QPen checkerPen(QColor(255,255,255,100), 5., Qt::SolidLine, Qt::RoundCap);
-
- gc.save();
-
- gc.setPen(Qt::NoPen);
- gc.setBrush(fillBrush);
- gc.drawEllipse(centerPoint, m_checkerRadius, m_checkerRadius);
-
- gc.setPen(checkerPen);
- gc.drawLine(centerPoint, centerPoint + QPointF(0, -m_checkerRadius));
-
- gc.restore();
- }
-}
-
-KisCanvas2* KisToolPan::kritaCanvas() const
-{
- KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas());
- Q_ASSERT(kritaCanvas);
- return kritaCanvas;
-}
-
-KisCanvasController* KisToolPan::kritaCanvasController() const
-{
- KisCanvasController *controller =
- dynamic_cast<KisCanvasController*>(canvas()->canvasController());
- Q_ASSERT(controller);
- return controller;
-}
-
-bool KisToolPan::isInCheckerArea(QPointF pt)
-{
- QPointF centerPoint = widgetCenterInWidgetPixels();
- pt -= centerPoint;
-
- return pt.x() * pt.x() + pt.y() * pt.y() <= m_checkerRadius * m_checkerRadius;
-}
-
-qreal KisToolPan::calculateAngle(QPointF oldPoint,
- QPointF newPoint)
-{
- QPointF centerPoint = widgetCenterInWidgetPixels();
- oldPoint -= centerPoint;
- newPoint -= centerPoint;
-
- qreal oldAngle = atan2(oldPoint.y(), oldPoint.x());
- qreal newAngle = atan2(newPoint.y(), newPoint.x());
-
- return (180 / 3.14) * (newAngle - oldAngle);
-}
-
-void KisToolPan::beginPrimaryAction(KoPointerEvent *event)
-{
- m_lastPosition = convertDocumentToWidget(e->point);
- e->accept();
-
- m_defaultCursor = KisCursor::closedHandCursor();
- adjustCursor();
-
- if(m_rotationMode && isInCheckerArea(m_lastPosition)) {
- kritaCanvasController()->resetCanvasRotation();
- }
-}
-
-void KisToolPan::continuePrimaryAction(KoPointerEvent *event)
-{
- Q_ASSERT(canvas());
- Q_ASSERT(canvas()->canvasController());
-
- QPointF actualPosition = convertDocumentToWidget(e->point);
-
- adjustCursor();
-
- if (!e->buttons())
- return;
- e->accept();
-
- if(e->modifiers() & Qt::ShiftModifier) {
- if(!isInCheckerArea(actualPosition)) {
- qreal angle = calculateAngle(m_lastPosition, actualPosition);
- kritaCanvasController()->rotateCanvas(angle);
- }
- }
- else {
- QPointF distance(m_lastPosition - actualPosition);
- kritaCanvasController()->pan(distance.toPoint());
- }
-
- m_lastPosition = actualPosition;
-}
-
-void KisToolPan::endPrimaryAction(KoPointerEvent *event)
-{
- Q_UNUSED(e);
- m_defaultCursor = KisCursor::openHandCursor();
- kritaCanvasController()->rotateCanvas(0.0);
- adjustCursor();
-}
-
-void KisToolPan::adjustCursor()
-{
- QPoint pt = canvas()->canvasWidget()->mapFromGlobal(QCursor::pos());
-
- if(m_rotationMode && isInCheckerArea(pt)) {
- useCursor(KisCursor::pointingHandCursor());
- }
- else {
- useCursor(m_defaultCursor);
- }
-}
-
-void KisToolPan::keyPressEvent(QKeyEvent *event)
-{
- KoCanvasControllerWidget *canvasControllerWidget = kritaCanvasController();
-
- switch (event->key()) {
- case Qt::Key_Up:
- canvasControllerWidget->pan(QPoint(0, \
-canvasControllerWidget->verticalScrollBar()->singleStep()));
- break;
- case Qt::Key_Down:
- canvasControllerWidget->pan(QPoint(0, \
canvasControllerWidget->verticalScrollBar()->singleStep()));
- break;
- case Qt::Key_Left:
- canvasControllerWidget->pan(QPoint(-canvasControllerWidget->horizontalScrollBar()->singleStep(), \
0));
- break;
- case Qt::Key_Right:
- canvasControllerWidget->pan(QPoint(canvasControllerWidget->horizontalScrollBar()->singleStep(), \
0));
- break;
- case Qt::Key_Shift:
- m_rotationMode = true;
- kritaCanvas()->updateCanvas();
- adjustCursor();
- break;
- }
- event->accept();
-}
-
-void KisToolPan::keyReleaseEvent(QKeyEvent *event)
-{
- switch (event->key()) {
- case Qt::Key_Shift:
- m_rotationMode = false;
- kritaCanvas()->updateCanvas();
- adjustCursor();
- break;
- }
-}
-
-#include "kis_tool_pan.moc"
diff --git a/krita/plugins/tools/defaulttools/kis_tool_pan.h \
b/krita/plugins/tools/defaulttools/kis_tool_pan.h deleted file mode 100644
index 05186d6..0000000
--- a/krita/plugins/tools/defaulttools/kis_tool_pan.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2010 Dmitry Kazakov <dimula73@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_PAN_H_
-#define KIS_TOOL_PAN_H_
-
-#include <KoPanTool.h>
-#include <KoToolFactoryBase.h>
-#include <kis_tool.h>
-#include <KoIcon.h>
-
-class KoCanvasBase;
-class KisCanvas2;
-class KisCanvasController;
-
-class KisToolPan : public KisTool
-{
-
- Q_OBJECT
-
-public:
- KisToolPan(KoCanvasBase * canvas);
- virtual ~KisToolPan();
-
-
-public:
-
- bool wantsAutoScroll() const;
-
- void beginPrimaryAction(KoPointerEvent *event);
- void continuePrimaryAction(KoPointerEvent *event);
- void endPrimaryAction(KoPointerEvent *event);
-
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *event);
-
- virtual void paint(QPainter& gc, const KoViewConverter &converter);
-
-private:
- void adjustCursor();
- bool isInCheckerArea(QPointF pt);
- qreal calculateAngle(QPointF oldPoint, QPointF newPoint);
- KisCanvas2* kritaCanvas() const;
- KisCanvasController* kritaCanvasController() const;
-
-private:
- static const qreal m_checkerRadius;
-
- QCursor m_defaultCursor;
- QPointF m_lastPosition;
- bool m_rotationMode;
-};
-
-
-class KisToolPanFactory : public KoToolFactoryBase
-{
-
-public:
- KisToolPanFactory(const QStringList&)
- : KoToolFactoryBase(KoPanTool_ID) {
- setToolTip(i18n("Move and rotate your canvas"));
- setToolType(navigationToolType());
- setActivationShapeId(KRITA_TOOL_ACTIVATION_ID);
- setPriority(5);
- setIconName(koIconNameCStr("krita_tool_pan"));
- //setShortcut( QKeySequence( Qt::SHIFT + Qt::Key_V ) );
- }
-
- virtual ~KisToolPanFactory() {}
-
- virtual KoToolBase * createTool(KoCanvasBase *canvas) {
- return new KisToolPan(canvas);
- }
-
-};
-
-#endif // KIS_TOOL_PAN_H_
-
diff --git a/krita/plugins/tools/defaulttools/krita_tool_pan.png \
b/krita/plugins/tools/defaulttools/krita_tool_pan.png deleted file mode 100644
index e6c2dee..0000000
Binary files a/krita/plugins/tools/defaulttools/krita_tool_pan.png and /dev/null \
differ
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic