From 9a526e6f9584286970acfac1da5a42855934e327 Mon Sep 17 00:00:00 2001 From: Darby Johnston Date: Sun, 31 Mar 2024 11:53:37 -0700 Subject: [PATCH] Use integers instead of times for frame markers --- lib/tlQtWidget/TimelineWidget.cpp | 10 ++++++++++ lib/tlQtWidget/TimelineWidget.h | 6 ++++++ lib/tlTimelineUI/TimelineItem.cpp | 7 ++++--- lib/tlTimelineUI/TimelineItem.h | 2 +- lib/tlTimelineUI/TimelineWidget.cpp | 6 +++--- lib/tlTimelineUI/TimelineWidget.h | 4 ++-- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/tlQtWidget/TimelineWidget.cpp b/lib/tlQtWidget/TimelineWidget.cpp index 0cae2033..c7603182 100644 --- a/lib/tlQtWidget/TimelineWidget.cpp +++ b/lib/tlQtWidget/TimelineWidget.cpp @@ -260,6 +260,11 @@ namespace tl return _p->timelineWidget->getItemOptions(); } + const std::vector& TimelineWidget::frameMarkers() const + { + return _p->timelineWidget->getFrameMarkers(); + } + QSize TimelineWidget::minimumSizeHint() const { //! \bug Hard-coded size hint. @@ -302,6 +307,11 @@ namespace tl _p->timelineWidget->setItemOptions(value); } + void TimelineWidget::setFrameMarkers(const std::vector& value) + { + _p->timelineWidget->setFrameMarkers(value); + } + void TimelineWidget::initializeGL() { TLRENDER_P(); diff --git a/lib/tlQtWidget/TimelineWidget.h b/lib/tlQtWidget/TimelineWidget.h index 39cfc656..0671edc2 100644 --- a/lib/tlQtWidget/TimelineWidget.h +++ b/lib/tlQtWidget/TimelineWidget.h @@ -58,6 +58,9 @@ namespace tl //! Get the item options. const timelineui::ItemOptions& itemOptions() const; + //! Get the frame markers. + const std::vector& frameMarkers() const; + QSize minimumSizeHint() const override; public Q_SLOTS: @@ -82,6 +85,9 @@ namespace tl //! Set the item options. void setItemOptions(const timelineui::ItemOptions&); + //! Set the frame markers. + void setFrameMarkers(const std::vector&); + Q_SIGNALS: //! This signal is emitted when the editable timeline is changed. void editableChanged(bool); diff --git a/lib/tlTimelineUI/TimelineItem.cpp b/lib/tlTimelineUI/TimelineItem.cpp index 594d5d30..9a6033aa 100644 --- a/lib/tlTimelineUI/TimelineItem.cpp +++ b/lib/tlTimelineUI/TimelineItem.cpp @@ -29,7 +29,7 @@ namespace tl timeline::PlayerCacheInfo cacheInfo; bool editable = false; bool stopOnScrub = true; - std::vector frameMarkers; + std::vector frameMarkers; std::shared_ptr thumbnailGenerator; struct Track @@ -289,7 +289,7 @@ namespace tl _p->stopOnScrub = value; } - void TimelineItem::setFrameMarkers(const std::vector& value) + void TimelineItem::setFrameMarkers(const std::vector& value) { TLRENDER_P(); if (value == p.frameMarkers) @@ -824,10 +824,11 @@ namespace tl { TLRENDER_P(); const math::Box2i& g = _geometry; + const double rate = _timeRange.duration().rate(); for (const auto& frameMarker : p.frameMarkers) { const math::Box2i g2( - _timeToPos(frameMarker), + _timeToPos(otime::RationalTime(frameMarker, rate)), p.size.scrollPos.y + g.min.y, p.size.border * 2, diff --git a/lib/tlTimelineUI/TimelineItem.h b/lib/tlTimelineUI/TimelineItem.h index c6bf1097..609644c0 100644 --- a/lib/tlTimelineUI/TimelineItem.h +++ b/lib/tlTimelineUI/TimelineItem.h @@ -68,7 +68,7 @@ namespace tl void setStopOnScrub(bool); //! Set the frame markers. - void setFrameMarkers(const std::vector&); + void setFrameMarkers(const std::vector&); void setOptions(const ItemOptions&) override; diff --git a/lib/tlTimelineUI/TimelineWidget.cpp b/lib/tlTimelineUI/TimelineWidget.cpp index 578d688c..379f245d 100644 --- a/lib/tlTimelineUI/TimelineWidget.cpp +++ b/lib/tlTimelineUI/TimelineWidget.cpp @@ -26,7 +26,7 @@ namespace tl float mouseWheelScale = 1.1F; double scale = 500.0; std::shared_ptr > itemOptions; - std::vector frameMarkers; + std::vector frameMarkers; bool sizeInit = true; std::shared_ptr window; @@ -284,12 +284,12 @@ namespace tl } } - const std::vector& TimelineWidget::getFrameMarkers() const + const std::vector& TimelineWidget::getFrameMarkers() const { return _p->frameMarkers; } - void TimelineWidget::setFrameMarkers(const std::vector& value) + void TimelineWidget::setFrameMarkers(const std::vector& value) { TLRENDER_P(); if (value == p.frameMarkers) diff --git a/lib/tlTimelineUI/TimelineWidget.h b/lib/tlTimelineUI/TimelineWidget.h index ac4e66de..0a273dc7 100644 --- a/lib/tlTimelineUI/TimelineWidget.h +++ b/lib/tlTimelineUI/TimelineWidget.h @@ -104,10 +104,10 @@ namespace tl void setItemOptions(const ItemOptions&); //! Get the frame markers. - const std::vector& getFrameMarkers() const; + const std::vector& getFrameMarkers() const; //! Set the frame markers. - void setFrameMarkers(const std::vector&); + void setFrameMarkers(const std::vector&); void setGeometry(const math::Box2i&) override; void tickEvent(