timeline: implemented some base ripple delete functionality

This commit is contained in:
itsmattkc
2020-03-07 18:07:55 +11:00
parent d5fdc555e1
commit 38a30b584a
7 changed files with 148 additions and 20 deletions
+30 -4
View File
@@ -150,7 +150,19 @@ Block *TrackOutput::NearestBlockBefore(const rational &time) const
return nullptr;
}
Block *TrackOutput::NearestBlockAfter(const rational &time) const
Block *TrackOutput::NearestBlockBeforeOrAt(const rational &time) const
{
foreach (Block* block, block_cache_) {
// Blocks are sorted by time, so the first Block who's out point is at/after this time is the correct Block
if (block->out() > time) {
return block;
}
}
return nullptr;
}
Block *TrackOutput::NearestBlockAfterOrAt(const rational &time) const
{
foreach (Block* block, block_cache_) {
// Blocks are sorted by time, so the first Block after this time is the correct Block
@@ -162,6 +174,18 @@ Block *TrackOutput::NearestBlockAfter(const rational &time) const
return nullptr;
}
Block *TrackOutput::NearestBlockAfter(const rational &time) const
{
foreach (Block* block, block_cache_) {
// Blocks are sorted by time, so the first Block after this time is the correct Block
if (block->in() > time) {
return block;
}
}
return nullptr;
}
Block *TrackOutput::BlockAtTime(const rational &time) const
{
if (IsMuted()) {
@@ -288,8 +312,6 @@ void TrackOutput::RippleRemoveBlock(Block *block)
void TrackOutput::ReplaceBlock(Block *old, Block *replace)
{
Q_ASSERT(old->length() == replace->length());
BlockInvalidateCache();
int index_of_old_block = block_cache_.indexOf(old);
@@ -302,7 +324,11 @@ void TrackOutput::ReplaceBlock(Block *old, Block *replace)
UnblockInvalidateCache();
InvalidateCache(replace->in(), replace->out());
if (old->length() == replace->length()) {
InvalidateCache(replace->in(), replace->out());
} else {
InvalidateCache(replace->in(), RATIONAL_MAX);
}
}
TrackOutput *TrackOutput::TrackFromBlock(Block *block)
+16
View File
@@ -57,8 +57,24 @@ public:
Block* BlockContainingTime(const rational& time) const;
/**
* @brief Returns the block that starts BEFORE a given time and ends some time AFTER or precisely AT that time
*/
Block* NearestBlockBefore(const rational& time) const;
/**
* @brief Returns the block that starts BEFORE a given time OR the block that starts precisely at that time
*/
Block* NearestBlockBeforeOrAt(const rational& time) const;
/**
* @brief Returns the block that starts either precisely AT a given time or the soonest block AFTER
*/
Block* NearestBlockAfterOrAt(const rational& time) const;
/**
* @brief Returns the block that starts AFTER the given time (but never AT the given time)
*/
Block* NearestBlockAfter(const rational& time) const;
Block* BlockAtTime(const rational& time) const;