documentation and minor timecode revision
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "qtversionabstraction.h"
|
||||
|
||||
int QFontMetricsWidth(const QFontMetrics* fm, const QString& s) {
|
||||
|
||||
@@ -1,8 +1,40 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef QTVERSIONABSTRACTION_H
|
||||
#define QTVERSIONABSTRACTION_H
|
||||
|
||||
/**
|
||||
*
|
||||
* A fairly simple header for reducing the amount of Qt version checks necessary throughout the code
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QFontMetrics>
|
||||
|
||||
/**
|
||||
* @brief Retrieves the width of a string according to certain QFontMetrics
|
||||
*
|
||||
* QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the latter was only
|
||||
* introduced in 5.11+. This function wraps the latter for 5.11+ and the former for earlier.
|
||||
*/
|
||||
int QFontMetricsWidth(const QFontMetrics* fm, const QString& s);
|
||||
|
||||
#endif // QTVERSIONABSTRACTION_H
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "timecodefunctions.h"
|
||||
|
||||
#include <QtMath>
|
||||
@@ -6,13 +26,11 @@ QString padded(int arg, int padding) {
|
||||
return QString("%1").arg(arg, padding, 10, QChar('0'));
|
||||
}
|
||||
|
||||
QString olive::timestamp_to_timecode(const rational& timestamp,
|
||||
QString olive::timestamp_to_timecode(const int64_t ×tamp,
|
||||
const rational& timebase,
|
||||
const TimecodeDisplay& display)
|
||||
{
|
||||
double timestamp_dbl = timestamp.ToDouble();
|
||||
|
||||
|
||||
double timestamp_dbl = (rational(timestamp) * timebase).ToDouble();
|
||||
|
||||
switch (display) {
|
||||
case kTimecodeFrames:
|
||||
@@ -43,9 +61,9 @@ QString olive::timestamp_to_timecode(const rational& timestamp,
|
||||
}
|
||||
}
|
||||
case kFrames:
|
||||
return QString::number(timestamp.numerator() / timebase.numerator());
|
||||
return QString::number(timestamp);
|
||||
case kMilliseconds:
|
||||
return QString::number(qFloor(timestamp_dbl * 1000));
|
||||
return QString::number(qRound(timestamp_dbl * 1000));
|
||||
}
|
||||
|
||||
return QString();
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMECODEFUNCTIONS_H
|
||||
#define TIMECODEFUNCTIONS_H
|
||||
|
||||
@@ -14,7 +34,10 @@ enum TimecodeDisplay {
|
||||
kMilliseconds
|
||||
};
|
||||
|
||||
QString timestamp_to_timecode(const rational& timestamp, const rational& timebase, const TimecodeDisplay& display);
|
||||
/**
|
||||
* @brief Convert a timestamp (according to a rational timebase) to a user-friendly string representation
|
||||
*/
|
||||
QString timestamp_to_timecode(const int64_t ×tamp, const rational& timebase, const TimecodeDisplay& display);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -120,9 +120,9 @@ void PlaybackControls::SetTimebase(const rational &r)
|
||||
time_base_ = r;
|
||||
}
|
||||
|
||||
void PlaybackControls::SetTime(const rational &r)
|
||||
void PlaybackControls::SetTime(const int64_t &r)
|
||||
{
|
||||
Q_ASSERT(time_base_.denominator() != 0);
|
||||
|
||||
cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, olive::kTimecodeFrames));
|
||||
cur_tc_lbl_->setText(olive::timestamp_to_timecode(r, time_base_, olive::kMilliseconds));
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
void SetTimebase(const rational& r);
|
||||
|
||||
public slots:
|
||||
void SetTime(const rational& r);
|
||||
void SetTime(const int64_t &r);
|
||||
|
||||
signals:
|
||||
/**
|
||||
|
||||
@@ -73,9 +73,9 @@ void ViewerWidget::SetTexture(GLuint tex)
|
||||
|
||||
void ViewerWidget::RulerTimeChange(int64_t i)
|
||||
{
|
||||
rational time_set = rational(i, 1) * time_base_;
|
||||
rational time_set = rational(i) * time_base_;
|
||||
|
||||
controls_->SetTime(time_set);
|
||||
controls_->SetTime(i);
|
||||
|
||||
emit TimeChanged(time_set);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user