Files
oak-editor/app/widget/timelinewidget/timelinescaledobject.cpp
T
itsmattkc b65abe4881 use floor instead of round when calculating frame from cursor
Fixes a bug where clicking on the right of a frame would register as clicking
the next frame.
2019-12-28 04:47:27 +11:00

40 lines
811 B
C++

#include "timelinescaledobject.h"
#include <QtMath>
TimelineScaledObject::TimelineScaledObject() :
scale_(1.0)
{
}
const rational &TimelineScaledObject::timebase()
{
return timebase_;
}
const double &TimelineScaledObject::timebase_dbl()
{
return timebase_dbl_;
}
double TimelineScaledObject::TimeToScene(const rational &time)
{
return time.toDouble() * scale_;
}
rational TimelineScaledObject::SceneToTime(const double &x)
{
// Adjust screen point by scale and timebase
qint64 scaled_x_mvmt = qFloor(x / scale_ / timebase_dbl_);
// Return a time in the timebase
return rational(scaled_x_mvmt * timebase_.numerator(), timebase_.denominator());
}
void TimelineScaledObject::SetTimebaseInternal(const rational &timebase)
{
timebase_ = timebase;
timebase_dbl_ = timebase_.toDouble();
}