implemented new block system
Fixes recurring design issue that the Blocks were a frequent exception to the DAG concept. The Blocks connecting to each others inputs/outputs while not necessarily being "dependent" on each other to produce an image continually causes issues while trying to create a rendering code path. This redesign should provide a more "directed" approach to the directed acyclic graph.
This commit is contained in:
@@ -276,7 +276,7 @@ void TimelineWidget::GoToNextCut()
|
||||
int64_t closest_cut = INT64_MAX;
|
||||
|
||||
foreach (TrackOutput* track, timeline_node_->Tracks()) {
|
||||
int64_t this_track_closest_cut = olive::time_to_timestamp(track->in(), timebase());
|
||||
int64_t this_track_closest_cut = olive::time_to_timestamp(track->track_length(), timebase());
|
||||
|
||||
if (this_track_closest_cut <= playhead_) {
|
||||
this_track_closest_cut = INT64_MAX;
|
||||
@@ -592,7 +592,7 @@ void TimelineWidget::AddBlock(Block *block, TrackReference track)
|
||||
connect(block, SIGNAL(Refreshed()), this, SLOT(BlockChanged()));
|
||||
break;
|
||||
}
|
||||
case Block::kEnd:
|
||||
case Block::kTrack:
|
||||
// Do nothing
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ rational TimelineWidget::PointerTool::ValidateOutTrimming(rational movement,
|
||||
if (prevent_overwriting) {
|
||||
// Determine if there's a block in the way
|
||||
Block* next = block->next();
|
||||
while (next != nullptr && next->type() != Block::kEnd) {
|
||||
while (next != nullptr) {
|
||||
if (next->type() == Block::kClip) {
|
||||
latest_out = qMin(latest_out, next->in());
|
||||
break;
|
||||
|
||||
@@ -129,9 +129,7 @@ void TimelineWidget::RippleTool::InitiateGhosts(TimelineViewBlockItem *clicked_i
|
||||
Block* block_before_ripple = track->NearestBlockBefore(earliest_ripple);
|
||||
|
||||
// If block is null, there will be no blocks after to ripple
|
||||
if (block_before_ripple != nullptr
|
||||
&& block_before_ripple->type() != Block::kEnd
|
||||
&& block_before_ripple->next()->type() != Block::kEnd) {
|
||||
if (block_before_ripple != nullptr) {
|
||||
TimelineViewGhostItem* ghost;
|
||||
|
||||
TrackReference track_ref(track->track_type(), track->Index());
|
||||
|
||||
@@ -90,7 +90,7 @@ void TimelineWidget::RollingTool::InitiateGhosts(TimelineViewBlockItem *clicked_
|
||||
if (ghost->mode() == olive::timeline::kTrimIn && ghost_block->previous() != nullptr) {
|
||||
// Add an extra Ghost for the previous block
|
||||
AddGhostFromBlock(ghost_block->previous(), ghost->Track(), olive::timeline::kTrimOut);
|
||||
} else if (ghost->mode() == olive::timeline::kTrimOut && ghost_block->next() != nullptr && ghost_block->next()->type() != Block::kEnd) {
|
||||
} else if (ghost->mode() == olive::timeline::kTrimOut && ghost_block->next() != nullptr) {
|
||||
AddGhostFromBlock(ghost_block->next(), ghost->Track(), olive::timeline::kTrimIn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void TimelineWidget::SlideTool::InitiateGhosts(TimelineViewBlockItem *clicked_it
|
||||
AddGhostFromBlock(ghost_block->previous(), ghost->Track(), olive::timeline::kTrimOut);
|
||||
}
|
||||
|
||||
if (ghost_block->next() != nullptr && ghost_block->next()->type() != Block::kEnd) {
|
||||
if (ghost_block->next() != nullptr) {
|
||||
AddGhostFromBlock(ghost_block->next(), ghost->Track(), olive::timeline::kTrimIn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,18 +38,6 @@ Node* TakeNodeFromParentGraph(Node* n, QObject* new_parent = nullptr)
|
||||
return n;
|
||||
}
|
||||
|
||||
TrackOutput* TrackFromBlock(Block* b)
|
||||
{
|
||||
Block* next = b;
|
||||
|
||||
do {
|
||||
next = next->next();
|
||||
} while (next != nullptr && next->type() != Block::kEnd);
|
||||
|
||||
// A little hacky, but this should either be a TrackOutput* or nullptr
|
||||
return static_cast<TrackOutput*>(next);
|
||||
}
|
||||
|
||||
BlockResizeCommand::BlockResizeCommand(Block *block, rational new_length, QUndoCommand* parent) :
|
||||
QUndoCommand(parent),
|
||||
block_(block),
|
||||
@@ -108,8 +96,7 @@ TrackRippleRemoveBlockCommand::TrackRippleRemoveBlockCommand(TrackOutput *track,
|
||||
QUndoCommand(parent),
|
||||
track_(track),
|
||||
block_(block),
|
||||
before_(block->previous()),
|
||||
after_(block->next())
|
||||
before_(block->previous())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -120,7 +107,7 @@ void TrackRippleRemoveBlockCommand::redo()
|
||||
|
||||
void TrackRippleRemoveBlockCommand::undo()
|
||||
{
|
||||
track_->InsertBlockBetweenBlocks(block_, before_, after_);
|
||||
track_->InsertBlockAfter(block_, before_);
|
||||
}
|
||||
|
||||
TrackInsertBlockBetweenBlocksCommand::TrackInsertBlockBetweenBlocksCommand(TrackOutput *track,
|
||||
@@ -138,7 +125,7 @@ TrackInsertBlockBetweenBlocksCommand::TrackInsertBlockBetweenBlocksCommand(Track
|
||||
|
||||
void TrackInsertBlockBetweenBlocksCommand::redo()
|
||||
{
|
||||
track_->InsertBlockBetweenBlocks(block_, before_, after_);
|
||||
track_->InsertBlockAfter(block_, before_);
|
||||
}
|
||||
|
||||
void TrackInsertBlockBetweenBlocksCommand::undo()
|
||||
@@ -245,7 +232,7 @@ void TrackRippleRemoveAreaCommand::redo()
|
||||
track_->AppendBlock(insert_);
|
||||
} else {
|
||||
// This is somewhere in the middle of the Sequence
|
||||
track_->InsertBlockBetweenBlocks(insert_, trim_out_, trim_in_);
|
||||
track_->InsertBlockAfter(insert_, trim_out_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,14 +307,14 @@ void TrackPlaceBlockCommand::redo()
|
||||
|
||||
track_ = timeline_->TrackAt(track_index_);
|
||||
|
||||
append_ = (in_ >= track_->in());
|
||||
append_ = (in_ >= track_->track_length());
|
||||
|
||||
// Check if the placement location is past the end of the timeline
|
||||
if (append_) {
|
||||
if (in_ > track_->in()) {
|
||||
if (in_ > track_->track_length()) {
|
||||
// If so, insert a gap here
|
||||
gap_ = new GapBlock();
|
||||
gap_->set_length(in_ - track_->in());
|
||||
gap_->set_length(in_ - track_->track_length());
|
||||
track_->AppendBlock(gap_);
|
||||
}
|
||||
|
||||
@@ -471,7 +458,11 @@ BlockSplitPreservingLinksCommand::BlockSplitPreservingLinksCommand(const QVector
|
||||
Block* b = blocks.at(j);
|
||||
|
||||
if (b->in() < time && b->out() > time) {
|
||||
BlockSplitCommand* split_command = new BlockSplitCommand(TrackFromBlock(b), b, time, this);
|
||||
TrackOutput* track = TrackOutput::TrackFromBlock(b);
|
||||
|
||||
Q_ASSERT(track);
|
||||
|
||||
BlockSplitCommand* split_command = new BlockSplitCommand(track, b, time, this);
|
||||
splits.replace(j, split_command->new_block());
|
||||
} else {
|
||||
splits.replace(j, nullptr);
|
||||
|
||||
@@ -80,7 +80,6 @@ private:
|
||||
Block* block_;
|
||||
|
||||
Block* before_;
|
||||
Block* after_;
|
||||
};
|
||||
|
||||
class TrackPrependBlockCommand : public QUndoCommand {
|
||||
|
||||
@@ -118,7 +118,7 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||
painter->fillRect(rect(), Qt::white);
|
||||
}
|
||||
break;
|
||||
case Block::kEnd:
|
||||
case Block::kTrack:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user