widget: use rational for internal playhead value

Fixes #1688
This commit is contained in:
itsmattkc
2021-08-02 10:55:01 -07:00
parent 4510f6d36a
commit 438cce1ce5
38 changed files with 217 additions and 334 deletions
+6 -12
View File
@@ -59,7 +59,7 @@ CurveWidget::CurveWidget(QWidget *parent) :
QHBoxLayout* top_controls = new QHBoxLayout();
key_control_ = new NodeParamViewKeyframeControl(false);
connect(key_control_, &NodeParamViewKeyframeControl::RequestSetTime, this, &CurveWidget::KeyControlRequestedTimeChanged);
connect(key_control_, &NodeParamViewKeyframeControl::RequestSetTime, this, &CurveWidget::SetTimeAndSignal);
top_controls->addWidget(key_control_);
top_controls->addStretch();
@@ -156,12 +156,12 @@ void CurveWidget::SetNodes(const QVector<Node *> &nodes)
nodes_ = nodes;
}
void CurveWidget::TimeChangedEvent(const int64_t &timestamp)
void CurveWidget::TimeChangedEvent(const rational &time)
{
TimeBasedWidget::TimeChangedEvent(timestamp);
TimeBasedWidget::TimeChangedEvent(time);
view_->SetTime(timestamp);
UpdateBridgeTime(timestamp);
view_->SetTime(time);
UpdateBridgeTime(time);
}
void CurveWidget::TimebaseChangedEvent(const rational &timebase)
@@ -211,9 +211,8 @@ void CurveWidget::SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type)
hold_button_->setChecked(type == NodeKeyframe::kHold);
}
void CurveWidget::UpdateBridgeTime(const int64_t &timestamp)
void CurveWidget::UpdateBridgeTime(const rational &time)
{
rational time = Timecode::timestamp_to_time(timestamp, view_->timebase());
key_control_->SetTime(time);
}
@@ -355,11 +354,6 @@ void CurveWidget::KeyframeTypeButtonTriggered(bool checked)
Core::instance()->undo_stack()->push(command);
}
void CurveWidget::KeyControlRequestedTimeChanged(const rational &time)
{
SetTimeAndSignal(Timecode::time_to_timestamp(time, view_->timebase()));
}
void CurveWidget::NodeEnabledChanged(Node* n, bool e)
{
ConnectNode(n, e);