First commit of brand new rewrite
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
#include "effectcontrols.h"
|
||||
#include "ui_effectcontrols.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "effects/effects.h"
|
||||
#include "project/clip.h"
|
||||
#include "project/effect.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
|
||||
|
||||
EffectControls::EffectControls(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::EffectControls)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
init_effects();
|
||||
|
||||
clip = NULL;
|
||||
set_clip(NULL);
|
||||
}
|
||||
|
||||
EffectControls::~EffectControls()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EffectControls::on_pushButton_clicked()
|
||||
{
|
||||
QMenu effects_menu(this);
|
||||
for (int i=0;i<video_effect_names.size();i++) {
|
||||
effects_menu.addAction(video_effect_names.at(i));
|
||||
}
|
||||
effects_menu.addSeparator();
|
||||
for (int i=0;i<audio_effect_names.size();i++) {
|
||||
effects_menu.addAction(audio_effect_names.at(i));
|
||||
}
|
||||
effects_menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void EffectControls::set_clip(Clip* c) {
|
||||
// clear ui->scrollAreaWidgetContents
|
||||
if (clip != NULL) {
|
||||
for (int i=0;i<clip->effects.size();i++) {
|
||||
clip->effects.at(i)->container->setParent(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
ui->pushButton->setEnabled(c != NULL);
|
||||
if (c != NULL) {
|
||||
for (int i=0;i<c->effects.size();i++) {
|
||||
static_cast<QVBoxLayout*>(ui->scrollAreaWidgetContents->layout())->insertWidget(i, c->effects.at(i)->container);
|
||||
}
|
||||
}
|
||||
clip = c;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef EFFECTCONTROLS_H
|
||||
#define EFFECTCONTROLS_H
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
struct Clip;
|
||||
|
||||
namespace Ui {
|
||||
class EffectControls;
|
||||
}
|
||||
|
||||
class EffectControls : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EffectControls(QWidget *parent = 0);
|
||||
~EffectControls();
|
||||
void set_clip(Clip* c);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::EffectControls *ui;
|
||||
Clip* clip;
|
||||
};
|
||||
|
||||
#endif // EFFECTCONTROLS_H
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EffectControls</class>
|
||||
<widget class="QDockWidget" name="EffectControls">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::AllDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Effect Controls</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>398</width>
|
||||
<height>253</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>[+] Add Effect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "panels.h"
|
||||
|
||||
Project* panel_project;
|
||||
EffectControls* panel_effect_controls;
|
||||
Viewer* panel_viewer;
|
||||
Timeline* panel_timeline;
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef PANELS_H
|
||||
#define PANELS_H
|
||||
|
||||
class Project;
|
||||
class EffectControls;
|
||||
class Viewer;
|
||||
class Timeline;
|
||||
|
||||
extern Project* panel_project;
|
||||
extern EffectControls* panel_effect_controls;
|
||||
extern Viewer* panel_viewer;
|
||||
extern Timeline* panel_timeline;
|
||||
|
||||
#endif // PANELS_H
|
||||
@@ -0,0 +1,164 @@
|
||||
#include "project.h"
|
||||
#include "ui_project.h"
|
||||
#include "io/media.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
#include <QCharRef>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "panels/timeline.h"
|
||||
#include "project/sequence.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
Project::Project(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::Project)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
Project::~Project()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString Project::get_next_sequence_name() {
|
||||
int n = 1;
|
||||
bool found = true;
|
||||
QString name;
|
||||
while (found) {
|
||||
found = false;
|
||||
name = "Sequence ";
|
||||
if (n < 10) {
|
||||
name += "0";
|
||||
}
|
||||
name += QString::number(n);
|
||||
for (int i=0;i<ui->treeWidget->topLevelItemCount();i++) {
|
||||
if (QString::compare(ui->treeWidget->topLevelItem(i)->text(0), name, Qt::CaseInsensitive) == 0) {
|
||||
found = true;
|
||||
n++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
void Project::new_sequence(Sequence *s) {
|
||||
Media* m = new Media();
|
||||
m->is_sequence = true;
|
||||
m->sequence = s;
|
||||
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
item->setText(0, s->name);
|
||||
item->setData(0, Qt::UserRole + 1, QVariant::fromValue(reinterpret_cast<quintptr>(m)));
|
||||
|
||||
ui->treeWidget->addTopLevelItem(item);
|
||||
source_table = ui->treeWidget;
|
||||
}
|
||||
|
||||
void Project::import_dialog() {
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, "Import media...", "", "All Files (*.*)");
|
||||
for (int i=0;i<files.count();i++) {
|
||||
QString file(files.at(i));
|
||||
char* filename = NULL;
|
||||
|
||||
// heuristic to determine whether file is part of an image sequence
|
||||
int lastcharindex = file.lastIndexOf(".")-1;
|
||||
if (file[lastcharindex].isDigit()) {
|
||||
bool is_img_sequence = false;
|
||||
QString sequence_test(file);
|
||||
char lastchar = sequence_test.at(lastcharindex).toLatin1();
|
||||
|
||||
sequence_test[lastcharindex] = lastchar + 1;
|
||||
if (QFileInfo::exists(sequence_test)) is_img_sequence = true;
|
||||
|
||||
sequence_test[lastcharindex] = lastchar - 1;
|
||||
if (QFileInfo::exists(sequence_test)) is_img_sequence = true;
|
||||
|
||||
if (is_img_sequence &&
|
||||
QMessageBox::question(this, "Image sequence detected", "The file '" + file + "' appears to be part of an image sequence. Would you like to import it as such?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
|
||||
// change url to an image sequence instead
|
||||
int digit_count = 0;
|
||||
QString ext = file.mid(lastcharindex+1);
|
||||
while (file[lastcharindex].isDigit()) {
|
||||
digit_count++;
|
||||
lastcharindex--;
|
||||
}
|
||||
QString new_filename = file.left(lastcharindex+1) + "%";
|
||||
if (digit_count < 10) {
|
||||
new_filename += "0";
|
||||
}
|
||||
new_filename += QString::number(digit_count) + "d" + ext;
|
||||
file = new_filename;
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray ba = file.toLatin1();
|
||||
filename = new char[ba.size()+1];
|
||||
strcpy(filename, ba.data());
|
||||
|
||||
AVFormatContext* pFormatCtx = NULL;
|
||||
int errCode = avformat_open_input(&pFormatCtx, filename, NULL, NULL);
|
||||
if(errCode != 0) {
|
||||
char err[1024];
|
||||
av_strerror(errCode, err, 1024);
|
||||
qDebug() << "[ERROR] Could not open" << filename << "-" << err;
|
||||
} else {
|
||||
errCode = avformat_find_stream_info(pFormatCtx, NULL);
|
||||
if (errCode < 0) {
|
||||
char err[1024];
|
||||
av_strerror(errCode, err, 1024);
|
||||
fprintf(stderr, "[ERROR] Could not find stream information. %s\n", err);
|
||||
} else {
|
||||
av_dump_format(pFormatCtx, 0, filename, 0);
|
||||
|
||||
Media* m = new Media();
|
||||
m->is_sequence = false;
|
||||
m->url = file;
|
||||
|
||||
// detect video/audio streams in file
|
||||
for (int i=0;i<(int)pFormatCtx->nb_streams;i++) {
|
||||
// Find the decoder for the video stream
|
||||
if (avcodec_find_decoder(pFormatCtx->streams[i]->codecpar->codec_id) == NULL) {
|
||||
qDebug() << "[ERROR] Unsupported codec in stream %d.\n";
|
||||
} else {
|
||||
if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
qDebug() << "[WARNING] INFINITE_LENGTH calculation is inaccurate in this build\n";
|
||||
// TODO BETTER infinite length calculator
|
||||
bool infinite_length = (pFormatCtx->streams[i]->nb_frames == 0);
|
||||
// bool infinite_length = false;
|
||||
|
||||
m->video_tracks.append({i, pFormatCtx->streams[i]->codecpar->width, pFormatCtx->streams[i]->codecpar->height, infinite_length});
|
||||
} else if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
m->audio_tracks.append({i, 0, 0, false});
|
||||
}
|
||||
}
|
||||
}
|
||||
m->name = files.at(i).mid(files.at(i).lastIndexOf('/')+1);
|
||||
m->length = pFormatCtx->duration;
|
||||
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
if (m->video_tracks.size() == 0) {
|
||||
item->setIcon(0, QIcon(":/icons/audiosource.png"));
|
||||
} else {
|
||||
item->setIcon(0, QIcon(":/icons/videosource.png"));
|
||||
}
|
||||
item->setText(0, m->name);
|
||||
item->setText(1, QString::number(m->length));
|
||||
item->setData(0, Qt::UserRole + 1, QVariant::fromValue(reinterpret_cast<quintptr>(m)));
|
||||
|
||||
ui->treeWidget->addTopLevelItem(item);
|
||||
}
|
||||
}
|
||||
avformat_close_input(&pFormatCtx);
|
||||
delete [] filename;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef PROJECT_H
|
||||
#define PROJECT_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QVector>
|
||||
|
||||
struct Media;
|
||||
struct Sequence;
|
||||
class Timeline;
|
||||
class Viewer;
|
||||
class SourceTable;
|
||||
|
||||
namespace Ui {
|
||||
class Project;
|
||||
}
|
||||
|
||||
class Project : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Project(QWidget *parent = 0);
|
||||
~Project();
|
||||
void import_dialog();
|
||||
void new_sequence(Sequence* s);
|
||||
QString get_next_sequence_name();
|
||||
|
||||
SourceTable* source_table;
|
||||
|
||||
private:
|
||||
Ui::Project *ui;
|
||||
};
|
||||
|
||||
#endif // PROJECT_H
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Project</class>
|
||||
<widget class="QDockWidget" name="Project">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>504</width>
|
||||
<height>371</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Project</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="SourceTable" name="treeWidget">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::CurrentChanged|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragOnly</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerDefaultSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Duration</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SourceTable</class>
|
||||
<extends>QTreeWidget</extends>
|
||||
<header>ui/sourcetable.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,320 @@
|
||||
#include "timeline.h"
|
||||
#include "ui_timeline.h"
|
||||
|
||||
#include "panels/panels.h"
|
||||
#include "panels/effectcontrols.h"
|
||||
#include "ui/timelinewidget.h"
|
||||
#include "project/sequence.h"
|
||||
#include "project/clip.h"
|
||||
#include "ui/viewerwidget.h"
|
||||
#include "playback/audio.h"
|
||||
#include "panels/viewer.h"
|
||||
#include "playback/cacher.h"
|
||||
#include "playback/playback.h"
|
||||
|
||||
#include <QTime>
|
||||
|
||||
Timeline::Timeline(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::Timeline)
|
||||
{
|
||||
selecting = moving_init = moving_proc = splitting = importing = playing = trim_in = false;
|
||||
last_frame = playhead = 0;
|
||||
trim_target = -1;
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->video_area->bottom_align = true;
|
||||
|
||||
tool_buttons.append(ui->toolArrowButton);
|
||||
tool_buttons.append(ui->toolEditButton);
|
||||
tool_buttons.append(ui->toolRippleButton);
|
||||
tool_buttons.append(ui->toolRazorButton);
|
||||
tool_buttons.append(ui->toolSlipButton);
|
||||
tool_buttons.append(ui->toolRollingButton);
|
||||
|
||||
ui->toolArrowButton->click();
|
||||
|
||||
zoom = 1.0f;
|
||||
|
||||
sequence = NULL;
|
||||
set_sequence(NULL);
|
||||
|
||||
connect(&playback_updater, SIGNAL(timeout()), this, SLOT(repaint_timeline()));
|
||||
}
|
||||
|
||||
Timeline::~Timeline()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Timeline::go_to_start() {
|
||||
seek(0);
|
||||
}
|
||||
|
||||
void Timeline::previous_frame() {
|
||||
seek(playhead-1);
|
||||
}
|
||||
|
||||
void Timeline::next_frame() {
|
||||
seek(playhead+1);
|
||||
}
|
||||
|
||||
void Timeline::seek(long p) {
|
||||
pause();
|
||||
|
||||
// reset all clip audio
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
Clip& c = sequence->get_clip(i);
|
||||
c.reset_audio = true;
|
||||
c.frame_sample_index = 0;
|
||||
}
|
||||
clear_cache(true, true);
|
||||
switch_audio_cache = true;
|
||||
reading_audio_cache_A = false;
|
||||
|
||||
playhead = p;
|
||||
}
|
||||
|
||||
bool Timeline::toggle_play() {
|
||||
if (playing) {
|
||||
pause();
|
||||
} else {
|
||||
play();
|
||||
}
|
||||
return playing;
|
||||
}
|
||||
|
||||
void Timeline::play() {
|
||||
playhead_start = playhead;
|
||||
playback_timer.start();
|
||||
playback_updater.start();
|
||||
playing = true;
|
||||
|
||||
if (switch_audio_cache) {
|
||||
// add something to pre-cache audio
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::pause() {
|
||||
playing = false;
|
||||
}
|
||||
|
||||
void Timeline::go_to_end() {
|
||||
seek(sequence->getEndFrame());
|
||||
}
|
||||
|
||||
void Timeline::set_sequence(Sequence *s) {
|
||||
if (sequence != NULL) {
|
||||
// clean up - close all open clips
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
Clip& c = sequence->get_clip(i);
|
||||
if (c.open) {
|
||||
close_clip(&c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sequence = s;
|
||||
bool null_sequence = (s == NULL);
|
||||
|
||||
for (int i=0;i<tool_buttons.count();i++) {
|
||||
tool_buttons[i]->setEnabled(!null_sequence);
|
||||
}
|
||||
ui->pushButton_4->setEnabled(!null_sequence);
|
||||
ui->pushButton_5->setEnabled(!null_sequence);
|
||||
ui->video_area->setEnabled(!null_sequence);
|
||||
ui->audio_area->setEnabled(!null_sequence);
|
||||
|
||||
if (null_sequence) {
|
||||
setWindowTitle("Timeline: <none>");
|
||||
} else {
|
||||
setWindowTitle("Timeline: " + sequence->name);
|
||||
redraw_all_clips();
|
||||
playback_updater.setInterval(floor(1000 / sequence->frame_rate));
|
||||
}
|
||||
}
|
||||
|
||||
bool Timeline::focused() {
|
||||
return (ui->video_area->hasFocus() || ui->audio_area->hasFocus());
|
||||
}
|
||||
|
||||
void Timeline::repaint_timeline() {
|
||||
if (playing) {
|
||||
playhead = playhead_start + (playback_timer.elapsed() * 0.001 * sequence->frame_rate);
|
||||
}
|
||||
ui->video_area->update();
|
||||
ui->audio_area->update();
|
||||
if (last_frame != playhead) {
|
||||
panel_viewer->viewer_widget->update();
|
||||
last_frame = playhead;
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::redraw_all_clips() {
|
||||
ui->video_area->redraw_clips();
|
||||
ui->audio_area->redraw_clips();
|
||||
}
|
||||
|
||||
void Timeline::select_all() {
|
||||
selections.clear();
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
Clip& c = sequence->get_clip(i);
|
||||
selections.append({c.timeline_in, c.timeline_out, c.track});
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::delete_selection(bool ripple_delete) {
|
||||
if (selections.size() > 0) {
|
||||
panel_effect_controls->set_clip(NULL);
|
||||
|
||||
long ripple_point = selections.at(0).in;
|
||||
long ripple_length = selections.at(0).out - selections.at(0).in;
|
||||
|
||||
for (int i=0;i<selections.size();i++) {
|
||||
const Selection& s = selections.at(i);
|
||||
sequence->delete_area(s.in, s.out, s.track);
|
||||
if (ripple_delete) {
|
||||
if (ripple_point > s.in) ripple_point = s.in;
|
||||
if (ripple_length > s.out - s.in) ripple_length = s.out - s.in;
|
||||
}
|
||||
}
|
||||
selections.clear();
|
||||
|
||||
if (ripple_delete) {
|
||||
long validator;
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
// check every clip after and see if it'll collide
|
||||
// NOTE, we could probably re-use the validation code for the ripple tool here for optimization (since it's technically better code I think)
|
||||
Clip& c = sequence->get_clip(i);
|
||||
if (c.timeline_in >= ripple_point) {
|
||||
for (int j=0;j<sequence->clip_count();j++) {
|
||||
Clip& cc = sequence->get_clip(j);
|
||||
if (cc.timeline_in < ripple_point) {
|
||||
validator = c.timeline_in - ripple_length - cc.timeline_out;
|
||||
if (validator < 0) ripple_length += validator;
|
||||
|
||||
if (ripple_length <= 0) {
|
||||
// we've seen all we need to see here (can't ripple so stop looping)
|
||||
i = j = sequence->clip_count();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ripple_length > 0) ripple(ripple_point, -ripple_length);
|
||||
}
|
||||
|
||||
redraw_all_clips();
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::zoom_in() {
|
||||
zoom *= 2;
|
||||
redraw_all_clips();
|
||||
}
|
||||
|
||||
void Timeline::zoom_out() {
|
||||
zoom /= 2;
|
||||
redraw_all_clips();
|
||||
}
|
||||
|
||||
void Timeline::ripple(long ripple_point, long ripple_length) {
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
Clip& c = sequence->get_clip(i);
|
||||
if (c.timeline_in >= ripple_point) {
|
||||
c.timeline_in += ripple_length;
|
||||
c.timeline_out += ripple_length;
|
||||
}
|
||||
}
|
||||
for (int i=0;i<selections.size();i++) {
|
||||
Selection& s = selections[i];
|
||||
if (s.in >= ripple_point) {
|
||||
s.in += ripple_length;
|
||||
s.out += ripple_length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::decheck_tool_buttons(QObject* sender) {
|
||||
for (int i=0;i<tool_buttons.count();i++) {
|
||||
if (tool_buttons[i] != sender) {
|
||||
tool_buttons[i]->setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::on_toolEditButton_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
decheck_tool_buttons(sender());
|
||||
ui->timeline_area->setCursor(Qt::IBeamCursor);
|
||||
tool = TIMELINE_TOOL_EDIT;
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::on_toolArrowButton_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
decheck_tool_buttons(sender());
|
||||
ui->timeline_area->setCursor(Qt::ArrowCursor);
|
||||
tool = TIMELINE_TOOL_POINTER;
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::on_toolRazorButton_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
decheck_tool_buttons(sender());
|
||||
ui->timeline_area->setCursor(Qt::IBeamCursor);
|
||||
tool = TIMELINE_TOOL_RAZOR;
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::on_pushButton_4_clicked()
|
||||
{
|
||||
zoom_in();
|
||||
}
|
||||
|
||||
void Timeline::on_pushButton_5_clicked()
|
||||
{
|
||||
zoom_out();
|
||||
}
|
||||
|
||||
bool Timeline::is_clip_selected(int clip_index) {
|
||||
Clip& clip = sequence->get_clip(clip_index);
|
||||
for (int i=0;i<selections.size();i++) {
|
||||
const Selection& s = selections.at(i);
|
||||
if (clip.track == s.track && clip.timeline_in >= s.in && clip.timeline_out <= s.out) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Timeline::on_toolRippleButton_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
decheck_tool_buttons(sender());
|
||||
ui->timeline_area->setCursor(Qt::ArrowCursor);
|
||||
tool = TIMELINE_TOOL_RIPPLE;
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::on_toolRollingButton_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
decheck_tool_buttons(sender());
|
||||
ui->timeline_area->setCursor(Qt::ArrowCursor);
|
||||
tool = TIMELINE_TOOL_ROLLING;
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::on_toolSlipButton_toggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
decheck_tool_buttons(sender());
|
||||
ui->timeline_area->setCursor(Qt::ArrowCursor);
|
||||
tool = TIMELINE_TOOL_SLIP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
#ifndef TIMELINE_H
|
||||
#define TIMELINE_H
|
||||
|
||||
#include "ui/timeline-tools.h"
|
||||
#include <QDockWidget>
|
||||
#include <QVector>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
|
||||
class QPushButton;
|
||||
class SourceTable;
|
||||
class ViewerWidget;
|
||||
struct Sequence;
|
||||
struct Clip;
|
||||
struct Media;
|
||||
struct MediaStream;
|
||||
|
||||
struct Ghost {
|
||||
Clip* clip;
|
||||
long in;
|
||||
long out;
|
||||
int track;
|
||||
long clip_in;
|
||||
|
||||
long old_in;
|
||||
long old_out;
|
||||
int old_track;
|
||||
long old_clip_in;
|
||||
|
||||
// importing variables
|
||||
Media* media;
|
||||
MediaStream* media_stream;
|
||||
|
||||
// other variables
|
||||
long ghost_length;
|
||||
long media_length;
|
||||
};
|
||||
|
||||
struct Selection {
|
||||
long in;
|
||||
long out;
|
||||
int track;
|
||||
|
||||
long old_in;
|
||||
long old_out;
|
||||
int old_track;
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class Timeline;
|
||||
}
|
||||
|
||||
class Timeline : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Timeline(QWidget *parent = 0);
|
||||
~Timeline();
|
||||
|
||||
bool focused();
|
||||
void zoom_in();
|
||||
void zoom_out();
|
||||
void set_sequence(Sequence* s);
|
||||
|
||||
Sequence* sequence;
|
||||
long playhead;
|
||||
|
||||
// playback functions
|
||||
void go_to_start();
|
||||
void previous_frame();
|
||||
void next_frame();
|
||||
void seek(long p);
|
||||
bool toggle_play();
|
||||
void play();
|
||||
void pause();
|
||||
void go_to_end();
|
||||
bool playing;
|
||||
long playhead_start;
|
||||
QTime playback_timer;
|
||||
QTimer playback_updater;
|
||||
|
||||
// shared information
|
||||
int tool;
|
||||
float zoom;
|
||||
long drag_frame_start;
|
||||
int drag_track_start;
|
||||
void redraw_all_clips();
|
||||
|
||||
// selecting functions
|
||||
bool selecting;
|
||||
QVector<Selection> selections;
|
||||
bool is_clip_selected(int clip_index);
|
||||
void delete_selection(bool ripple);
|
||||
void select_all();
|
||||
|
||||
// moving
|
||||
bool moving_init;
|
||||
bool moving_proc;
|
||||
QVector<Ghost> ghosts;
|
||||
|
||||
// trimming
|
||||
int trim_target;
|
||||
bool trim_in;
|
||||
|
||||
// splitting
|
||||
bool splitting;
|
||||
|
||||
// importing
|
||||
bool importing;
|
||||
|
||||
// ripple
|
||||
void ripple(long ripple_point, long ripple_length);
|
||||
|
||||
public slots:
|
||||
void repaint_timeline();
|
||||
|
||||
private slots:
|
||||
void on_toolEditButton_toggled(bool checked);
|
||||
|
||||
void on_toolArrowButton_toggled(bool checked);
|
||||
|
||||
void on_toolRazorButton_toggled(bool checked);
|
||||
|
||||
void on_pushButton_4_clicked();
|
||||
|
||||
void on_pushButton_5_clicked();
|
||||
|
||||
void on_toolRippleButton_toggled(bool checked);
|
||||
|
||||
void on_toolRollingButton_toggled(bool checked);
|
||||
|
||||
void on_toolSlipButton_toggled(bool checked);
|
||||
|
||||
private:
|
||||
Ui::Timeline *ui;
|
||||
QVector<QPushButton*> tool_buttons;
|
||||
void decheck_tool_buttons(QObject* sender);
|
||||
void set_tool(int tool);
|
||||
long last_frame;
|
||||
};
|
||||
|
||||
#endif // TIMELINE_H
|
||||
@@ -0,0 +1,355 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Timeline</class>
|
||||
<widget class="QDockWidget" name="Timeline">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>840</width>
|
||||
<height>535</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Timeline</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolArrowButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Pointer Tool (V)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons/icons.qrc">
|
||||
<normaloff>:/icons/arrow.png</normaloff>:/icons/arrow.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolEditButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit Tool (X)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons/icons.qrc">
|
||||
<normaloff>:/icons/beam.png</normaloff>:/icons/beam.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolRippleButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ripple Tool (B)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons/icons.qrc">
|
||||
<normaloff>:/icons/ripple.png</normaloff>:/icons/ripple.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolRollingButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rolling Tool (N)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons/icons.qrc">
|
||||
<normaloff>:/icons/rolling.png</normaloff>:/icons/rolling.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolRazorButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Razor Tool (C)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons/icons.qrc">
|
||||
<normaloff>:/icons/razor.png</normaloff>:/icons/razor.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="toolSlipButton">
|
||||
<property name="toolTip">
|
||||
<string>Slip Tool (Y)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/slip.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Zoom In (=)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Zoom Out (-)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="timeline_area">
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>789</width>
|
||||
<height>494</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="TimelineWidget" name="video_area" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TimelineWidget" name="audio_area" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>TimelineWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ui/timelinewidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons/icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,79 @@
|
||||
#include "viewer.h"
|
||||
#include "ui_viewer.h"
|
||||
|
||||
#include "playback/audio.h"
|
||||
#include "timeline.h"
|
||||
#include "project/sequence.h"
|
||||
#include "panels/panels.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
Viewer::Viewer(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::Viewer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->glViewerPane->child = ui->openGLWidget;
|
||||
viewer_widget = ui->openGLWidget;
|
||||
set_sequence(NULL);
|
||||
}
|
||||
|
||||
Viewer::~Viewer()
|
||||
{
|
||||
init_audio(NULL);
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Viewer::set_sequence(Sequence* s) {
|
||||
bool null_sequence = (s == NULL);
|
||||
sequence = s;
|
||||
|
||||
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);
|
||||
|
||||
if (!null_sequence) {
|
||||
ui->glViewerPane->aspect_ratio = (float) sequence->width / (float) sequence->height;
|
||||
ui->glViewerPane->adjust();
|
||||
}
|
||||
|
||||
init_audio(s);
|
||||
update();
|
||||
}
|
||||
|
||||
void Viewer::on_pushButton_clicked()
|
||||
{
|
||||
panel_timeline->go_to_start();
|
||||
}
|
||||
|
||||
void Viewer::on_pushButton_5_clicked()
|
||||
{
|
||||
panel_timeline->go_to_end();
|
||||
}
|
||||
|
||||
void Viewer::on_pushButton_2_clicked()
|
||||
{
|
||||
panel_timeline->previous_frame();
|
||||
}
|
||||
|
||||
void Viewer::on_pushButton_4_clicked()
|
||||
{
|
||||
panel_timeline->next_frame();
|
||||
}
|
||||
|
||||
void Viewer::on_pushButton_3_clicked()
|
||||
{
|
||||
if (panel_timeline->toggle_play()) {
|
||||
// playing
|
||||
ui->pushButton_3->setIcon(QIcon(":/icons/pause.png"));
|
||||
} else {
|
||||
ui->pushButton_3->setIcon(QIcon(":/icons/play.png"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef VIEWER_H
|
||||
#define VIEWER_H
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
class Timeline;
|
||||
class ViewerWidget;
|
||||
struct Sequence;
|
||||
|
||||
namespace Ui {
|
||||
class Viewer;
|
||||
}
|
||||
|
||||
class Viewer : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Viewer(QWidget *parent = 0);
|
||||
~Viewer();
|
||||
void set_sequence(Sequence* s);
|
||||
void compose();
|
||||
|
||||
Sequence* sequence;
|
||||
ViewerWidget* viewer_widget;
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_5_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
void on_pushButton_4_clicked();
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
private:
|
||||
Ui::Viewer *ui;
|
||||
};
|
||||
|
||||
#endif // VIEWER_H
|
||||
@@ -0,0 +1,319 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Viewer</class>
|
||||
<widget class="QDockWidget" name="Viewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>583</width>
|
||||
<height>396</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Viewer</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ViewerContainer" name="glViewerPane" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="ViewerWidget" name="openGLWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>60</y>
|
||||
<width>301</width>
|
||||
<height>221</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="playbackControls" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>36</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons/icons.qrc">
|
||||
<normaloff>:/icons/prev.png</normaloff>:/icons/prev.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>14</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>36</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons/icons.qrc">
|
||||
<normaloff>:/icons/rew.png</normaloff>:/icons/rew.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>14</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>36</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/play.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>14</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>36</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/ff.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>14</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>36</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons/icons.qrc">
|
||||
<normaloff>:/icons/next.png</normaloff>:/icons/next.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>14</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ViewerWidget</class>
|
||||
<extends>QOpenGLWidget</extends>
|
||||
<header>ui/viewerwidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ViewerContainer</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ui/viewercontainer.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons/icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user