Add horizontal adjustment in marker and line tools

This commit is contained in:
lupoDharkael
2017-08-01 21:28:39 +02:00
parent 2ea32e061b
commit 2ca525326e
4 changed files with 30 additions and 2 deletions

View File

@@ -18,6 +18,8 @@
#include "linetool.h"
#include <QPainter>
#define ADJ_VALUE 13
LineTool::LineTool(QObject *parent) : CaptureTool(parent) {
}
@@ -47,9 +49,18 @@ void LineTool::processImage(
const QVector<QPoint> &points,
const QColor &color)
{
QPoint p0 = points[0];
QPoint p1 = points[1];
if (needsAdjustment(p0, p1)) {
p1.setY(p0.y());
}
painter.setPen(QPen(color, 2));
painter.drawLine(points[0], points[1]);
painter.drawLine(p0, p1);
}
void LineTool::onPressed() {
}
bool LineTool::needsAdjustment(const QPoint &p0, const QPoint &p1) const {
return (p1.y() >= p0.y() - ADJ_VALUE) && (p1.y() <= p0.y() + ADJ_VALUE);
}