Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix Node.paint script functions to use given node

Freya Lupen8227190c6acd
diff --git a/libs/libkis/Node.cpp b/libs/libkis/Node.cpp
index a82b5adf8b..d0165fc338 100644
--- a/libs/libkis/Node.cpp
+++ b/libs/libkis/Node.cpp
@@ -879,7 +879,7 @@ void Node::paintLine(const QPointF pointOne, const QPointF pointTwo, double pres
pointTwoInfo.setPressure(pressureTwo);
pointTwoInfo.setPos(pointTwo);
- KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, strokeStyle);
+ KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle);
helper.paintLine(pointOneInfo, pointTwoInfo);
}
@@ -894,7 +894,7 @@ void Node::paintRectangle(const QRectF &rect, const QString strokeStyle, const Q
// reference class where this stuff is being done. Maybe can use the "facade" like that does for setup?
// void KisFigurePaintingToolHelper::paintRect(const QRectF &rect)
- KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, strokeStyle, fillStyle);
+ KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle, fillStyle);
helper.paintRect(rect);
}
@@ -908,7 +908,7 @@ void Node::paintPolygon(const QList<QPointF> listPoint, const QString strokeStyl
// strategy needs points in vPointF format
QVector<QPointF> points = points.fromList(listPoint);
- KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, strokeStyle, fillStyle);
+ KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle, fillStyle);
helper.paintPolygon(points);
}
@@ -920,7 +920,7 @@ void Node::paintEllipse(const QRectF &rect, const QString strokeStyle, const QSt
return;
}
- KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, strokeStyle, fillStyle);
+ KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle, fillStyle);
helper.paintEllipse(rect);
}
@@ -932,6 +932,6 @@ void Node::paintPath(const QPainterPath &path, const QString strokeStyle, const
return;
}
- KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, strokeStyle, fillStyle);
+ KisFigurePaintingToolHelper helper = PaintingResources::createHelper(d->image, node(), strokeStyle, fillStyle);
helper.paintPainterPath(path);
}
diff --git a/libs/libkis/PaintingResources.cpp b/libs/libkis/PaintingResources.cpp
index 2865bedaf3..391a5c5c28 100644
--- a/libs/libkis/PaintingResources.cpp
+++ b/libs/libkis/PaintingResources.cpp
@@ -28,6 +28,7 @@ const QStringList FillStyle = {
};
KisFigurePaintingToolHelper PaintingResources::createHelper(KisImageWSP image,
+ KisNodeSP node,
const QString strokeStyleString,
const QString fillStyleString)
{
@@ -35,9 +36,6 @@ KisFigurePaintingToolHelper PaintingResources::createHelper(KisImageWSP image,
KisView *activeView = KisPart::instance()->currentMainwindow()->activeView();
KoCanvasResourceProvider *resourceManager = activeView->viewManager()->canvasResourceProvider()->resourceManager();
- // grab the image and current layer
- KisNodeSP node = activeView->currentNode();
-
int strokeIndex = StrokeStyle.indexOf(strokeStyleString);
if (strokeIndex == -1) {
dbgScript << "Script tried to paint with invalid strokeStyle" << strokeStyleString << ", ignoring and using" << defaultStrokeStyle << ".";
diff --git a/libs/libkis/PaintingResources.h b/libs/libkis/PaintingResources.h
index 470a3779d8..e1012092b1 100644
--- a/libs/libkis/PaintingResources.h
+++ b/libs/libkis/PaintingResources.h
@@ -21,6 +21,7 @@ namespace PaintingResources
const QString defaultFillStyle = "None";
KisFigurePaintingToolHelper createHelper(KisImageWSP image,
+ KisNodeSP node,
const QString strokeStyle = defaultStrokeStyle,
const QString fillStyle = defaultFillStyle);