mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-01-07 01:23:58 +00:00
Add horizontal adjustment in marker and line tools
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user