place timecode conversion functions into a Timecode class rather than an olive namespace
Code cleanup and improvement.
This commit is contained in:
@@ -137,7 +137,7 @@ void NodeParamView::SetScale(const double& scale)
|
||||
|
||||
void NodeParamView::SetTime(const rational &time)
|
||||
{
|
||||
int64_t timestamp = olive::time_to_timestamp(time, keyframe_view_->timebase());
|
||||
int64_t timestamp = Timecode::time_to_timestamp(time, keyframe_view_->timebase());
|
||||
|
||||
ruler_->SetTime(timestamp);
|
||||
keyframe_view_->SetTime(timestamp);
|
||||
@@ -160,7 +160,7 @@ void NodeParamView::UpdateItemTime(const rational &time)
|
||||
|
||||
void NodeParamView::RulerTimeChanged(const int64_t ×tamp)
|
||||
{
|
||||
rational time = olive::timestamp_to_time(timestamp, keyframe_view_->timebase());
|
||||
rational time = Timecode::timestamp_to_time(timestamp, keyframe_view_->timebase());
|
||||
|
||||
UpdateItemTime(time);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
private:
|
||||
void CreateWidgets();
|
||||
|
||||
void SetInputValue(NodeInput* input, const QVariant& value);
|
||||
void SetInputValue(const QVariant& value);
|
||||
|
||||
NodeInput* input_;
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ void PlaybackControls::SetTimeLabelInternal(QLabel* label, const int64_t& time)
|
||||
return;
|
||||
}
|
||||
|
||||
label->setText(olive::timestamp_to_timecode(time,
|
||||
time_base_,
|
||||
olive::CurrentTimecodeDisplay()));
|
||||
label->setText(Timecode::timestamp_to_timecode(time,
|
||||
time_base_,
|
||||
Timecode::CurrentDisplay()));
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ QString TimeSlider::ValueToString(const QVariant &v)
|
||||
return IntegerSlider::ValueToString(v);
|
||||
}
|
||||
|
||||
return olive::timestamp_to_timecode(v.toLongLong(),
|
||||
timebase_,
|
||||
olive::CurrentTimecodeDisplay());
|
||||
return Timecode::timestamp_to_timecode(v.toLongLong(),
|
||||
timebase_,
|
||||
Timecode::CurrentDisplay());
|
||||
}
|
||||
|
||||
QVariant TimeSlider::StringToValue(const QString &s, bool *ok)
|
||||
{
|
||||
return olive::timecode_to_timestamp(s, timebase_, olive::CurrentTimecodeDisplay(), ok);
|
||||
return Timecode::timecode_to_timestamp(s, timebase_, Timecode::CurrentDisplay(), ok);
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ void TimelineWidget::GoToPrevCut()
|
||||
int64_t this_track_closest_cut = 0;
|
||||
|
||||
foreach (Block* block, track->Blocks()) {
|
||||
int64_t block_out_ts = olive::time_to_timestamp(block->out(), timebase());
|
||||
int64_t block_out_ts = Timecode::time_to_timestamp(block->out(), timebase());
|
||||
|
||||
if (block_out_ts < playhead_) {
|
||||
this_track_closest_cut = block_out_ts;
|
||||
@@ -314,14 +314,14 @@ void TimelineWidget::GoToNextCut()
|
||||
int64_t closest_cut = INT64_MAX;
|
||||
|
||||
foreach (TrackOutput* track, timeline_node_->Tracks()) {
|
||||
int64_t this_track_closest_cut = olive::time_to_timestamp(track->track_length(), timebase());
|
||||
int64_t this_track_closest_cut = Timecode::time_to_timestamp(track->track_length(), timebase());
|
||||
|
||||
if (this_track_closest_cut <= playhead_) {
|
||||
this_track_closest_cut = INT64_MAX;
|
||||
}
|
||||
|
||||
foreach (Block* block, track->Blocks()) {
|
||||
int64_t block_in_ts = olive::time_to_timestamp(block->in(), timebase());
|
||||
int64_t block_in_ts = Timecode::time_to_timestamp(block->in(), timebase());
|
||||
|
||||
if (block_in_ts > playhead_) {
|
||||
this_track_closest_cut = block_in_ts;
|
||||
@@ -339,7 +339,7 @@ void TimelineWidget::GoToNextCut()
|
||||
|
||||
void TimelineWidget::SplitAtPlayhead()
|
||||
{
|
||||
rational playhead_time = olive::timestamp_to_time(playhead_, timebase());
|
||||
rational playhead_time = Timecode::timestamp_to_time(playhead_, timebase());
|
||||
|
||||
QList<TimelineViewBlockItem *> selected_blocks = GetSelectedBlocks();
|
||||
|
||||
@@ -494,7 +494,7 @@ QList<TimelineViewBlockItem *> TimelineWidget::GetSelectedBlocks()
|
||||
|
||||
void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool insert_gaps)
|
||||
{
|
||||
rational playhead_time = olive::timestamp_to_time(playhead_, timebase());
|
||||
rational playhead_time = Timecode::timestamp_to_time(playhead_, timebase());
|
||||
|
||||
rational closest_point_to_playhead;
|
||||
if (mode == olive::timeline::kTrimIn) {
|
||||
@@ -551,7 +551,7 @@ void TimelineWidget::RippleEditTo(olive::timeline::MovementMode mode, bool inser
|
||||
olive::undo_stack.pushIfHasChildren(command);
|
||||
|
||||
if (mode == olive::timeline::kTrimIn && !insert_gaps) {
|
||||
int64_t new_time = olive::time_to_timestamp(closest_point_to_playhead, timebase());
|
||||
int64_t new_time = Timecode::time_to_timestamp(closest_point_to_playhead, timebase());
|
||||
|
||||
SetTimeAndSignal(new_time);
|
||||
}
|
||||
|
||||
@@ -185,10 +185,10 @@ void TimelineWidget::ImportTool::DragMove(TimelineViewMouseEvent *event)
|
||||
}
|
||||
|
||||
// Generate tooltip (showing earliest in point of imported clip)
|
||||
int64_t earliest_timestamp = olive::time_to_timestamp(earliest_ghost, parent()->timebase());
|
||||
QString tooltip_text = olive::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase(),
|
||||
olive::CurrentTimecodeDisplay());
|
||||
int64_t earliest_timestamp = Timecode::time_to_timestamp(earliest_ghost, parent()->timebase());
|
||||
QString tooltip_text = Timecode::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase(),
|
||||
Timecode::CurrentDisplay());
|
||||
|
||||
// Force tooltip to update (otherwise the tooltip won't move as written in the documentation, and could get in the way
|
||||
// of the cursor)
|
||||
|
||||
@@ -326,11 +326,11 @@ void TimelineWidget::PointerTool::ProcessDrag(const TimelineCoordinate &mouse_po
|
||||
|
||||
// Show tooltip
|
||||
// Generate tooltip (showing earliest in point of imported clip)
|
||||
int64_t earliest_timestamp = olive::time_to_timestamp(time_movement, parent()->timebase());
|
||||
QString tooltip_text = olive::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase(),
|
||||
olive::CurrentTimecodeDisplay(),
|
||||
true);
|
||||
int64_t earliest_timestamp = Timecode::time_to_timestamp(time_movement, parent()->timebase());
|
||||
QString tooltip_text = Timecode::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase(),
|
||||
Timecode::CurrentDisplay(),
|
||||
true);
|
||||
|
||||
// Force tooltip to update (otherwise the tooltip won't move as written in the documentation, and could get in the way
|
||||
// of the cursor)
|
||||
|
||||
@@ -51,11 +51,11 @@ void TimelineWidget::SlipTool::ProcessDrag(const TimelineCoordinate &mouse_pos)
|
||||
|
||||
// Show tooltip
|
||||
// Generate tooltip (showing earliest in point of imported clip)
|
||||
int64_t earliest_timestamp = olive::time_to_timestamp(time_movement, parent()->timebase());
|
||||
QString tooltip_text = olive::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase(),
|
||||
olive::CurrentTimecodeDisplay(),
|
||||
true);
|
||||
int64_t earliest_timestamp = Timecode::time_to_timestamp(time_movement, parent()->timebase());
|
||||
QString tooltip_text = Timecode::timestamp_to_timecode(earliest_timestamp,
|
||||
parent()->timebase(),
|
||||
Timecode::CurrentDisplay(),
|
||||
true);
|
||||
// Force tooltip to update (otherwise the tooltip won't move as written in the documentation, and could get in the way
|
||||
// of the cursor)
|
||||
QToolTip::hideText();
|
||||
|
||||
@@ -89,7 +89,7 @@ bool TimelineViewBase::PlayheadMove(QMouseEvent *event)
|
||||
QPointF scene_pos = mapToScene(event->pos());
|
||||
rational mouse_time = SceneToTime(scene_pos.x());
|
||||
|
||||
int64_t target_ts = olive::time_to_timestamp(mouse_time, timebase());
|
||||
int64_t target_ts = Timecode::time_to_timestamp(mouse_time, timebase());
|
||||
|
||||
SetTime(target_ts);
|
||||
emit TimeChanged(target_ts);
|
||||
|
||||
@@ -156,7 +156,7 @@ void TimeRuler::paintEvent(QPaintEvent *)
|
||||
if (text_visible_) {
|
||||
QFontMetrics fm = p.fontMetrics();
|
||||
double width_of_second = scale_;
|
||||
int average_text_width = QFontMetricsWidth(fm, olive::timestamp_to_timecode(0, timebase_, olive::CurrentTimecodeDisplay()));
|
||||
int average_text_width = QFontMetricsWidth(fm, Timecode::timestamp_to_timecode(0, timebase_, Timecode::CurrentDisplay()));
|
||||
half_average_text_width = average_text_width/2;
|
||||
while (width_of_second * text_skip < average_text_width) {
|
||||
text_skip++;
|
||||
@@ -202,7 +202,8 @@ void TimeRuler::paintEvent(QPaintEvent *)
|
||||
|
||||
// Try to draw text here
|
||||
if (text_visible_ && sec%text_skip == 0) {
|
||||
QString timecode_string = olive::timestamp_to_timecode(sec, timebase_, olive::CurrentTimecodeDisplay());
|
||||
int64_t timestamp_here = Timecode::time_to_timestamp(rational(sec), timebase_);
|
||||
QString timecode_string = Timecode::timestamp_to_timecode(timestamp_here, timebase_, Timecode::CurrentDisplay());
|
||||
|
||||
int text_x = i;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ const double &ViewerWidget::scale() const
|
||||
|
||||
rational ViewerWidget::GetTime() const
|
||||
{
|
||||
return olive::timestamp_to_time(ruler_->GetTime(), time_base_);
|
||||
return Timecode::timestamp_to_time(ruler_->GetTime(), time_base_);
|
||||
}
|
||||
|
||||
void ViewerWidget::SetScale(const double &scale_)
|
||||
@@ -330,7 +330,7 @@ void ViewerWidget::GoToEnd()
|
||||
if (viewer_node_ != nullptr) {
|
||||
Pause();
|
||||
|
||||
SetTime(olive::time_to_timestamp(viewer_node_->Length(), time_base_));
|
||||
SetTime(Timecode::time_to_timestamp(viewer_node_->Length(), time_base_));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ void ViewerWidget::SizeChangedSlot(int width, int height)
|
||||
|
||||
void ViewerWidget::LengthChangedSlot(const rational &length)
|
||||
{
|
||||
controls_->SetEndTime(olive::time_to_timestamp(length, time_base_));
|
||||
controls_->SetEndTime(Timecode::time_to_timestamp(length, time_base_));
|
||||
}
|
||||
|
||||
void ViewerWidget::resizeEvent(QResizeEvent *event)
|
||||
|
||||
Reference in New Issue
Block a user