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 @@
<developer_name>Krita Foundation</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="es">Fundación 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="pl">Fundacja Krity</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="sv">Krita-stiftelsen</developer_name>
......
......@@ -120,6 +120,8 @@ KisReferenceImage * KisReferenceImage::fromFile(const QString &filename, const K
void KisReferenceImage::paint(QPainter &gc, const KoViewConverter &converter, KoShapePaintingContext &/*paintcontext*/)
{
if (!parent()) return;
gc.save();
applyConversion(gc, converter);
......
......@@ -61,20 +61,27 @@ struct KisReferenceImagesDecoration::Private {
}
private:
void updateBuffer(const QRectF &widgetRect, const QRectF &imageRect)
void updateBuffer(QRectF widgetRect, QRectF imageRect)
{
KisCoordinatesConverter *viewConverter = q->view()->viewConverter();
QTransform transform = viewConverter->imageToWidgetTransform();
if (buffer.image.isNull() || !buffer.bounds().contains(widgetRect)) {
// TODO: only use enough buffer to cover the BB of the shapes
buffer.position = QPointF();
buffer.image = QImage(q->view()->width(), q->view()->height(), QImage::Format_ARGB32);
const QRectF boundingImageRect = layer->boundingImageRect();
const QRectF boundingWidgetRect = q->view()->viewConverter()->imageToWidget(boundingImageRect);
widgetRect = boundingWidgetRect.intersected(q->view()->rect());
buffer.position = widgetRect.topLeft();
buffer.image = QImage(widgetRect.size().toSize(), QImage::Format_ARGB32);
buffer.image.fill(Qt::transparent);
imageRect = q->view()->viewConverter()->widgetToImage(widgetRect);
}
QPainter gc(&buffer.image);
gc.setTransform(transform);
gc.translate(-buffer.position);
gc.setTransform(transform, true);
gc.save();
gc.setCompositionMode(QPainter::CompositionMode_Source);
......
......@@ -64,8 +64,7 @@ public:
void forceRepaint() override
{
QRectF rect = KoShape::boundingRect(m_layer->shapes());
m_layer->signalUpdate(m_viewConverter->documentToView(rect));
m_layer->signalUpdate(m_layer->boundingImageRect());
}
void rerenderAfterBeingInvisible() override {}
......@@ -81,7 +80,7 @@ KisReferenceImagesLayer::KisReferenceImagesLayer(KoShapeBasedDocumentBase* shape
{}
KisReferenceImagesLayer::KisReferenceImagesLayer(const KisReferenceImagesLayer &rhs)
: KisShapeLayer(rhs)
: KisShapeLayer(rhs, rhs.shapeController(), new ReferenceImagesCanvas(this, rhs.image()))
{}
KUndo2Command * KisReferenceImagesLayer::addReferenceImage(KisReferenceImage *referenceImage)
......@@ -126,6 +125,11 @@ void KisReferenceImagesLayer::signalUpdate(const QRectF &rect)
emit sigUpdateCanvas(rect);
}
QRectF KisReferenceImagesLayer::boundingImageRect() const
{
return converter()->documentToView(boundingRect());
}
QColor KisReferenceImagesLayer::getPixel(QPointF position) const
{
const QPointF docPoint = converter()->viewToDocument(position);
......
......@@ -35,6 +35,7 @@ public:
KUndo2Command * addReferenceImage(KisReferenceImage *referenceImage);
QVector<KisReferenceImage*> referenceImages() const;
QRectF boundingImageRect() const;
QColor getPixel(QPointF position) const;
void paintReferences(QPainter &painter);
......
......@@ -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)
, KoShapeLayer(new ShapeLayerContainerModel(this)) //no _rhs here otherwise both layer have the same KoShapeContainerModel
, m_d(new Private())
{
// 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
......
......@@ -58,7 +58,7 @@ public:
KisShapeLayer(KoShapeBasedDocumentBase* shapeController, KisImageWSP image, const QString &name, quint8 opacity);
KisShapeLayer(const KisShapeLayer& _rhs);
KisShapeLayer(const KisShapeLayer& _rhs, KoShapeBasedDocumentBase* controller);
KisShapeLayer(const KisShapeLayer& _rhs, KoShapeBasedDocumentBase* controller, KisShapeLayerCanvasBase *canvas = 0);
/**
* Merge constructor.
*
......
......@@ -386,7 +386,7 @@ void KisToolPaint::addPickerJob(const PickingJob &pickingJob)
auto *referencesLayer = kisCanvas->imageView()->document()->referenceImagesLayer();
if (referencesLayer) {
QColor color = referencesLayer->getPixel(imagePoint);
if (color.isValid() && !color.alpha() == 0) {
if (color.isValid() && color.alpha() != 0) {
slotColorPickingFinished(KoColor(color, image()->colorSpace()));
return;
}
......
......@@ -31,7 +31,6 @@ from PyQt5.QtCore import QStandardPaths, QSettings
from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox
import PyQt5.uic as uic
try:
import krita
CONTEXT_KRITA = True
......@@ -107,11 +106,14 @@ class {class_name}(Extension):
super().__init__(parent)
def setup(self):
app = Krita.instance()
action = app.createAction(EXTENSION_ID, MENU_ENTRY)
pass
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 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):
pass # your active code goes here.
......@@ -182,12 +184,20 @@ class KritaScriptStarter(EXTENSION):
target_directory = os.path.join(target_directory, "pykrita")
self.target_directory = target_directory
if CONTEXT_KRITA:
app = Krita.instance()
action = app.createAction(MAIN_KRITA_ID, MAIN_KRITA_MENU_ENTRY)
# 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
action.triggered.connect(self.action_triggered)
# if CONTEXT_KRITA:
# app = Krita.instance()
# action = app.createAction(MAIN_KRITA_ID, MAIN_KRITA_MENU_ENTRY)
# # 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
# 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):
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