From 2941dbff48a062926c8a324f1f94822f91f67c5f Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 7 Jan 2020 02:28:31 +1100 Subject: [PATCH] handle transitions that have been set to zero length Transition is removed wholesale if its length is set to zero. --- app/widget/timelinewidget/tool/pointer.cpp | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/app/widget/timelinewidget/tool/pointer.cpp b/app/widget/timelinewidget/tool/pointer.cpp index 6d5e10d51..96556e109 100644 --- a/app/widget/timelinewidget/tool/pointer.cpp +++ b/app/widget/timelinewidget/tool/pointer.cpp @@ -184,6 +184,7 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e QList blocks_to_temp_remove; QList tracks_affected; + QList ignore_ghosts; bool duplicate_clips = (event->GetModifiers() & Qt::AltModifier); @@ -194,14 +195,15 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e // If the ghost has not been adjusted nothing needs to be done if (!ghost->HasBeenAdjusted()) { + ignore_ghosts.append(ghost); continue; } Block* b = Node::ValueToPtr(ghost->data(TimelineViewGhostItem::kAttachedBlock)); - // If we're duplicating (user is holding ALT), no need to remove the original clip. However if the ghost was - // trimmed, it can't be duplicated. if (!duplicate_clips || ghost->mode() != Timeline::kMove || b->type() == Block::kTransition) { + // If we're duplicating (user is holding ALT), no need to remove the original clip. However if the ghost was + // trimmed, it can't be duplicated. blocks_to_temp_remove.append(b); } @@ -223,11 +225,12 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e TimelineViewGhostItem* ghost = parent()->ghost_items_.at(i); // If the ghost has not been adjusted nothing needs to be done - if (!ghost->HasBeenAdjusted()) { + if (ignore_ghosts.contains(ghost)) { continue; } const TrackReference& track_ref = ghost->GetAdjustedTrack(); + TrackOutput* track = parent()->GetTrackFromReference(track_ref); Block* b = Node::ValueToPtr(ghost->data(TimelineViewGhostItem::kAttachedBlock)); @@ -264,11 +267,18 @@ void TimelineWidget::PointerTool::MouseReleaseInternal(TimelineViewMouseEvent *e } } - new TrackPlaceBlockCommand(parent()->timeline_node_->track_list(track_ref.type()), - track_ref.index(), - b, - ghost->GetAdjustedIn(), - command); + // Remove transitions that have been reduced to zero length + if (b->type() == Block::kTransition) { + new NodeRemoveCommand(static_cast(b->parent()), + {b}, + command); + } else { + new TrackPlaceBlockCommand(parent()->timeline_node_->track_list(track_ref.type()), + track_ref.index(), + b, + ghost->GetAdjustedIn(), + command); + } } if (command->childCount() > 0) {