timeline: heavily optimized and improved nearly all timeline optimizations
Features a lot of timeline-related cache optimizations as well as general optimizations and improvements in timeline behavior. Should improve usability significantly.
This commit is contained in:
@@ -29,77 +29,47 @@ TimelineWidget::RollingTool::RollingTool(TimelineWidget* parent) :
|
||||
PointerTool(parent)
|
||||
{
|
||||
SetMovementAllowed(false);
|
||||
SetTrimOverwriteAllowed(true);
|
||||
}
|
||||
|
||||
void TimelineWidget::RollingTool::MouseReleaseInternal(TimelineViewMouseEvent *event)
|
||||
void TimelineWidget::RollingTool::InitiateDrag(TimelineViewBlockItem *clicked_item,
|
||||
Timeline::MovementMode trim_mode,
|
||||
bool allow_gap_trimming)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
PointerTool::InitiateDrag(clicked_item, trim_mode, true);
|
||||
|
||||
// For each ghost, we make an equivalent Ghost on the next/previous block
|
||||
foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) {
|
||||
Block* ghost_block = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
|
||||
|
||||
if (ghost->mode() == Timeline::kTrimIn && ghost_block->previous()) {
|
||||
// Add an extra Ghost for the previous block
|
||||
AddGhostFromBlock(ghost_block->previous(), ghost->Track(), Timeline::kTrimOut);
|
||||
} else if (ghost->mode() == Timeline::kTrimOut && ghost_block->next()) {
|
||||
AddGhostFromBlock(ghost_block->next(), ghost->Track(), Timeline::kTrimIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidget::RollingTool::FinishDrag(TimelineViewMouseEvent *event)
|
||||
{
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
// Find earliest point to ripple around
|
||||
foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) {
|
||||
Block* b = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
|
||||
if (ghost->mode() == drag_movement_mode()) {
|
||||
Block* b = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
|
||||
|
||||
if (ghost->mode() == Timeline::kTrimIn) {
|
||||
if (b->previous() == nullptr) {
|
||||
// We'll need to insert a gap here, so we'll do a Place command instead
|
||||
GapBlock* gap = new GapBlock();
|
||||
gap->set_length_and_media_out(ghost->Length());
|
||||
new NodeAddCommand(static_cast<NodeGraph*>(b->parent()),
|
||||
gap,
|
||||
command);
|
||||
|
||||
new TrackReplaceBlockCommand(parent()->GetTrackFromReference(ghost->Track()), b, gap, command);
|
||||
}
|
||||
|
||||
new BlockResizeWithMediaInCommand(b, ghost->AdjustedLength(), command);
|
||||
|
||||
if (b->previous() == nullptr) {
|
||||
const TrackReference& track_ref = ghost->Track();
|
||||
|
||||
new TrackPlaceBlockCommand(parent()->GetConnectedNode()->track_list(track_ref.type()),
|
||||
track_ref.index(),
|
||||
b,
|
||||
ghost->GetAdjustedIn(),
|
||||
command);
|
||||
}
|
||||
} else if (ghost->mode() == Timeline::kTrimOut) {
|
||||
new BlockResizeCommand(b, ghost->AdjustedLength(), command);
|
||||
BlockTrimCommand* c = new BlockTrimCommand(parent()->GetTrackFromReference(ghost->Track()),
|
||||
b,
|
||||
ghost->AdjustedLength(),
|
||||
drag_movement_mode(),
|
||||
command);
|
||||
c->SetAllowNonGapTrimming(true);
|
||||
}
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
}
|
||||
|
||||
rational TimelineWidget::RollingTool::FrameValidateInternal(rational time_movement, const QVector<TimelineViewGhostItem *> &ghosts)
|
||||
{
|
||||
// Only validate trimming, and we don't care about "overwriting" since the rolling tool is designed to trim at collisions
|
||||
time_movement = ValidateInTrimming(time_movement, ghosts, false);
|
||||
time_movement = ValidateOutTrimming(time_movement, ghosts, false);
|
||||
|
||||
return time_movement;
|
||||
}
|
||||
|
||||
void TimelineWidget::RollingTool::InitiateGhosts(TimelineViewBlockItem *clicked_item,
|
||||
Timeline::MovementMode trim_mode,
|
||||
bool allow_gap_trimming)
|
||||
{
|
||||
Q_UNUSED(allow_gap_trimming)
|
||||
|
||||
PointerTool::InitiateGhosts(clicked_item, trim_mode, true);
|
||||
|
||||
// For each ghost, we make an equivalent Ghost on the next/previous block
|
||||
foreach (TimelineViewGhostItem* ghost, parent()->ghost_items_) {
|
||||
Block* ghost_block = Node::ValueToPtr<Block>(ghost->data(TimelineViewGhostItem::kAttachedBlock));
|
||||
|
||||
if (ghost->mode() == Timeline::kTrimIn && ghost_block->previous() != nullptr) {
|
||||
// Add an extra Ghost for the previous block
|
||||
AddGhostFromBlock(ghost_block->previous(), ghost->Track(), Timeline::kTrimOut);
|
||||
} else if (ghost->mode() == Timeline::kTrimOut && ghost_block->next() != nullptr) {
|
||||
AddGhostFromBlock(ghost_block->next(), ghost->Track(), Timeline::kTrimIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Reference in New Issue
Block a user