Files
oak-editor/app/widget/timelinewidget/timelinescaledobject.cpp
T
itsmattkc b713ab47eb keyframes: only update active frames even from curve and param editor
When adjusting a slider, keyframe time, or curve value, it is undesirable to
re-cache the entire affected area while the user is still dragging UI objects.
Since the video is unlikely to be playing, the priority must go to the
currently active frame so the user gets visual feedback on the rendered image
as soon as possible. This was implemented in some areas, but this commit should
have that functionality in all areas.
2020-01-25 17:51:34 +11:00

53 lines
1.1 KiB
C++

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