From af0eccc586d2df536102b699ea22c681689fa1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Tue, 26 Sep 2023 04:09:06 -0300 Subject: [PATCH] Added insert callback. --- lib/tlTimelineUI/TimelineItem.cpp | 10 +++++++++- lib/tlTimelineUI/TimelineItem.h | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tlTimelineUI/TimelineItem.cpp b/lib/tlTimelineUI/TimelineItem.cpp index c76b94706..9438733ac 100644 --- a/lib/tlTimelineUI/TimelineItem.cpp +++ b/lib/tlTimelineUI/TimelineItem.cpp @@ -29,6 +29,7 @@ namespace tl timeline::PlayerCacheInfo cacheInfo; bool editable = false; bool stopOnScrub = true; + std::function&)> insertCallback; struct Track { @@ -539,6 +540,8 @@ namespace tl insertData.push_back({ item->p->getComposable(), track, dropTarget.index }); item->p->setVisible(false); } + if (p.insertCallback) + p.insertCallback(insertData); auto otioTimeline = insert( p.player->getTimeline()->getTimeline().value, insertData); @@ -559,7 +562,12 @@ namespace tl TLRENDER_P(); return p.mouse.mode == Private::MouseMode::Item; } - + + void TimelineItem::setInsertCallback(const std::function&)>& value) + { + _p->insertCallback = value; + } + /*void TimelineItem::keyPressEvent(ui::KeyEvent& event) { TLRENDER_P(); diff --git a/lib/tlTimelineUI/TimelineItem.h b/lib/tlTimelineUI/TimelineItem.h index 63b91a25f..c101a7709 100644 --- a/lib/tlTimelineUI/TimelineItem.h +++ b/lib/tlTimelineUI/TimelineItem.h @@ -6,6 +6,7 @@ #include +#include #include namespace tl @@ -56,6 +57,9 @@ namespace tl //! Returns whether a clip is getting dragged. bool isDragging() const; + + //! Sets a callback for inserting items + void setInsertCallback(const std::function&)>&); void setGeometry(const math::Box2i&) override; void sizeHintEvent(const ui::SizeHintEvent&) override;