added proper timecodes in the timeline
This commit is contained in:
+10
-3
@@ -17,7 +17,8 @@ Config::Config()
|
||||
select_also_seeks(false),
|
||||
paste_seeks(true),
|
||||
rectified_waveforms(false),
|
||||
default_transition_length(30)
|
||||
default_transition_length(30),
|
||||
timecode_view(TIMECODE_DROP)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -55,10 +56,15 @@ void Config::load(QString path) {
|
||||
stream.readNext();
|
||||
img_seq_formats = stream.text().toString();
|
||||
} else if (stream.name() == "RectifiedWaveforms") {
|
||||
stream.readNext();
|
||||
rectified_waveforms = (stream.text() == "1");
|
||||
} else if (stream.name() == "DefaultTransitionLength") {
|
||||
rectified_waveforms = stream.text().toInt();
|
||||
}
|
||||
stream.readNext();
|
||||
default_transition_length = stream.text().toInt();
|
||||
} else if (stream.name() == "TimecodeView") {
|
||||
stream.readNext();
|
||||
timecode_view = stream.text().toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stream.hasError()) {
|
||||
@@ -114,6 +120,7 @@ void Config::save(QString path) {
|
||||
stream.writeTextElement("ImageSequenceFormats", img_seq_formats);
|
||||
stream.writeTextElement("RectifiedWaveforms", QString::number(rectified_waveforms));
|
||||
stream.writeTextElement("DefaultTransitionLength", QString::number(default_transition_length));
|
||||
stream.writeTextElement("TimecodeView", QString::number(timecode_view));
|
||||
|
||||
stream.writeEndElement();
|
||||
stream.writeEndDocument(); // doc
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
#define SAVE_VERSION "180820" // YYMMDD
|
||||
|
||||
#define TIMECODE_DROP 0
|
||||
#define TIMECODE_NONDROP 1
|
||||
#define TIMECODE_FRAMES 2
|
||||
|
||||
struct Config {
|
||||
Config();
|
||||
bool saved_layout;
|
||||
@@ -17,6 +21,7 @@ struct Config {
|
||||
QString img_seq_formats;
|
||||
bool rectified_waveforms;
|
||||
int default_transition_length;
|
||||
int timecode_view;
|
||||
|
||||
void load(QString path);
|
||||
void save(QString path);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "media.h"
|
||||
#include "panels/viewer.h"
|
||||
#include "io/config.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
@@ -90,7 +91,7 @@ void PreviewGenerator::finalize_media() {
|
||||
if (!contains_still_image || media->audio_tracks.size() > 0) {
|
||||
double frame_rate = 30;
|
||||
if (!contains_still_image && media->video_tracks.size() > 0) frame_rate = media->video_tracks.at(0)->video_frame_rate;
|
||||
item->setText(1, frame_to_timecode(media->get_length_in_frames(frame_rate), TIMECODE_DROP, frame_rate));
|
||||
item->setText(1, frame_to_timecode(media->get_length_in_frames(frame_rate), config.timecode_view, frame_rate));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -39,7 +39,7 @@
|
||||
|
||||
QTimer autorecovery_timer;
|
||||
QString config_dir;
|
||||
QString appName = "Olive (August 2018 | Alpha)";
|
||||
QString appName = "Olive (September 2018 | Alpha)";
|
||||
bool demoNoticeShown = false;
|
||||
|
||||
void MainWindow::setup_layout() {
|
||||
@@ -538,15 +538,15 @@ void MainWindow::windowMenu_About_To_Be_Shown() {
|
||||
|
||||
void MainWindow::viewMenu_About_To_Be_Shown() {
|
||||
ui->actionTimeline_Track_Lines->setChecked(config.show_track_lines);
|
||||
ui->actionFrames->setChecked(panel_viewer->timecode_view == TIMECODE_FRAMES);
|
||||
ui->actionDrop_Frame->setChecked(panel_viewer->timecode_view == TIMECODE_DROP);
|
||||
if (sequence != NULL) ui->actionDrop_Frame->setEnabled(frame_rate_is_droppable(sequence->frame_rate));
|
||||
ui->actionNon_Drop_Frame->setChecked(panel_viewer->timecode_view == TIMECODE_NONDROP);
|
||||
ui->actionFrames->setChecked(config.timecode_view == TIMECODE_FRAMES);
|
||||
ui->actionDrop_Frame->setChecked(config.timecode_view == TIMECODE_DROP);
|
||||
// if (sequence != NULL) ui->actionDrop_Frame->setEnabled(frame_rate_is_droppable(sequence->frame_rate));
|
||||
ui->actionNon_Drop_Frame->setChecked(config.timecode_view == TIMECODE_NONDROP);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionFrames_triggered()
|
||||
{
|
||||
panel_viewer->timecode_view = TIMECODE_FRAMES;
|
||||
config.timecode_view = TIMECODE_FRAMES;
|
||||
if (sequence != NULL) {
|
||||
panel_viewer->update_playhead_timecode(panel_timeline->playhead);
|
||||
panel_viewer->update_end_timecode();
|
||||
@@ -555,7 +555,7 @@ void MainWindow::on_actionFrames_triggered()
|
||||
|
||||
void MainWindow::on_actionDrop_Frame_triggered()
|
||||
{
|
||||
panel_viewer->timecode_view = TIMECODE_DROP;
|
||||
config.timecode_view = TIMECODE_DROP;
|
||||
if (sequence != NULL) {
|
||||
panel_viewer->update_playhead_timecode(panel_timeline->playhead);
|
||||
panel_viewer->update_end_timecode();
|
||||
@@ -564,7 +564,7 @@ void MainWindow::on_actionDrop_Frame_triggered()
|
||||
|
||||
void MainWindow::on_actionNon_Drop_Frame_triggered()
|
||||
{
|
||||
panel_viewer->timecode_view = TIMECODE_NONDROP;
|
||||
config.timecode_view = TIMECODE_NONDROP;
|
||||
if (sequence != NULL) {
|
||||
panel_viewer->update_playhead_timecode(panel_timeline->playhead);
|
||||
panel_viewer->update_end_timecode();
|
||||
|
||||
+3
-2
@@ -82,6 +82,7 @@ Timeline::Timeline(QWidget *parent) :
|
||||
int timeline_area_height = (ui->timeline_area->height()>>1);
|
||||
ui->videoScrollArea->resize(ui->videoScrollArea->width(), timeline_area_height);
|
||||
ui->audioScrollArea->resize(ui->audioScrollArea->width(), timeline_area_height);
|
||||
ui->headerScrollArea->setMaximumHeight(ui->headers->minimumHeight());
|
||||
connect(ui->audioScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)), ui->videoScrollArea->horizontalScrollBar(), SLOT(setValue(int)));
|
||||
connect(ui->audioScrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)), ui->headerScrollArea->horizontalScrollBar(), SLOT(setValue(int)));
|
||||
|
||||
@@ -1095,7 +1096,7 @@ void Timeline::deselect() {
|
||||
}
|
||||
|
||||
long getFrameFromScreenPoint(double zoom, int x) {
|
||||
long f = round((float) x / zoom);
|
||||
long f = qRound((float) x / zoom);
|
||||
if (f < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1103,7 +1104,7 @@ long getFrameFromScreenPoint(double zoom, int x) {
|
||||
}
|
||||
|
||||
int getScreenPointFromFrame(double zoom, long frame) {
|
||||
return (int) round(frame*zoom);
|
||||
return (int) qRound(frame*zoom);
|
||||
}
|
||||
|
||||
long Timeline::getTimelineFrameFromScreenPoint(int x) {
|
||||
|
||||
+9
-26
@@ -304,17 +304,11 @@
|
||||
<item>
|
||||
<widget class="QScrollArea" name="headerScrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
@@ -327,18 +321,13 @@
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>821</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -369,12 +358,6 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
@@ -389,7 +372,7 @@
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
@@ -422,8 +405,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>807</width>
|
||||
<height>163</height>
|
||||
<width>817</width>
|
||||
<height>174</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@@ -473,8 +456,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>807</width>
|
||||
<height>377</height>
|
||||
<width>817</width>
|
||||
<height>339</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
|
||||
+6
-6
@@ -5,6 +5,7 @@
|
||||
#include "timeline.h"
|
||||
#include "project/sequence.h"
|
||||
#include "panels/panels.h"
|
||||
#include "io/config.h"
|
||||
|
||||
#define FRAMES_IN_ONE_MINUTE 1798 // 1800 - 2
|
||||
#define FRAMES_IN_TEN_MINUTES 17978 // (FRAMES_IN_ONE_MINUTE * 10) - 2
|
||||
@@ -22,7 +23,6 @@ Viewer::Viewer(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
ui->glViewerPane->child = ui->openGLWidget;
|
||||
viewer_widget = ui->openGLWidget;
|
||||
timecode_view = TIMECODE_DROP;
|
||||
update_sequence();
|
||||
|
||||
update_playhead_timecode(0);
|
||||
@@ -99,14 +99,14 @@ bool frame_rate_is_droppable(float rate) {
|
||||
}
|
||||
|
||||
void Viewer::update_playhead_timecode(long p) {
|
||||
ui->currentTimecode->setText(frame_to_timecode(p, timecode_view, (sequence != NULL) ? sequence->frame_rate : 30));
|
||||
ui->currentTimecode->setText(frame_to_timecode(p, config.timecode_view, (sequence != NULL) ? sequence->frame_rate : 30));
|
||||
}
|
||||
|
||||
void Viewer::update_end_timecode() {
|
||||
if (sequence == NULL) {
|
||||
ui->endTimecode->setText(frame_to_timecode(0, timecode_view, 30));
|
||||
ui->endTimecode->setText(frame_to_timecode(0, config.timecode_view, 30));
|
||||
} else {
|
||||
ui->endTimecode->setText(frame_to_timecode(sequence->getEndFrame(), timecode_view, sequence->frame_rate));
|
||||
ui->endTimecode->setText(frame_to_timecode(sequence->getEndFrame(), config.timecode_view, sequence->frame_rate));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,9 +125,9 @@ void Viewer::update_sequence() {
|
||||
|
||||
if (!null_sequence) {
|
||||
if (frame_rate_is_droppable(sequence->frame_rate)) {
|
||||
timecode_view = TIMECODE_DROP;
|
||||
config.timecode_view = TIMECODE_DROP;
|
||||
} else {
|
||||
timecode_view = TIMECODE_NONDROP;
|
||||
config.timecode_view = TIMECODE_NONDROP;
|
||||
}
|
||||
|
||||
update_playhead_timecode(panel_timeline->playhead);
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#ifndef VIEWER_H
|
||||
#define VIEWER_H
|
||||
|
||||
#define TIMECODE_DROP 0
|
||||
#define TIMECODE_NONDROP 1
|
||||
#define TIMECODE_FRAMES 2
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
class Timeline;
|
||||
@@ -28,7 +24,6 @@ public:
|
||||
void update_sequence();
|
||||
void compose();
|
||||
void set_playpause_icon(bool play);
|
||||
int timecode_view;
|
||||
void update_playhead_timecode(long p);
|
||||
void update_end_timecode();
|
||||
|
||||
|
||||
+59
-18
@@ -4,17 +4,22 @@
|
||||
#include "panels/timeline.h"
|
||||
#include "project/sequence.h"
|
||||
#include "project/undo.h"
|
||||
#include "panels/viewer.h"
|
||||
#include "io/config.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QScrollArea>
|
||||
#include <QtMath>
|
||||
|
||||
#define CLICK_RANGE 5
|
||||
#define PLAYHEAD_SIZE 6
|
||||
|
||||
TimelineHeader::TimelineHeader(QWidget *parent) : QWidget(parent), dragging(false), resizing_workarea(false), zoom(1), in_visible(0), snapping(true) {
|
||||
TimelineHeader::TimelineHeader(QWidget *parent) : QWidget(parent), dragging(false), resizing_workarea(false), zoom(1), in_visible(0), snapping(true), fm(font()) {
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setMouseTracking(true);
|
||||
setMinimumHeight(fm.height()*2);
|
||||
}
|
||||
|
||||
void TimelineHeader::set_playhead(int mouse_x) {
|
||||
@@ -121,22 +126,58 @@ void TimelineHeader::update_header(double z) {
|
||||
update();
|
||||
}
|
||||
|
||||
#define LINE_MIN_PADDING 50
|
||||
|
||||
void TimelineHeader::paintEvent(QPaintEvent*) {
|
||||
if (sequence != NULL) {
|
||||
QPainter p(this);
|
||||
p.setPen(Qt::gray);
|
||||
int interval = 0;
|
||||
int multiplier = 0;
|
||||
do {
|
||||
multiplier++;
|
||||
interval = getScreenPointFromFrame(zoom, 1*multiplier);
|
||||
} while (interval < 10);
|
||||
for (int i=0;i<width();i+=interval) {
|
||||
int drawHeight = height();
|
||||
if (i%5 > 0) {
|
||||
drawHeight = drawHeight>>1;
|
||||
}
|
||||
p.drawLine(i, 0, i, drawHeight);
|
||||
int yoff = height()/2;
|
||||
|
||||
double interval = sequence->frame_rate;
|
||||
int textWidth = 0;
|
||||
int lastTextBoundary = 0;
|
||||
|
||||
int i = 0;
|
||||
int lastLineX = -LINE_MIN_PADDING-1;
|
||||
|
||||
int sublineCount = 1;
|
||||
int sublineTest = qRound(interval*zoom);
|
||||
int sublineInterval = 1;
|
||||
while (sublineTest > LINE_MIN_PADDING
|
||||
&& sublineInterval >= 1) {
|
||||
sublineCount *= 2;
|
||||
sublineInterval = (interval/sublineCount);
|
||||
sublineTest = qRound(sublineInterval*zoom);
|
||||
}
|
||||
sublineCount = qMin(sublineCount, qRound(interval));
|
||||
|
||||
while (true) {
|
||||
long frame = qRound(interval*i);
|
||||
int lineX = qRound(frame*zoom);
|
||||
if (lineX > width()) break;
|
||||
if (lineX > lastLineX+LINE_MIN_PADDING) {
|
||||
// draw text
|
||||
if (lineX-textWidth > lastTextBoundary) {
|
||||
p.setPen(Qt::white);
|
||||
QString timecode = frame_to_timecode(frame, config.timecode_view, sequence->frame_rate);
|
||||
textWidth = fm.width(timecode)>>1;
|
||||
lastTextBoundary = lineX+textWidth;
|
||||
p.drawText(QRect(lineX-textWidth, 0, lastTextBoundary, yoff), timecode);
|
||||
}
|
||||
|
||||
// draw line markers
|
||||
p.setPen(Qt::gray);
|
||||
p.drawLine(lineX, yoff, lineX, height());
|
||||
|
||||
lastLineX = lineX;
|
||||
|
||||
// draw sub-line markers
|
||||
for (int j=1;j<sublineCount;j++) {
|
||||
int sublineX = lineX+(qRound(j*interval/sublineCount)*zoom);
|
||||
p.drawLine(sublineX, yoff, sublineX, yoff+(yoff>>1));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// draw in/out selection
|
||||
@@ -151,12 +192,12 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
|
||||
}
|
||||
|
||||
// draw playhead triangle
|
||||
in_x = getScreenPointFromFrame(zoom, panel_timeline->playhead - in_visible);
|
||||
QPoint start(in_x, height());
|
||||
in_x = getScreenPointFromFrame(zoom, panel_timeline->playhead - in_visible);
|
||||
QPoint start(in_x, height()+2);
|
||||
QPainterPath path;
|
||||
path.moveTo(start);
|
||||
path.lineTo(in_x-PLAYHEAD_SIZE, 0);
|
||||
path.lineTo(in_x+PLAYHEAD_SIZE, 0);
|
||||
path.lineTo(in_x-PLAYHEAD_SIZE, yoff);
|
||||
path.lineTo(in_x+PLAYHEAD_SIZE, yoff);
|
||||
path.lineTo(start);
|
||||
p.fillPath(path, Qt::red);
|
||||
}
|
||||
|
||||
+5
-1
@@ -2,6 +2,8 @@
|
||||
#define TIMELINEHEADER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFontMetrics>
|
||||
class QScrollArea;
|
||||
|
||||
class TimelineHeader : public QWidget
|
||||
{
|
||||
@@ -13,7 +15,7 @@ public:
|
||||
|
||||
bool snapping;
|
||||
|
||||
void update_header(double z);
|
||||
void update_header(double z);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
@@ -36,6 +38,8 @@ private:
|
||||
|
||||
void set_playhead(int mouse_x);
|
||||
|
||||
QFontMetrics fm;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
Reference in New Issue
Block a user