added basic razor tool

This commit is contained in:
itsmattkc
2019-08-23 12:12:13 +10:00
parent 44dfacfa7a
commit 9439494c10
9 changed files with 175 additions and 11 deletions
+16
View File
@@ -64,6 +64,7 @@ void TimelineOutput::AttachTimeline(TimelinePanel *timeline)
//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)));
// Remove existing UI objects from TimelinePanel
attached_timeline_->Clear();
@@ -86,6 +87,7 @@ void TimelineOutput::AttachTimeline(TimelinePanel *timeline)
//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)));
}
}
@@ -255,3 +257,17 @@ void TimelineOutput::ReplaceBlock(Block *old, Block *replace, int track)
{
track_cache_.at(track)->ReplaceBlock(old, replace);
}
void TimelineOutput::SplitAtTime(rational time, int track)
{
if (track >= track_cache_.size()) {
return;
}
track_cache_.at(track)->SplitAtTime(time);
}
void TimelineOutput::ResizeBlock(Block *block, rational new_length)
{
block->set_length(new_length);
}
+10
View File
@@ -112,6 +112,16 @@ private slots:
*/
void ReplaceBlock(Block* old, Block* replace, int track);
/**
* @brief Forwards a SplitAtTime signal to the appropriate track
*/
void SplitAtTime(rational time, int track);
/**
* @brief Resizes a Block
*/
void ResizeBlock(Block* block, rational new_length);
};
#endif // TIMELINEOUTPUT_H
+17
View File
@@ -327,6 +327,23 @@ Block* TrackOutput::SplitBlock(Block *block, rational time)
return copy;
}
void TrackOutput::SplitAtTime(rational time)
{
// Find Block that contains this time
for (int i=0;i<block_cache_.size();i++) {
Block* b = block_cache_.at(i);
if (b->out() == time) {
// This time is between blocks, no split needs to occur
return;
} else if (b->in() < time && b->out() > time) {
// We found the Block, split it
SplitBlock(b, time);
return;
}
}
}
void TrackOutput::RippleRemoveArea(rational in, rational out, Block *insert)
{
// Block that needs to be split to remove this area
+7
View File
@@ -116,6 +116,13 @@ public:
*/
Block *SplitBlock(Block* block, rational time);
/**
* @brief Attempt to split at a certain time
*
* Finds the Block that surrounds this time and splits it. If there is no Block there, this is a no-op.
*/
void SplitAtTime(rational time);
/**
* @brief Clears the area between in and out
*