Commit d5bd36e2 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Transform invisible layers if they are part of the group

When transforming a group recursively, some of the layers may be invisible
so the user may just forget about them. Now we transform the layers even if
they are invisible. The user still can avoid this behavior by
setting the layer as "locked".

Thanks Roman Ilin for suggestion!

Ref T475
CC:kimageshop@kde.org
parent 94098089
......@@ -902,7 +902,17 @@ void KisToolTransform::startStroke(ToolTransformArgs::TransformMode mode)
}
m_strokeData = StrokeData(image()->startStroke(strategy));
clearDevices(m_transaction.rootNode(), m_workRecursively);
bool haveInvisibleNodes = clearDevices(m_transaction.rootNode(), m_workRecursively);
if (haveInvisibleNodes) {
KisCanvas2 *kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
kisCanvas->viewManager()->
showFloatingMessage(
i18nc("floating message in transformation tool",
"Invisible sublayers will also be transformed. Lock layers if you do not want them to be transformed "),
QIcon(), 4000, KisFloatingMessage::Low);
}
Q_ASSERT(m_changesTracker.isEmpty());
commitChanges();
......@@ -957,15 +967,18 @@ void KisToolTransform::slotTrackerChangedConfig()
updateOptionWidget();
}
void KisToolTransform::clearDevices(KisNodeSP node, bool recursive)
bool KisToolTransform::clearDevices(KisNodeSP node, bool recursive)
{
if (!node->isEditable()) return;
bool haveInvisibleNodes = false;
if (!node->isEditable(false)) return haveInvisibleNodes;
haveInvisibleNodes = !node->visible(false);
if (recursive) {
// simple tail-recursive iteration
KisNodeSP prevNode = node->lastChild();
while(prevNode) {
clearDevices(prevNode, recursive);
haveInvisibleNodes |= clearDevices(prevNode, recursive);
prevNode = prevNode->prevSibling();
}
}
......@@ -979,6 +992,8 @@ void KisToolTransform::clearDevices(KisNodeSP node, bool recursive)
* applicable nodes right in the beginning of the processing
*/
m_strokeData.addClearedNode(node);
return haveInvisibleNodes;
}
void KisToolTransform::transformDevices(KisNodeSP node, bool recursive)
......
......@@ -211,7 +211,7 @@ public Q_SLOTS:
void imageTooBigRequested(bool value);
private:
void clearDevices(KisNodeSP node, bool recursive);
bool clearDevices(KisNodeSP node, bool recursive);
void transformDevices(KisNodeSP node, bool recursive);
void startStroke(ToolTransformArgs::TransformMode mode);
......
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