diff --git a/krita/data/actions/MoveTool.action b/krita/data/actions/MoveTool.action
index 29a95e989c..e350b59233 100644
--- a/krita/data/actions/MoveTool.action
+++ b/krita/data/actions/MoveTool.action
@@ -1,85 +1,95 @@
Path Tool
Move up
Up
Move up
false
Move up
Move down
Down
Move down
false
Move down
+
+ Show Coordinates
+ Ctrl+Alt+Shift+C
+ Show absolute coordinates and offset while move action
+
+
+
+ true
+ Show Coordinates
+
Move left
Left
Move left
false
Move left
Move right
Right
Move right
false
Move up more
Shift+Up
Move up more
false
Move up more
Move down more
Shift+Down
Move down more
false
Move down more
Move left more
Shift+Left
Move left more
false
Move left more
Move right more
Shift+Right
Move right more
false
Move right
diff --git a/plugins/tools/basictools/kis_tool_move.cc b/plugins/tools/basictools/kis_tool_move.cc
index fbc1014aff..9886a9b237 100644
--- a/plugins/tools/basictools/kis_tool_move.cc
+++ b/plugins/tools/basictools/kis_tool_move.cc
@@ -1,391 +1,527 @@
/*
* Copyright (c) 1999 Matthias Elter
* 1999 Michael Koch
* 2002 Patrick Julien
* 2004 Boudewijn Rempt
* 2016 Michael Abrahams
*
* 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_move.h"
#include
#include "kis_cursor.h"
#include "kis_selection.h"
#include "kis_canvas2.h"
#include "kis_image.h"
#include "kis_tool_utils.h"
#include "kis_paint_layer.h"
#include "strokes/move_stroke_strategy.h"
#include "kis_tool_movetooloptionswidget.h"
#include "strokes/move_selection_stroke_strategy.h"
#include "kis_resources_snapshot.h"
#include "kis_action_registry.h"
#include "krita_utils.h"
+#include
+#include
+
+#include "kis_node_manager.h"
KisToolMove::KisToolMove(KoCanvasBase * canvas)
: KisTool(canvas, KisCursor::moveCursor())
{
setObjectName("tool_move");
m_optionsWidget = 0;
m_moveInProgress = false;
QAction *a;
KisActionRegistry *actionRegistry = KisActionRegistry::instance();
a = actionRegistry->makeQAction("movetool-move-up", this);
addAction("movetool-move-up", a);
connect(a, &QAction::triggered, [&](){moveDiscrete(MoveDirection::Up, false);});
a = actionRegistry->makeQAction("movetool-move-down", this);
addAction("movetool-move-down", a);
connect(a, &QAction::triggered, [&](){moveDiscrete(MoveDirection::Down, false);});
a = actionRegistry->makeQAction("movetool-move-left", this);
addAction("movetool-move-left", a);
connect(a, &QAction::triggered, [&](){moveDiscrete(MoveDirection::Left, false);});
a = actionRegistry->makeQAction("movetool-move-right", this);
addAction("movetool-move-right", a);
connect(a, &QAction::triggered, [&](){moveDiscrete(MoveDirection::Right, false);});
a = actionRegistry->makeQAction("movetool-move-up-more", this);
addAction("movetool-move-up-more", a);
connect(a, &QAction::triggered, [&](){moveDiscrete(MoveDirection::Up, true);});
a = actionRegistry->makeQAction("movetool-move-down-more", this);
addAction("movetool-move-down-more", a);
connect(a, &QAction::triggered, [&](){moveDiscrete(MoveDirection::Down, true);});
a = actionRegistry->makeQAction("movetool-move-left-more", this);
addAction("movetool-move-left-more", a);
connect(a, &QAction::triggered, [&](){moveDiscrete(MoveDirection::Left, true);});
a = actionRegistry->makeQAction("movetool-move-right-more", this);
addAction("movetool-move-right-more", a);
connect(a, &QAction::triggered, [&](){moveDiscrete(MoveDirection::Right, true);});
+ m_showCoordinatesAction = actionRegistry->makeQAction("movetool-show-coordinates", this);
+ addAction("movetool-show-coordinates", m_showCoordinatesAction);
}
KisToolMove::~KisToolMove()
{
endStroke();
}
void KisToolMove::resetCursorStyle()
{
KisTool::resetCursorStyle();
overrideCursorIfNotEditable();
}
bool KisToolMove::startStrokeImpl(MoveToolMode mode, const QPoint *pos)
{
if (!currentNode()->isEditable()) return false;
KisNodeSP node;
KisNodeList nodes;
KisImageSP image = this->image();
KisResourcesSnapshotSP resources =
new KisResourcesSnapshot(image, currentNode(), 0, this->canvas()->resourceManager());
KisSelectionSP selection = resources->activeSelection();
if (mode != MoveSelectedLayer && pos) {
bool wholeGroup = !selection && mode == MoveGroup;
node = KisToolUtils::findNode(image->root(), *pos, wholeGroup);
if (node) {
nodes = {node};
}
}
if (nodes.isEmpty()) {
nodes = this->selectedNodes();
KritaUtils::filterContainer(nodes,
[](KisNodeSP node) {
return node->isEditable();
});
}
if (nodes.size() == 1) {
node = nodes.first();
}
if (nodes.isEmpty()) {
return false;
}
/**
* If the target node has changed, the stroke should be
* restarted. Otherwise just continue processing current node.
*/
if (m_strokeId) {
if (KritaUtils::compareListsUnordered(nodes, m_currentlyProcessingNodes)) {
+ QRect totalBounds;
+
+ Q_FOREACH (KisNodeSP node, m_currentlyProcessingNodes) {
+ totalBounds |= node->projection()->nonDefaultPixelArea();
+ }
+
+ m_totalTopLeft = totalBounds.topLeft();
+
return true;
} else {
endStroke();
}
}
KisStrokeStrategy *strategy;
KisPaintLayerSP paintLayer = node ?
dynamic_cast(node.data()) : 0;
if (paintLayer && selection &&
!selection->isTotallyUnselected(image->bounds())) {
strategy =
new MoveSelectionStrokeStrategy(paintLayer,
selection,
image.data(),
image->postExecutionUndoAdapter());
} else {
strategy =
new MoveStrokeStrategy(nodes, image.data(),
image->postExecutionUndoAdapter());
}
m_strokeId = image->startStroke(strategy);
m_currentlyProcessingNodes = nodes;
m_accumulatedOffset = QPoint();
+ QRect totalBounds;
+
+ Q_FOREACH (KisNodeSP node, m_currentlyProcessingNodes) {
+ totalBounds |= node->projection()->nonDefaultPixelArea();
+ }
+
+ m_totalTopLeft = totalBounds.topLeft();
+
return true;
}
void KisToolMove::moveDiscrete(MoveDirection direction, bool big)
{
if (mode() == KisTool::PAINT_MODE) return; // Don't interact with dragging
if (!currentNode()->isEditable()) return; // Don't move invisible nodes
if (startStrokeImpl(MoveSelectedLayer, 0)) {
setMode(KisTool::PAINT_MODE);
}
// Larger movement if "shift" key is pressed.
qreal scale = big ? m_optionsWidget->moveScale() : 1.0;
qreal moveStep = m_optionsWidget->moveStep() * scale;
QPoint offset = direction == Up ? QPoint( 0, -moveStep) :
direction == Down ? QPoint( 0, moveStep) :
direction == Left ? QPoint(-moveStep, 0) :
QPoint( moveStep, 0) ;
+ const bool showCoordinates =
+ m_optionsWidget ? m_optionsWidget->showCoordinates() : true;
+
+ if (showCoordinates) {
+ KisCanvas2 *kisCanvas = dynamic_cast(canvas());
+ kisCanvas->viewManager()->
+ showFloatingMessage(
+ i18nc("floating message in move tool",
+ "X: %1 px, Y: %2 px",
+ (m_totalTopLeft + offset).x(),
+ (m_totalTopLeft + offset).y()),
+ QIcon(), 1000, KisFloatingMessage::High);
+ }
+
+ emit moveInNewPosition(m_totalTopLeft + offset);
+
image()->addJob(m_strokeId, new MoveStrokeStrategy::Data(m_accumulatedOffset + offset));
m_accumulatedOffset += offset;
m_moveInProgress = false;
emit moveInProgressChanged();
setMode(KisTool::HOVER_MODE);
}
void KisToolMove::activate(ToolActivation toolActivation, const QSet &shapes)
{
KisTool::activate(toolActivation, shapes);
+ QRect totalBounds;
+
+ Q_FOREACH (KisNodeSP node, this->selectedNodes()) {
+ totalBounds |= node->projection()->nonDefaultPixelArea();
+ }
+
+ m_startPosition = totalBounds.topLeft();
+
+ if (m_optionsWidget)
+ m_optionsWidget->slotSetTranslate(m_startPosition);
}
void KisToolMove::paint(QPainter& gc, const KoViewConverter &converter)
{
Q_UNUSED(gc);
Q_UNUSED(converter);
}
void KisToolMove::deactivate()
{
endStroke();
KisTool::deactivate();
}
void KisToolMove::requestStrokeEnd()
{
endStroke();
}
void KisToolMove::requestStrokeCancellation()
{
cancelStroke();
}
void KisToolMove::beginPrimaryAction(KoPointerEvent *event)
{
startAction(event, moveToolMode());
}
void KisToolMove::continuePrimaryAction(KoPointerEvent *event)
{
continueAction(event);
}
void KisToolMove::endPrimaryAction(KoPointerEvent *event)
{
endAction(event);
}
void KisToolMove::beginAlternateAction(KoPointerEvent *event, AlternateAction action)
{
// Ctrl+Right click toggles between moving current layer and moving layer w/ content
if (action == PickFgNode || action == PickBgImage) {
MoveToolMode mode = moveToolMode();
if (mode == MoveSelectedLayer) {
mode = MoveFirstLayer;
} else if (mode == MoveFirstLayer) {
mode = MoveSelectedLayer;
}
startAction(event, mode);
} else {
startAction(event, MoveGroup);
}
}
void KisToolMove::continueAlternateAction(KoPointerEvent *event, AlternateAction action)
{
Q_UNUSED(action)
continueAction(event);
}
void KisToolMove::endAlternateAction(KoPointerEvent *event, AlternateAction action)
{
Q_UNUSED(action)
endAction(event);
}
void KisToolMove::startAction(KoPointerEvent *event, MoveToolMode mode)
{
QPoint pos = convertToPixelCoordAndSnap(event).toPoint();
m_dragStart = pos;
m_moveInProgress = true;
emit moveInProgressChanged();
if (startStrokeImpl(mode, &pos)) {
setMode(KisTool::PAINT_MODE);
} else {
event->ignore();
}
}
void KisToolMove::continueAction(KoPointerEvent *event)
{
CHECK_MODE_SANITY_OR_RETURN(KisTool::PAINT_MODE);
if (!m_strokeId) return;
QPoint pos = convertToPixelCoordAndSnap(event).toPoint();
+
+ const bool showCoordinates =
+ m_optionsWidget ? m_optionsWidget->showCoordinates() : true;
+
+ if (showCoordinates) {
+ KisCanvas2 *kisCanvas = dynamic_cast(canvas());
+ kisCanvas->viewManager()->
+ showFloatingMessage(
+ i18nc("floating message in move tool",
+ "X: %1 px, Y: %2 px",
+ (m_totalTopLeft + (pos - m_dragStart)).x(),
+ (m_totalTopLeft + (pos - m_dragStart)).y()),
+ QIcon(), 1000, KisFloatingMessage::High);
+ }
+
+ emit moveInNewPosition(m_totalTopLeft + (pos - m_dragStart));
+
pos = applyModifiers(event->modifiers(), pos);
drag(pos);
}
void KisToolMove::endAction(KoPointerEvent *event)
{
CHECK_MODE_SANITY_OR_RETURN(KisTool::PAINT_MODE);
setMode(KisTool::HOVER_MODE);
if (!m_strokeId) return;
QPoint pos = convertToPixelCoordAndSnap(event).toPoint();
pos = applyModifiers(event->modifiers(), pos);
drag(pos);
m_accumulatedOffset += pos - m_dragStart;
}
void KisToolMove::drag(const QPoint& newPos)
{
KisImageWSP image = currentImage();
QPoint offset = m_accumulatedOffset + newPos - m_dragStart;
image->addJob(m_strokeId,
new MoveStrokeStrategy::Data(offset));
}
void KisToolMove::endStroke()
{
if (!m_strokeId) return;
KisImageWSP image = currentImage();
image->endStroke(m_strokeId);
m_strokeId.clear();
m_currentlyProcessingNodes.clear();
m_moveInProgress = false;
emit moveInProgressChanged();
}
void KisToolMove::cancelStroke()
{
if (!m_strokeId) return;
KisImageWSP image = currentImage();
image->cancelStroke(m_strokeId);
m_strokeId.clear();
m_currentlyProcessingNodes.clear();
m_moveInProgress = false;
emit moveInProgressChanged();
}
QWidget* KisToolMove::createOptionWidget()
{
if (!currentImage())
return 0;
m_optionsWidget = new MoveToolOptionsWidget(0, currentImage()->xRes(), toolId());
// See https://bugs.kde.org/show_bug.cgi?id=316896
QWidget *specialSpacer = new QWidget(m_optionsWidget);
specialSpacer->setObjectName("SpecialSpacer");
specialSpacer->setFixedSize(0, 0);
m_optionsWidget->layout()->addWidget(specialSpacer);
m_optionsWidget->setFixedHeight(m_optionsWidget->sizeHint().height());
+ connect(m_showCoordinatesAction, SIGNAL(triggered(bool)), m_optionsWidget, SLOT(setShowCoordinates(bool)));
+ connect(m_optionsWidget, SIGNAL(showCoordinatesChanged(bool)), m_showCoordinatesAction, SLOT(setChecked(bool)));
+
+ m_showCoordinatesAction->setChecked(m_optionsWidget->showCoordinates());
+
+ m_optionsWidget->slotSetTranslate(m_startPosition);
+
+ connect(m_optionsWidget, SIGNAL(sigSetTranslateX(int)), SLOT(moveBySpinX(int)));
+ connect(m_optionsWidget, SIGNAL(sigSetTranslateY(int)), SLOT(moveBySpinY(int)));
+
+ connect(this, SIGNAL(moveInNewPosition(QPoint)), m_optionsWidget, SLOT(slotSetTranslate(QPoint)));
+
+ KisCanvas2 *kisCanvas = dynamic_cast(canvas());
+
+ connect(kisCanvas->viewManager()->nodeManager(), SIGNAL(sigUiNeedChangeSelectedNodes(KisNodeList)),
+ this, SLOT(slotNodeChanged(KisNodeList)));
+
return m_optionsWidget;
}
KisToolMove::MoveToolMode KisToolMove::moveToolMode() const
{
if (m_optionsWidget)
return m_optionsWidget->mode();
return MoveSelectedLayer;
}
bool KisToolMove::moveInProgress() const
{
return m_moveInProgress;
}
QPoint KisToolMove::applyModifiers(Qt::KeyboardModifiers modifiers, QPoint pos)
{
QPoint move = pos - m_dragStart;
// Snap to axis
if (modifiers & Qt::ShiftModifier) {
move = snapToClosestAxis(move);
}
// "Precision mode" - scale down movement by 1/5
if (modifiers & Qt::AltModifier) {
const qreal SCALE_FACTOR = .2;
move = SCALE_FACTOR * move;
}
return m_dragStart + move;
}
+
+void KisToolMove::moveBySpinX(int newX)
+{
+ if (mode() == KisTool::PAINT_MODE) return; // Don't interact with dragging
+ if (!currentNode()->isEditable()) return; // Don't move invisible nodes
+
+ if (startStrokeImpl(MoveSelectedLayer, 0)) {
+ setMode(KisTool::PAINT_MODE);
+ }
+
+ KisImageWSP image = currentImage();
+
+ QPoint offset = QPoint(newX, m_totalTopLeft.y()) - m_totalTopLeft;
+
+ image->addJob(m_strokeId,
+ new MoveStrokeStrategy::Data(m_accumulatedOffset + offset));
+ m_accumulatedOffset += offset;
+
+ setMode(KisTool::HOVER_MODE);
+}
+
+void KisToolMove::moveBySpinY(int newY)
+{
+ if (mode() == KisTool::PAINT_MODE) return; // Don't interact with dragging
+ if (!currentNode()->isEditable()) return; // Don't move invisible nodes
+
+ if (startStrokeImpl(MoveSelectedLayer, 0)) {
+ setMode(KisTool::PAINT_MODE);
+ }
+
+ KisImageWSP image = currentImage();
+
+ QPoint offset = QPoint(m_totalTopLeft.x(), newY) - m_totalTopLeft;
+
+ image->addJob(m_strokeId,
+ new MoveStrokeStrategy::Data(m_accumulatedOffset + offset));
+ m_accumulatedOffset += offset;
+
+ setMode(KisTool::HOVER_MODE);
+}
+
+void KisToolMove::slotNodeChanged(KisNodeList nodes)
+{
+ QRect totalBounds;
+
+ Q_FOREACH (KisNodeSP node, nodes) {
+ totalBounds |= node->projection()->nonDefaultPixelArea();
+ }
+
+ m_startPosition = totalBounds.topLeft();
+
+ if (m_optionsWidget)
+ m_optionsWidget->slotSetTranslate(m_startPosition);
+}
diff --git a/plugins/tools/basictools/kis_tool_move.h b/plugins/tools/basictools/kis_tool_move.h
index 069770d5cd..8437b39232 100644
--- a/plugins/tools/basictools/kis_tool_move.h
+++ b/plugins/tools/basictools/kis_tool_move.h
@@ -1,147 +1,163 @@
/*
* Copyright (c) 1999 Matthias Elter
* 1999 Michael Koch
* 2003 Patrick Julien
*
* 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_MOVE_H_
#define KIS_TOOL_MOVE_H_
#include
#include
#include
#include
#include
#include
#include
#include
#include
class KoCanvasBase;
class MoveToolOptionsWidget;
+class KisDocument;
class KisToolMove : public KisTool
{
Q_OBJECT
Q_ENUMS(MoveToolMode);
Q_PROPERTY(bool moveInProgress READ moveInProgress NOTIFY moveInProgressChanged);
public:
KisToolMove(KoCanvasBase * canvas);
virtual ~KisToolMove();
public Q_SLOTS:
virtual void activate(ToolActivation toolActivation, const QSet &shapes);
void deactivate();
public Q_SLOTS:
void requestStrokeEnd();
void requestStrokeCancellation();
protected Q_SLOTS:
virtual void resetCursorStyle();
public:
enum MoveToolMode {
MoveSelectedLayer,
MoveFirstLayer,
MoveGroup
};
enum MoveDirection {
Up,
Down,
Left,
Right
};
void beginPrimaryAction(KoPointerEvent *event);
void continuePrimaryAction(KoPointerEvent *event);
void endPrimaryAction(KoPointerEvent *event);
void beginAlternateAction(KoPointerEvent *event, AlternateAction action);
void continueAlternateAction(KoPointerEvent *event, AlternateAction action);
void endAlternateAction(KoPointerEvent *event, AlternateAction action);
void startAction(KoPointerEvent *event, MoveToolMode mode);
void continueAction(KoPointerEvent *event);
void endAction(KoPointerEvent *event);
virtual void paint(QPainter& gc, const KoViewConverter &converter);
virtual QWidget* createOptionWidget();
void updateUIUnit(int newUnit);
MoveToolMode moveToolMode() const;
bool moveInProgress() const;
+
+ void setShowCoordinates(bool value);
+
public Q_SLOTS:
void moveDiscrete(MoveDirection direction, bool big);
+ void moveBySpinX(int newX);
+ void moveBySpinY(int newY);
+
+ void slotNodeChanged(KisNodeList nodes);
+
Q_SIGNALS:
void moveToolModeChanged();
void moveInProgressChanged();
+ void moveInNewPosition(QPoint);
private:
void drag(const QPoint& newPos);
void cancelStroke();
QPoint applyModifiers(Qt::KeyboardModifiers modifiers, QPoint pos);
bool startStrokeImpl(MoveToolMode mode, const QPoint *pos);
private Q_SLOTS:
void endStroke();
private:
MoveToolOptionsWidget* m_optionsWidget;
+ QPoint m_totalTopLeft;
+
QPoint m_dragStart; ///< Point where current cursor dragging began
QPoint m_accumulatedOffset; ///< Total offset including multiple clicks, up/down/left/right keys, etc. added together
+ QPoint m_startPosition;
+
KisStrokeId m_strokeId;
bool m_moveInProgress;
KisNodeList m_currentlyProcessingNodes;
int m_resolution;
+
+ QAction *m_showCoordinatesAction;
};
class KisToolMoveFactory : public KoToolFactoryBase
{
public:
KisToolMoveFactory()
: KoToolFactoryBase("KritaTransform/KisToolMove") {
setToolTip(i18n("Move Tool"));
setToolType(TOOL_TYPE_TRANSFORM);
setActivationShapeId(KRITA_TOOL_ACTIVATION_ID);
setPriority(11);
setIconName(koIconNameCStr("krita_tool_move"));
setShortcut(QKeySequence( Qt::Key_T));
}
virtual ~KisToolMoveFactory() {}
virtual KoToolBase * createTool(KoCanvasBase *canvas) {
return new KisToolMove(canvas);
}
};
#endif // KIS_TOOL_MOVE_H_
diff --git a/plugins/tools/basictools/kis_tool_movetooloptionswidget.cpp b/plugins/tools/basictools/kis_tool_movetooloptionswidget.cpp
index 323432316b..c0c0dddfad 100644
--- a/plugins/tools/basictools/kis_tool_movetooloptionswidget.cpp
+++ b/plugins/tools/basictools/kis_tool_movetooloptionswidget.cpp
@@ -1,139 +1,186 @@
/*
Copyright (C) 2012 Dan Leinir Turthra Jensen
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_movetooloptionswidget.h"
#include
#include
MoveToolOptionsWidget::MoveToolOptionsWidget(QWidget *parent, int resolution, QString toolId)
: QWidget(parent)
, m_resolution(resolution)
+ , m_showCoordinates(false)
{
setupUi(this);
m_configGroup = KSharedConfig::openConfig()->group(toolId);
// load radio button
m_moveToolMode = static_cast(m_configGroup.readEntry("moveToolMode", 0));
if(m_moveToolMode == KisToolMove::MoveSelectedLayer)
radioSelectedLayer->setChecked(true);
else if (m_moveToolMode == KisToolMove::MoveFirstLayer)
radioFirstLayer->setChecked(true);
else
radioGroup->setChecked(true);
// Keyboard shortcut move step
m_moveStep = m_configGroup.readEntry("moveToolStep", 1);
m_moveStepUnit = m_configGroup.readEntry("moveToolUnit", KoUnit(KoUnit::Pixel).indexInListForUi());
cmbUnit->addItems(KoUnit::listOfUnitNameForUi());
cmbUnit->setCurrentIndex(m_moveStepUnit);
updateUIUnit(m_moveStepUnit);
// Scale for large moves
m_moveScale = m_configGroup.readEntry("moveToolScale", 10.0);
spinMoveScale->blockSignals(true);
spinMoveScale->setValue(m_moveScale);
spinMoveScale->setSuffix("x");
spinMoveScale->blockSignals(false);
+ // Switch mode for showing coordinates
+ m_showCoordinates = m_configGroup.readEntry("moveToolShowCoordinates", false);
+ connect(chkShowCoordinates, SIGNAL(toggled(bool)), SIGNAL(showCoordinatesChanged(bool)));
+
+ chkShowCoordinates->setChecked(m_showCoordinates);
+
+ translateXBox->setSuffix(i18n(" px"));
+ translateYBox->setSuffix(i18n(" px"));
+ translateXBox->setRange(-10000, 10000);
+ translateYBox->setRange(-10000, 10000);
}
void MoveToolOptionsWidget::updateUIUnit(int newUnit)
{
const KoUnit selectedUnit = KoUnit::fromListForUi(newUnit);
qreal valueForUI;
if (selectedUnit != KoUnit(KoUnit::Pixel)) {
spinMoveStep->setRange(0.0001, 10000.000);
spinMoveStep->setSingleStep(.1);
spinMoveStep->setDecimals(4);
valueForUI = selectedUnit.toUserValue((qreal)m_moveStep / (qreal)m_resolution);
} else {
spinMoveStep->setRange(1, 10000);
spinMoveStep->setSingleStep(1);
spinMoveStep->setDecimals(0);
valueForUI = m_moveStep;
}
spinMoveStep->blockSignals(true);
spinMoveStep->setValue(valueForUI);
spinMoveStep->blockSignals(false);
}
void MoveToolOptionsWidget::on_spinMoveStep_valueChanged(double UIMoveStep)
{
const KoUnit selectedUnit = KoUnit::fromListForUi(m_moveStepUnit);
const double scaledUiMoveStep = (selectedUnit == KoUnit(KoUnit::Pixel)) ?
UIMoveStep : selectedUnit.fromUserValue(UIMoveStep * m_resolution);
m_moveStep = qRound(scaledUiMoveStep);
m_configGroup.writeEntry("moveToolStep", m_moveStep);
}
void MoveToolOptionsWidget::on_spinMoveScale_valueChanged(double UIMoveScale)
{
m_moveScale = UIMoveScale;
m_configGroup.writeEntry("moveToolScale", m_moveScale);
}
void MoveToolOptionsWidget::on_cmbUnit_currentIndexChanged(int newUnit)
{
m_moveStepUnit = newUnit;
updateUIUnit(newUnit);
m_configGroup.writeEntry("moveToolUnit", newUnit);
}
void MoveToolOptionsWidget::on_radioSelectedLayer_toggled(bool checked)
{
Q_UNUSED(checked);
setMoveToolMode(KisToolMove::MoveSelectedLayer);
}
void MoveToolOptionsWidget::on_radioFirstLayer_toggled(bool checked)
{
Q_UNUSED(checked);
setMoveToolMode(KisToolMove::MoveFirstLayer);
}
void MoveToolOptionsWidget::on_radioGroup_toggled(bool checked)
{
Q_UNUSED(checked);
setMoveToolMode(KisToolMove::MoveGroup);
}
void MoveToolOptionsWidget::setMoveToolMode(KisToolMove::MoveToolMode newMode)
{
m_moveToolMode = newMode;
m_configGroup.writeEntry("moveToolMode", static_cast(newMode));
}
+void MoveToolOptionsWidget::on_chkShowCoordinates_toggled(bool checked)
+{
+ m_showCoordinates = checked;
+ m_configGroup.writeEntry("moveToolShowCoordinates", m_showCoordinates);
+}
+
KisToolMove::MoveToolMode MoveToolOptionsWidget::mode()
{
return m_moveToolMode;
}
int MoveToolOptionsWidget::moveStep()
{
return m_moveStep;
}
double MoveToolOptionsWidget::moveScale()
{
return m_moveScale;
}
+
+bool MoveToolOptionsWidget::showCoordinates() const
+{
+ return m_showCoordinates;
+}
+
+void MoveToolOptionsWidget::setShowCoordinates(bool value)
+{
+ chkShowCoordinates->setChecked(value);
+}
+
+void MoveToolOptionsWidget::slotSetTranslate(QPoint newPos)
+{
+ translateXBox->setValue(newPos.x());
+ translateYBox->setValue(newPos.y());
+}
+
+void MoveToolOptionsWidget::on_translateXBox_valueChanged(int arg1)
+{
+ m_TranslateX = arg1;
+ m_configGroup.writeEntry("moveToolChangedValueX", m_TranslateX);
+ emit sigSetTranslateX(arg1);
+}
+
+void MoveToolOptionsWidget::on_translateYBox_valueChanged(int arg1)
+{
+ m_TranslateY = arg1;
+ m_configGroup.writeEntry("moveToolChangedValueY", m_TranslateY);
+ emit sigSetTranslateY(arg1);
+}
diff --git a/plugins/tools/basictools/kis_tool_movetooloptionswidget.h b/plugins/tools/basictools/kis_tool_movetooloptionswidget.h
index 9b21e87732..f1434bfd20 100644
--- a/plugins/tools/basictools/kis_tool_movetooloptionswidget.h
+++ b/plugins/tools/basictools/kis_tool_movetooloptionswidget.h
@@ -1,61 +1,83 @@
/*
Copyright (C) 2012 Dan Leinir Turthra Jensen
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_MOVETOOLOPTIONSWIDGET_H
#define KIS_TOOL_MOVETOOLOPTIONSWIDGET_H
#include "ui_wdgmovetool.h"
#include
#include "kis_tool_move.h"
class MoveToolOptionsWidget : public QWidget, public Ui::WdgMoveTool
{
Q_OBJECT
public:
MoveToolOptionsWidget(QWidget *parent, int resolution, QString toolId);
int moveStep();
double moveScale();
KisToolMove::MoveToolMode mode();
+ bool showCoordinates() const;
+
+public Q_SLOTS:
+ void setShowCoordinates(bool value);
+
+ void slotSetTranslate(QPoint newPos);
private Q_SLOTS:
void on_spinMoveStep_valueChanged(double UIMoveStep);
void on_spinMoveScale_valueChanged(double UIMoveScale);
void on_cmbUnit_currentIndexChanged(int newUnit);
void on_radioSelectedLayer_toggled(bool checked);
void on_radioFirstLayer_toggled(bool checked);
void on_radioGroup_toggled(bool checked);
+ void on_chkShowCoordinates_toggled(bool checked);
+
+ void on_translateXBox_valueChanged(int arg1);
+
+ void on_translateYBox_valueChanged(int arg1);
+
+Q_SIGNALS:
+ void showCoordinatesChanged(bool value);
+
+ void sigSetTranslateX(int value);
+ void sigSetTranslateY(int value);
+
private:
void updateUIUnit(int newUnit);
void setMoveToolMode(KisToolMove::MoveToolMode newMode);
int m_resolution;
int m_moveStep;
int m_moveStepUnit;
qreal m_moveScale;
KisToolMove::MoveToolMode m_moveToolMode;
+ bool m_showCoordinates;
+
+ int m_TranslateX;
+ int m_TranslateY;
KConfigGroup m_configGroup;
};
#endif // KIS_TOOL_MOVETOOLOPTIONSWIDGET_H
diff --git a/plugins/tools/basictools/wdgmovetool.ui b/plugins/tools/basictools/wdgmovetool.ui
index 5ffb53cde7..262b0c89b2 100644
--- a/plugins/tools/basictools/wdgmovetool.ui
+++ b/plugins/tools/basictools/wdgmovetool.ui
@@ -1,125 +1,246 @@
WdgMoveTool
0
0
- 246
- 130
+ 269
+ 394
-
Selection Mode
-
Move the layer that you have currently selected in the layerbox with its masks. Shortcut: ctrl-click.
Move current layer
true
-
Move the first layer with visible content at the place where you click. This will also select that layer in the layerbox.
Move layer with content
false
-
Move the group containing the first layer that contains visible content. Shortcut: ctrl-shift-click.
Move the whole group
-
-
-
- -
Shortcut Move Distance
-
-
-
-
- 1
-
-
- 100000
-
-
- 1
-
-
- Number of pixels to move after move shortcut keypress.
-
-
-
+ -
+
+
+ Number of pixels to move after move shortcut keypress.
+
+
+ 1.000000000000000
+
+
+ 100000.000000000000000
+
+
+ 1.000000000000000
+
+
+
-
-
+
-
-
-
- 1
+
+
+ When holding shift, move keyboard shortcuts scale up by this amount.
+
+
+ 1.000000000000000
+
+
+ 1000.000000000000000
+
+
+ 10.000000000000000
+
+
+
+ -
+
+
+ Large Move Scale
+
+
+
+
+
+
+ -
+
+
+ Show coordinates on canvas
+
+
+ Show coordinates
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 240
+ 70
+
+
+
+ Position
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+
+ 2
+
+
+ 5
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ QFormLayout::AllNonFixedFieldsGrow
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Horizontal Translation
-
- 1000
+
+ Qt::LeftToRight
-
- 10
+
+ x:
+
+
+ translateXBox
+
+
+
+ -
+
+
+
+ 0
+ 0
+
- When holding shift, move keyboard shortcuts scale up by this amount.
+ Horizontal Translation
+
+
+ Qt::LeftToRight
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Vertical Translation
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Vertical Translation
-
-
- -
-
- Large Move Scale
+ y:
-
+
+ translateYBox
+
+
+
+
+ -
+
+
-
-
- KisSliderSpinBox
- QWidget
-
- 1
-
-