diff --git a/libs/image/kis_signal_compressor.h b/libs/image/kis_signal_compressor.h --- a/libs/image/kis_signal_compressor.h +++ b/libs/image/kis_signal_compressor.h @@ -36,7 +36,7 @@ * * FIRST_ACTIVE emits the timeout() event immediately and sets a timer of * duration \p delay. If the compressor is triggered during this time, it will - * fire another signal at the end of the delay period. Further events are + * wait until the end of the delay period to fire the signal. Further events are * ignored until the timer elapses. Think of it as a queue with size 1, and * where the leading element is popped every \p delay ms. * diff --git a/plugins/tools/basictools/kis_tool_line.cc b/plugins/tools/basictools/kis_tool_line.cc --- a/plugins/tools/basictools/kis_tool_line.cc +++ b/plugins/tools/basictools/kis_tool_line.cc @@ -64,7 +64,7 @@ m_strokeIsRunning(false), m_infoBuilder(new KisConverterPaintingInformationBuilder(getCoordinatesConverter(canvas))), m_helper(new KisToolLineHelper(m_infoBuilder.data(), kundo2_i18n("Draw Line"))), - m_strokeUpdateCompressor(500, KisSignalCompressor::FIRST_ACTIVE), + m_strokeUpdateCompressor(500, KisSignalCompressor::POSTPONE), m_longStrokeUpdateCompressor(1000, KisSignalCompressor::FIRST_INACTIVE) { setObjectName("tool_line"); @@ -149,9 +149,21 @@ { Q_UNUSED(converter); + + // Paint one-pixel path + QPainterPath path; + if (m_strokeIsRunning) { + path.moveTo(pixelToView(m_startPoint)); + path.lineTo(pixelToView(m_endPoint)); + } + if(mode() == KisTool::PAINT_MODE) { paintLine(gc,QRect()); } + + + paintToolOutline(&gc, path); + KisToolPaint::paint(gc,converter); } @@ -210,7 +222,10 @@ m_helper->addPoint(event); } + // If the cursor has moved a significant amount, immediately clear the + // current preview and redraw. Otherwise, do slow redraws periodically. if ((pixelToView(m_lastUpdatedPoint) - pixelToView(pos)).manhattanLength() > 10) { + m_helper->clearPaint(); m_longStrokeUpdateCompressor.stop(); m_strokeUpdateCompressor.start(); m_lastUpdatedPoint = pos; diff --git a/plugins/tools/basictools/kis_tool_line_helper.h b/plugins/tools/basictools/kis_tool_line_helper.h --- a/plugins/tools/basictools/kis_tool_line_helper.h +++ b/plugins/tools/basictools/kis_tool_line_helper.h @@ -45,6 +45,7 @@ void translatePoints(const QPointF &offset); void end(); void cancel(); + void clearPaint(); using KisToolFreehandHelper::isRunning; diff --git a/plugins/tools/basictools/kis_tool_line_helper.cpp b/plugins/tools/basictools/kis_tool_line_helper.cpp --- a/plugins/tools/basictools/kis_tool_line_helper.cpp +++ b/plugins/tools/basictools/kis_tool_line_helper.cpp @@ -161,3 +161,11 @@ cancelPaint(); m_d->linePoints.clear(); } + + +void KisToolLineHelper::clearPaint() +{ + if (!m_d->enabled) return; + + cancelPaint(); +}