added timecode displays (finally)

This commit is contained in:
itsmattkc
2018-06-20 01:01:51 -07:00
parent 8bca36368e
commit b73826d04f
4 changed files with 45 additions and 3 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ Media* Project::import_file(QString file) {
pg->fmt_ctx = pFormatCtx; // cleaned up in PG
pg->media = m;
connect(pg, SIGNAL(finished()), pg, SLOT(deleteLater()));
pg->run();
pg->start(QThread::LowPriority);
delete [] filename;
return m;
+28 -1
View File
@@ -12,6 +12,7 @@
#include "panels/viewer.h"
#include "playback/cacher.h"
#include "playback/playback.h"
#include "ui_viewer.h"
#include <QTime>
#include <QScrollBar>
@@ -149,6 +150,19 @@ void Timeline::redo() {
}
}
QString frame_to_timecode(long f) {
int int_fps = qRound(sequence->frame_rate);
int hours = f/ (3600 * int_fps);
int mins = f / (60*int_fps) % 60;
int secs = f/int_fps % 60;
int frames = f%int_fps;
return QString(QString::number(hours).rightJustified(2, '0') +
":" + QString::number(mins).rightJustified(2, '0') +
":" + QString::number(secs).rightJustified(2, '0') +
":" + QString::number(frames).rightJustified(2, '0')
);
}
void Timeline::repaint_timeline() {
if (playing) {
playhead = round(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * sequence->frame_rate));
@@ -160,6 +174,7 @@ void Timeline::repaint_timeline() {
panel_viewer->viewer_widget->update();
last_frame = playhead;
}
panel_viewer->ui->currentTimecode->setText(frame_to_timecode(playhead));
}
void Timeline::redraw_all_clips() {
@@ -170,6 +185,8 @@ void Timeline::redraw_all_clips() {
ui->video_area->redraw_clips();
ui->audio_area->redraw_clips();
ui->headers->update();
panel_viewer->ui->endTimecode->setText(frame_to_timecode(sequence->getEndFrame()));
}
void Timeline::select_all() {
@@ -225,13 +242,23 @@ void Timeline::delete_selection(bool ripple_delete) {
}
}
int lerp(int a, int b, float t) {
return ((1.0f - t) * a) + (t * b);
}
void Timeline::set_zoom(bool in) {
if (in) {
zoom *= 2;
} else {
zoom /= 2;
}
ui->timeline_area->horizontalScrollBar()->setValue(getScreenPointFromFrame(playhead) - (ui->timeline_area->width()/2));
ui->timeline_area->horizontalScrollBar()->setValue(
lerp(
ui->timeline_area->horizontalScrollBar()->value(),
getScreenPointFromFrame(playhead) - (ui->timeline_area->width()/2),
0.99f
)
);
redraw_all_clips();
}
+2 -1
View File
@@ -24,6 +24,7 @@ public:
ViewerWidget* viewer_widget;
Ui::Viewer *ui;
private slots:
void on_pushButton_clicked();
@@ -36,7 +37,7 @@ private slots:
void on_pushButton_3_clicked();
private:
Ui::Viewer *ui;
};
#endif // VIEWER_H
+14
View File
@@ -79,6 +79,13 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="currentTimecode">
<property name="text">
<string>00:00:00;00</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@@ -285,6 +292,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="endTimecode">
<property name="text">
<string>00:00:00;00</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>