base pointer movement in timeline
This commit is contained in:
@@ -63,6 +63,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)));
|
||||
|
||||
// Remove existing UI objects from TimelinePanel
|
||||
attached_timeline_->Clear();
|
||||
@@ -84,6 +85,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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,9 +242,16 @@ void TimelineOutput::TrackEdgeRemoved(NodeEdgePtr edge)
|
||||
|
||||
void TimelineOutput::PlaceBlock(Block *block, rational start, int track)
|
||||
{
|
||||
Q_ASSERT(track >= 0);
|
||||
|
||||
while (track >= track_cache_.size()) {
|
||||
AddTrack();
|
||||
}
|
||||
|
||||
track_cache_.at(track)->PlaceBlock(block, start);
|
||||
}
|
||||
|
||||
void TimelineOutput::ReplaceBlock(Block *old, Block *replace, int track)
|
||||
{
|
||||
track_cache_.at(track)->ReplaceBlock(old, replace);
|
||||
}
|
||||
|
||||
@@ -101,9 +101,17 @@ private slots:
|
||||
|
||||
/**
|
||||
* @brief Forwards a PlaceBlock signal to the requested track
|
||||
*
|
||||
* If the track index doesn't exist, tracks are automatically created until a track at that index does exist
|
||||
* (provided the track index is positive). A negative track index fails immediately.
|
||||
*/
|
||||
void PlaceBlock(Block* block, rational start, int track);
|
||||
|
||||
/**
|
||||
* @brief Forwards a ReplaceBlock signal to the appropriate track
|
||||
*/
|
||||
void ReplaceBlock(Block* old, Block* replace, int track);
|
||||
|
||||
};
|
||||
|
||||
#endif // TIMELINEOUTPUT_H
|
||||
|
||||
@@ -245,12 +245,12 @@ void TrackOutput::AddBlockToGraph(Block *block)
|
||||
|
||||
void TrackOutput::PlaceBlock(Block *block, rational start)
|
||||
{
|
||||
AddBlockToGraph(block);
|
||||
|
||||
if (block->in() == start) {
|
||||
if (block_cache_.contains(block) && block->in() == start) {
|
||||
return;
|
||||
}
|
||||
|
||||
AddBlockToGraph(block);
|
||||
|
||||
// Check if the placement location is past the end of the timeline
|
||||
if (start >= in()) {
|
||||
if (start > in()) {
|
||||
@@ -408,3 +408,22 @@ void TrackOutput::RippleRemoveArea(rational in, rational out, Block *insert)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrackOutput::ReplaceBlock(Block *old, Block *replace)
|
||||
{
|
||||
Block* previous = old->previous();
|
||||
Block* next = old->next();
|
||||
|
||||
AddBlockToGraph(replace);
|
||||
|
||||
// Disconnect old block from its surroundings
|
||||
if (previous != nullptr) {
|
||||
Block::DisconnectBlocks(previous, old);
|
||||
Block::ConnectBlocks(previous, replace);
|
||||
}
|
||||
|
||||
if (next != nullptr) {
|
||||
Block::DisconnectBlocks(old, next);
|
||||
Block::ConnectBlocks(replace, next);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,13 @@ public:
|
||||
*/
|
||||
void RippleRemoveArea(rational in, rational out, Block* insert = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Replaces Block `old` with Block `replace`
|
||||
*
|
||||
* Makes no modification to the lengths of either Blocks
|
||||
*/
|
||||
void ReplaceBlock(Block* old, Block* replace);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when a Block is added to this Track
|
||||
|
||||
Reference in New Issue
Block a user