Commit 70f26c68 authored by Dmitry Kazakov's avatar Dmitry Kazakov

[FEATURE] Make Fill Tool work in Wraparound mode!

The filling bounds are still a rect bounding the image but
you can click multiple times at any point of the canvas to
achieve your goal. The main problem is solved, you can press
at any point of the canvas.

CC:kimageshop@kde.org
BUG:349565
parent be6e1720
......@@ -36,6 +36,12 @@ struct KisWrappedRect : public QVector<QRect> {
return y;
}
static inline QPoint ptToWrappedPt(QPoint pt, const QRect &wrapRect) {
pt.rx() = xToWrappedX(pt.x(), wrapRect);
pt.ry() = yToWrappedY(pt.y(), wrapRect);
return pt;
}
enum {
TOPLEFT = 0,
TOPRIGHT,
......
......@@ -107,7 +107,8 @@ void KisToolFill::endPrimaryAction(KoPointerEvent *event)
setMode(KisTool::HOVER_MODE);
if (!currentNode() ||
!currentImage()->bounds().contains(m_startPos)) {
(!image()->wrapAroundModePermitted() &&
!image()->bounds().contains(m_startPos))) {
return;
}
......@@ -132,7 +133,7 @@ void KisToolFill::endPrimaryAction(KoPointerEvent *event)
bool useFastMode = m_useFastMode->isChecked();
KisProcessingApplicator applicator(currentImage(), currentNode(),
KisProcessingApplicator::NONE,
KisProcessingApplicator::SUPPORTS_WRAPAROUND_MODE,
KisImageSignalVector() << ModifiedSignal,
kundo2_i18n("Flood Fill"));
......
......@@ -21,6 +21,7 @@
#include <kis_node.h>
#include <kis_image.h>
#include <kis_fill_painter.h>
#include <kis_wrapped_rect.h>
FillProcessingVisitor::FillProcessingVisitor(const QPoint &startPoint,
......@@ -62,6 +63,12 @@ void FillProcessingVisitor::visitNodeWithPaintDevice(KisNode *node, KisUndoAdapt
ProgressHelper helper(node);
QRect fillRect = m_resources->image()->bounds();
if (!device->defaultBounds()->wrapAroundMode() &&
!fillRect.contains(m_startPoint)) {
return;
}
if (m_selectionOnly) {
KisPaintDeviceSP filledDevice = device->createCompositionSourceDevice();
KisFillPainter fillPainter(filledDevice);
......@@ -94,6 +101,11 @@ void FillProcessingVisitor::visitNodeWithPaintDevice(KisNode *node, KisUndoAdapt
} else {
QPoint startPoint = m_startPoint;
if (device->defaultBounds()->wrapAroundMode()) {
startPoint = KisWrappedRect::ptToWrappedPt(startPoint, device->defaultBounds()->bounds());
}
KisFillPainter fillPainter(device, m_selection);
fillPainter.beginTransaction();
......@@ -111,9 +123,9 @@ void FillProcessingVisitor::visitNodeWithPaintDevice(KisNode *node, KisUndoAdapt
KisPaintDeviceSP sourceDevice = m_unmerged ? device : m_resources->image()->projection();
if (m_usePattern) {
fillPainter.fillPattern(m_startPoint.x(), m_startPoint.y(), sourceDevice);
fillPainter.fillPattern(startPoint.x(), startPoint.y(), sourceDevice);
} else {
fillPainter.fillColor(m_startPoint.x(), m_startPoint.y(), sourceDevice);
fillPainter.fillColor(startPoint.x(), startPoint.y(), sourceDevice);
}
fillPainter.endTransaction(undoAdapter);
......
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