Commit ff7d4aad authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

krita: Tweak mirror axes display and default position of move handles

Mirror axis are now thinner and handles are positioned next to the
indicators.
parent fa81254f
......@@ -50,11 +50,13 @@ public:
, resourceProvider(0)
, mirrorHorizontal(false)
, mirrorVertical(false)
, handleSize(32)
, handleSize(32.f)
, xActive(false)
, yActive(false)
, horizontalHandlePosition(30.f)
, verticalHandlePosition(30.f)
, horizontalHandlePosition(0.f)
, verticalHandlePosition(0.f)
, sideMargin(10.f)
, minHandlePosition(10.f + 32.f)
{ }
void setAxisPosition(float x, float y);
......@@ -77,6 +79,8 @@ public:
bool yActive;
float horizontalHandlePosition;
float verticalHandlePosition;
float sideMargin;
float minHandlePosition;
};
KisMirrorAxis::KisMirrorAxis(KisCanvasResourceProvider* provider, KisView2* parent)
......@@ -96,9 +100,6 @@ KisMirrorAxis::KisMirrorAxis(KisCanvasResourceProvider* provider, KisView2* pare
int imageHeight = parent->canvasBase()->image()->height();
QPointF point(imageWidth / 2, imageHeight / 2);
d->resourceProvider->resourceManager()->setResource(KisCanvasResourceProvider::MirrorAxesCenter, point);
QPointF handlePos = parent->canvasBase()->coordinatesConverter()->imageToViewport(QPointF(imageWidth / 3, imageHeight / 3));
d->horizontalHandlePosition = handlePos.y();
d->verticalHandlePosition = handlePos.x();
parent->installEventFilter(this);
parent->canvasBase()->inputManager()->attachPriorityEventFilter(this);
......@@ -122,6 +123,7 @@ void KisMirrorAxis::setHandleSize(float newSize)
d->verticalIcon = koIcon("symmetry-vertical").pixmap(d->handleSize, QIcon::Normal, QIcon::On);
d->horizontalHandleIcon = koIcon("transform-move").pixmap(d->handleSize, QIcon::Normal, QIcon::On);
d->verticalHandleIcon = koIcon("transform-move").pixmap(d->handleSize, QIcon::Normal, QIcon::On);
d->minHandlePosition = d->sideMargin + newSize;
emit handleSizeChanged();
}
}
......@@ -130,7 +132,7 @@ void KisMirrorAxis::drawDecoration(QPainter& gc, const QRectF& updateArea, const
{
Q_UNUSED(updateArea);
gc.setPen(QPen(Qt::black, 2));
gc.setPen(QPen(QColor(0, 0, 0, 128), 1));
gc.setBrush(Qt::white);
gc.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
......@@ -201,13 +203,13 @@ bool KisMirrorAxis::eventFilter(QObject* target, QEvent* event)
QMouseEvent* me = static_cast<QMouseEvent*>(event);
if(d->xActive) {
d->setAxisPosition(me->posF().x(), d->axisPosition.y());
d->horizontalHandlePosition = qBound<float>(0.f, me->posF().y() - d->handleSize / 2, view()->height() - d->handleSize);
d->horizontalHandlePosition = qBound<float>(d->minHandlePosition, me->posF().y() - d->handleSize / 2, view()->height() - d->handleSize);
event->accept();
return true;
}
if(d->yActive) {
d->setAxisPosition(d->axisPosition.x(), me->posF().y());
d->verticalHandlePosition = qBound<float>(0.f, me->posF().x() - d->handleSize / 2, view()->width() - d->handleSize);
d->verticalHandlePosition = qBound<float>(d->minHandlePosition, me->posF().x() - d->handleSize / 2, view()->width() - d->handleSize);
event->accept();
return true;
}
......@@ -236,8 +238,8 @@ bool KisMirrorAxis::eventFilter(QObject* target, QEvent* event)
if(target == view() && event->type() == QEvent::Resize) {
QResizeEvent* re = static_cast<QResizeEvent*>(event);
if(re->oldSize().width() > 0 && re->oldSize().height() > 0) {
d->horizontalHandlePosition = qBound<float>(0.f, (d->horizontalHandlePosition / re->oldSize().height()) * re->size().height(), re->size().height());
d->verticalHandlePosition = qBound<float>(0.f, (d->verticalHandlePosition / re->oldSize().width()) * re->size().width(), re->size().width());
d->horizontalHandlePosition = qBound<float>(d->minHandlePosition, (d->horizontalHandlePosition / re->oldSize().height()) * re->size().height(), re->size().height());
d->verticalHandlePosition = qBound<float>(d->minHandlePosition, (d->verticalHandlePosition / re->oldSize().width()) * re->size().width(), re->size().width());
}
}
return QObject::eventFilter(target, event);
......
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