Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To allow moving the canvas around without having to hold down a key or needing a middle click button on the pen. Implements #1217.
- Loading branch information
1 parent
22f1040
commit 4988174
Showing
17 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#include "desktop/toolwidgets/pansettings.h" | ||
#include "desktop/widgets/groupedtoolbutton.h" | ||
#include <QButtonGroup> | ||
#include <QPushButton> | ||
#include <QVBoxLayout> | ||
#include <QWidget> | ||
|
||
namespace tools { | ||
|
||
PanSettings::PanSettings(ToolController *ctrl, QObject *parent) | ||
: ToolSettings(ctrl, parent) | ||
{ | ||
} | ||
|
||
QWidget *PanSettings::createUiWidget(QWidget *parent) | ||
{ | ||
QWidget *widget = new QWidget(parent); | ||
// The pan tool has no settings. | ||
return widget; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#ifndef DESKTOP_TOOLWIDGETS_PANSETTINGS_H | ||
#define DESKTOP_TOOLWIDGETS_PANSETTINGS_H | ||
#include "desktop/toolwidgets/toolsettings.h" | ||
|
||
class QAction; | ||
|
||
namespace widgets { | ||
class GroupedToolButton; | ||
} | ||
|
||
namespace tools { | ||
|
||
class PanSettings final : public ToolSettings { | ||
Q_OBJECT | ||
public: | ||
PanSettings(ToolController *ctrl, QObject *parent = nullptr); | ||
|
||
QString toolType() const override { return QStringLiteral("pan"); } | ||
|
||
void setForeground(const QColor &color) override { Q_UNUSED(color); } | ||
|
||
int getSize() const override { return 0; } | ||
bool getSubpixelMode() const override { return false; } | ||
|
||
protected: | ||
QWidget *createUiWidget(QWidget *parent) override; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#include "libclient/tools/pan.h" | ||
#include "libclient/tools/toolcontroller.h" | ||
#include <QCursor> | ||
#include <QPixmap> | ||
|
||
namespace tools { | ||
|
||
PanTool::PanTool(ToolController &owner) | ||
: Tool(owner, PAN, QCursor(Qt::OpenHandCursor), true, false, true) | ||
{ | ||
} | ||
|
||
void PanTool::begin( | ||
const canvas::Point &point, bool right, float zoom, const QPointF &viewPos) | ||
{ | ||
Q_UNUSED(point); | ||
Q_UNUSED(zoom); | ||
if(!right) { | ||
setCursor(Qt::ClosedHandCursor); | ||
m_lastViewPos = viewPos; | ||
m_panning = true; | ||
} | ||
} | ||
|
||
void PanTool::motion( | ||
const canvas::Point &point, bool constrain, bool center, | ||
const QPointF &viewPos) | ||
{ | ||
Q_UNUSED(point); | ||
Q_UNUSED(constrain); | ||
Q_UNUSED(center); | ||
if(m_panning) { | ||
QPointF delta = m_lastViewPos - viewPos; | ||
emit m_owner.panRequested(qRound(delta.x()), qRound(delta.y())); | ||
m_lastViewPos = viewPos; | ||
} | ||
} | ||
|
||
void PanTool::end() | ||
{ | ||
if(m_panning) { | ||
setCursor(Qt::OpenHandCursor); | ||
m_panning = false; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#ifndef LIBCLIENT_TOOLS_PAN_H | ||
#define LIBCLIENT_TOOLS_PAN_H | ||
#include "libclient/tools/tool.h" | ||
#include <QPointF> | ||
|
||
namespace tools { | ||
|
||
class PanTool final : public Tool { | ||
public: | ||
PanTool(ToolController &owner); | ||
|
||
void begin( | ||
const canvas::Point &point, bool right, float zoom, | ||
const QPointF &viewPos) override; | ||
|
||
void motion( | ||
const canvas::Point &point, bool constrain, bool center, | ||
const QPointF &viewPos) override; | ||
|
||
void end() override; | ||
|
||
private: | ||
QPointF m_lastViewPos; | ||
bool m_panning = false; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ class Tool { | |
LASERPOINTER, | ||
SELECTION, | ||
POLYGONSELECTION, | ||
PAN, | ||
ZOOM, | ||
INSPECTOR, | ||
_LASTTOOL, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters