flipped timeline node/panel affinity
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
#include "node/blend/alphaover/alphaover.h"
|
||||
#include "node/block/gap/gap.h"
|
||||
#include "node/graph.h"
|
||||
#include "panel/timeline/timeline.h"
|
||||
|
||||
TimelineOutput::TimelineOutput() :
|
||||
attached_timeline_(nullptr)
|
||||
TimelineOutput::TimelineOutput()
|
||||
{
|
||||
track_input_ = new NodeInput("track_in");
|
||||
track_input_->add_data_input(NodeParam::kTrack);
|
||||
@@ -61,43 +61,6 @@ QString TimelineOutput::Description()
|
||||
return tr("Node for communicating between a Timeline panel and the node graph.");
|
||||
}
|
||||
|
||||
void TimelineOutput::AttachTimeline(TimelinePanel *timeline)
|
||||
{
|
||||
if (attached_timeline_ != nullptr) {
|
||||
TimelineView* view = attached_timeline_->view();
|
||||
|
||||
//disconnect(view, SIGNAL(RequestInsertBlockAtIndex(Block*, int)), this, SLOT(InsertBlockAtIndex(Block*, int)));
|
||||
disconnect(view, SIGNAL(RequestPlaceBlock(Block*, rational, int)), this, SLOT(PlaceBlock(Block*, rational, int)));
|
||||
disconnect(view, SIGNAL(RequestReplaceBlock(Block*, Block*, int)), this, SLOT(ReplaceBlock(Block*, Block*, int)));
|
||||
disconnect(view, SIGNAL(RequestSplitAtTime(rational, int)), this, SLOT(SplitAtTime(rational, int)));
|
||||
disconnect(view, SIGNAL(RequestRippleBlocks(QList<Block*>, rational, olive::timeline::MovementMode)), this, SLOT(RippleBlocks(QList<Block*>, rational, olive::timeline::MovementMode)));
|
||||
|
||||
// Remove existing UI objects from TimelinePanel
|
||||
attached_timeline_->Clear();
|
||||
}
|
||||
|
||||
attached_timeline_ = timeline;
|
||||
|
||||
if (attached_timeline_ != nullptr) {
|
||||
// FIXME: TEST CODE ONLY
|
||||
attached_timeline_->SetTimebase(rational(1001, 30000));
|
||||
// END TEST CODE
|
||||
|
||||
foreach (TrackOutput* track, track_cache_) {
|
||||
// Defer to the track to make all the block UI items necessary
|
||||
track->GenerateBlockWidgets();
|
||||
}
|
||||
|
||||
TimelineView* view = attached_timeline_->view();
|
||||
|
||||
//connect(view, SIGNAL(RequestInsertBlockAtIndex(Block*, int)), this, SLOT(InsertBlockAtIndex(Block*, int)));
|
||||
connect(view, SIGNAL(RequestPlaceBlock(Block*, rational, int)), this, SLOT(PlaceBlock(Block*, rational, int)));
|
||||
connect(view, SIGNAL(RequestReplaceBlock(Block*, Block*, int)), this, SLOT(ReplaceBlock(Block*, Block*, int)));
|
||||
connect(view, SIGNAL(RequestSplitAtTime(rational, int)), this, SLOT(SplitAtTime(rational, int)));
|
||||
connect(view, SIGNAL(RequestRippleBlocks(QList<Block*>, rational, olive::timeline::MovementMode)), this, SLOT(RippleBlocks(QList<Block*>, rational, olive::timeline::MovementMode)));
|
||||
}
|
||||
}
|
||||
|
||||
NodeInput *TimelineOutput::track_input()
|
||||
{
|
||||
return track_input_;
|
||||
@@ -108,6 +71,11 @@ NodeOutput *TimelineOutput::length_output()
|
||||
return length_output_;
|
||||
}
|
||||
|
||||
const QVector<TrackOutput *> &TimelineOutput::Tracks()
|
||||
{
|
||||
return track_cache_;
|
||||
}
|
||||
|
||||
QVariant TimelineOutput::Value(NodeOutput *output, const rational &time)
|
||||
{
|
||||
if (output == length_output_) {
|
||||
@@ -126,11 +94,6 @@ QVariant TimelineOutput::Value(NodeOutput *output, const rational &time)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TimelineOutput::GetTrackIndex(TrackOutput *track)
|
||||
{
|
||||
return track_cache_.indexOf(track);
|
||||
}
|
||||
|
||||
rational TimelineOutput::GetSequenceLength()
|
||||
{
|
||||
rational length = 0;
|
||||
@@ -158,11 +121,13 @@ void TimelineOutput::AttachTrack(TrackOutput *track)
|
||||
connect(current_track, SIGNAL(BlockAdded(Block*)), this, SLOT(TrackAddedBlock(Block*)));
|
||||
connect(current_track, SIGNAL(BlockRemoved(Block*)), this, SLOT(TrackRemovedBlock(Block*)));
|
||||
|
||||
current_track->SetIndex(track_cache_.size());
|
||||
|
||||
track_cache_.append(current_track);
|
||||
|
||||
// This function must be called after the track is added to track_cache_, since it uses track_cache_ to determine
|
||||
// the track's index
|
||||
current_track->GenerateBlockWidgets();
|
||||
emit TrackAdded(current_track);
|
||||
|
||||
current_track = current_track->next_track();
|
||||
}
|
||||
@@ -174,7 +139,9 @@ void TimelineOutput::DetachTrack(TrackOutput *track)
|
||||
|
||||
// Traverse through Tracks uncaching and disconnecting them
|
||||
while (current_track != nullptr) {
|
||||
current_track->DestroyBlockWidgets();
|
||||
emit TrackRemoved(current_track);
|
||||
|
||||
current_track->SetIndex(-1);
|
||||
|
||||
disconnect(current_track, SIGNAL(EdgeAdded(NodeEdgePtr)), this, SLOT(TrackEdgeAdded(NodeEdgePtr)));
|
||||
disconnect(current_track, SIGNAL(EdgeRemoved(NodeEdgePtr)), this, SLOT(TrackEdgeRemoved(NodeEdgePtr)));
|
||||
@@ -191,9 +158,7 @@ void TimelineOutput::SetTimebase(const rational &timebase)
|
||||
{
|
||||
timebase_ = timebase;
|
||||
|
||||
if (attached_timeline_ != nullptr) {
|
||||
attached_timeline_->SetTimebase(timebase_);
|
||||
}
|
||||
emit TimebaseChanged(timebase_);
|
||||
}
|
||||
|
||||
void TimelineOutput::AddTrack()
|
||||
@@ -243,9 +208,8 @@ void TimelineOutput::TrackConnectionAdded(NodeEdgePtr edge)
|
||||
|
||||
AttachTrack(attached_track());
|
||||
|
||||
if (attached_timeline_ != nullptr) {
|
||||
attached_timeline_->SetTimebase(timebase_);
|
||||
}
|
||||
// FIXME: Is this necessary?
|
||||
emit TimebaseChanged(timebase_);
|
||||
}
|
||||
|
||||
void TimelineOutput::TrackConnectionRemoved(NodeEdgePtr edge)
|
||||
@@ -256,23 +220,17 @@ void TimelineOutput::TrackConnectionRemoved(NodeEdgePtr edge)
|
||||
|
||||
DetachTrack(ValueToPtr<TrackOutput>(edge->output()->get_value(0)));
|
||||
|
||||
if (attached_timeline_ != nullptr) {
|
||||
attached_timeline_->Clear();
|
||||
}
|
||||
emit TimelineCleared();
|
||||
}
|
||||
|
||||
void TimelineOutput::TrackAddedBlock(Block *block)
|
||||
{
|
||||
if (attached_timeline_ != nullptr) {
|
||||
attached_timeline_->view()->AddBlock(block, GetTrackIndex(static_cast<TrackOutput*>(sender())));
|
||||
}
|
||||
emit BlockAdded(block, static_cast<TrackOutput*>(sender())->Index());
|
||||
}
|
||||
|
||||
void TimelineOutput::TrackRemovedBlock(Block *block)
|
||||
{
|
||||
if (attached_timeline_ != nullptr) {
|
||||
attached_timeline_->view()->RemoveBlock(block);
|
||||
}
|
||||
emit BlockRemoved(block);
|
||||
}
|
||||
|
||||
void TimelineOutput::TrackEdgeAdded(NodeEdgePtr edge)
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#ifndef TIMELINEOUTPUT_H
|
||||
#define TIMELINEOUTPUT_H
|
||||
|
||||
#include "common/timelinecommon.h"
|
||||
#include "node/block/block.h"
|
||||
#include "node/output/track/track.h"
|
||||
#include "panel/timeline/timeline.h"
|
||||
|
||||
/**
|
||||
* @brief Node that represents the end of the Timeline as well as a time traversal Node
|
||||
@@ -39,46 +39,15 @@ public:
|
||||
virtual QString Category() override;
|
||||
virtual QString Description() override;
|
||||
|
||||
void AttachTimeline(TimelinePanel* timeline);
|
||||
|
||||
void SetTimebase(const rational& timebase);
|
||||
|
||||
NodeInput* track_input();
|
||||
|
||||
NodeOutput* length_output();
|
||||
|
||||
protected:
|
||||
virtual QVariant Value(NodeOutput* output, const rational& time) override;
|
||||
const QVector<TrackOutput*>& Tracks();
|
||||
|
||||
private:
|
||||
int GetTrackIndex(TrackOutput* track);
|
||||
|
||||
rational GetSequenceLength();
|
||||
|
||||
TrackOutput* attached_track();
|
||||
|
||||
void AttachTrack(TrackOutput *track);
|
||||
|
||||
void DetachTrack(TrackOutput* track);
|
||||
|
||||
void AddTrack();
|
||||
|
||||
static TrackOutput* TrackFromBlock(Block* block);
|
||||
|
||||
TimelinePanel* attached_timeline_;
|
||||
|
||||
NodeInput* track_input_;
|
||||
|
||||
NodeOutput* length_output_;
|
||||
|
||||
/**
|
||||
* @brief A cache of connected Tracks
|
||||
*/
|
||||
QVector<TrackOutput*> track_cache_;
|
||||
|
||||
rational timebase_;
|
||||
|
||||
private slots:
|
||||
public slots:
|
||||
/**
|
||||
* @brief Slot for when the track connection is added
|
||||
*/
|
||||
@@ -134,6 +103,46 @@ private slots:
|
||||
|
||||
void RippleBlocks(QList<Block*> blocks, rational ripple_length, olive::timeline::MovementMode mode);
|
||||
|
||||
signals:
|
||||
void TimebaseChanged(const rational &timebase);
|
||||
|
||||
void TimelineCleared();
|
||||
|
||||
void BlockAdded(Block* block, int index);
|
||||
|
||||
void BlockRemoved(Block* block);
|
||||
|
||||
void TrackAdded(TrackOutput* track);
|
||||
|
||||
void TrackRemoved(TrackOutput* track);
|
||||
|
||||
protected:
|
||||
virtual QVariant Value(NodeOutput* output, const rational& time) override;
|
||||
|
||||
private:
|
||||
rational GetSequenceLength();
|
||||
|
||||
TrackOutput* attached_track();
|
||||
|
||||
void AttachTrack(TrackOutput *track);
|
||||
|
||||
void DetachTrack(TrackOutput* track);
|
||||
|
||||
void AddTrack();
|
||||
|
||||
static TrackOutput* TrackFromBlock(Block* block);
|
||||
|
||||
NodeInput* track_input_;
|
||||
|
||||
NodeOutput* length_output_;
|
||||
|
||||
/**
|
||||
* @brief A cache of connected Tracks
|
||||
*/
|
||||
QVector<TrackOutput*> track_cache_;
|
||||
|
||||
rational timebase_;
|
||||
|
||||
};
|
||||
|
||||
#endif // TIMELINEOUTPUT_H
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
TrackOutput::TrackOutput() :
|
||||
current_block_(this),
|
||||
block_invalidate_cache_stack_(0)
|
||||
block_invalidate_cache_stack_(0),
|
||||
index_(-1)
|
||||
{
|
||||
track_input_ = new NodeInput("track_in");
|
||||
track_input_->add_data_input(NodeParam::kTrack);
|
||||
@@ -107,6 +108,16 @@ void TrackOutput::Refresh()
|
||||
qDebug() << "Refreshed with in point" << in().toDouble() << "(from connected block" << previous() << ")";
|
||||
}
|
||||
|
||||
const int &TrackOutput::Index()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
void TrackOutput::SetIndex(const int &index)
|
||||
{
|
||||
index_ = index;
|
||||
}
|
||||
|
||||
QList<NodeDependency> TrackOutput::RunDependencies(NodeOutput* output, const rational &time)
|
||||
{
|
||||
QList<NodeDependency> deps;
|
||||
@@ -122,20 +133,6 @@ QList<NodeDependency> TrackOutput::RunDependencies(NodeOutput* output, const rat
|
||||
return deps;
|
||||
}
|
||||
|
||||
void TrackOutput::GenerateBlockWidgets()
|
||||
{
|
||||
foreach (Block* block, block_cache_) {
|
||||
emit BlockAdded(block);
|
||||
}
|
||||
}
|
||||
|
||||
void TrackOutput::DestroyBlockWidgets()
|
||||
{
|
||||
foreach (Block* block, block_cache_) {
|
||||
emit BlockRemoved(block);
|
||||
}
|
||||
}
|
||||
|
||||
TrackOutput *TrackOutput::next_track()
|
||||
{
|
||||
return ValueToPtr<TrackOutput>(track_input_->get_value(0));
|
||||
@@ -163,6 +160,11 @@ Block *TrackOutput::NearestBlockAfter(const rational &time)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QVector<Block *> &TrackOutput::Blocks()
|
||||
{
|
||||
return block_cache_;
|
||||
}
|
||||
|
||||
void TrackOutput::InvalidateCache(const rational &start_range, const rational &end_range, NodeInput *from)
|
||||
{
|
||||
// We intercept IC signals from Blocks since we may be performing several options and they may over-signal
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define TRACKOUTPUT_H
|
||||
|
||||
#include "node/block/block.h"
|
||||
#include "panel/timeline/timeline.h"
|
||||
|
||||
/**
|
||||
* @brief A time traversal Node for sorting through one channel/track of Blocks
|
||||
@@ -46,15 +45,14 @@ public:
|
||||
|
||||
virtual void Refresh() override;
|
||||
|
||||
const int& Index();
|
||||
void SetIndex(const int& index);
|
||||
|
||||
/**
|
||||
* @brief Override swaps "attached block" with "current block"
|
||||
*/
|
||||
virtual QList<NodeDependency> RunDependencies(NodeOutput* param, const rational& time) override;
|
||||
|
||||
void GenerateBlockWidgets();
|
||||
|
||||
void DestroyBlockWidgets();
|
||||
|
||||
TrackOutput* next_track();
|
||||
|
||||
NodeInput* track_input();
|
||||
@@ -63,6 +61,8 @@ public:
|
||||
|
||||
Block* NearestBlockAfter(const rational& time);
|
||||
|
||||
const QVector<Block*>& Blocks();
|
||||
|
||||
virtual void InvalidateCache(const rational& start_range, const rational& end_range, NodeInput* from = nullptr) override;
|
||||
|
||||
/**
|
||||
@@ -203,6 +203,8 @@ private:
|
||||
|
||||
int block_invalidate_cache_stack_;
|
||||
|
||||
int index_;
|
||||
|
||||
private slots:
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user