Commit 5c0fcf00 authored by Scott Petrovic's avatar Scott Petrovic

make the move to center canvas work on the mirror tool options

parent 7e7ded7a
......@@ -45,6 +45,7 @@ public:
Private(KisMirrorAxis* qq)
: q(qq)
, resourceProvider(0)
, image(0)
, mirrorHorizontal(false)
, mirrorVertical(false)
, lockHorizontal(false)
......@@ -70,6 +71,7 @@ public:
KisMirrorAxis* q;
KisCanvasResourceProvider* resourceProvider;
KisImageWSP image;
bool mirrorHorizontal;
bool mirrorVertical;
......@@ -107,6 +109,9 @@ KisMirrorAxis::KisMirrorAxis(KisCanvasResourceProvider* provider, QPointer<KisVi
{
d->resourceProvider = provider;
connect(d->resourceProvider, SIGNAL(mirrorModeChanged()), SLOT(mirrorModeChanged()));
connect(d->resourceProvider, SIGNAL(moveMirrorVerticalCenter()), SLOT(moveVerticalAxisToCenter()));
connect(d->resourceProvider, SIGNAL(moveMirrorHorizontalCenter()), SLOT(moveHorizontalAxisToCenter()));
d->mirrorHorizontal = d->resourceProvider->mirrorHorizontal();
d->mirrorVertical = d->resourceProvider->mirrorVertical();
d->horizontalIcon = KisIconUtils::loadIcon("mirrorAxis-HorizontalMove").pixmap(d->handleSize, QIcon::Normal, QIcon::On);
......@@ -115,8 +120,11 @@ KisMirrorAxis::KisMirrorAxis(KisCanvasResourceProvider* provider, QPointer<KisVi
d->verticalHandleIcon = KisIconUtils::loadIcon("transform-move").pixmap(d->handleSize, QIcon::Normal, QIcon::On);
setVisible(d->mirrorHorizontal || d->mirrorVertical);
int imageWidth = parent->canvasBase()->image()->width();
int imageHeight = parent->canvasBase()->image()->height();
d->image = parent->canvasBase()->image();
int imageWidth = d->image->width();
int imageHeight = d->image->height();
QPointF point(imageWidth / 2, imageHeight / 2);
d->resourceProvider->resourceManager()->setResource(KisCanvasResourceProvider::MirrorAxesCenter, point);
}
......@@ -358,6 +366,18 @@ void KisMirrorAxis::setVisible(bool v)
}
}
void KisMirrorAxis::moveHorizontalAxisToCenter()
{
d->setAxisPosition(d->image->width()/2, d->axisPosition.y());
}
void KisMirrorAxis::moveVerticalAxisToCenter()
{
d->setAxisPosition(d->axisPosition.x(), d->image->height()/2 );
}
void KisMirrorAxis::Private::setAxisPosition(float x, float y)
{
QPointF newPosition = QPointF(x, y);
......@@ -367,6 +387,7 @@ void KisMirrorAxis::Private::setAxisPosition(float x, float y)
q->view()->canvasBase()->updateCanvas();
}
void KisMirrorAxis::Private::recomputeVisibleAxes(QRect viewport)
{
KisCoordinatesConverter *converter = q->view()->viewConverter();
......
......@@ -51,6 +51,8 @@ private:
private Q_SLOTS:
void mirrorModeChanged();
void moveHorizontalAxisToCenter();
void moveVerticalAxisToCenter();
};
#endif // KISMIRRORAXIS_H
......@@ -455,14 +455,19 @@ void KisCanvasResourceProvider::setMirrorHorizontalHideDecorations(bool hide)
}
bool KisCanvasResourceProvider::mirrorVerticalLock() {
return m_resourceManager->resource(MirrorVerticalLock).toBool();
}
void KisCanvasResourceProvider::mirrorVerticalMoveCanvasToCenter() {
emit moveMirrorVerticalCenter();
}
void KisCanvasResourceProvider::mirrorHorizontalMoveCanvasToCenter() {
emit moveMirrorHorizontalCenter();
}
void KisCanvasResourceProvider::setOpacity(qreal opacity)
{
......
......@@ -144,7 +144,8 @@ public:
void setMirrorHorizontalHideDecorations(bool hide);
bool mirrorHorizontalHideDecorations();
void mirrorVerticalMoveCanvasToCenter();
void mirrorHorizontalMoveCanvasToCenter();
......@@ -205,6 +206,9 @@ Q_SIGNALS:
void sigLoadingWorkspace(KisWorkspaceResource* workspace);
void mirrorModeChanged();
void moveMirrorVerticalCenter();
void moveMirrorHorizontalCenter();
private:
......
......@@ -236,8 +236,8 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
connect(lockActionX, SIGNAL(toggled(bool)), this, SLOT(slotLockXMirrorToggle(bool)));
connect(lockActionY, SIGNAL(toggled(bool)), this, SLOT(slotLockYMirrorToggle(bool)));
connect(moveToCenterActionX, SIGNAL(changed()), this, SLOT(slotMoveToCenterMirrorX()));
connect(moveToCenterActionY, SIGNAL(changed()), this, SLOT(slotMoveToCenterMirrorY()));
connect(moveToCenterActionX, SIGNAL(triggered(bool)), this, SLOT(slotMoveToCenterMirrorX()));
connect(moveToCenterActionY, SIGNAL(triggered(bool)), this, SLOT(slotMoveToCenterMirrorY()));
connect(moveToPreviousLocationActionX, SIGNAL(changed()), this, SLOT(slotMoveToPreviousLocationMirrorX()));
connect(moveToPreviousLocationActionY, SIGNAL(changed()), this, SLOT(slotMoveToPreviousLocationMirrorY()));
......@@ -1212,11 +1212,11 @@ void KisPaintopBox::slotHideDecorationMirrorY(bool toggled) {
void KisPaintopBox::slotMoveToCenterMirrorX() {
// m_resourceProvider->setLockMirrorVertical(toggleLock);
m_resourceProvider->mirrorHorizontalMoveCanvasToCenter();
}
void KisPaintopBox::slotMoveToCenterMirrorY() {
// m_resourceProvider->setLockMirrorVertical(toggleLock);
m_resourceProvider->mirrorVerticalMoveCanvasToCenter();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment