Paste P210

Masterwork From Distant Lands
ActivePublic

Authored by dkazakov on May 10 2018, 4:22 PM.
diff --git a/libs/image/kis_base_node.cpp b/libs/image/kis_base_node.cpp
index 5451a88..7c3a701 100644
--- a/libs/image/kis_base_node.cpp
+++ b/libs/image/kis_base_node.cpp
@@ -274,23 +274,6 @@ void KisBaseNode::setUserLocked(bool locked)
baseNodeChangedCallback();
}
-bool KisBaseNode::hasPixelData()
-{
- KisBaseNodeSP parentNode = parentCallback();
- return parentNode->hasPixelData();
-}
-
-void KisBaseNode::setHasPixelData(bool hasPixelData)
-{
- // check for already set data
- KisBaseNodeSP parentNode = parentCallback();
- bool hasData = parentNode->hasPixelData();
-
- emit pixelDataChanged(hasData);
- baseNodeChangedCallback();
-}
-
-
bool KisBaseNode::isEditable(bool checkVisibility) const
{
bool editable = true;
diff --git a/libs/image/kis_base_node.h b/libs/image/kis_base_node.h
index 5af7e3b..991d8c1 100644
--- a/libs/image/kis_base_node.h
+++ b/libs/image/kis_base_node.h
@@ -390,14 +390,6 @@ public:
virtual void setUserLocked(bool l);
/**
- * @brief setHasPixelData
- * @param hasPixelData
- */
- void setHasPixelData(bool hasPixelData);
-
- bool hasPixelData();
-
- /**
* @return true if the node can be edited:
*
* if checkVisibility is true, then the node is only editable if it is visible and not locked.
@@ -573,11 +565,6 @@ Q_SIGNALS:
*/
void userLockingChanged(bool);
- /**
- * @brief This signal emitted when the node either contains data or the content is empty
- */
- void pixelDataChanged(bool);
-
void keyframeChannelAdded(KisKeyframeChannel *channel);
private:
diff --git a/libs/image/kis_keyframe.cpp b/libs/image/kis_keyframe.cpp
index 5b9a2c9..7657361 100644
--- a/libs/image/kis_keyframe.cpp
+++ b/libs/image/kis_keyframe.cpp
@@ -41,7 +41,6 @@ struct KisKeyframe::Private
QPointF leftTangent;
QPointF rightTangent;
int colorLabel{0};
- bool hasContent = false;
Private(KisKeyframeChannel *channel, int time)
: channel(channel), time(time), interpolationMode(Constant)
@@ -63,7 +62,6 @@ KisKeyframe::KisKeyframe(const KisKeyframe *rhs, KisKeyframeChannel *channel)
m_d->leftTangent = rhs->m_d->leftTangent;
m_d->rightTangent = rhs->m_d->rightTangent;
m_d->colorLabel = rhs->m_d->colorLabel;
- m_d->hasContent = rhs->m_d->hasContent;
}
KisKeyframe::~KisKeyframe()
@@ -125,13 +123,8 @@ void KisKeyframe::setColorLabel(int label)
m_d->colorLabel = label;
}
-void KisKeyframe::setHasContent(bool content)
-{
- m_d->hasContent = content ;
-}
-
-bool KisKeyframe::hasContent() {
- return m_d->hasContent;
+bool KisKeyframe::hasContent() const {
+ return true;
}
KisKeyframeChannel *KisKeyframe::channel() const
diff --git a/libs/image/kis_keyframe.h b/libs/image/kis_keyframe.h
index 8fdfe4e..8e04d15 100644
--- a/libs/image/kis_keyframe.h
+++ b/libs/image/kis_keyframe.h
@@ -64,8 +64,7 @@ public:
int colorLabel() const;
void setColorLabel(int label);
- bool hasContent(); // does any content exist in keyframe, or is it empty?
- void setHasContent(bool content);
+ virtual bool hasContent() const; // does any content exist in keyframe, or is it empty?
KisKeyframeChannel *channel() const;
diff --git a/libs/image/kis_keyframe_channel.cpp b/libs/image/kis_keyframe_channel.cpp
index acf69b1..cb848ad 100644
--- a/libs/image/kis_keyframe_channel.cpp
+++ b/libs/image/kis_keyframe_channel.cpp
@@ -501,7 +501,6 @@ QDomElement KisKeyframeChannel::toXML(QDomDocument doc, const QString &layerFile
QDomElement keyframeElement = doc.createElement("keyframe");
keyframeElement.setAttribute("time", keyframe->time());
keyframeElement.setAttribute("color-label", keyframe->colorLabel());
- keyframeElement.setAttribute("has-content", keyframe->hasContent());
saveKeyframe(keyframe, keyframeElement, layerFilename);
@@ -522,11 +521,6 @@ void KisKeyframeChannel::loadXML(const QDomElement &channelNode)
keyframe->setColorLabel(keyframeNode.attribute("color-label").toUInt());
}
- if (keyframeNode.hasAttribute("has-content")) {
- keyframe->setHasContent(keyframeNode.attribute("has-content").toUInt());
- }
-
-
m_d->keys.insert(keyframe->time(), keyframe);
}
}
diff --git a/libs/image/kis_layer_properties_icons.h b/libs/image/kis_layer_properties_icons.h
index ac19a3d..1909761 100644
--- a/libs/image/kis_layer_properties_icons.h
+++ b/libs/image/kis_layer_properties_icons.h
@@ -44,7 +44,6 @@ public:
static const KoID colorizeEditKeyStrokes;
static const KoID colorizeShowColoring;
static const KoID openFileLayerFile;
- static const KoID hasPixelData; // useful for rendering GUI in timeline
static KisLayerPropertiesIcons* instance();
diff --git a/libs/image/kis_raster_keyframe_channel.cpp b/libs/image/kis_raster_keyframe_channel.cpp
index c8f1545..8fbc73d 100644
--- a/libs/image/kis_raster_keyframe_channel.cpp
+++ b/libs/image/kis_raster_keyframe_channel.cpp
@@ -45,6 +45,12 @@ struct KisRasterKeyframe : public KisKeyframe
return toQShared(new KisRasterKeyframe(this, channel));
}
+ bool hasContent() const override {
+ KisRasterKeyframeChannel *channel = dynamic_cast<KisRasterKeyframeChannel*>(this->channel());
+ KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(channel, true);
+
+ return channel->keyframeHasContent(this);
+ }
};
struct KisRasterKeyframeChannel::Private
@@ -83,7 +89,12 @@ KisRasterKeyframeChannel::~KisRasterKeyframeChannel()
int KisRasterKeyframeChannel::frameId(KisKeyframeSP keyframe) const
{
- KisRasterKeyframe *key = dynamic_cast<KisRasterKeyframe*>(keyframe.data());
+ return frameId(keyframe.data());
+}
+
+int KisRasterKeyframeChannel::frameId(const KisKeyframe *keyframe) const
+{
+ const KisRasterKeyframe *key = dynamic_cast<const KisRasterKeyframe*>(keyframe);
KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(key, -1);
return key->frameId;
}
@@ -280,6 +291,11 @@ KisKeyframeSP KisRasterKeyframeChannel::loadKeyframe(const QDomElement &keyframe
return keyframe;
}
+bool KisRasterKeyframeChannel::keyframeHasContent(const KisKeyframe *keyframe) const
+{
+ return !m_d->paintDevice->framesInterface()->frameBounds(frameId(keyframe)).isEmpty();
+}
+
bool KisRasterKeyframeChannel::hasScalarValue() const
{
return false;
diff --git a/libs/image/kis_raster_keyframe_channel.h b/libs/image/kis_raster_keyframe_channel.h
index a7cb202..2ccec11 100644
--- a/libs/image/kis_raster_keyframe_channel.h
+++ b/libs/image/kis_raster_keyframe_channel.h
@@ -79,10 +79,14 @@ protected:
void saveKeyframe(KisKeyframeSP keyframe, QDomElement keyframeElement, const QString &layerFilename) override;
KisKeyframeSP loadKeyframe(const QDomElement &keyframeNode) override;
+ friend class KisRasterKeyframe;
+ bool keyframeHasContent(const KisKeyframe *keyframe) const;
+
private:
void setFrameFilename(int frameId, const QString &filename);
QString chooseFrameFilename(int frameId, const QString &layerFilename);
int frameId(KisKeyframeSP keyframe) const;
+ int frameId(const KisKeyframe *keyframe) const;
struct Private;
QScopedPointer<Private> m_d;
diff --git a/libs/libkis/Node.cpp b/libs/libkis/Node.cpp
index d38063e..18834bf 100644
--- a/libs/libkis/Node.cpp
+++ b/libs/libkis/Node.cpp
@@ -310,14 +310,7 @@ void Node::setLocked(bool value)
bool Node::hasExtents()
{
- if (d->node->extent().height() == 0 || d->node->extent().width() == 0 ) {
- d->node->setHasPixelData(false);
- return false;
- }
- else {
- d->node->setHasPixelData(true);
- return true;
- }
+ return !d->node->extent().isEmpty();
}
QString Node::name() const
diff --git a/plugins/dockers/animation/timeline_docker.cpp b/plugins/dockers/animation/timeline_docker.cpp
index 08172f5..ca90098 100644
--- a/plugins/dockers/animation/timeline_docker.cpp
+++ b/plugins/dockers/animation/timeline_docker.cpp
@@ -37,7 +37,6 @@
#include "kis_node_manager.h"
#include <QPointer>
-#include <QTimer>
struct TimelineDocker::Private
{
@@ -46,7 +45,6 @@ struct TimelineDocker::Private
view(new TimelineFramesView(parent))
{
view->setModel(model);
- refreshTimelineUITimer = new QTimer(parent);
}
TimelineFramesModel *model;
@@ -54,10 +52,6 @@ struct TimelineDocker::Private
QPointer<KisCanvas2> canvas;
-
- QTimer *refreshTimelineUITimer;
-
-
KisSignalAutoConnectionsStore canvasConnections;
};
@@ -131,12 +125,6 @@ void TimelineDocker::setCanvas(KoCanvasBase * canvas)
m_d->canvasConnections.addConnection(
m_d->canvas->viewManager()->mainWindow(), SIGNAL(themeChanged()),
this, SLOT(slotUpdateIcons()) );
-
- m_d->canvasConnections.addConnection(m_d->canvas->image(), SIGNAL(sigImageUpdated(const QRect &)),
- this, SLOT(slotImageUpdated()));
-
- m_d->canvasConnections.addConnection(m_d->refreshTimelineUITimer, SIGNAL(timeout()), this, SLOT(slotRefreshUI()));
-
}
}
@@ -148,29 +136,6 @@ void TimelineDocker::slotUpdateIcons()
}
}
-void TimelineDocker::slotImageUpdated()
-{
- m_d->refreshTimelineUITimer->setSingleShot(true);
- m_d->refreshTimelineUITimer->start(500);
-}
-
-void TimelineDocker::slotRefreshUI()
-{
- m_d->refreshTimelineUITimer->stop();
-
-
- // Potential hack...
- // the animation timeline UI updates its display when the frame changes
- // this forces that refresh to happen by quickly changing frames back and forth
- // just setting the frame to the current frame has no effect
- if (m_d->canvas && m_d->canvas->image() ) {
- int currentFrame = m_d->model->currentTime();
- m_d->canvas->image()->animationInterface()->sigUiTimeChanged(currentFrame+1);
- m_d->canvas->image()->animationInterface()->sigUiTimeChanged(currentFrame-1);
- m_d->canvas->image()->animationInterface()->sigUiTimeChanged(currentFrame);
- }
-}
-
void TimelineDocker::unsetCanvas()
{
setCanvas(0);
diff --git a/plugins/dockers/animation/timeline_docker.h b/plugins/dockers/animation/timeline_docker.h
index 8699f5f..d441ce2 100644
--- a/plugins/dockers/animation/timeline_docker.h
+++ b/plugins/dockers/animation/timeline_docker.h
@@ -43,8 +43,6 @@ public:
public Q_SLOTS:
void slotUpdateIcons();
- void slotImageUpdated();
- void slotRefreshUI();
private:
struct Private;
diff --git a/plugins/dockers/animation/timeline_frames_model.cpp b/plugins/dockers/animation/timeline_frames_model.cpp
index f7eb727..6bb695a 100644
--- a/plugins/dockers/animation/timeline_frames_model.cpp
+++ b/plugins/dockers/animation/timeline_frames_model.cpp
@@ -111,7 +111,7 @@ struct TimelineFramesModel::Private
if (!primaryChannel) return false;
// first check if we are a key frame
- KisKeyframeSP frame = primaryChannel->activeKeyframeAt(column); // primaryChannel->keyframeAt(column);
+ KisKeyframeSP frame = primaryChannel->activeKeyframeAt(column);
if (!frame) return false;
return frame->hasContent();
@@ -135,7 +135,7 @@ struct TimelineFramesModel::Private
KisKeyframeChannel *primaryChannel = dummy->node()->getKeyframeChannel(KisKeyframeChannel::Content.id());
if (!primaryChannel) return -1;
- KisKeyframeSP frame = primaryChannel->keyframeAt(column);
+ KisKeyframeSP frame = primaryChannel->activeKeyframeAt(column);
if (!frame) return -1;
return frame->colorLabel();
@@ -154,27 +154,6 @@ struct TimelineFramesModel::Private
frame->setColorLabel(color);
}
- void setHasContent(int row, int column)
- {
- KisNodeDummy *dummy = converter->dummyFromRow(row);
- if (!dummy) return;
-
- bool valueToSet;
- if ( dummy->node()->paintDevice()->extent().height() || dummy->node()->paintDevice()->extent().width()) {
- valueToSet = true;
- } else {
- valueToSet = false;
- }
-
- KisKeyframeChannel *primaryChannel = dummy->node()->getKeyframeChannel(KisKeyframeChannel::Content.id());
- if (!primaryChannel) return;
-
- KisKeyframeSP frame = primaryChannel->currentlyActiveKeyframe();
- if (!frame) return;
-
- frame->setHasContent(valueToSet);
- }
-
int layerColorLabel(int row) const {
KisNodeDummy *dummy = converter->dummyFromRow(row);
if (!dummy) return -1;
@@ -294,6 +273,7 @@ void TimelineFramesModel::setDummiesFacade(KisDummiesFacadeBase *dummiesFacade,
SIGNAL(sigAudioChannelChanged()), SIGNAL(sigAudioChannelChanged()));
connect(m_d->image->animationInterface(),
SIGNAL(sigAudioVolumeChanged()), SIGNAL(sigAudioChannelChanged()));
+ connect(m_d->image, SIGNAL(sigImageModified()), SLOT(slotImageContentChanged()));
}
if (m_d->dummiesFacade != oldDummiesFacade) {
@@ -315,6 +295,16 @@ void TimelineFramesModel::slotDummyChanged(KisNodeDummy *dummy)
m_d->updateTimer.start();
}
+void TimelineFramesModel::slotImageContentChanged()
+{
+ if (m_d->activeLayerIndex < 0) return;
+
+ KisNodeDummy *dummy = m_d->converter->dummyFromRow(m_d->activeLayerIndex);
+ if (!dummy) return;
+
+ slotDummyChanged(dummy);
+}
+
void TimelineFramesModel::processUpdateQueue()
{
Q_FOREACH (KisNodeDummy *dummy, m_d->updateQueue) {
@@ -384,24 +374,6 @@ QVariant TimelineFramesModel::data(const QModelIndex &index, int role) const
}
case FrameColorLabelIndexRole: {
int label = m_d->frameColorLabel(index.row(), index.column());
-
-
- // hold frames inherit from their keyframe
- if( !m_d->frameExists(index.row(), index.column()) && m_d->frameHasContent(index.row(), index.column())){
- KisNodeSP node = nodeAt(index);
- KIS_SAFE_ASSERT_RECOVER(node) { return label > 0 ? label : QVariant(); }
-
- KisKeyframeChannel *channel = node->getKeyframeChannel(KisKeyframeChannel::Content.id());
-
-
- KisKeyframeSP keyFrame = channel->activeKeyframeAt(index.column());
-
- return keyFrame->colorLabel();
- }
-
-
-
-
return label > 0 ? label : QVariant();
}
case Qt::DisplayRole: {
@@ -463,15 +435,6 @@ bool TimelineFramesModel::setData(const QModelIndex &index, const QVariant &valu
break;
}
-
- // don't calculate content if row does not have animation enabled.
- // this also fixes a crash if a vector layer accessed this function
- KisNodeDummy *dummy = m_d->converter->dummyFromRow(m_d->activeLayerIndex);
- if (dummy->node()->isAnimated()) {
- m_d->setHasContent(index.row(), index.column());
- }
-
-
return ModelWithExternalNotifications::setData(index, value, role);
}
diff --git a/plugins/dockers/animation/timeline_frames_model.h b/plugins/dockers/animation/timeline_frames_model.h
index 7c93cd0..63fbbb4 100644
--- a/plugins/dockers/animation/timeline_frames_model.h
+++ b/plugins/dockers/animation/timeline_frames_model.h
@@ -129,6 +129,7 @@ protected:
private Q_SLOTS:
void slotDummyChanged(KisNodeDummy *dummy);
+ void slotImageContentChanged();
void processUpdateQueue();
public Q_SLOTS:
dkazakov edited the content of this paste. (Show Details)May 10 2018, 4:22 PM
dkazakov changed the title of this paste from untitled to Masterwork From Distant Lands.
dkazakov updated the paste's language from autodetect to autodetect.