[calligra/calligra/2.9] krita: [FEATURE] Make Fill Tool work in Wraparound mode!
Dmitry Kazakov
dimula73 at gmail.com
Thu Aug 20 11:29:46 UTC 2015
Git commit 36e77cf49766981447503fa8a8d3da83d5f8c43d by Dmitry Kazakov.
Committed on 20/08/2015 at 11:29.
Pushed by dkazakov into branch 'calligra/2.9'.
[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 at kde.org
BUG:349565
M +6 -0 krita/image/kis_wrapped_rect.h
M +3 -2 krita/plugins/tools/defaulttools/kis_tool_fill.cc
M +14 -2 krita/ui/processing/fill_processing_visitor.cpp
http://commits.kde.org/calligra/36e77cf49766981447503fa8a8d3da83d5f8c43d
diff --git a/krita/image/kis_wrapped_rect.h b/krita/image/kis_wrapped_rect.h
index d094952..92b07b1 100644
--- a/krita/image/kis_wrapped_rect.h
+++ b/krita/image/kis_wrapped_rect.h
@@ -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,
diff --git a/krita/plugins/tools/defaulttools/kis_tool_fill.cc b/krita/plugins/tools/defaulttools/kis_tool_fill.cc
index 3836cd1..9bc2d07 100644
--- a/krita/plugins/tools/defaulttools/kis_tool_fill.cc
+++ b/krita/plugins/tools/defaulttools/kis_tool_fill.cc
@@ -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"));
diff --git a/krita/ui/processing/fill_processing_visitor.cpp b/krita/ui/processing/fill_processing_visitor.cpp
index cb2fcda..47c3a7a 100644
--- a/krita/ui/processing/fill_processing_visitor.cpp
+++ b/krita/ui/processing/fill_processing_visitor.cpp
@@ -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);
More information about the kimageshop
mailing list