diff --git a/app/panel/timeline/timeline.cpp b/app/panel/timeline/timeline.cpp index 8e4c00159..015badff1 100644 --- a/app/panel/timeline/timeline.cpp +++ b/app/panel/timeline/timeline.cpp @@ -143,6 +143,16 @@ void TimelinePanel::PasteInsert() static_cast(GetTimeBasedWidget())->Paste(true); } +void TimelinePanel::DeleteInToOut() +{ + static_cast(GetTimeBasedWidget())->DeleteInToOut(false); +} + +void TimelinePanel::RippleDeleteInToOut() +{ + static_cast(GetTimeBasedWidget())->DeleteInToOut(true); +} + void TimelinePanel::InsertFootageAtPlayhead(const QList &footage) { static_cast(GetTimeBasedWidget())->InsertFootageAtPlayhead(footage); diff --git a/app/panel/timeline/timeline.h b/app/panel/timeline/timeline.h index 391a1279d..f1b2825a7 100644 --- a/app/panel/timeline/timeline.h +++ b/app/panel/timeline/timeline.h @@ -73,6 +73,10 @@ public: virtual void PasteInsert() override; + virtual void DeleteInToOut() override; + + virtual void RippleDeleteInToOut() override; + void InsertFootageAtPlayhead(const QList &footage); void OverwriteFootageAtPlayhead(const QList &footage); diff --git a/app/timeline/timelineworkarea.cpp b/app/timeline/timelineworkarea.cpp index dee0ca39c..0f68f0ad7 100644 --- a/app/timeline/timelineworkarea.cpp +++ b/app/timeline/timelineworkarea.cpp @@ -99,4 +99,9 @@ const rational &TimelineWorkArea::out() const return workarea_range_.out(); } +const rational &TimelineWorkArea::length() const +{ + return workarea_range_.length(); +} + OLIVE_NAMESPACE_EXIT diff --git a/app/timeline/timelineworkarea.h b/app/timeline/timelineworkarea.h index d7ec567e7..602d88b43 100644 --- a/app/timeline/timelineworkarea.h +++ b/app/timeline/timelineworkarea.h @@ -40,6 +40,7 @@ public: const rational& in() const; const rational& out() const; + const rational& length() const; const TimeRange& range() const; void set_range(const TimeRange& range); diff --git a/app/widget/panel/panel.h b/app/widget/panel/panel.h index cbedb87d5..72d2842d1 100644 --- a/app/widget/panel/panel.h +++ b/app/widget/panel/panel.h @@ -150,6 +150,10 @@ public: virtual void GoToOut(){} + virtual void DeleteInToOut(){} + + virtual void RippleDeleteInToOut(){} + protected: /** * @brief paintEvent diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index fdcc57c5c..c6fa5e4e2 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -689,6 +689,47 @@ void TimelineWidget::Paste(bool insert) Core::instance()->undo_stack()->pushIfHasChildren(command); } +void TimelineWidget::DeleteInToOut(bool ripple) +{ + if (!GetConnectedNode() + || !GetConnectedTimelinePoints() + || !GetConnectedTimelinePoints()->workarea()->enabled()) { + return; + } + + QUndoCommand* command = new QUndoCommand(); + + foreach (TrackOutput* track, GetConnectedNode()->Tracks()) { + if (!track->IsLocked()) { + if (ripple) { + new TrackRippleRemoveAreaCommand(track, + GetConnectedTimelinePoints()->workarea()->in(), + GetConnectedTimelinePoints()->workarea()->out(), + command); + } else { + GapBlock* gap = new GapBlock(); + + gap->set_length_and_media_out(GetConnectedTimelinePoints()->workarea()->length()); + + new NodeAddCommand(static_cast(track->parent()), + gap, + command); + + new TrackPlaceBlockCommand(GetConnectedNode()->track_list(track->track_type()), + track->Index(), + gap, + GetConnectedTimelinePoints()->workarea()->in(), + command); + } + } + } + + // Clear workarea after this + new WorkareaSetEnabledCommand(GetConnectedTimelinePoints(), false, command); + + Core::instance()->undo_stack()->push(command); +} + QList TimelineWidget::GetSelectedBlocks() { QList list; diff --git a/app/widget/timelinewidget/timelinewidget.h b/app/widget/timelinewidget/timelinewidget.h index b4f893070..a5acb759e 100644 --- a/app/widget/timelinewidget/timelinewidget.h +++ b/app/widget/timelinewidget/timelinewidget.h @@ -86,6 +86,8 @@ public: void Paste(bool insert); + void DeleteInToOut(bool ripple); + QList GetSelectedBlocks(); signals: diff --git a/app/window/mainwindow/mainmenu.cpp b/app/window/mainwindow/mainmenu.cpp index c47c701ec..28c324e1f 100644 --- a/app/window/mainwindow/mainmenu.cpp +++ b/app/window/mainwindow/mainmenu.cpp @@ -505,12 +505,12 @@ void MainMenu::ClearOpenRecentTriggered() void MainMenu::DeleteInOutTriggered() { - qDebug() << "FIXME: Stub"; + PanelManager::instance()->CurrentlyFocused()->DeleteInToOut(); } void MainMenu::RippleDeleteInOutTriggered() { - qDebug() << "FIXME: Stub"; + PanelManager::instance()->CurrentlyFocused()->RippleDeleteInToOut(); } void MainMenu::GoToInTriggered()