Merge branch 'master' into otio
This commit is contained in:
@@ -55,6 +55,11 @@ TrackOutput::TrackOutput() :
|
||||
track_height_ = kTrackHeightDefault;
|
||||
}
|
||||
|
||||
TrackOutput::~TrackOutput()
|
||||
{
|
||||
DisconnectAll();
|
||||
}
|
||||
|
||||
void TrackOutput::set_track_type(const Timeline::TrackType &track_type)
|
||||
{
|
||||
track_type_ = track_type;
|
||||
@@ -91,15 +96,6 @@ QString TrackOutput::Description() const
|
||||
"a Sequence.");
|
||||
}
|
||||
|
||||
QString TrackOutput::GetTrackName()
|
||||
{
|
||||
if (track_name_.isEmpty()) {
|
||||
return GetDefaultTrackName(track_type_, index_);
|
||||
}
|
||||
|
||||
return track_name_;
|
||||
}
|
||||
|
||||
const double &TrackOutput::GetTrackHeight() const
|
||||
{
|
||||
return track_height_;
|
||||
@@ -435,11 +431,6 @@ void TrackOutput::Hash(QCryptographicHash &hash, const rational &time) const
|
||||
}
|
||||
}
|
||||
|
||||
void TrackOutput::SetTrackName(const QString &name)
|
||||
{
|
||||
track_name_ = name;
|
||||
}
|
||||
|
||||
void TrackOutput::SetMuted(bool e)
|
||||
{
|
||||
muted_input_->set_standard_value(e);
|
||||
@@ -555,7 +546,7 @@ void TrackOutput::BlockConnected(NodeEdgePtr edge)
|
||||
|
||||
void TrackOutput::BlockDisconnected(NodeEdgePtr edge)
|
||||
{
|
||||
Block* b = static_cast<Block*>(edge->output()->parentNode());
|
||||
Block* b = static_cast<Block*>(edge->output_node());
|
||||
|
||||
if (block_cache_.contains(b)) {
|
||||
block_cache_.removeOne(b);
|
||||
|
||||
@@ -36,6 +36,8 @@ class TrackOutput : public Node
|
||||
public:
|
||||
TrackOutput();
|
||||
|
||||
virtual ~TrackOutput() override;
|
||||
|
||||
const Timeline::TrackType& track_type() const;
|
||||
void set_track_type(const Timeline::TrackType& track_type);
|
||||
|
||||
@@ -46,8 +48,6 @@ public:
|
||||
virtual QList<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
QString GetTrackName();
|
||||
|
||||
const double& GetTrackHeight() const;
|
||||
void SetTrackHeight(const double& height);
|
||||
|
||||
@@ -227,8 +227,6 @@ public:
|
||||
static const double kTrackHeightInterval;
|
||||
|
||||
public slots:
|
||||
void SetTrackName(const QString& name);
|
||||
|
||||
void SetMuted(bool e);
|
||||
|
||||
void SetLocked(bool e);
|
||||
@@ -294,8 +292,6 @@ private:
|
||||
|
||||
double track_height_;
|
||||
|
||||
QString track_name_;
|
||||
|
||||
int index_;
|
||||
|
||||
bool locked_;
|
||||
|
||||
@@ -134,7 +134,7 @@ TrackOutput* TrackList::AddTrack()
|
||||
return track;
|
||||
}
|
||||
|
||||
void TrackList::RemoveTrack()
|
||||
void TrackList::RemoveTrack(QObject* new_parent)
|
||||
{
|
||||
if (track_cache_.isEmpty()) {
|
||||
return;
|
||||
@@ -144,7 +144,11 @@ void TrackList::RemoveTrack()
|
||||
|
||||
GetParentGraph()->TakeNode(track);
|
||||
|
||||
delete track;
|
||||
if (!new_parent) {
|
||||
delete track;
|
||||
} else {
|
||||
track->setParent(new_parent);
|
||||
}
|
||||
|
||||
track_input_->RemoveLast();
|
||||
}
|
||||
@@ -184,7 +188,8 @@ void TrackList::TrackConnected(NodeEdgePtr edge)
|
||||
track_cache_.append(connected_track);
|
||||
}
|
||||
|
||||
connected_track->SetIndex(track_index);
|
||||
// Update track indexes in the list (including this track)
|
||||
UpdateTrackIndexesFrom(track_index);
|
||||
}
|
||||
|
||||
connect(connected_track, &TrackOutput::BlockAdded, this, &TrackList::TrackAddedBlock);
|
||||
@@ -220,9 +225,7 @@ void TrackList::TrackDisconnected(NodeEdgePtr edge)
|
||||
track_cache_.removeAt(index_of_track);
|
||||
|
||||
// Update indices for all subsequent tracks
|
||||
for (int i=index_of_track; i<track_cache_.size(); i++) {
|
||||
track_cache_.at(i)->SetIndex(i);
|
||||
}
|
||||
UpdateTrackIndexesFrom(index_of_track);
|
||||
|
||||
// Traverse through Tracks uncaching and disconnecting them
|
||||
emit TrackRemoved(track);
|
||||
@@ -241,6 +244,13 @@ void TrackList::TrackDisconnected(NodeEdgePtr edge)
|
||||
}
|
||||
}
|
||||
|
||||
void TrackList::UpdateTrackIndexesFrom(int index)
|
||||
{
|
||||
for (int i=index; i<track_cache_.size(); i++) {
|
||||
track_cache_.at(i)->SetIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
NodeGraph *TrackList::GetParentGraph() const
|
||||
{
|
||||
return static_cast<NodeGraph*>(parent()->parent());
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
TrackOutput *AddTrack();
|
||||
|
||||
void RemoveTrack();
|
||||
void RemoveTrack(QObject *new_parent);
|
||||
|
||||
const rational& GetTotalLength() const;
|
||||
|
||||
@@ -68,6 +68,8 @@ signals:
|
||||
void TrackHeightChanged(int index, int height);
|
||||
|
||||
private:
|
||||
void UpdateTrackIndexesFrom(int index);
|
||||
|
||||
/**
|
||||
* @brief A cache of connected Tracks
|
||||
*/
|
||||
|
||||
@@ -52,7 +52,7 @@ ViewerOutput::ViewerOutput() :
|
||||
connect(list, &TrackList::TrackListChanged, this, &ViewerOutput::UpdateTrackCache);
|
||||
connect(list, &TrackList::LengthChanged, this, &ViewerOutput::VerifyLength);
|
||||
connect(list, &TrackList::BlockAdded, this, &ViewerOutput::TrackListAddedBlock);
|
||||
connect(list, &TrackList::BlockRemoved, this, &ViewerOutput::BlockRemoved);
|
||||
connect(list, &TrackList::BlockRemoved, this, &ViewerOutput::SignalBlockRemoved);
|
||||
connect(list, &TrackList::TrackAdded, this, &ViewerOutput::TrackListAddedTrack);
|
||||
connect(list, &TrackList::TrackRemoved, this, &ViewerOutput::TrackRemoved);
|
||||
connect(list, &TrackList::TrackHeightChanged, this, &ViewerOutput::TrackHeightChangedSlot);
|
||||
@@ -62,6 +62,11 @@ ViewerOutput::ViewerOutput() :
|
||||
uuid_ = QUuid::createUuid();
|
||||
}
|
||||
|
||||
ViewerOutput::~ViewerOutput()
|
||||
{
|
||||
DisconnectAll();
|
||||
}
|
||||
|
||||
Node *ViewerOutput::copy() const
|
||||
{
|
||||
return new ViewerOutput();
|
||||
@@ -274,6 +279,27 @@ void ViewerOutput::set_media_name(const QString &name)
|
||||
emit MediaNameChanged(media_name_);
|
||||
}
|
||||
|
||||
void ViewerOutput::SignalBlockAdded(Block *block, const TrackReference& track)
|
||||
{
|
||||
if (!operation_stack_) {
|
||||
emit BlockAdded(block, track);
|
||||
} else {
|
||||
cached_block_removed_.removeOne(block);
|
||||
cached_block_added_.insert(block, track);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerOutput::SignalBlockRemoved(Block *block)
|
||||
{
|
||||
if (!operation_stack_) {
|
||||
emit BlockRemoved({block});
|
||||
} else {
|
||||
// We keep track of all blocks that are removed, even if we don't end up signalling them
|
||||
cached_block_added_.remove(block);
|
||||
cached_block_removed_.append(block);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerOutput::BeginOperation()
|
||||
{
|
||||
operation_stack_++;
|
||||
@@ -285,13 +311,23 @@ void ViewerOutput::EndOperation()
|
||||
{
|
||||
operation_stack_--;
|
||||
|
||||
if (!operation_stack_) {
|
||||
for (auto it=cached_block_added_.cbegin(); it!=cached_block_added_.cend(); it++) {
|
||||
emit BlockAdded(it.key(), it.value());
|
||||
}
|
||||
cached_block_added_.clear();
|
||||
|
||||
emit BlockRemoved(cached_block_removed_);
|
||||
cached_block_removed_.clear();
|
||||
}
|
||||
|
||||
Node::EndOperation();
|
||||
}
|
||||
|
||||
void ViewerOutput::TrackListAddedBlock(Block *block, int index)
|
||||
{
|
||||
Timeline::TrackType type = static_cast<TrackList*>(sender())->type();
|
||||
emit BlockAdded(block, TrackReference(type, index));
|
||||
SignalBlockAdded(block, TrackReference(type, index));
|
||||
}
|
||||
|
||||
void ViewerOutput::TrackListAddedTrack(TrackOutput *track)
|
||||
|
||||
@@ -47,6 +47,8 @@ class ViewerOutput : public Node
|
||||
public:
|
||||
ViewerOutput();
|
||||
|
||||
virtual ~ViewerOutput() override;
|
||||
|
||||
virtual Node* copy() const override;
|
||||
|
||||
virtual QString Name() const override;
|
||||
@@ -139,7 +141,7 @@ signals:
|
||||
void AudioParamsChanged();
|
||||
|
||||
void BlockAdded(Block* block, TrackReference track);
|
||||
void BlockRemoved(Block* block);
|
||||
void BlockRemoved(const QList<Block*>& blocks);
|
||||
|
||||
void TrackAdded(TrackOutput* track, Timeline::TrackType type);
|
||||
void TrackRemoved(TrackOutput* track);
|
||||
@@ -149,6 +151,9 @@ signals:
|
||||
void MediaNameChanged(const QString& name);
|
||||
|
||||
private:
|
||||
QMap<Block*, TrackReference> cached_block_added_;
|
||||
QList<Block*> cached_block_removed_;
|
||||
|
||||
QUuid uuid_;
|
||||
|
||||
NodeInput* texture_input_;
|
||||
@@ -186,6 +191,9 @@ private slots:
|
||||
|
||||
void TrackHeightChangedSlot(int index, int height);
|
||||
|
||||
void SignalBlockAdded(Block *block, const TrackReference &track);
|
||||
void SignalBlockRemoved(Block *block);
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Reference in New Issue
Block a user