work started on media viewer panel

This commit is contained in:
itsmattkc
2018-10-14 20:16:33 +11:00
parent 21165b6e8e
commit 3c69c69ccd
7 changed files with 86 additions and 84 deletions
+7 -17
View File
@@ -55,7 +55,6 @@ Timeline::Timeline(QWidget *parent) :
trim_in_point(false),
splitting(false),
importing(false),
zoomChanged(false),
ui(new Ui::Timeline),
last_frame(0),
creating(false),
@@ -315,15 +314,7 @@ void Timeline::repaint_timeline(bool changed) {
panel_sequence_viewer->viewer_widget->update();
ui->audio_monitor->update();
last_frame = sequence->playhead;
}
if (zoomChanged) {
zoomChanged = false;
int target_scroll = getScreenPointFromFrame(zoom, sequence->playhead)-(ui->editAreas->width()>>1);
// TODO find a way to gradually move towards target_scroll instead of just setting it?
ui->horizontalScrollBar->setValue(target_scroll);
}
}
panel_sequence_viewer->update_playhead_timecode(sequence->playhead);
@@ -488,14 +479,13 @@ int lerp(int a, int b, double t) {
}
void Timeline::set_zoom(bool in) {
if (in) {
zoom *= 2;
} else {
zoom /= 2;
}
zoom *= (in) ? 2 : 0.5;
ui->headers->update_zoom(zoom);
zoomChanged = true;
repaint_timeline(false);
repaint_timeline(false);
// TODO find a way to gradually move towards target_scroll instead of just setting it?
int target_scroll = getScreenPointFromFrame(zoom, sequence->playhead)-(ui->editAreas->width()>>1);
ui->horizontalScrollBar->setValue(target_scroll);
}
void Timeline::decheck_tool_buttons(QObject* sender) {
+1 -4
View File
@@ -173,10 +173,7 @@ public:
QVector<int> split_cache;
// importing
bool importing;
// zoom variables
bool zoomChanged;
bool importing;
// creating variables
bool creating;
+61 -49
View File
@@ -11,6 +11,8 @@
#define FRAMES_IN_ONE_MINUTE 1798 // 1800 - 2
#define FRAMES_IN_TEN_MINUTES 17978 // (FRAMES_IN_ONE_MINUTE * 10) - 2
QString panel_name = "Viewer: ";
extern "C" {
#include <libavcodec/avcodec.h>
}
@@ -19,13 +21,14 @@ extern "C" {
Viewer::Viewer(QWidget *parent) :
QDockWidget(parent),
ui(new Ui::Viewer)
ui(new Ui::Viewer),
seq(NULL)
{
ui->setupUi(this);
ui->headers->show_text(false);
ui->glViewerPane->child = ui->openGLWidget;
viewer_widget = ui->openGLWidget;
update_media(MEDIA_TYPE_SEQUENCE, NULL);
set_media(MEDIA_TYPE_SEQUENCE, NULL);
ui->currentTimecode->setEnabled(false);
ui->currentTimecode->set_default_value(qSNaN());
@@ -38,7 +41,11 @@ Viewer::Viewer(QWidget *parent) :
}
Viewer::~Viewer() {
delete ui;
delete ui;
}
void Viewer::set_main_sequence() {
set_sequence(true, sequence);
}
QString frame_to_timecode(long f, int view, double frame_rate) {
@@ -113,80 +120,85 @@ void Viewer::update_playhead_timecode(long p) {
}
void Viewer::update_end_timecode() {
ui->endTimecode->setText((sequence == NULL) ? frame_to_timecode(0, config.timecode_view, 30) : frame_to_timecode(sequence->getEndFrame(), config.timecode_view, sequence->frame_rate));
ui->endTimecode->setText((seq == NULL) ? frame_to_timecode(0, config.timecode_view, 30) : frame_to_timecode(seq->getEndFrame(), config.timecode_view, seq->frame_rate));
}
void Viewer::update_media(int type, void* media) {
void Viewer::set_media(int type, void* media) {
switch (type) {
case MEDIA_TYPE_FOOTAGE:
{
}
break;
case MEDIA_TYPE_SEQUENCE:
{
Sequence* s = static_cast<Sequence*>(media);
bool null_sequence = (s == NULL);
ui->currentTimecode->setEnabled(!null_sequence);
ui->openGLWidget->setEnabled(!null_sequence);
ui->openGLWidget->setVisible(!null_sequence);
ui->pushButton->setEnabled(!null_sequence);
ui->pushButton_2->setEnabled(!null_sequence);
ui->pushButton_3->setEnabled(!null_sequence);
ui->pushButton_4->setEnabled(!null_sequence);
ui->pushButton_5->setEnabled(!null_sequence);
init_audio();
if (!null_sequence) {
config.timecode_view = (frame_rate_is_droppable(s->frame_rate)) ? TIMECODE_DROP : TIMECODE_NONDROP;
update_playhead_timecode(s->playhead);
update_end_timecode();
ui->glViewerPane->aspect_ratio = (float) s->width / (float) s->height;
ui->glViewerPane->adjust();
} else {
update_playhead_timecode(0);
update_end_timecode();
}
viewer_widget->update();
update();
}
set_sequence(false, static_cast<Sequence*>(media));
break;
}
}
void Viewer::on_pushButton_clicked()
{
void Viewer::on_pushButton_clicked() {
panel_timeline->go_to_start();
}
void Viewer::on_pushButton_5_clicked()
{
void Viewer::on_pushButton_5_clicked() {
panel_timeline->go_to_end();
}
void Viewer::on_pushButton_2_clicked()
{
void Viewer::on_pushButton_2_clicked() {
panel_timeline->previous_frame();
}
void Viewer::on_pushButton_4_clicked()
{
void Viewer::on_pushButton_4_clicked() {
panel_timeline->next_frame();
}
void Viewer::on_pushButton_3_clicked()
{
void Viewer::on_pushButton_3_clicked() {
panel_timeline->toggle_play();
}
void Viewer::update_playhead() {
panel_timeline->seek(ui->currentTimecode->value());
panel_timeline->seek(ui->currentTimecode->value());
}
void Viewer::set_sequence(bool main, Sequence *s) {
main_sequence = main;
seq = (main) ? sequence : s;
viewer_widget->display_sequence = seq;
bool null_sequence = (seq == NULL);
ui->headers->setEnabled(!null_sequence);
ui->currentTimecode->setEnabled(!null_sequence);
ui->openGLWidget->setEnabled(!null_sequence);
ui->openGLWidget->setVisible(!null_sequence);
ui->pushButton->setEnabled(!null_sequence);
ui->pushButton_2->setEnabled(!null_sequence);
ui->pushButton_3->setEnabled(!null_sequence);
ui->pushButton_4->setEnabled(!null_sequence);
ui->pushButton_5->setEnabled(!null_sequence);
init_audio();
if (!null_sequence) {
config.timecode_view = (frame_rate_is_droppable(seq->frame_rate)) ? TIMECODE_DROP : TIMECODE_NONDROP;
update_playhead_timecode(seq->playhead);
update_end_timecode();
ui->glViewerPane->aspect_ratio = (float) seq->width / (float) seq->height;
ui->glViewerPane->adjust();
setWindowTitle(panel_name + seq->name);
} else {
update_playhead_timecode(0);
update_end_timecode();
setWindowTitle(panel_name + "(none)");
}
viewer_widget->update();
update();
}
void Viewer::set_playpause_icon(bool play) {
+8 -7
View File
@@ -21,7 +21,9 @@ class Viewer : public QDockWidget
public:
explicit Viewer(QWidget *parent = 0);
~Viewer();
void update_media(int type, void* media);
void set_main_sequence();
void set_media(int type, void* media);
void compose();
void set_playpause_icon(bool play);
void update_playhead_timecode(long p);
@@ -32,16 +34,15 @@ public:
Ui::Viewer *ui;
private slots:
void on_pushButton_clicked();
void on_pushButton_5_clicked();
void on_pushButton_5_clicked();
void on_pushButton_2_clicked();
void on_pushButton_4_clicked();
void on_pushButton_3_clicked();
void update_playhead();
private:
void set_sequence(bool main, Sequence* s);
bool main_sequence;
Sequence* seq;
};
#endif // VIEWER_H
+1 -1
View File
@@ -397,7 +397,7 @@ void set_sequence(Sequence* s) {
panel_effect_controls->clear_effects(true);
sequence = s;
panel_timeline->update_sequence();
panel_sequence_viewer->update_media(MEDIA_TYPE_SEQUENCE, sequence);
panel_sequence_viewer->set_main_sequence();
panel_timeline->setFocus();
}
+7 -6
View File
@@ -29,7 +29,8 @@ extern "C" {
ViewerWidget::ViewerWidget(QWidget *parent) :
QOpenGLWidget(parent),
rendering(false),
default_fbo(NULL)
default_fbo(NULL),
display_sequence(NULL)
{
QSurfaceFormat format;
format.setDepthBufferSize(24);
@@ -43,7 +44,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
void ViewerWidget::deleteFunction() {
// destroy all textures as well
makeCurrent();
closeActiveClips(sequence, true);
closeActiveClips(display_sequence, true);
doneCurrent();
}
@@ -164,8 +165,8 @@ GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture) {
}
GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) {
Sequence* s = sequence;
long playhead = sequence->playhead;
Sequence* s = display_sequence;
long playhead = display_sequence->playhead;
if (nest != NULL) {
s = static_cast<Sequence*>(nest->media);
@@ -323,7 +324,7 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) {
for (int j=0;j<c->effects.size();j++) {
Effect* e = c->effects.at(j);
if (e->is_enabled()) {
double timecode = ((double)(sequence->playhead-c->timeline_in+c->clip_in)/(double)sequence->frame_rate);
double timecode = ((double)(playhead-c->timeline_in+c->clip_in)/(double)c->sequence->frame_rate);
if (e->enable_coords) {
e->process_coords(timecode, coords);
}
@@ -415,7 +416,7 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) {
}
// visually update all the keyframe values
double ts = (playhead - c->timeline_in + c->clip_in)/sequence->frame_rate;
double ts = (playhead - c->timeline_in + c->clip_in)/s->frame_rate;
for (int i=0;i<c->effects.size();i++) {
Effect* e = c->effects.at(i);
for (int j=0;j<e->row_count();j++) {
+1
View File
@@ -22,6 +22,7 @@ public:
bool rendering;
void paintGL();
void initializeGL();
Sequence* display_sequence;
QOpenGLFramebufferObject* default_fbo;
protected: