Commit 94098089 authored by Halla Rempt's avatar Halla Rempt
Browse files

BUG:345619 All Drag & Drop of masks

The default bounds associated with a mask need to know about the
image. When we load a dropped mask, we create it with a temporary
image to reconstruct the hierarchy, and then we need to "internalize"
the nodes to the target image.

That was only done for layers, because we said

// Only layers know about the image

that was a lie...
parent 878b75d1
......@@ -47,6 +47,11 @@ KisDefaultBounds::~KisDefaultBounds()
delete m_d;
}
void KisDefaultBounds::setImage(KisImageWSP image)
{
m_d->image = image;
}
QRect KisDefaultBounds::bounds() const
{
/**
......@@ -87,7 +92,6 @@ QRect KisSelectionDefaultBounds::bounds() const
return additionalRect | KisDefaultBounds::bounds();
}
/******************************************************************/
/* KisSelectionEmptyBounds */
/******************************************************************/
......
......@@ -37,6 +37,8 @@ public:
KisDefaultBounds(KisImageWSP image = 0);
virtual ~KisDefaultBounds();
void setImage(KisImageWSP image);
QRect bounds() const;
bool wrapAroundMode() const;
......
......@@ -299,9 +299,15 @@ void KisLayer::setImage(KisImageWSP image)
m_d->image = image;
for (uint i = 0; i < childCount(); ++i) {
// Only layers know about the image
KisLayer * layer = dynamic_cast<KisLayer*>(at(i).data());
if (layer)
KisLayer *layer = dynamic_cast<KisLayer*>(at(i).data());
if (layer) {
layer->setImage(image);
}
// We lied, through the defaultBounds, masks also know about the image
KisMask *mask = dynamic_cast<KisMask*>(at(i).data());
if (mask) {
mask->setImage(image);
}
}
}
......
......@@ -93,6 +93,15 @@ KisMask::~KisMask()
delete m_d;
}
void KisMask::setImage(KisImageWSP image)
{
KisDefaultBoundsBaseSP db = m_d->selection->pixelSelection()->defaultBounds();
KisDefaultBounds *defaultBounds = dynamic_cast<KisDefaultBounds*>(db.data());
if (defaultBounds) {
defaultBounds->setImage(image);
}
}
bool KisMask::allowAsChild(KisNodeSP node) const
{
Q_UNUSED(node);
......
......@@ -83,6 +83,8 @@ public:
virtual ~KisMask();
void setImage(KisImageWSP image);
bool allowAsChild(KisNodeSP node) const;
/**
......
......@@ -468,7 +468,7 @@ void KisView::dragEnterEvent(QDragEnterEvent *event)
void KisView::dropEvent(QDropEvent *event)
{
KisImageSP kisimage = image();
KisImageWSP kisimage = image();
Q_ASSERT(kisimage);
QPoint cursorPos = canvasBase()->coordinatesConverter()->widgetToImage(event->pos()).toPoint();
......
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