Commit b6d75fa1 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix outline of Group Layers in Move Tool and Transform Tool

If a group layer is outside the canvas area, we should regenerate these
hidden regions separately.

CCBUG:392717
parent d619b713
......@@ -300,40 +300,10 @@ namespace KisLayerUtils {
m_info->image->bounds() : QRect();
foreach (KisNodeSP node, m_info->allSrcNodes()) {
refreshHiddenAreaAsync(node, preparedRect);
refreshHiddenAreaAsync(m_info->image, node, preparedRect);
}
}
private:
QRect realNodeExactBounds(KisNodeSP rootNode, QRect currentRect = QRect()) {
KisNodeSP node = rootNode->firstChild();
while(node) {
currentRect |= realNodeExactBounds(node, currentRect);
node = node->nextSibling();
}
if (!rootNode->isFakeNode()) {
// TODO: it would be better to count up changeRect inside
// node's extent() method
currentRect |= rootNode->projectionPlane()->changeRect(rootNode->exactBounds());
}
return currentRect;
}
void refreshHiddenAreaAsync(KisNodeSP rootNode, const QRect &preparedArea) {
QRect realNodeRect = realNodeExactBounds(rootNode);
if (!preparedArea.contains(realNodeRect)) {
QRegion dirtyRegion = realNodeRect;
dirtyRegion -= preparedArea;
foreach(const QRect &rc, dirtyRegion.rects()) {
m_info->image->refreshGraphAsync(rootNode, rc, realNodeRect);
}
}
}
private:
MergeDownInfoBaseSP m_info;
};
......@@ -1592,4 +1562,45 @@ namespace KisLayerUtils {
return 0;
}
namespace Private {
QRect realNodeChangeRect(KisNodeSP rootNode, QRect currentRect = QRect()) {
KisNodeSP node = rootNode->firstChild();
while(node) {
currentRect |= realNodeChangeRect(node, currentRect);
node = node->nextSibling();
}
if (!rootNode->isFakeNode()) {
// TODO: it would be better to count up changeRect inside
// node's extent() method
currentRect |= rootNode->projectionPlane()->changeRect(rootNode->exactBounds());
}
return currentRect;
}
}
void refreshHiddenAreaAsync(KisImageSP image, KisNodeSP rootNode, const QRect &preparedArea) {
QRect realNodeRect = Private::realNodeChangeRect(rootNode);
if (!preparedArea.contains(realNodeRect)) {
QRegion dirtyRegion = realNodeRect;
dirtyRegion -= preparedArea;
Q_FOREACH (const QRect &rc, dirtyRegion.rects()) {
image->refreshGraphAsync(rootNode, rc, realNodeRect);
}
}
}
QRect recursiveNodeExactBounds(KisNodeSP rootNode)
{
QRect exactBounds;
recursiveApplyNodes(rootNode, [&exactBounds] (KisNodeSP node) {
exactBounds |= node->exactBounds();
});
return exactBounds;
}
}
......@@ -43,6 +43,8 @@ namespace KisLayerUtils
KRITAIMAGE_EXPORT KisNodeList sortAndFilterAnyMergableNodesSafe(const KisNodeList &nodes, KisImageSP image);
KRITAIMAGE_EXPORT bool checkIsChildOf(KisNodeSP node, const KisNodeList &parents);
KRITAIMAGE_EXPORT void filterUnlockedNodes(KisNodeList &nodes);
KRITAIMAGE_EXPORT void refreshHiddenAreaAsync(KisImageSP image, KisNodeSP rootNode, const QRect &preparedArea);
KRITAIMAGE_EXPORT QRect recursiveNodeExactBounds(KisNodeSP rootNode);
/**
* Returns true if:
......
......@@ -93,7 +93,7 @@ void MoveStrokeStrategy::initStrokeCallback()
Q_FOREACH(KisNodeSP node, m_nodes) {
saveInitialNodeOffsets(node);
handlesRect |= node->exactBounds();
handlesRect |= KisLayerUtils::recursiveNodeExactBounds(node);
}
KisStrokeStrategyUndoCommandBased::initStrokeCallback();
......
......@@ -19,7 +19,7 @@
#include "KisMoveBoundsCalculationJob.h"
#include "kis_node.h"
#include "kis_selection.h"
#include "kis_layer_utils.h"
KisMoveBoundsCalculationJob::KisMoveBoundsCalculationJob(KisNodeList nodes,
KisSelectionSP selection,
......@@ -36,7 +36,7 @@ void KisMoveBoundsCalculationJob::run()
QRect handlesRect;
Q_FOREACH (KisNodeSP node, m_nodes) {
handlesRect |= node->exactBounds();
handlesRect |= KisLayerUtils::recursiveNodeExactBounds(node);
}
if (m_selection) {
......
......@@ -197,6 +197,7 @@ void TransformStrokeStrategy::doStrokeCallback(KisStrokeJobData *data)
});
clonedImage->refreshGraph();
KisLayerUtils::refreshHiddenAreaAsync(clonedImage, clonedGroup, clonedImage->bounds());
KisLayerUtils::forceAllDelayedNodesUpdate(clonedGroup);
clonedImage->waitForDone();
......
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