Skip to content

Commit

Permalink
Use integers instead of times for frame markers
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Mar 31, 2024
1 parent 1ca7128 commit 9a526e6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
10 changes: 10 additions & 0 deletions lib/tlQtWidget/TimelineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ namespace tl
return _p->timelineWidget->getItemOptions();
}

const std::vector<int64_t>& TimelineWidget::frameMarkers() const
{
return _p->timelineWidget->getFrameMarkers();
}

QSize TimelineWidget::minimumSizeHint() const
{
//! \bug Hard-coded size hint.
Expand Down Expand Up @@ -302,6 +307,11 @@ namespace tl
_p->timelineWidget->setItemOptions(value);
}

void TimelineWidget::setFrameMarkers(const std::vector<int64_t>& value)
{
_p->timelineWidget->setFrameMarkers(value);
}

void TimelineWidget::initializeGL()
{
TLRENDER_P();
Expand Down
6 changes: 6 additions & 0 deletions lib/tlQtWidget/TimelineWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ namespace tl
//! Get the item options.
const timelineui::ItemOptions& itemOptions() const;

//! Get the frame markers.
const std::vector<int64_t>& frameMarkers() const;

QSize minimumSizeHint() const override;

public Q_SLOTS:
Expand All @@ -82,6 +85,9 @@ namespace tl
//! Set the item options.
void setItemOptions(const timelineui::ItemOptions&);

//! Set the frame markers.
void setFrameMarkers(const std::vector<int64_t>&);

Q_SIGNALS:
//! This signal is emitted when the editable timeline is changed.
void editableChanged(bool);
Expand Down
7 changes: 4 additions & 3 deletions lib/tlTimelineUI/TimelineItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace tl
timeline::PlayerCacheInfo cacheInfo;
bool editable = false;
bool stopOnScrub = true;
std::vector<otime::RationalTime> frameMarkers;
std::vector<int64_t> frameMarkers;
std::shared_ptr<ui::ThumbnailGenerator> thumbnailGenerator;

struct Track
Expand Down Expand Up @@ -289,7 +289,7 @@ namespace tl
_p->stopOnScrub = value;
}

void TimelineItem::setFrameMarkers(const std::vector<otime::RationalTime>& value)
void TimelineItem::setFrameMarkers(const std::vector<int64_t>& value)
{
TLRENDER_P();
if (value == p.frameMarkers)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/tlTimelineUI/TimelineItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace tl
void setStopOnScrub(bool);

//! Set the frame markers.
void setFrameMarkers(const std::vector<otime::RationalTime>&);
void setFrameMarkers(const std::vector<int64_t>&);

void setOptions(const ItemOptions&) override;

Expand Down
6 changes: 3 additions & 3 deletions lib/tlTimelineUI/TimelineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace tl
float mouseWheelScale = 1.1F;
double scale = 500.0;
std::shared_ptr<observer::Value<ItemOptions> > itemOptions;
std::vector<otime::RationalTime> frameMarkers;
std::vector<int64_t> frameMarkers;
bool sizeInit = true;

std::shared_ptr<gl::GLFWWindow> window;
Expand Down Expand Up @@ -284,12 +284,12 @@ namespace tl
}
}

const std::vector<otime::RationalTime>& TimelineWidget::getFrameMarkers() const
const std::vector<int64_t>& TimelineWidget::getFrameMarkers() const
{
return _p->frameMarkers;
}

void TimelineWidget::setFrameMarkers(const std::vector<otime::RationalTime>& value)
void TimelineWidget::setFrameMarkers(const std::vector<int64_t>& value)
{
TLRENDER_P();
if (value == p.frameMarkers)
Expand Down
4 changes: 2 additions & 2 deletions lib/tlTimelineUI/TimelineWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ namespace tl
void setItemOptions(const ItemOptions&);

//! Get the frame markers.
const std::vector<otime::RationalTime>& getFrameMarkers() const;
const std::vector<int64_t>& getFrameMarkers() const;

//! Set the frame markers.
void setFrameMarkers(const std::vector<otime::RationalTime>&);
void setFrameMarkers(const std::vector<int64_t>&);

void setGeometry(const math::Box2i&) override;
void tickEvent(
Expand Down

0 comments on commit 9a526e6

Please sign in to comment.