Commit dea66447 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Merge remote-tracking branch 'origin' into rempt/T379-resource-management

parents 4a5f2102 04deaee0
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
<developer_name>Krita Foundation</developer_name> <developer_name>Krita Foundation</developer_name>
<developer_name xml:lang="ca">Fundació Krita</developer_name> <developer_name xml:lang="ca">Fundació Krita</developer_name>
<developer_name xml:lang="ca-valencia">Fundació Krita</developer_name> <developer_name xml:lang="ca-valencia">Fundació Krita</developer_name>
<developer_name xml:lang="es">Fundación Krita</developer_name>
<developer_name xml:lang="it">Fondazione Krita</developer_name> <developer_name xml:lang="it">Fondazione Krita</developer_name>
<developer_name xml:lang="nl">Krita Foundation</developer_name> <developer_name xml:lang="nl">Krita Foundation</developer_name>
<developer_name xml:lang="pl">Fundacja Krity</developer_name>
<developer_name xml:lang="pt">Fundação do Krita</developer_name> <developer_name xml:lang="pt">Fundação do Krita</developer_name>
<developer_name xml:lang="pt-BR">Krita Foundation</developer_name> <developer_name xml:lang="pt-BR">Krita Foundation</developer_name>
<developer_name xml:lang="sv">Krita-stiftelsen</developer_name> <developer_name xml:lang="sv">Krita-stiftelsen</developer_name>
......
...@@ -120,6 +120,8 @@ KisReferenceImage * KisReferenceImage::fromFile(const QString &filename, const K ...@@ -120,6 +120,8 @@ KisReferenceImage * KisReferenceImage::fromFile(const QString &filename, const K
void KisReferenceImage::paint(QPainter &gc, const KoViewConverter &converter, KoShapePaintingContext &/*paintcontext*/) void KisReferenceImage::paint(QPainter &gc, const KoViewConverter &converter, KoShapePaintingContext &/*paintcontext*/)
{ {
if (!parent()) return;
gc.save(); gc.save();
applyConversion(gc, converter); applyConversion(gc, converter);
......
...@@ -61,20 +61,27 @@ struct KisReferenceImagesDecoration::Private { ...@@ -61,20 +61,27 @@ struct KisReferenceImagesDecoration::Private {
} }
private: private:
void updateBuffer(const QRectF &widgetRect, const QRectF &imageRect) void updateBuffer(QRectF widgetRect, QRectF imageRect)
{ {
KisCoordinatesConverter *viewConverter = q->view()->viewConverter(); KisCoordinatesConverter *viewConverter = q->view()->viewConverter();
QTransform transform = viewConverter->imageToWidgetTransform(); QTransform transform = viewConverter->imageToWidgetTransform();
if (buffer.image.isNull() || !buffer.bounds().contains(widgetRect)) { if (buffer.image.isNull() || !buffer.bounds().contains(widgetRect)) {
// TODO: only use enough buffer to cover the BB of the shapes const QRectF boundingImageRect = layer->boundingImageRect();
buffer.position = QPointF(); const QRectF boundingWidgetRect = q->view()->viewConverter()->imageToWidget(boundingImageRect);
buffer.image = QImage(q->view()->width(), q->view()->height(), QImage::Format_ARGB32); widgetRect = boundingWidgetRect.intersected(q->view()->rect());
buffer.position = widgetRect.topLeft();
buffer.image = QImage(widgetRect.size().toSize(), QImage::Format_ARGB32);
buffer.image.fill(Qt::transparent); buffer.image.fill(Qt::transparent);
imageRect = q->view()->viewConverter()->widgetToImage(widgetRect);
} }
QPainter gc(&buffer.image); QPainter gc(&buffer.image);
gc.setTransform(transform);
gc.translate(-buffer.position);
gc.setTransform(transform, true);
gc.save(); gc.save();
gc.setCompositionMode(QPainter::CompositionMode_Source); gc.setCompositionMode(QPainter::CompositionMode_Source);
......
...@@ -64,8 +64,7 @@ public: ...@@ -64,8 +64,7 @@ public:
void forceRepaint() override void forceRepaint() override
{ {
QRectF rect = KoShape::boundingRect(m_layer->shapes()); m_layer->signalUpdate(m_layer->boundingImageRect());
m_layer->signalUpdate(m_viewConverter->documentToView(rect));
} }
void rerenderAfterBeingInvisible() override {} void rerenderAfterBeingInvisible() override {}
...@@ -81,7 +80,7 @@ KisReferenceImagesLayer::KisReferenceImagesLayer(KoShapeBasedDocumentBase* shape ...@@ -81,7 +80,7 @@ KisReferenceImagesLayer::KisReferenceImagesLayer(KoShapeBasedDocumentBase* shape
{} {}
KisReferenceImagesLayer::KisReferenceImagesLayer(const KisReferenceImagesLayer &rhs) KisReferenceImagesLayer::KisReferenceImagesLayer(const KisReferenceImagesLayer &rhs)
: KisShapeLayer(rhs) : KisShapeLayer(rhs, rhs.shapeController(), new ReferenceImagesCanvas(this, rhs.image()))
{} {}
KUndo2Command * KisReferenceImagesLayer::addReferenceImage(KisReferenceImage *referenceImage) KUndo2Command * KisReferenceImagesLayer::addReferenceImage(KisReferenceImage *referenceImage)
...@@ -126,6 +125,11 @@ void KisReferenceImagesLayer::signalUpdate(const QRectF &rect) ...@@ -126,6 +125,11 @@ void KisReferenceImagesLayer::signalUpdate(const QRectF &rect)
emit sigUpdateCanvas(rect); emit sigUpdateCanvas(rect);
} }
QRectF KisReferenceImagesLayer::boundingImageRect() const
{
return converter()->documentToView(boundingRect());
}
QColor KisReferenceImagesLayer::getPixel(QPointF position) const QColor KisReferenceImagesLayer::getPixel(QPointF position) const
{ {
const QPointF docPoint = converter()->viewToDocument(position); const QPointF docPoint = converter()->viewToDocument(position);
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
KUndo2Command * addReferenceImage(KisReferenceImage *referenceImage); KUndo2Command * addReferenceImage(KisReferenceImage *referenceImage);
QVector<KisReferenceImage*> referenceImages() const; QVector<KisReferenceImage*> referenceImages() const;
QRectF boundingImageRect() const;
QColor getPixel(QPointF position) const; QColor getPixel(QPointF position) const;
void paintReferences(QPainter &painter); void paintReferences(QPainter &painter);
......
...@@ -164,13 +164,13 @@ KisShapeLayer::KisShapeLayer(const KisShapeLayer& rhs) ...@@ -164,13 +164,13 @@ KisShapeLayer::KisShapeLayer(const KisShapeLayer& rhs)
{ {
} }
KisShapeLayer::KisShapeLayer(const KisShapeLayer& _rhs, KoShapeBasedDocumentBase* controller) KisShapeLayer::KisShapeLayer(const KisShapeLayer& _rhs, KoShapeBasedDocumentBase* controller, KisShapeLayerCanvasBase *canvas)
: KisExternalLayer(_rhs) : KisExternalLayer(_rhs)
, KoShapeLayer(new ShapeLayerContainerModel(this)) //no _rhs here otherwise both layer have the same KoShapeContainerModel , KoShapeLayer(new ShapeLayerContainerModel(this)) //no _rhs here otherwise both layer have the same KoShapeContainerModel
, m_d(new Private()) , m_d(new Private())
{ {
// copy the projection to avoid extra round of updates! // copy the projection to avoid extra round of updates!
initShapeLayer(controller, _rhs.m_d->paintDevice); initShapeLayer(controller, _rhs.m_d->paintDevice, canvas);
/** /**
* The transformaitons of the added shapes are automatically merged into the transformation * The transformaitons of the added shapes are automatically merged into the transformation
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
KisShapeLayer(KoShapeBasedDocumentBase* shapeController, KisImageWSP image, const QString &name, quint8 opacity); KisShapeLayer(KoShapeBasedDocumentBase* shapeController, KisImageWSP image, const QString &name, quint8 opacity);
KisShapeLayer(const KisShapeLayer& _rhs); KisShapeLayer(const KisShapeLayer& _rhs);
KisShapeLayer(const KisShapeLayer& _rhs, KoShapeBasedDocumentBase* controller); KisShapeLayer(const KisShapeLayer& _rhs, KoShapeBasedDocumentBase* controller, KisShapeLayerCanvasBase *canvas = 0);
/** /**
* Merge constructor. * Merge constructor.
* *
......
...@@ -386,7 +386,7 @@ void KisToolPaint::addPickerJob(const PickingJob &pickingJob) ...@@ -386,7 +386,7 @@ void KisToolPaint::addPickerJob(const PickingJob &pickingJob)
auto *referencesLayer = kisCanvas->imageView()->document()->referenceImagesLayer(); auto *referencesLayer = kisCanvas->imageView()->document()->referenceImagesLayer();
if (referencesLayer) { if (referencesLayer) {
QColor color = referencesLayer->getPixel(imagePoint); QColor color = referencesLayer->getPixel(imagePoint);
if (color.isValid() && !color.alpha() == 0) { if (color.isValid() && color.alpha() != 0) {
slotColorPickingFinished(KoColor(color, image()->colorSpace())); slotColorPickingFinished(KoColor(color, image()->colorSpace()));
return; return;
} }
......
...@@ -31,7 +31,6 @@ from PyQt5.QtCore import QStandardPaths, QSettings ...@@ -31,7 +31,6 @@ from PyQt5.QtCore import QStandardPaths, QSettings
from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox
import PyQt5.uic as uic import PyQt5.uic as uic
try: try:
import krita import krita
CONTEXT_KRITA = True CONTEXT_KRITA = True
...@@ -107,11 +106,14 @@ class {class_name}(Extension): ...@@ -107,11 +106,14 @@ class {class_name}(Extension):
super().__init__(parent) super().__init__(parent)
def setup(self): def setup(self):
app = Krita.instance() pass
action = app.createAction(EXTENSION_ID, MENU_ENTRY)
def createActions(self, window):
action = window.createAction(EXTENSION_ID, MENU_ENTRY, "tools/scripts")
# parameter 1 = the name that Krita uses to identify the action # parameter 1 = the name that Krita uses to identify the action
# parameter 2 = the text to be added to the menu entry for this script # parameter 2 = the text to be added to the menu entry for this script
action.triggered.connect(self.action_triggered) # parameter 3 = location of menu entry
action.triggered.connect(self.action_triggered)
def action_triggered(self): def action_triggered(self):
pass # your active code goes here. pass # your active code goes here.
...@@ -182,12 +184,20 @@ class KritaScriptStarter(EXTENSION): ...@@ -182,12 +184,20 @@ class KritaScriptStarter(EXTENSION):
target_directory = os.path.join(target_directory, "pykrita") target_directory = os.path.join(target_directory, "pykrita")
self.target_directory = target_directory self.target_directory = target_directory
if CONTEXT_KRITA: # if CONTEXT_KRITA:
app = Krita.instance() # app = Krita.instance()
action = app.createAction(MAIN_KRITA_ID, MAIN_KRITA_MENU_ENTRY) # action = app.createAction(MAIN_KRITA_ID, MAIN_KRITA_MENU_ENTRY)
# parameter 1 = the name that Krita uses to identify the action # # parameter 1 = the name that Krita uses to identify the action
# parameter 2 = the text to be added to the menu entry for this script # # parameter 2 = the text to be added to the menu entry for this script
action.triggered.connect(self.action_triggered) # action.triggered.connect(self.action_triggered)
def createActions(self, window):
""" Called by Krita to create actions."""
action = window.createAction(MAIN_KRITA_ID, MAIN_KRITA_MENU_ENTRY, "tools/scripts")
# parameter 1 = the name that Krita uses to identify the action
# parameter 2 = the text to be added to the menu entry for this script
# parameter 3 = location of menu entry
action.triggered.connect(self.action_triggered)
def action_triggered(self): def action_triggered(self):
self.ui.show() self.ui.show()
......
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