Add 45-multiple degree adjustment for line, arrow and marker tools (#439)

* Add 45-multiple degree adjustment for line, arrow and marker tools

* Adjustment: Ctrl press is checked + widened functionality for two-point tools
This commit is contained in:
Nikolai Oplachko
2019-03-31 13:38:31 +03:00
committed by Dharkael
parent bd83eea7af
commit b42f1cf01d
13 changed files with 99 additions and 35 deletions

View File

@@ -20,18 +20,13 @@
namespace {
#define ADJ_VALUE 13
#define PADDING_VALUE 2
// Have to force horizontal position
bool needsAdjustment(const QPoint &p0, const QPoint &p1) {
return (p1.y() >= p0.y() - ADJ_VALUE) && (p1.y() <= p0.y() + ADJ_VALUE);
}
}
LineTool::LineTool(QObject *parent) : AbstractTwoPointTool(parent) {
m_supportsOrthogonalAdj = true;
m_supportsDiagonalAdj = true;
}
QIcon LineTool::icon(const QColor &background, bool inEditor) const {
@@ -67,13 +62,6 @@ void LineTool::paintMousePreview(QPainter &painter, const CaptureContext &contex
painter.drawLine(context.mousePos, context.mousePos);
}
void LineTool::drawMove(const QPoint &p) {
m_points.second = p;
if (needsAdjustment(m_points.first, m_points.second)) {
m_points.second.setY(m_points.first.y());
}
}
void LineTool::drawStart(const CaptureContext &context) {
m_color = context.color;
m_thickness = context.thickness + PADDING_VALUE;