Skip to content

Commit

Permalink
Timeline scaling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Jun 10, 2024
1 parent c8b81ea commit cc8a7d6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/tlTimelineUI/AudioClipItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ namespace tl

if (_displayOptions.waveformWidth > 0 && p.ioInfo)
{
const int w = _sizeHint.w;
const int w = g.w();
for (int x = 0; x < w; x += _displayOptions.waveformWidth)
{
const math::Box2i box(
Expand Down
28 changes: 26 additions & 2 deletions lib/tlTimelineUI/TimelineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ namespace tl
TLRENDER_P();
const int w = _geometry.w();
const double zoomMin = _getTimelineScale();
const double zoomMax = w;
const double zoomMax = _getTimelineScaleMax();
const double zoomClamped = math::clamp(zoomNew, zoomMin, zoomMax);
if (zoomClamped != p.scale)
{
Expand All @@ -564,7 +564,7 @@ namespace tl
double TimelineWidget::_getTimelineScale() const
{
TLRENDER_P();
double out = 100.0;
double out = 1.0;
if (p.player)
{
const otime::TimeRange& timeRange = p.player->getTimeRange();
Expand All @@ -578,6 +578,30 @@ namespace tl
return out;
}

double TimelineWidget::_getTimelineScaleMax() const
{
TLRENDER_P();
double out = 1.0;
if (p.player)
{
const math::Box2i scrollViewport = p.scrollWidget->getViewport();
const otime::TimeRange& timeRange = p.player->getTimeRange();
const double duration = timeRange.duration().rescaled_to(1.0).value();
if (duration < 1.0)
{
if (duration > 0.0)
{
out = scrollViewport.w() / duration;
}
}
else
{
out = scrollViewport.w();
}
}
return out;
}

void TimelineWidget::_setItemScale()
{
TLRENDER_P();
Expand Down
1 change: 1 addition & 0 deletions lib/tlTimelineUI/TimelineWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ namespace tl
const math::Vector2i& scrollPos);

double _getTimelineScale() const;
double _getTimelineScaleMax() const;

void _setItemScale();
void _setItemScale(
Expand Down
2 changes: 1 addition & 1 deletion lib/tlTimelineUI/VideoClipItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ namespace tl
0;
if (thumbnailWidth > 0)
{
const int w = _sizeHint.w;
const int w = g.w();
for (int x = 0; x < w; x += thumbnailWidth)
{
const math::Box2i box(
Expand Down
4 changes: 2 additions & 2 deletions lib/tlUI/ThumbnailSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,11 @@ namespace tl
//std::cout << x << ": " << x0 << " " << x1 << std::endl;
audio::F32_T min = 0.F;
audio::F32_T max = 0.F;
if (x0 < x1)
if (x0 <= x1)
{
min = audio::F32Range.getMax();
max = audio::F32Range.getMin();
for (int i = x0; i < x1; ++i)
for (int i = x0; i <= x1 && i < sampleCount; ++i)
{
const audio::F32_T v = *(data + i * info.channelCount);
min = std::min(min, v);
Expand Down

0 comments on commit cc8a7d6

Please sign in to comment.