removed effect controls and viewer ui files

This commit is contained in:
itsmattkc
2018-12-30 17:16:27 +11:00
parent 6130db2713
commit efdbeec549
13 changed files with 1774 additions and 2287 deletions
+4 -5
View File
@@ -1,5 +1,4 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "io/config.h"
#include "io/path.h"
@@ -43,6 +42,9 @@
#include <QInputDialog>
#include <QRegExp>
#include <QSortFilterProxyModel>
#include <QStatusBar>
#include <QMenu>
#include <QMenuBar>
MainWindow* mainWindow;
@@ -127,8 +129,6 @@ MainWindow::MainWindow(QWidget *parent) :
updateTitle("");
statusBar()->showMessage("Welcome to " + appName);
setDockNestingEnabled(true);
layout()->invalidate();
@@ -199,6 +199,7 @@ MainWindow::MainWindow(QWidget *parent) :
panel_timeline = new Timeline(this);
QStatusBar* statusBar = new QStatusBar(this);
statusBar->showMessage("Welcome to " + appName);
setStatusBar(statusBar);
setup_menus();
@@ -220,8 +221,6 @@ MainWindow::MainWindow(QWidget *parent) :
setup_layout(false);
init_audio();
}
MainWindow::~MainWindow() {
+1 -3
View File
@@ -8,10 +8,8 @@ class EffectControls;
class Viewer;
class Timeline;
class MainWindow : public QMainWindow
{
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
void updateTitle(const QString &url);
-2
View File
@@ -188,8 +188,6 @@ HEADERS += \
ui/keyframenavigator.h
FORMS += \
panels/effectcontrols.ui \
panels/viewer.ui \
panels/timeline.ui \
dialogs/aboutdialog.ui \
dialogs/newsequencedialog.ui \
+411 -224
View File
@@ -1,10 +1,16 @@
#include "effectcontrols.h"
#include "ui_effectcontrols.h"
#include <QMenu>
#include <QVBoxLayout>
#include <QResizeEvent>
#include <QScrollBar>
#include <QSplitter>
#include <QScrollArea>
#include <QPushButton>
#include <QSpacerItem>
#include <QLabel>
#include <QVBoxLayout>
#include <QIcon>
#include "panels/panels.h"
#include "project/effect.h"
@@ -18,44 +24,44 @@
#include "panels/viewer.h"
#include "ui/viewerwidget.h"
#include "io/clipboard.h"
#include "ui/timelineheader.h"
#include "ui/keyframeview.h"
#include "ui/resizablescrollbar.h"
#include "debug.h"
EffectControls::EffectControls(QWidget *parent) :
QDockWidget(parent),
multiple(false),
zoom(1),
ui(new Ui::EffectControls),
panel_name("Effects: "),
mode(TA_NO_TRANSITION)
zoom(1),
panel_name("Effects: "),
mode(TA_NO_TRANSITION)
{
ui->setupUi(this);
setup_ui();
init_effects();
clear_effects(false);
ui->headers->viewer = panel_sequence_viewer;
ui->headers->snapping = false;
clear_effects(false);
headers->viewer = panel_sequence_viewer;
headers->snapping = false;
ui->effects_area->parent_widget = ui->scrollArea;
ui->effects_area->keyframe_area = ui->keyframeView;
ui->effects_area->header = ui->headers;
ui->keyframeView->header = ui->headers;
effects_area->parent_widget = scrollArea;
effects_area->keyframe_area = keyframeView;
effects_area->header = headers;
keyframeView->header = headers;
ui->lblMultipleClipsSelected->setVisible(false);
lblMultipleClipsSelected->setVisible(false);
connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), ui->headers, SLOT(set_scroll(int)));
connect(ui->horizontalScrollBar, SIGNAL(resize_move(double)), ui->keyframeView, SLOT(resize_move(double)));
connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), ui->keyframeView, SLOT(set_x_scroll(int)));
connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), ui->keyframeView, SLOT(set_y_scroll(int)));
connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), ui->scrollArea->verticalScrollBar(), SLOT(setValue(int)));
connect(ui->scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->verticalScrollBar, SLOT(setValue(int)));
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), headers, SLOT(set_scroll(int)));
connect(horizontalScrollBar, SIGNAL(resize_move(double)), keyframeView, SLOT(resize_move(double)));
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), keyframeView, SLOT(set_x_scroll(int)));
connect(verticalScrollBar, SIGNAL(valueChanged(int)), keyframeView, SLOT(set_y_scroll(int)));
connect(verticalScrollBar, SIGNAL(valueChanged(int)), scrollArea->verticalScrollBar(), SLOT(setValue(int)));
connect(scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), verticalScrollBar, SLOT(setValue(int)));
}
EffectControls::~EffectControls() {
delete ui;
}
EffectControls::~EffectControls() {}
bool EffectControls::keyframe_focus() {
return ui->headers->hasFocus() || ui->keyframeView->hasFocus();
return headers->hasFocus() || keyframeView->hasFocus();
}
void EffectControls::set_zoom(bool in) {
@@ -64,292 +70,473 @@ void EffectControls::set_zoom(bool in) {
}
void EffectControls::menu_select(QAction* q) {
ComboAction* ca = new ComboAction();
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
if ((c->track < 0) == (effect_menu_subtype == EFFECT_TYPE_VIDEO)) {
ComboAction* ca = new ComboAction();
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
if ((c->track < 0) == (effect_menu_subtype == EFFECT_TYPE_VIDEO)) {
const EffectMeta* meta = reinterpret_cast<const EffectMeta*>(q->data().value<quintptr>());
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
if (c->get_opening_transition() == NULL) {
ca->append(new AddTransitionCommand(c, NULL, NULL, meta, TA_OPENING_TRANSITION, 30));
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
if (c->get_opening_transition() == NULL) {
ca->append(new AddTransitionCommand(c, NULL, NULL, meta, TA_OPENING_TRANSITION, 30));
}
if (c->get_closing_transition() == NULL) {
ca->append(new AddTransitionCommand(c, NULL, NULL, meta, TA_CLOSING_TRANSITION, 30));
if (c->get_closing_transition() == NULL) {
ca->append(new AddTransitionCommand(c, NULL, NULL, meta, TA_CLOSING_TRANSITION, 30));
}
} else {
ca->append(new AddEffectCommand(c, NULL, meta));
ca->append(new AddEffectCommand(c, NULL, meta));
}
}
}
undo_stack.push(ca);
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
}
}
undo_stack.push(ca);
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
update_ui(true);
} else {
reload_clips();
panel_sequence_viewer->viewer_widget->update();
}
}
}
void EffectControls::update_keyframes() {
ui->headers->update_zoom(zoom);
ui->keyframeView->update();
headers->update_zoom(zoom);
keyframeView->update();
}
void EffectControls::delete_selected_keyframes() {
ui->keyframeView->delete_selected_keyframes();
keyframeView->delete_selected_keyframes();
}
void EffectControls::copy(bool del) {
if (mode == TA_NO_TRANSITION) {
bool cleared = false;
if (mode == TA_NO_TRANSITION) {
bool cleared = false;
ComboAction* ca = new ComboAction();
EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : NULL;
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
for (int j=0;j<c->effects.size();j++) {
Effect* effect = c->effects.at(j);
if (effect->container->selected) {
if (!cleared) {
clear_clipboard();
cleared = true;
ComboAction* ca = new ComboAction();
EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : NULL;
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
for (int j=0;j<c->effects.size();j++) {
Effect* effect = c->effects.at(j);
if (effect->container->selected) {
if (!cleared) {
clear_clipboard();
cleared = true;
clipboard_type = CLIPBOARD_TYPE_EFFECT;
}
}
clipboard.append(effect->copy(NULL));
clipboard.append(effect->copy(NULL));
if (del_com != NULL) {
del_com->clips.append(c);
del_com->fx.append(j);
}
}
}
}
if (del_com != NULL) {
if (del_com->clips.size() > 0) {
ca->append(del_com);
} else {
delete del_com;
}
}
undo_stack.push(ca);
}
if (del_com != NULL) {
del_com->clips.append(c);
del_com->fx.append(j);
}
}
}
}
if (del_com != NULL) {
if (del_com->clips.size() > 0) {
ca->append(del_com);
} else {
delete del_com;
}
}
undo_stack.push(ca);
}
}
void EffectControls::show_effect_menu(int type, int subtype) {
effect_menu_type = type;
effect_menu_subtype = subtype;
effect_menu_type = type;
effect_menu_subtype = subtype;
effects_loaded.lock();
effects_loaded.lock();
QMenu effects_menu(this);
for (int i=0;i<effects.size();i++) {
const EffectMeta& em = effects.at(i);
QMenu effects_menu(this);
for (int i=0;i<effects.size();i++) {
const EffectMeta& em = effects.at(i);
if (em.type == type && em.subtype == subtype) {
QAction* action = new QAction(&effects_menu);
action->setText(em.name);
action->setData(reinterpret_cast<quintptr>(&em));
if (em.type == type && em.subtype == subtype) {
QAction* action = new QAction(&effects_menu);
action->setText(em.name);
action->setData(reinterpret_cast<quintptr>(&em));
QMenu* parent = &effects_menu;
if (!em.category.isEmpty()) {
bool found = false;
for (int j=0;j<effects_menu.actions().size();j++) {
QAction* action = effects_menu.actions().at(j);
if (action->menu() != NULL) {
if (action->menu()->title() == em.category) {
parent = action->menu();
found = true;
break;
}
}
}
if (!found) {
parent = new QMenu(&effects_menu);
parent->setTitle(em.category);
QMenu* parent = &effects_menu;
if (!em.category.isEmpty()) {
bool found = false;
for (int j=0;j<effects_menu.actions().size();j++) {
QAction* action = effects_menu.actions().at(j);
if (action->menu() != NULL) {
if (action->menu()->title() == em.category) {
parent = action->menu();
found = true;
break;
}
}
}
if (!found) {
parent = new QMenu(&effects_menu);
parent->setTitle(em.category);
bool found = false;
for (int i=0;i<effects_menu.actions().size();i++) {
QAction* comp_action = effects_menu.actions().at(i);
if (comp_action->text() > em.category) {
effects_menu.insertMenu(comp_action, parent);
found = true;
break;
}
}
if (!found) effects_menu.addMenu(parent);
}
}
bool found = false;
for (int i=0;i<effects_menu.actions().size();i++) {
QAction* comp_action = effects_menu.actions().at(i);
if (comp_action->text() > em.category) {
effects_menu.insertMenu(comp_action, parent);
found = true;
break;
}
}
if (!found) effects_menu.addMenu(parent);
}
}
bool found = false;
for (int i=0;i<parent->actions().size();i++) {
QAction* comp_action = parent->actions().at(i);
if (comp_action->text() > action->text()) {
parent->insertAction(comp_action, action);
found = true;
break;
}
}
if (!found) parent->addAction(action);
}
}
bool found = false;
for (int i=0;i<parent->actions().size();i++) {
QAction* comp_action = parent->actions().at(i);
if (comp_action->text() > action->text()) {
parent->insertAction(comp_action, action);
found = true;
break;
}
}
if (!found) parent->addAction(action);
}
}
effects_loaded.unlock();
effects_loaded.unlock();
connect(&effects_menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_select(QAction*)));
effects_menu.exec(QCursor::pos());
connect(&effects_menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_select(QAction*)));
effects_menu.exec(QCursor::pos());
}
void EffectControls::clear_effects(bool clear_cache) {
// clear existing clips
deselect_all_effects(NULL);
QVBoxLayout* video_layout = static_cast<QVBoxLayout*>(ui->video_effect_area->layout());
QVBoxLayout* audio_layout = static_cast<QVBoxLayout*>(ui->audio_effect_area->layout());
QLayoutItem* item;
while ((item = video_layout->takeAt(0))) {
item->widget()->setParent(NULL);
QVBoxLayout* video_layout = static_cast<QVBoxLayout*>(video_effect_area->layout());
QVBoxLayout* audio_layout = static_cast<QVBoxLayout*>(audio_effect_area->layout());
QLayoutItem* item;
while ((item = video_layout->takeAt(0))) {
item->widget()->setParent(NULL);
disconnect(static_cast<CollapsibleWidget*>(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
}
while ((item = audio_layout->takeAt(0))) {
item->widget()->setParent(NULL);
disconnect(static_cast<CollapsibleWidget*>(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
}
ui->lblMultipleClipsSelected->setVisible(false);
ui->vcontainer->setVisible(false);
ui->acontainer->setVisible(false);
ui->headers->setVisible(false);
ui->keyframeView->setEnabled(false);
if (clear_cache) selected_clips.clear();
setWindowTitle(panel_name + "(none)");
}
while ((item = audio_layout->takeAt(0))) {
item->widget()->setParent(NULL);
disconnect(static_cast<CollapsibleWidget*>(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
}
lblMultipleClipsSelected->setVisible(false);
vcontainer->setVisible(false);
acontainer->setVisible(false);
headers->setVisible(false);
keyframeView->setEnabled(false);
if (clear_cache) selected_clips.clear();
setWindowTitle(panel_name + "(none)");
}
void EffectControls::deselect_all_effects(QWidget* sender) {
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
for (int j=0;j<c->effects.size();j++) {
if (c->effects.at(j)->container != sender) {
c->effects.at(j)->container->header_click(false, false);
}
}
}
panel_sequence_viewer->viewer_widget->update();
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
for (int j=0;j<c->effects.size();j++) {
if (c->effects.at(j)->container != sender) {
c->effects.at(j)->container->header_click(false, false);
}
}
}
panel_sequence_viewer->viewer_widget->update();
}
void EffectControls::open_effect(QVBoxLayout* layout, Effect* e) {
CollapsibleWidget* container = e->container;
layout->addWidget(container);
connect(container, SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
CollapsibleWidget* container = e->container;
layout->addWidget(container);
connect(container, SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*)));
}
void EffectControls::setup_ui() {
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
QWidget* contents = new QWidget();
QHBoxLayout* layout = new QHBoxLayout(contents);
layout->setSpacing(0);
layout->setMargin(0);
QSplitter* splitter = new QSplitter(contents);
splitter->setOrientation(Qt::Horizontal);
splitter->setChildrenCollapsible(false);
scrollArea = new QScrollArea(splitter);
scrollArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
scrollArea->setFrameShape(QFrame::NoFrame);
scrollArea->setFrameShadow(QFrame::Plain);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setWidgetResizable(true);
QWidget* scrollAreaWidgetContents = new QWidget();
QHBoxLayout* scrollAreaLayout = new QHBoxLayout(scrollAreaWidgetContents);
scrollAreaLayout->setSpacing(0);
scrollAreaLayout->setMargin(0);
effects_area = new EffectsArea(scrollAreaWidgetContents);
QVBoxLayout* effects_area_layout = new QVBoxLayout(effects_area);
effects_area_layout->setSpacing(0);
effects_area_layout->setMargin(0);
vcontainer = new QWidget(effects_area);
QVBoxLayout* vcontainerLayout = new QVBoxLayout(vcontainer);
vcontainerLayout->setSpacing(0);
vcontainerLayout->setMargin(0);
QWidget* veHeader = new QWidget(vcontainer);
veHeader->setObjectName(QStringLiteral("veHeader"));
veHeader->setStyleSheet(QLatin1String("#veHeader { background: rgba(0, 0, 0, 0.25); }"));
QHBoxLayout* veHeaderLayout = new QHBoxLayout(veHeader);
veHeaderLayout->setSpacing(0);
veHeaderLayout->setMargin(0);
QPushButton* btnAddVideoEffect = new QPushButton(veHeader);
btnAddVideoEffect->setIcon(QIcon(":/icons/add-effect.png"));
btnAddVideoEffect->setToolTip("Add Video Effect");
veHeaderLayout->addWidget(btnAddVideoEffect);
connect(btnAddVideoEffect, SIGNAL(clicked(bool)), this, SLOT(video_effect_click()));
veHeaderLayout->addStretch();
QLabel* lblVideoEffects = new QLabel(veHeader);
QFont font;
font.setPointSize(9);
lblVideoEffects->setFont(font);
lblVideoEffects->setAlignment(Qt::AlignCenter);
lblVideoEffects->setText("VIDEO EFFECTS");
veHeaderLayout->addWidget(lblVideoEffects);
veHeaderLayout->addStretch();
QPushButton* btnAddVideoTransition = new QPushButton(veHeader);
btnAddVideoTransition->setIcon(QIcon(":/icons/add-transition.png"));
btnAddVideoTransition->setToolTip("Add Video Transition");
connect(btnAddVideoTransition, SIGNAL(clicked(bool)), this, SLOT(video_transition_click()));
veHeaderLayout->addWidget(btnAddVideoTransition);
vcontainerLayout->addWidget(veHeader);
video_effect_area = new QWidget(vcontainer);
QVBoxLayout* veAreaLayout = new QVBoxLayout(video_effect_area);
veAreaLayout->setSpacing(0);
veAreaLayout->setMargin(0);
vcontainerLayout->addWidget(video_effect_area);
effects_area_layout->addWidget(vcontainer);
acontainer = new QWidget(effects_area);
QVBoxLayout* acontainerLayout = new QVBoxLayout(acontainer);
acontainerLayout->setSpacing(0);
acontainerLayout->setMargin(0);
QWidget* aeHeader = new QWidget(acontainer);
aeHeader->setObjectName(QStringLiteral("aeHeader"));
aeHeader->setStyleSheet(QLatin1String("#aeHeader { background: rgba(0, 0, 0, 0.25); }"));
QHBoxLayout* aeHeaderLayout = new QHBoxLayout(aeHeader);
aeHeaderLayout->setSpacing(0);
aeHeaderLayout->setMargin(0);
QPushButton* btnAddAudioEffect = new QPushButton(aeHeader);
btnAddAudioEffect->setIcon(QIcon(":/icons/add-effect.png"));
btnAddAudioEffect->setToolTip("Add Audio Effect");
connect(btnAddAudioEffect, SIGNAL(clicked(bool)), this, SLOT(audio_effect_click()));
aeHeaderLayout->addWidget(btnAddAudioEffect);
aeHeaderLayout->addStretch();
QLabel* lblAudioEffects = new QLabel(aeHeader);
lblAudioEffects->setFont(font);
lblAudioEffects->setAlignment(Qt::AlignCenter);
lblAudioEffects->setText("AUDIO EFFECTS");
aeHeaderLayout->addWidget(lblAudioEffects);
aeHeaderLayout->addStretch();
QPushButton* btnAddAudioTransition = new QPushButton(aeHeader);
btnAddAudioTransition->setIcon(QIcon(":/icons/add-transition.png"));
btnAddAudioTransition->setToolTip("Add Audio Transition");
connect(btnAddAudioTransition, SIGNAL(clicked(bool)), this, SLOT(audio_transition_click()));
aeHeaderLayout->addWidget(btnAddAudioTransition);
acontainerLayout->addWidget(aeHeader);
audio_effect_area = new QWidget(acontainer);
QVBoxLayout* aeAreaLayout = new QVBoxLayout(audio_effect_area);
aeAreaLayout->setSpacing(0);
aeAreaLayout->setMargin(0);
acontainerLayout->addWidget(audio_effect_area);
effects_area_layout->addWidget(acontainer);
lblMultipleClipsSelected = new QLabel(effects_area);
lblMultipleClipsSelected->setAlignment(Qt::AlignCenter);
lblMultipleClipsSelected->setText("(Multiple clips selected)");
effects_area_layout->addWidget(lblMultipleClipsSelected);
effects_area_layout->addStretch();
scrollAreaLayout->addWidget(effects_area);
scrollArea->setWidget(scrollAreaWidgetContents);
splitter->addWidget(scrollArea);
QWidget* keyframeArea = new QWidget(splitter);
QSizePolicy keyframe_sp;
keyframe_sp.setHorizontalPolicy(QSizePolicy::Minimum);
keyframe_sp.setVerticalPolicy(QSizePolicy::Preferred);
keyframe_sp.setHorizontalStretch(1);
keyframeArea->setSizePolicy(keyframe_sp);
QVBoxLayout* keyframeAreaLayout = new QVBoxLayout(keyframeArea);
keyframeAreaLayout->setSpacing(0);
keyframeAreaLayout->setMargin(0);
headers = new TimelineHeader(keyframeArea);
keyframeAreaLayout->addWidget(headers);
QWidget* keyframeCenterWidget = new QWidget(keyframeArea);
QHBoxLayout* keyframeCenterLayout = new QHBoxLayout(keyframeCenterWidget);
keyframeCenterLayout->setSpacing(0);
keyframeCenterLayout->setMargin(0);
keyframeView = new KeyframeView(keyframeCenterWidget);
keyframeCenterLayout->addWidget(keyframeView);
verticalScrollBar = new QScrollBar(keyframeCenterWidget);
verticalScrollBar->setOrientation(Qt::Vertical);
keyframeCenterLayout->addWidget(verticalScrollBar);
keyframeAreaLayout->addWidget(keyframeCenterWidget);
horizontalScrollBar = new ResizableScrollBar(keyframeArea);
horizontalScrollBar->setOrientation(Qt::Horizontal);
keyframeAreaLayout->addWidget(horizontalScrollBar);
splitter->addWidget(keyframeArea);
layout->addWidget(splitter);
setWidget(contents);
}
void EffectControls::load_effects() {
ui->lblMultipleClipsSelected->setVisible(multiple);
lblMultipleClipsSelected->setVisible(multiple);
if (!multiple) {
if (!multiple) {
// load in new clips
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
Clip* c = sequence->clips.at(selected_clips.at(i));
QVBoxLayout* layout;
if (c->track < 0) {
ui->vcontainer->setVisible(true);
layout = static_cast<QVBoxLayout*>(ui->video_effect_area->layout());
vcontainer->setVisible(true);
layout = static_cast<QVBoxLayout*>(video_effect_area->layout());
} else {
ui->acontainer->setVisible(true);
layout = static_cast<QVBoxLayout*>(ui->audio_effect_area->layout());
acontainer->setVisible(true);
layout = static_cast<QVBoxLayout*>(audio_effect_area->layout());
}
if (mode == TA_NO_TRANSITION) {
for (int j=0;j<c->effects.size();j++) {
open_effect(layout, c->effects.at(j));
}
} else if (mode == TA_OPENING_TRANSITION && c->get_opening_transition() != NULL) {
open_effect(layout, c->get_opening_transition());
} else if (mode == TA_CLOSING_TRANSITION && c->get_closing_transition() != NULL) {
open_effect(layout, c->get_closing_transition());
}
if (mode == TA_NO_TRANSITION) {
for (int j=0;j<c->effects.size();j++) {
open_effect(layout, c->effects.at(j));
}
} else if (mode == TA_OPENING_TRANSITION && c->get_opening_transition() != NULL) {
open_effect(layout, c->get_opening_transition());
} else if (mode == TA_CLOSING_TRANSITION && c->get_closing_transition() != NULL) {
open_effect(layout, c->get_closing_transition());
}
}
if (selected_clips.size() > 0) {
setWindowTitle(panel_name + sequence->clips.at(selected_clips.at(0))->name);
ui->verticalScrollBar->setMaximum(qMax(0, ui->effects_area->sizeHint().height() - ui->headers->height() + ui->scrollArea->horizontalScrollBar()->height()/* - ui->keyframeView->height() - ui->headers->height()*/));
ui->keyframeView->setEnabled(true);
ui->headers->setVisible(true);
ui->keyframeView->update();
setWindowTitle(panel_name + sequence->clips.at(selected_clips.at(0))->name);
verticalScrollBar->setMaximum(qMax(0, effects_area->sizeHint().height() - headers->height() + scrollArea->horizontalScrollBar()->height()/* - keyframeView->height() - headers->height()*/));
keyframeView->setEnabled(true);
headers->setVisible(true);
keyframeView->update();
}
}
}
void EffectControls::delete_effects() {
// load in new clips
if (mode == TA_NO_TRANSITION) {
EffectDeleteCommand* command = new EffectDeleteCommand();
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
for (int j=0;j<c->effects.size();j++) {
Effect* effect = c->effects.at(j);
if (effect->container->selected) {
command->clips.append(c);
command->fx.append(j);
}
}
}
if (command->clips.size() > 0) {
undo_stack.push(command);
panel_sequence_viewer->viewer_widget->update();
} else {
delete command;
}
}
// load in new clips
if (mode == TA_NO_TRANSITION) {
EffectDeleteCommand* command = new EffectDeleteCommand();
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
for (int j=0;j<c->effects.size();j++) {
Effect* effect = c->effects.at(j);
if (effect->container->selected) {
command->clips.append(c);
command->fx.append(j);
}
}
}
if (command->clips.size() > 0) {
undo_stack.push(command);
panel_sequence_viewer->viewer_widget->update();
} else {
delete command;
}
}
}
void EffectControls::reload_clips() {
clear_effects(false);
load_effects();
clear_effects(false);
load_effects();
}
void EffectControls::set_clips(QVector<int>& clips, int m) {
clear_effects(true);
clear_effects(true);
// replace clip vector
selected_clips = clips;
mode = m;
// replace clip vector
selected_clips = clips;
mode = m;
load_effects();
load_effects();
}
void EffectControls::on_btnAddVideoEffect_clicked() {
show_effect_menu(EFFECT_TYPE_EFFECT, EFFECT_TYPE_VIDEO);
void EffectControls::video_effect_click() {
show_effect_menu(EFFECT_TYPE_EFFECT, EFFECT_TYPE_VIDEO);
}
void EffectControls::on_btnAddAudioEffect_clicked() {
show_effect_menu(EFFECT_TYPE_EFFECT, EFFECT_TYPE_AUDIO);
void EffectControls::audio_effect_click() {
show_effect_menu(EFFECT_TYPE_EFFECT, EFFECT_TYPE_AUDIO);
}
void EffectControls::on_btnAddVideoTransition_clicked() {
show_effect_menu(EFFECT_TYPE_TRANSITION, EFFECT_TYPE_VIDEO);
void EffectControls::video_transition_click() {
show_effect_menu(EFFECT_TYPE_TRANSITION, EFFECT_TYPE_VIDEO);
}
void EffectControls::on_btnAddAudioTransition_clicked() {
show_effect_menu(EFFECT_TYPE_TRANSITION, EFFECT_TYPE_AUDIO);
void EffectControls::audio_transition_click() {
show_effect_menu(EFFECT_TYPE_TRANSITION, EFFECT_TYPE_AUDIO);
}
void EffectControls::resizeEvent(QResizeEvent*) {
ui->verticalScrollBar->setMaximum(qMax(0, ui->effects_area->height() - ui->keyframeView->height() - ui->headers->height()));
verticalScrollBar->setMaximum(qMax(0, effects_area->height() - keyframeView->height() - headers->height()));
}
bool EffectControls::is_focused() {
if (this->hasFocus()) return true;
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
if (c != NULL) {
for (int j=0;j<c->effects.size();j++) {
if (c->effects.at(j)->container->is_focused()) {
return true;
}
}
} else {
if (this->hasFocus()) return true;
for (int i=0;i<selected_clips.size();i++) {
Clip* c = sequence->clips.at(selected_clips.at(i));
if (c != NULL) {
for (int j=0;j<c->effects.size();j++) {
if (c->effects.at(j)->container->is_focused()) {
return true;
}
}
} else {
dout << "[WARNING] Tried to check focus of a NULL clip";
}
}
return false;
}
}
return false;
}
EffectsArea::EffectsArea(QWidget* parent) : QWidget(parent) {}
+37 -24
View File
@@ -11,6 +11,10 @@ class TimelineHeader;
class QScrollArea;
class KeyframeView;
class QVBoxLayout;
class ResizableScrollBar;
class QLabel;
class KeyframeView;
class QScrollBar;
class EffectsArea : public QWidget {
public:
@@ -21,10 +25,6 @@ public:
TimelineHeader* header;
};
namespace Ui {
class EffectControls;
}
class EffectControls : public QDockWidget
{
Q_OBJECT
@@ -32,45 +32,58 @@ class EffectControls : public QDockWidget
public:
explicit EffectControls(QWidget *parent = 0);
~EffectControls();
void set_clips(QVector<int>& clips, int mode);
void clear_effects(bool clear_cache);
void delete_effects();
bool is_focused();
void reload_clips();
void set_clips(QVector<int>& clips, int mode);
void clear_effects(bool clear_cache);
void delete_effects();
bool is_focused();
void reload_clips();
void set_zoom(bool in);
bool keyframe_focus();
void delete_selected_keyframes();
void copy(bool del);
void copy(bool del);
bool multiple;
QVector<int> selected_clips;
double zoom;
Ui::EffectControls *ui;
ResizableScrollBar* horizontalScrollBar;
QScrollBar* verticalScrollBar;
public slots:
void update_keyframes();
void update_keyframes();
private slots:
void menu_select(QAction* q);
void menu_select(QAction* q);
void on_btnAddVideoEffect_clicked();
void on_btnAddAudioEffect_clicked();
void on_btnAddVideoTransition_clicked();
void on_btnAddAudioTransition_clicked();
void video_effect_click();
void audio_effect_click();
void video_transition_click();
void audio_transition_click();
void deselect_all_effects(QWidget*);
void deselect_all_effects(QWidget*);
protected:
void resizeEvent(QResizeEvent *event);
private:
void show_effect_menu(int type, int subtype);
void show_effect_menu(int type, int subtype);
void load_effects();
void load_keyframes();
void open_effect(QVBoxLayout* layout, Effect* e);
void open_effect(QVBoxLayout* layout, Effect* e);
int effect_menu_type;
int effect_menu_subtype;
QString panel_name;
int mode;
void setup_ui();
int effect_menu_type;
int effect_menu_subtype;
QString panel_name;
int mode;
TimelineHeader* headers;
EffectsArea* effects_area;
QScrollArea* scrollArea;
QLabel* lblMultipleClipsSelected;
KeyframeView* keyframeView;
QWidget* video_effect_area;
QWidget* audio_effect_area;
QWidget* vcontainer;
QWidget* acontainer;
};
#endif // EFFECTCONTROLS_H
-554
View File
@@ -1,554 +0,0 @@
<?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>621</width>
<height>510</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="QHBoxLayout" name="horizontalLayout_4">
<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="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</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>189</width>
<height>483</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<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="EffectsArea" name="effects_area" native="true">
<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="QWidget" name="vcontainer" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<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="QWidget" name="veHeader" native="true">
<property name="styleSheet">
<string notr="true">#veHeader {
background: rgba(0, 0, 0, 0.25);
}</string>
</property>
<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="QPushButton" name="btnAddVideoEffect">
<property name="toolTip">
<string>Add Video Effect</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/add-effect.png</normalon>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="hsLeftVideoEffects">
<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="QLabel" name="lblVideoEffects">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>VIDEO EFFECTS</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="hsRightVideoEffects">
<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="btnAddVideoTransition">
<property name="toolTip">
<string>Add Video Transition</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/add-transition.png</normalon>
</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="video_effect_area" native="true">
<layout class="QVBoxLayout" name="verticalLayout_6">
<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>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="acontainer" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<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="QWidget" name="aeHeader" native="true">
<property name="styleSheet">
<string notr="true">#aeHeader {
background: rgba(0, 0, 0, 0.25);
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<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="QPushButton" name="btnAddAudioEffect">
<property name="toolTip">
<string>Add Audio Effect</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/add-effect.png</normalon>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="hsLeftAudioEffects">
<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="QLabel" name="lblAudioEffects">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>AUDIO EFFECTS</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="hsRightAudioEffects">
<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="btnAddAudioTransition">
<property name="toolTip">
<string>Add Audio Transition</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/add-transition.png</normalon>
</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="audio_effect_area" native="true">
<layout class="QVBoxLayout" name="verticalLayout_5">
<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>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lblMultipleClipsSelected">
<property name="text">
<string>(Multiple clips selected)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</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>
</layout>
</widget>
</widget>
<widget class="QWidget" name="keyframeArea" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<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="TimelineHeader" name="headers" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="keyframeCenterWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<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="KeyframeView" name="keyframeView" native="true"/>
</item>
<item>
<widget class="QScrollBar" name="verticalScrollBar">
<property name="maximum">
<number>0</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="pageStep">
<number>1826</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="ResizableScrollBar" name="horizontalScrollBar">
<property name="maximum">
<number>0</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="pageStep">
<number>1826</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>KeyframeView</class>
<extends>QWidget</extends>
<header>ui/keyframeview.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TimelineHeader</class>
<extends>QWidget</extends>
<header>ui/timelineheader.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>EffectsArea</class>
<extends>QWidget</extends>
<header>panels/effectcontrols.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResizableScrollBar</class>
<extends>QScrollBar</extends>
<header>ui/resizablescrollbar.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+1 -7
View File
@@ -60,13 +60,7 @@ QString recent_proj_file;
Project::Project(QWidget *parent) :
QDockWidget(parent)
{
setObjectName("Project");
resize(504, 371);
QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
setSizePolicy(sizePolicy);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
QWidget* dockWidgetContents = new QWidget();
QVBoxLayout* verticalLayout = new QVBoxLayout(dockWidgetContents);
+728 -729
View File
File diff suppressed because it is too large Load Diff
+370 -274
View File
@@ -1,5 +1,4 @@
#include "viewer.h"
#include "ui_viewer.h"
#include "playback/audio.h"
#include "timeline.h"
@@ -15,6 +14,8 @@
#include "ui_timeline.h"
#include "playback/playback.h"
#include "ui/viewerwidget.h"
#include "ui/viewercontainer.h"
#include "ui/labelslider.h"
#include "debug.h"
#define FRAMES_IN_ONE_MINUTE 1798 // 1800 - 2
@@ -32,62 +33,60 @@ extern "C" {
#include <QTimer>
Viewer::Viewer(QWidget *parent) :
QDockWidget(parent),
QDockWidget(parent),
playing(false),
just_played(false),
media(NULL),
seq(NULL),
ui(new Ui::Viewer),
created_sequence(false),
cue_recording_internal(false),
panel_name("Viewer: "),
minimum_zoom(1.0)
just_played(false),
media(NULL),
seq(NULL),
created_sequence(false),
cue_recording_internal(false),
panel_name("Viewer: "),
minimum_zoom(1.0)
{
ui->setupUi(this);
ui->headers->viewer = this;
ui->headers->snapping = false;
ui->headers->show_text(false);
ui->glViewerPane->viewer = this;
viewer_widget = ui->glViewerPane->child;
viewer_widget->viewer = this;
set_media(NULL);
setup_ui();
ui->currentTimecode->setEnabled(false);
ui->currentTimecode->set_minimum_value(0);
ui->currentTimecode->set_default_value(qSNaN());
ui->currentTimecode->set_value(0, false);
ui->currentTimecode->set_display_type(LABELSLIDER_FRAMENUMBER);
connect(ui->currentTimecode, SIGNAL(valueChanged()), this, SLOT(update_playhead()));
headers->viewer = this;
headers->snapping = false;
headers->show_text(false);
glViewerPane->viewer = this;
viewer_widget = glViewerPane->child;
viewer_widget->viewer = this;
set_media(NULL);
currentTimecode->setEnabled(false);
currentTimecode->set_minimum_value(0);
currentTimecode->set_default_value(qSNaN());
currentTimecode->set_value(0, false);
currentTimecode->set_display_type(LABELSLIDER_FRAMENUMBER);
connect(currentTimecode, SIGNAL(valueChanged()), this, SLOT(update_playhead()));
recording_flasher.setInterval(500);
connect(&playback_updater, SIGNAL(timeout()), this, SLOT(timer_update()));
connect(&recording_flasher, SIGNAL(timeout()), this, SLOT(recording_flasher_update()));
connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), ui->headers, SLOT(set_scroll(int)));
connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), viewer_widget, SLOT(set_waveform_scroll(int)));
connect(ui->horizontalScrollBar, SIGNAL(resize_move(double)), this, SLOT(resize_move(double)));
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), headers, SLOT(set_scroll(int)));
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), viewer_widget, SLOT(set_waveform_scroll(int)));
connect(horizontalScrollBar, SIGNAL(resize_move(double)), this, SLOT(resize_move(double)));
update_playhead_timecode(0);
update_end_timecode();
update_playhead_timecode(0);
update_end_timecode();
}
Viewer::~Viewer() {
delete ui;
}
Viewer::~Viewer() {}
bool Viewer::is_focused() {
return ui->headers->hasFocus()
|| viewer_widget->hasFocus()
|| ui->btnSkipToStart->hasFocus()
|| ui->btnRewind->hasFocus()
|| ui->btnPlay->hasFocus()
|| ui->btnFastForward->hasFocus()
|| ui->btnSkipToEnd->hasFocus();
return headers->hasFocus()
|| viewer_widget->hasFocus()
|| btnSkipToStart->hasFocus()
|| btnRewind->hasFocus()
|| btnPlay->hasFocus()
|| btnFastForward->hasFocus()
|| btnSkipToEnd->hasFocus();
}
void Viewer::set_main_sequence() {
clean_created_seq();
set_sequence(true, sequence);
set_sequence(true, sequence);
}
void Viewer::reset_all_audio() {
@@ -101,43 +100,43 @@ void Viewer::reset_all_audio() {
if (c != NULL) c->reset_audio();
}
}
clear_audio_ibuffer();
clear_audio_ibuffer();
}
long timecode_to_frame(const QString& s, int view, double frame_rate) {
QList<QString> list = s.split(QRegExp("[:;]"));
QList<QString> list = s.split(QRegExp("[:;]"));
if (view == TIMECODE_FRAMES || (list.size() == 1 && view != TIMECODE_MILLISECONDS)) {
if (view == TIMECODE_FRAMES || (list.size() == 1 && view != TIMECODE_MILLISECONDS)) {
return s.toLong();
}
int frRound = qRound(frame_rate);
int hours, minutes, seconds, frames;
int hours, minutes, seconds, frames;
if (view == TIMECODE_MILLISECONDS) {
long milliseconds = s.toLong();
if (view == TIMECODE_MILLISECONDS) {
long milliseconds = s.toLong();
hours = milliseconds/3600000;
milliseconds -= (hours*3600000);
minutes = milliseconds/60000;
milliseconds -= (minutes*60000);
seconds = milliseconds/1000;
milliseconds -= (seconds*1000);
frames = qRound64((milliseconds*0.001)*frame_rate);
hours = milliseconds/3600000;
milliseconds -= (hours*3600000);
minutes = milliseconds/60000;
milliseconds -= (minutes*60000);
seconds = milliseconds/1000;
milliseconds -= (seconds*1000);
frames = qRound64((milliseconds*0.001)*frame_rate);
seconds = qRound64(seconds * frame_rate);
minutes = qRound64(minutes * frame_rate * 60);
hours = qRound64(hours * frame_rate * 3600);
} else {
hours = ((list.size() > 0) ? list.at(0).toInt() : 0) * frRound * 3600;
minutes = ((list.size() > 1) ? list.at(1).toInt() : 0) * frRound * 60;
seconds = ((list.size() > 2) ? list.at(2).toInt() : 0) * frRound;
frames = (list.size() > 3) ? list.at(3).toInt() : 0;
}
seconds = qRound64(seconds * frame_rate);
minutes = qRound64(minutes * frame_rate * 60);
hours = qRound64(hours * frame_rate * 3600);
} else {
hours = ((list.size() > 0) ? list.at(0).toInt() : 0) * frRound * 3600;
minutes = ((list.size() > 1) ? list.at(1).toInt() : 0) * frRound * 60;
seconds = ((list.size() > 2) ? list.at(2).toInt() : 0) * frRound;
frames = (list.size() > 3) ? list.at(3).toInt() : 0;
}
int f = (frames + seconds + minutes + hours);
if ((view == TIMECODE_DROP || view == TIMECODE_MILLISECONDS) && frame_rate_is_droppable(frame_rate)) {
if ((view == TIMECODE_DROP || view == TIMECODE_MILLISECONDS) && frame_rate_is_droppable(frame_rate)) {
// return drop
int d;
int m;
@@ -161,69 +160,69 @@ long timecode_to_frame(const QString& s, int view, double frame_rate) {
}
QString frame_to_timecode(long f, int view, double frame_rate) {
if (view == TIMECODE_FRAMES) {
return QString::number(f);
}
if (view == TIMECODE_FRAMES) {
return QString::number(f);
}
// return timecode
int hours = 0;
int mins = 0;
int secs = 0;
int frames = 0;
QString token = ":";
// return timecode
int hours = 0;
int mins = 0;
int secs = 0;
int frames = 0;
QString token = ":";
if ((view == TIMECODE_DROP || view == TIMECODE_MILLISECONDS) && frame_rate_is_droppable(frame_rate)) {
//CONVERT A FRAME NUMBER TO DROP FRAME TIMECODE
//Code by David Heidelberger, adapted from Andrew Duncan, further adapted for Olive by Olive Team
//Given an int called framenumber and a double called framerate
//Framerate should be 29.97, 59.94, or 23.976, otherwise the calculations will be off.
if ((view == TIMECODE_DROP || view == TIMECODE_MILLISECONDS) && frame_rate_is_droppable(frame_rate)) {
//CONVERT A FRAME NUMBER TO DROP FRAME TIMECODE
//Code by David Heidelberger, adapted from Andrew Duncan, further adapted for Olive by Olive Team
//Given an int called framenumber and a double called framerate
//Framerate should be 29.97, 59.94, or 23.976, otherwise the calculations will be off.
int d;
int m;
int d;
int m;
int dropFrames = round(frame_rate * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
int framesPerHour = round(frame_rate*60*60); //Number of frqRound64ames in an hour
int framesPer24Hours = framesPerHour*24; //Number of frames in a day - timecode rolls over after 24 hours
int framesPer10Minutes = round(frame_rate * 60 * 10); //Number of frames per ten minutes
int framesPerMinute = (round(frame_rate)*60)- dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
int dropFrames = round(frame_rate * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
int framesPerHour = round(frame_rate*60*60); //Number of frqRound64ames in an hour
int framesPer24Hours = framesPerHour*24; //Number of frames in a day - timecode rolls over after 24 hours
int framesPer10Minutes = round(frame_rate * 60 * 10); //Number of frames per ten minutes
int framesPerMinute = (round(frame_rate)*60)- dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
//If framenumber is greater than 24 hrs, next operation will rollover clock
f = f % framesPer24Hours; //% is the modulus operator, which returns a remainder. a % b = the remainder of a/b
//If framenumber is greater than 24 hrs, next operation will rollover clock
f = f % framesPer24Hours; //% is the modulus operator, which returns a remainder. a % b = the remainder of a/b
d = f / framesPer10Minutes; // \ means integer division, which is a/b without a remainder. Some languages you could use floor(a/b)
m = f % framesPer10Minutes;
d = f / framesPer10Minutes; // \ means integer division, which is a/b without a remainder. Some languages you could use floor(a/b)
m = f % framesPer10Minutes;
//In the original post, the next line read m>1, which only worked for 29.97. Jean-Baptiste Mardelle correctly pointed out that m should be compared to dropFrames.
if (m > dropFrames) {
f = f + (dropFrames*9*d) + dropFrames * ((m - dropFrames) / framesPerMinute);
} else {
f = f + dropFrames*9*d;
}
//In the original post, the next line read m>1, which only worked for 29.97. Jean-Baptiste Mardelle correctly pointed out that m should be compared to dropFrames.
if (m > dropFrames) {
f = f + (dropFrames*9*d) + dropFrames * ((m - dropFrames) / framesPerMinute);
} else {
f = f + dropFrames*9*d;
}
int frRound = round(frame_rate);
frames = f % frRound;
secs = (f / frRound) % 60;
mins = ((f / frRound) / 60) % 60;
hours = (((f / frRound) / 60) / 60);
int frRound = round(frame_rate);
frames = f % frRound;
secs = (f / frRound) % 60;
mins = ((f / frRound) / 60) % 60;
hours = (((f / frRound) / 60) / 60);
token = ";";
} else {
token = ";";
} else {
// non-drop timecode
int int_fps = qRound(frame_rate);
int int_fps = qRound(frame_rate);
hours = f / (3600 * int_fps);
mins = f / (60*int_fps) % 60;
secs = f/int_fps % 60;
frames = f%int_fps;
}
if (view == TIMECODE_MILLISECONDS) {
return QString::number((hours*3600000)+(mins*60000)+(secs*1000)+qCeil(frames*1000/frame_rate));
}
return QString(QString::number(hours).rightJustified(2, '0') +
":" + QString::number(mins).rightJustified(2, '0') +
":" + QString::number(secs).rightJustified(2, '0') +
token + QString::number(frames).rightJustified(2, '0')
);
mins = f / (60*int_fps) % 60;
secs = f/int_fps % 60;
frames = f%int_fps;
}
if (view == TIMECODE_MILLISECONDS) {
return QString::number((hours*3600000)+(mins*60000)+(secs*1000)+qCeil(frames*1000/frame_rate));
}
return QString(QString::number(hours).rightJustified(2, '0') +
":" + QString::number(mins).rightJustified(2, '0') +
":" + QString::number(secs).rightJustified(2, '0') +
token + QString::number(frames).rightJustified(2, '0')
);
}
bool frame_rate_is_droppable(float rate) {
@@ -234,8 +233,8 @@ void Viewer::seek(long p) {
pause();
seq->playhead = p;
update_parents();
reset_all_audio();
audio_scrub = true;
reset_all_audio();
audio_scrub = true;
}
void Viewer::go_to_start() {
@@ -278,7 +277,7 @@ void Viewer::cue_recording(long start, long end, int track) {
void Viewer::uncue_recording() {
cue_recording_internal = false;
recording_flasher.stop();
ui->btnPlay->setStyleSheet(QString());
btnPlay->setStyleSheet(QString());
}
bool Viewer::is_recording_cued() {
@@ -298,7 +297,7 @@ void Viewer::play() {
if (panel_footage_viewer->playing) panel_footage_viewer->pause();
if (seq != NULL) {
reset_all_audio();
reset_all_audio();
if (is_recording_cued() && !start_recording()) {
dout << "[ERROR] Failed to record audio";
return;
@@ -316,7 +315,7 @@ void Viewer::play_wake() {
if (just_played) {
start_msecs = QDateTime::currentMSecsSinceEpoch();
playback_updater.start();
if (audio_thread != NULL) audio_thread->notifyReceiver();
if (audio_thread != NULL) audio_thread->notifyReceiver();
just_played = false;
}
}
@@ -336,27 +335,27 @@ void Viewer::pause() {
// import audio
QStringList file_list;
file_list.append(get_recorded_audio_filename());
panel_project->process_file_list(file_list);
panel_project->process_file_list(file_list);
// add it to the sequence
Clip* c = new Clip(seq);
Media* m = panel_project->last_imported_media.at(0);
Footage* f = m->to_footage();
Media* m = panel_project->last_imported_media.at(0);
Footage* f = m->to_footage();
f->ready_lock.lock();
f->ready_lock.lock();
c->media = m; // latest media
c->media = m; // latest media
c->media_stream = 0;
c->timeline_in = recording_start;
c->timeline_out = f->get_length_in_frames(seq->frame_rate);
c->timeline_out = f->get_length_in_frames(seq->frame_rate);
c->clip_in = 0;
c->track = recording_track;
c->color_r = 128;
c->color_g = 192;
c->color_b = 128;
c->name = m->get_name();
c->name = m->get_name();
f->ready_lock.unlock();
f->ready_lock.unlock();
QVector<Clip*> add_clips;
add_clips.append(c);
@@ -366,24 +365,24 @@ void Viewer::pause() {
}
void Viewer::update_playhead_timecode(long p) {
ui->currentTimecode->set_value(p, false);
currentTimecode->set_value(p, false);
}
void Viewer::update_end_timecode() {
ui->endTimecode->setText((seq == NULL) ? frame_to_timecode(0, config.timecode_view, 30) : frame_to_timecode(seq->getEndFrame(), config.timecode_view, seq->frame_rate));
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_header_zoom() {
if (seq != NULL) {
long sequenceEndFrame = seq->getEndFrame();
if (cached_end_frame != sequenceEndFrame) {
minimum_zoom = (sequenceEndFrame > 0) ? ((double) ui->headers->width() / (double) sequenceEndFrame) : 1;
ui->headers->update_zoom(qMax(ui->headers->get_zoom(), minimum_zoom));
set_sb_max();
viewer_widget->waveform_zoom = ui->headers->get_zoom();
} else {
ui->headers->update();
}
if (cached_end_frame != sequenceEndFrame) {
minimum_zoom = (sequenceEndFrame > 0) ? ((double) headers->width() / (double) sequenceEndFrame) : 1;
headers->update_zoom(qMax(headers->get_zoom(), minimum_zoom));
set_sb_max();
viewer_widget->waveform_zoom = headers->get_zoom();
} else {
headers->update();
}
}
}
@@ -392,137 +391,234 @@ void Viewer::update_parents() {
update_ui(false);
} else {
update_viewer();
}
}
}
void Viewer::resizeEvent(QResizeEvent *event) {
if (seq != NULL) {
set_sb_max();
}
if (seq != NULL) {
set_sb_max();
}
}
void Viewer::update_viewer() {
update_header_zoom();
update_header_zoom();
viewer_widget->update();
if (seq != NULL) update_playhead_timecode(seq->playhead);
update_end_timecode();
update_end_timecode();
}
void Viewer::clear_inout_point() {
if (seq->using_workarea) {
undo_stack.push(new SetTimelineInOutCommand(seq, false, 0, 0));
update_parents();
}
if (seq->using_workarea) {
undo_stack.push(new SetTimelineInOutCommand(seq, false, 0, 0));
update_parents();
}
}
void Viewer::set_in_point() {
ui->headers->set_in_point(seq->playhead);
headers->set_in_point(seq->playhead);
}
void Viewer::set_out_point() {
ui->headers->set_out_point(seq->playhead);
headers->set_out_point(seq->playhead);
}
void Viewer::set_zoom(bool in) {
if (seq != NULL) {
set_zoom_value(in ? ui->headers->get_zoom()*2 : qMax(minimum_zoom, ui->headers->get_zoom()*0.5));
}
if (seq != NULL) {
set_zoom_value(in ? headers->get_zoom()*2 : qMax(minimum_zoom, headers->get_zoom()*0.5));
}
}
void Viewer::set_zoom_value(double d) {
ui->headers->update_zoom(d);
if (viewer_widget->waveform) {
viewer_widget->waveform_zoom = d;
viewer_widget->update();
}
if (seq != NULL) {
set_sb_max();
if (!ui->horizontalScrollBar->is_resizing())
center_scroll_to_playhead(ui->horizontalScrollBar, ui->headers->get_zoom(), seq->playhead);
}
headers->update_zoom(d);
if (viewer_widget->waveform) {
viewer_widget->waveform_zoom = d;
viewer_widget->update();
}
if (seq != NULL) {
set_sb_max();
if (!horizontalScrollBar->is_resizing())
center_scroll_to_playhead(horizontalScrollBar, headers->get_zoom(), seq->playhead);
}
}
void Viewer::set_sb_max() {
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, seq->getEndFrame(), ui->headers->width());
headers->set_scrollbar_max(horizontalScrollBar, seq->getEndFrame(), headers->width());
}
void Viewer::setup_ui() {
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
QWidget* contents = new QWidget();
QVBoxLayout* layout = new QVBoxLayout(contents);
layout->setSpacing(0);
layout->setMargin(0);
glViewerPane = new ViewerContainer(contents);
glViewerPane->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layout->addWidget(glViewerPane);
headers = new TimelineHeader(contents);
layout->addWidget(headers);
horizontalScrollBar = new ResizableScrollBar(contents);
horizontalScrollBar->setSingleStep(20);
horizontalScrollBar->setOrientation(Qt::Horizontal);
layout->addWidget(horizontalScrollBar);
QWidget* lower_controls = new QWidget(contents);
QHBoxLayout* lower_control_layout = new QHBoxLayout(lower_controls);
lower_control_layout->setMargin(0);
// current time code
QWidget* current_timecode_container = new QWidget(lower_controls);
QHBoxLayout* current_timecode_container_layout = new QHBoxLayout(current_timecode_container);
current_timecode_container_layout->setSpacing(0);
current_timecode_container_layout->setMargin(0);
currentTimecode = new LabelSlider(current_timecode_container);
current_timecode_container_layout->addWidget(currentTimecode);
lower_control_layout->addWidget(current_timecode_container);
QWidget* playback_controls = new QWidget(lower_controls);
QHBoxLayout* playback_control_layout = new QHBoxLayout(playback_controls);
playback_control_layout->setSpacing(0);
playback_control_layout->setMargin(0);
btnSkipToStart = new QPushButton(playback_controls);
QIcon goToStartIcon;
goToStartIcon.addFile(QStringLiteral(":/icons/prev.png"), QSize(), QIcon::Normal, QIcon::Off);
goToStartIcon.addFile(QStringLiteral(":/icons/prev-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off);
btnSkipToStart->setIcon(goToStartIcon);
playback_control_layout->addWidget(btnSkipToStart);
btnRewind = new QPushButton(playback_controls);
QIcon rewindIcon;
rewindIcon.addFile(QStringLiteral(":/icons/rew.png"), QSize(), QIcon::Normal, QIcon::Off);
rewindIcon.addFile(QStringLiteral(":/icons/rew-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off);
btnRewind->setIcon(rewindIcon);
playback_control_layout->addWidget(btnRewind);
btnPlay = new QPushButton(playback_controls);
QIcon playIcon;
playIcon.addFile(QStringLiteral(":/icons/play.png"), QSize(), QIcon::Normal, QIcon::Off);
playIcon.addFile(QStringLiteral(":/icons/play-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off);
btnPlay->setIcon(playIcon);
playback_control_layout->addWidget(btnPlay);
btnFastForward = new QPushButton(playback_controls);
QIcon ffIcon;
ffIcon.addFile(QStringLiteral(":/icons/ff.png"), QSize(), QIcon::Normal, QIcon::On);
ffIcon.addFile(QStringLiteral(":/icons/ff-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off);
btnFastForward->setIcon(ffIcon);
playback_control_layout->addWidget(btnFastForward);
btnSkipToEnd = new QPushButton(playback_controls);
QIcon nextIcon;
nextIcon.addFile(QStringLiteral(":/icons/next.png"), QSize(), QIcon::Normal, QIcon::Off);
nextIcon.addFile(QStringLiteral(":/icons/next-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off);
btnSkipToEnd->setIcon(nextIcon);
playback_control_layout->addWidget(btnSkipToEnd);
lower_control_layout->addWidget(playback_controls);
QWidget* end_timecode_container = new QWidget(lower_controls);
QHBoxLayout* end_timecode_layout = new QHBoxLayout(end_timecode_container);
end_timecode_layout->setSpacing(0);
end_timecode_layout->setMargin(0);
endTimecode = new QLabel(end_timecode_container);
endTimecode->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
end_timecode_layout->addWidget(endTimecode);
lower_control_layout->addWidget(end_timecode_container);
layout->addWidget(lower_controls);
setWidget(contents);
}
void Viewer::set_media(Media* m) {
main_sequence = false;
media = m;
clean_created_seq();
if (media != NULL) {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
Footage* footage = media->to_footage();
media = m;
clean_created_seq();
if (media != NULL) {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
Footage* footage = media->to_footage();
seq = new Sequence();
created_sequence = true;
seq->wrapper_sequence = true;
seq->name = footage->name;
seq = new Sequence();
created_sequence = true;
seq->wrapper_sequence = true;
seq->name = footage->name;
seq->using_workarea = footage->using_inout;
if (footage->using_inout) {
seq->workarea_in = footage->in;
seq->workarea_out = footage->out;
}
seq->using_workarea = footage->using_inout;
if (footage->using_inout) {
seq->workarea_in = footage->in;
seq->workarea_out = footage->out;
}
seq->frame_rate = 30;
seq->frame_rate = 30;
if (footage->video_tracks.size() > 0) {
FootageStream* video_stream = footage->video_tracks.at(0);
seq->width = video_stream->video_width;
seq->height = video_stream->video_height;
if (video_stream->video_frame_rate > 0 && !video_stream->infinite_length) seq->frame_rate = video_stream->video_frame_rate;
if (footage->video_tracks.size() > 0) {
FootageStream* video_stream = footage->video_tracks.at(0);
seq->width = video_stream->video_width;
seq->height = video_stream->video_height;
if (video_stream->video_frame_rate > 0 && !video_stream->infinite_length) seq->frame_rate = video_stream->video_frame_rate;
Clip* c = new Clip(seq);
c->media = media;
c->media_stream = video_stream->file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
if (c->timeline_out <= 0) c->timeline_out = 150;
c->track = -1;
c->clip_in = 0;
c->recalculateMaxLength();
seq->clips.append(c);
} else {
seq->width = 1920;
seq->height = 1080;
}
Clip* c = new Clip(seq);
c->media = media;
c->media_stream = video_stream->file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
if (c->timeline_out <= 0) c->timeline_out = 150;
c->track = -1;
c->clip_in = 0;
c->recalculateMaxLength();
seq->clips.append(c);
} else {
seq->width = 1920;
seq->height = 1080;
}
if (footage->audio_tracks.size() > 0) {
FootageStream* audio_stream = footage->audio_tracks.at(0);
seq->audio_frequency = audio_stream->audio_frequency;
if (footage->audio_tracks.size() > 0) {
FootageStream* audio_stream = footage->audio_tracks.at(0);
seq->audio_frequency = audio_stream->audio_frequency;
Clip* c = new Clip(seq);
c->media = media;
c->media_stream = audio_stream->file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
c->track = 0;
c->clip_in = 0;
c->recalculateMaxLength();
seq->clips.append(c);
Clip* c = new Clip(seq);
c->media = media;
c->media_stream = audio_stream->file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
c->track = 0;
c->clip_in = 0;
c->recalculateMaxLength();
seq->clips.append(c);
if (footage->video_tracks.size() == 0) {
viewer_widget->waveform = true;
viewer_widget->waveform_clip = c;
viewer_widget->waveform_ms = audio_stream;
viewer_widget->update();
}
} else {
seq->audio_frequency = 48000;
}
if (footage->video_tracks.size() == 0) {
viewer_widget->waveform = true;
viewer_widget->waveform_clip = c;
viewer_widget->waveform_ms = audio_stream;
viewer_widget->update();
}
} else {
seq->audio_frequency = 48000;
}
seq->audio_layout = AV_CH_LAYOUT_STEREO;
}
break;
case MEDIA_TYPE_SEQUENCE:
seq = media->to_sequence();
break;
}
}
set_sequence(false, seq);
seq->audio_layout = AV_CH_LAYOUT_STEREO;
}
break;
case MEDIA_TYPE_SEQUENCE:
seq = media->to_sequence();
break;
}
}
set_sequence(false, seq);
}
void Viewer::on_btnSkipToStart_clicked() {
@@ -546,45 +642,45 @@ void Viewer::on_btnPlay_clicked() {
}
void Viewer::update_playhead() {
seek(ui->currentTimecode->value());
seek(currentTimecode->value());
}
void Viewer::timer_update() {
long previous_playhead = seq->playhead;
long previous_playhead = seq->playhead;
seq->playhead = qRound(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * seq->frame_rate));
seq->playhead = qRound(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * seq->frame_rate));
update_parents();
long end_frame = (seq->using_workarea && previous_playhead < seq->workarea_out) ? seq->workarea_out : seq->getEndFrame();
if ((!recording
&& playing
&& seq->playhead >= end_frame
&& previous_playhead < end_frame)
|| (recording && recording_start != recording_end && seq->playhead >= recording_end)) {
pause();
}
long end_frame = (seq->using_workarea && previous_playhead < seq->workarea_out) ? seq->workarea_out : seq->getEndFrame();
if ((!recording
&& playing
&& seq->playhead >= end_frame
&& previous_playhead < end_frame)
|| (recording && recording_start != recording_end && seq->playhead >= recording_end)) {
pause();
}
}
void Viewer::recording_flasher_update() {
if (ui->btnPlay->styleSheet().isEmpty()) {
ui->btnPlay->setStyleSheet("background: red;");
if (btnPlay->styleSheet().isEmpty()) {
btnPlay->setStyleSheet("background: red;");
} else {
ui->btnPlay->setStyleSheet(QString());
}
btnPlay->setStyleSheet(QString());
}
}
void Viewer::resize_move(double d) {
set_zoom_value(ui->headers->get_zoom()*d);
set_zoom_value(headers->get_zoom()*d);
}
void Viewer::clean_created_seq() {
viewer_widget->waveform = false;
if (created_sequence) {
// TODO delete undo commands referencing this sequence to avoid crashes
/*for (int i=0;i<undo_stack.count();i++) {
undo_stack.command(i)
}*/
// TODO delete undo commands referencing this sequence to avoid crashes
/*for (int i=0;i<undo_stack.count();i++) {
undo_stack.command(i)
}*/
delete seq;
seq = NULL;
@@ -592,49 +688,49 @@ void Viewer::clean_created_seq() {
}
}
void Viewer::set_sequence(bool main, Sequence *s) {
void Viewer::set_sequence(bool main, Sequence *s) {
reset_all_audio();
main_sequence = main;
main_sequence = main;
seq = (main) ? sequence : s;
bool null_sequence = (seq == NULL);
bool null_sequence = (seq == NULL);
ui->headers->setEnabled(!null_sequence);
ui->currentTimecode->setEnabled(!null_sequence);
viewer_widget->setEnabled(!null_sequence);
viewer_widget->setVisible(!null_sequence);
ui->btnSkipToStart->setEnabled(!null_sequence);
ui->btnRewind->setEnabled(!null_sequence);
ui->btnPlay->setEnabled(!null_sequence);
ui->btnFastForward->setEnabled(!null_sequence);
ui->btnSkipToEnd->setEnabled(!null_sequence);
headers->setEnabled(!null_sequence);
currentTimecode->setEnabled(!null_sequence);
viewer_widget->setEnabled(!null_sequence);
viewer_widget->setVisible(!null_sequence);
btnSkipToStart->setEnabled(!null_sequence);
btnRewind->setEnabled(!null_sequence);
btnPlay->setEnabled(!null_sequence);
btnFastForward->setEnabled(!null_sequence);
btnSkipToEnd->setEnabled(!null_sequence);
if (!null_sequence) {
ui->currentTimecode->set_frame_rate(seq->frame_rate);
if (!null_sequence) {
currentTimecode->set_frame_rate(seq->frame_rate);
playback_updater.setInterval(qFloor(1000 / seq->frame_rate));
update_playhead_timecode(seq->playhead);
update_end_timecode();
update_playhead_timecode(seq->playhead);
update_end_timecode();
ui->glViewerPane->adjust();
glViewerPane->adjust();
setWindowTitle(panel_name + seq->name);
} else {
update_playhead_timecode(0);
update_end_timecode();
setWindowTitle(panel_name + seq->name);
} else {
update_playhead_timecode(0);
update_end_timecode();
setWindowTitle(panel_name + "(none)");
}
setWindowTitle(panel_name + "(none)");
}
update_header_zoom();
viewer_widget->update();
update();
update();
}
void Viewer::set_playpause_icon(bool play) {
ui->btnPlay->setIcon(QIcon((play) ? ":/icons/play.png" : ":/icons/pause.png"));
btnPlay->setIcon(QIcon((play) ? ":/icons/play.png" : ":/icons/pause.png"));
}
+45 -31
View File
@@ -8,10 +8,12 @@ class Timeline;
class ViewerWidget;
class Media;
struct Sequence;
namespace Ui {
class Viewer;
}
class TimelineHeader;
class ResizableScrollBar;
class ViewerContainer;
class LabelSlider;
class QPushButton;
class QLabel;
bool frame_rate_is_droppable(float rate);
long timecode_to_frame(const QString& s, int view, double frame_rate);
@@ -26,18 +28,18 @@ public:
~Viewer();
bool is_focused();
void set_main_sequence();
void set_media(Media *m);
void set_main_sequence();
void set_media(Media *m);
void compose();
void set_playpause_icon(bool play);
void update_playhead_timecode(long p);
void update_end_timecode();
void set_playpause_icon(bool play);
void update_playhead_timecode(long p);
void update_end_timecode();
void update_header_zoom();
void update_viewer();
void clear_inout_point();
void clear_inout_point();
void set_in_point();
void set_out_point();
void set_zoom(bool in);
void set_zoom(bool in);
// playback functions
void go_to_start();
@@ -56,51 +58,63 @@ public:
void cue_recording(long start, long end, int track);
void uncue_recording();
bool is_recording_cued();
bool is_recording_cued();
long recording_start;
long recording_end;
int recording_track;
int recording_track;
void reset_all_audio();
void reset_all_audio();
void update_parents();
ViewerWidget* viewer_widget;
Media* media;
Media* media;
Sequence* seq;
Ui::Viewer *ui;
void resizeEvent(QResizeEvent *event);
void resizeEvent(QResizeEvent *event);
public slots:
void play_wake();
private slots:
void on_btnSkipToStart_clicked();
void on_btnRewind_clicked();
void on_btnPlay_clicked();
void on_btnFastForward_clicked();
void on_btnSkipToEnd_clicked();
void on_btnSkipToStart_clicked();
void on_btnRewind_clicked();
void on_btnPlay_clicked();
void on_btnFastForward_clicked();
void on_btnSkipToEnd_clicked();
void update_playhead();
void timer_update();
void recording_flasher_update();
void resize_move(double d);
void resize_move(double d);
private:
void clean_created_seq();
void set_sequence(bool main, Sequence* s);
void set_sequence(bool main, Sequence* s);
bool main_sequence;
bool created_sequence;
long cached_end_frame;
QString panel_name;
double minimum_zoom;
void set_zoom_value(double d);
void set_sb_max();
long cached_end_frame;
QString panel_name;
double minimum_zoom;
void set_zoom_value(double d);
void set_sb_max();
void setup_ui();
TimelineHeader* headers;
ResizableScrollBar* horizontalScrollBar;
ViewerContainer* glViewerPane;
LabelSlider* currentTimecode;
QLabel* endTimecode;
QPushButton* btnSkipToStart;
QPushButton* btnRewind;
QPushButton* btnPlay;
QPushButton* btnFastForward;
QPushButton* btnSkipToEnd;
bool cue_recording_internal;
QTimer recording_flasher;
QTimer recording_flasher;
};
#endif // VIEWER_H
-259
View File
@@ -1,259 +0,0 @@
<?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>
<property name="bottomMargin">
<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>
</item>
<item>
<widget class="TimelineHeader" name="headers" native="true"/>
</item>
<item>
<widget class="ResizableScrollBar" name="horizontalScrollBar">
<property name="maximum">
<number>0</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="pageStep">
<number>1826</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</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>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<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="LabelSlider" name="currentTimecode">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<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="QPushButton" name="btnSkipToStart">
<property name="enabled">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/prev.png</normaloff>
<disabledoff>:/icons/prev-disabled.png</disabledoff>:/icons/prev.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRewind">
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/rew.png</normaloff>
<disabledoff>:/icons/rew-disabled.png</disabledoff>:/icons/rew.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnPlay">
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/play.png</normaloff>
<disabledoff>:/icons/play-disabled.png</disabledoff>:/icons/play.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnFastForward">
<property name="icon">
<iconset>
<normalon>:/icons/ff.png</normalon>
<disabledoff>:/icons/ff-disabled.png</disabledoff>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSkipToEnd">
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/next.png</normaloff>
<disabledoff>:/icons/next-disabled.png</disabledoff>:/icons/next.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<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="QLabel" name="endTimecode">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>TimelineHeader</class>
<extends>QWidget</extends>
<header>ui/timelineheader.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResizableScrollBar</class>
<extends>QScrollBar</extends>
<header>ui/resizablescrollbar.h</header>
</customwidget>
<customwidget>
<class>ViewerContainer</class>
<extends>QWidget</extends>
<header>ui/viewercontainer.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LabelSlider</class>
<extends>QLabel</extends>
<header>ui/labelslider.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../icons/icons.qrc"/>
</resources>
<connections/>
</ui>
+109 -109
View File
@@ -11,7 +11,7 @@
#include "panels/viewer.h"
#include "ui/viewerwidget.h"
#include "project/sequence.h"
#include "ui_effectcontrols.h"
#include "ui/resizablescrollbar.h"
#include <QLabel>
#include <QMouseEvent>
@@ -27,44 +27,44 @@ long KeyframeView::adjust_row_keyframe(EffectRow* row, long time) {
KeyframeView::KeyframeView(QWidget *parent) :
QWidget(parent),
visible_in(0),
visible_out(0),
visible_in(0),
visible_out(0),
mousedown(false),
dragging(false),
keys_selected(false),
select_rect(false),
select_rect(false),
x_scroll(0),
y_scroll(0),
scroll_drag(false)
y_scroll(0),
scroll_drag(false)
{
setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu(const QPoint&)));
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu(const QPoint&)));
}
void KeyframeView::show_context_menu(const QPoint& pos) {
if (selected_rows.size() > 0) {
QMenu menu(this);
QAction* linear = menu.addAction("Linear");
linear->setData(KEYFRAME_TYPE_LINEAR);
QAction* smooth = menu.addAction("Smooth");
smooth->setData(KEYFRAME_TYPE_SMOOTH);
/*QAction* bezier = menu.addAction("Bezier");
bezier->setData(KEYFRAME_TYPE_BEZIER);*/
connect(&menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_set_key_type(QAction*)));
menu.exec(mapToGlobal(pos));
}
if (selected_rows.size() > 0) {
QMenu menu(this);
QAction* linear = menu.addAction("Linear");
linear->setData(KEYFRAME_TYPE_LINEAR);
QAction* smooth = menu.addAction("Smooth");
smooth->setData(KEYFRAME_TYPE_SMOOTH);
/*QAction* bezier = menu.addAction("Bezier");
bezier->setData(KEYFRAME_TYPE_BEZIER);*/
connect(&menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_set_key_type(QAction*)));
menu.exec(mapToGlobal(pos));
}
}
void KeyframeView::menu_set_key_type(QAction* a) {
ComboAction* ca = new ComboAction();
for (int i=0;i<selected_rows.size();i++) {
ca->append(new SetInt(&selected_rows.at(i)->keyframe_types[selected_keyframes.at(i)], a->data().toInt()));
}
undo_stack.push(ca);
update();
ComboAction* ca = new ComboAction();
for (int i=0;i<selected_rows.size();i++) {
ca->append(new SetInt(&selected_rows.at(i)->keyframe_types[selected_keyframes.at(i)], a->data().toInt()));
}
undo_stack.push(ca);
update();
}
void KeyframeView::paintEvent(QPaintEvent*) {
@@ -99,7 +99,7 @@ void KeyframeView::paintEvent(QPaintEvent*) {
bool keyframe_selected = keyframeIsSelected(row, k);
long keyframe_frame = adjust_row_keyframe(row, row->keyframe_times.at(k));
if (dragging && keyframe_selected) keyframe_frame += frame_diff;
draw_keyframe(p, row->keyframe_types.at(k), getScreenPointFromFrame(panel_effect_controls->zoom, keyframe_frame) - x_scroll, keyframe_y, keyframe_selected);
draw_keyframe(p, row->keyframe_types.at(k), getScreenPointFromFrame(panel_effect_controls->zoom, keyframe_frame) - x_scroll, keyframe_y, keyframe_selected);
}
rows.append(row);
@@ -113,7 +113,7 @@ void KeyframeView::paintEvent(QPaintEvent*) {
if (max_width < width()) {
p.fillRect(QRect(max_width, 0, width(), height()), QColor(0, 0, 0, 64));
}
panel_effect_controls->ui->horizontalScrollBar->setMaximum(qMax(max_width - width(), 0));
panel_effect_controls->horizontalScrollBar->setMaximum(qMax(max_width - width(), 0));
header->set_visible_in(visible_in);
int playhead_x = getScreenPointFromFrame(panel_effect_controls->zoom, sequence->playhead-visible_in) - x_scroll;
@@ -129,9 +129,9 @@ void KeyframeView::paintEvent(QPaintEvent*) {
draw_selection_rectangle(p, QRect(rect_select_x, rect_select_y, rect_select_w, rect_select_h));
}
/*if (mouseover && mouseover_row < rowY.size()) {
/*if (mouseover && mouseover_row < rowY.size()) {
draw_keyframe(p, getScreenPointFromFrame(panel_effect_controls->zoom, mouseover_frame - visible_in), rowY.at(mouseover_row), true);
}*/
}*/
}
bool KeyframeView::keyframeIsSelected(EffectRow *row, int keyframe) {
@@ -173,98 +173,98 @@ void KeyframeView::set_y_scroll(int s) {
}
void KeyframeView::draw_keyframe(QPainter &p, int type, int x, int y, bool darker) {
int color = (darker) ? 100 : 160;
p.setPen(QColor(0, 0, 0));
p.setBrush(QColor(color, color, color));
int color = (darker) ? 100 : 160;
p.setPen(QColor(0, 0, 0));
p.setBrush(QColor(color, color, color));
switch (type) {
case KEYFRAME_TYPE_LINEAR:
{
QPoint points[KEYFRAME_POINT_COUNT] = {QPoint(x-KEYFRAME_SIZE, y), QPoint(x, y-KEYFRAME_SIZE), QPoint(x+KEYFRAME_SIZE, y), QPoint(x, y+KEYFRAME_SIZE)};
p.drawPolygon(points, KEYFRAME_POINT_COUNT);
}
break;
case KEYFRAME_TYPE_SMOOTH:
p.drawEllipse(QPoint(x, y), KEYFRAME_SIZE, KEYFRAME_SIZE);
break;
}
switch (type) {
case KEYFRAME_TYPE_LINEAR:
{
QPoint points[KEYFRAME_POINT_COUNT] = {QPoint(x-KEYFRAME_SIZE, y), QPoint(x, y-KEYFRAME_SIZE), QPoint(x+KEYFRAME_SIZE, y), QPoint(x, y+KEYFRAME_SIZE)};
p.drawPolygon(points, KEYFRAME_POINT_COUNT);
}
break;
case KEYFRAME_TYPE_SMOOTH:
p.drawEllipse(QPoint(x, y), KEYFRAME_SIZE, KEYFRAME_SIZE);
break;
}
}
void KeyframeView::resize_move(double d) {
header->update_zoom(header->get_zoom()*d);
header->update_zoom(header->get_zoom()*d);
}
void KeyframeView::mousePressEvent(QMouseEvent *event) {
rect_select_x = event->x();
rect_select_y = event->y();
rect_select_x = event->x();
rect_select_y = event->y();
if (panel_timeline->tool == TIMELINE_TOOL_HAND || event->buttons() & Qt::MiddleButton) {
scroll_drag = true;
return;
}
if (panel_timeline->tool == TIMELINE_TOOL_HAND || event->buttons() & Qt::MiddleButton) {
scroll_drag = true;
return;
}
int mouse_x = event->x() + x_scroll;
int mouse_y = event->y();
int row_index = -1;
int keyframe_index = -1;
long frame_diff = 0;
long frame_min = getFrameFromScreenPoint(panel_effect_controls->zoom, mouse_x-KEYFRAME_SIZE);
drag_frame_start = getFrameFromScreenPoint(panel_effect_controls->zoom, mouse_x);
long frame_max = getFrameFromScreenPoint(panel_effect_controls->zoom, mouse_x+KEYFRAME_SIZE);
for (int i=0;i<rowY.size();i++) {
if (mouse_y > rowY.at(i)-KEYFRAME_SIZE-KEYFRAME_SIZE && mouse_y < rowY.at(i)+KEYFRAME_SIZE+KEYFRAME_SIZE) {
EffectRow* row = rows.at(i);
for (int j=0;j<row->keyframe_times.size();j++) {
long eval_keyframe_time = row->keyframe_times.at(j)-row->parent_effect->parent_clip->clip_in+(row->parent_effect->parent_clip->timeline_in-visible_in);
if (eval_keyframe_time >= frame_min && eval_keyframe_time <= frame_max) {
long eval_frame_diff = qAbs(eval_keyframe_time - drag_frame_start);
if (keyframe_index == -1 || eval_frame_diff < frame_diff) {
row_index = i;
keyframe_index = j;
frame_diff = eval_frame_diff;
}
}
}
break;
}
}
bool already_selected = false;
keys_selected = false;
if (keyframe_index > -1) already_selected = keyframeIsSelected(rows.at(row_index), keyframe_index);
if (!already_selected) {
if (!(event->modifiers() & Qt::ShiftModifier)) {
selected_rows.clear();
selected_keyframes.clear();
}
if (keyframe_index > -1) {
selected_rows.append(rows.at(row_index));
selected_keyframes.append(keyframe_index);
}
}
int mouse_x = event->x() + x_scroll;
int mouse_y = event->y();
int row_index = -1;
int keyframe_index = -1;
long frame_diff = 0;
long frame_min = getFrameFromScreenPoint(panel_effect_controls->zoom, mouse_x-KEYFRAME_SIZE);
drag_frame_start = getFrameFromScreenPoint(panel_effect_controls->zoom, mouse_x);
long frame_max = getFrameFromScreenPoint(panel_effect_controls->zoom, mouse_x+KEYFRAME_SIZE);
for (int i=0;i<rowY.size();i++) {
if (mouse_y > rowY.at(i)-KEYFRAME_SIZE-KEYFRAME_SIZE && mouse_y < rowY.at(i)+KEYFRAME_SIZE+KEYFRAME_SIZE) {
EffectRow* row = rows.at(i);
for (int j=0;j<row->keyframe_times.size();j++) {
long eval_keyframe_time = row->keyframe_times.at(j)-row->parent_effect->parent_clip->clip_in+(row->parent_effect->parent_clip->timeline_in-visible_in);
if (eval_keyframe_time >= frame_min && eval_keyframe_time <= frame_max) {
long eval_frame_diff = qAbs(eval_keyframe_time - drag_frame_start);
if (keyframe_index == -1 || eval_frame_diff < frame_diff) {
row_index = i;
keyframe_index = j;
frame_diff = eval_frame_diff;
}
}
}
break;
}
}
bool already_selected = false;
keys_selected = false;
if (keyframe_index > -1) already_selected = keyframeIsSelected(rows.at(row_index), keyframe_index);
if (!already_selected) {
if (!(event->modifiers() & Qt::ShiftModifier)) {
selected_rows.clear();
selected_keyframes.clear();
}
if (keyframe_index > -1) {
selected_rows.append(rows.at(row_index));
selected_keyframes.append(keyframe_index);
}
}
if (selected_rows.size() > 0) {
keys_selected = true;
}
if (selected_rows.size() > 0) {
keys_selected = true;
}
update();
update();
if (event->button() == Qt::LeftButton) {
mousedown = true;
}
if (event->button() == Qt::LeftButton) {
mousedown = true;
}
}
void KeyframeView::mouseMoveEvent(QMouseEvent* event) {
if (panel_timeline->tool == TIMELINE_TOOL_HAND) {
setCursor(Qt::OpenHandCursor);
} else {
unsetCursor();
}
if (scroll_drag) {
panel_effect_controls->ui->horizontalScrollBar->setValue(panel_effect_controls->ui->horizontalScrollBar->value() + rect_select_x - event->pos().x());
panel_effect_controls->ui->verticalScrollBar->setValue(panel_effect_controls->ui->verticalScrollBar->value() + rect_select_y - event->pos().y());
rect_select_x = event->pos().x();
rect_select_y = event->pos().y();
} else if (mousedown) {
if (panel_timeline->tool == TIMELINE_TOOL_HAND) {
setCursor(Qt::OpenHandCursor);
} else {
unsetCursor();
}
if (scroll_drag) {
panel_effect_controls->horizontalScrollBar->setValue(panel_effect_controls->horizontalScrollBar->value() + rect_select_x - event->pos().x());
panel_effect_controls->verticalScrollBar->setValue(panel_effect_controls->verticalScrollBar->value() + rect_select_y - event->pos().y());
rect_select_x = event->pos().x();
rect_select_y = event->pos().y();
} else if (mousedown) {
int mouse_x = event->x() + x_scroll;
if (keys_selected) {
// move keyframes
@@ -333,7 +333,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent* event) {
select_rect = true;
}
update();
}
}
}
void KeyframeView::mouseReleaseEvent(QMouseEvent*) {
@@ -347,8 +347,8 @@ void KeyframeView::mouseReleaseEvent(QMouseEvent*) {
select_rect = false;
dragging = false;
mousedown = false;
scroll_drag = false;
mousedown = false;
scroll_drag = false;
panel_timeline->snapped = false;
update();
}
+68 -66
View File
@@ -9,96 +9,98 @@
#define RESIZE_HANDLE_SIZE 10
ResizableScrollBar::ResizableScrollBar(QWidget *parent) :
QScrollBar(parent),
resize_init(false),
resize_proc(false)
QScrollBar(parent),
resize_init(false),
resize_proc(false)
{
setMouseTracking(true);
setSingleStep(20);
setMaximum(0);
setMouseTracking(true);
}
bool ResizableScrollBar::is_resizing() {
return resize_proc;
return resize_proc;
}
void ResizableScrollBar::resizeEvent(QResizeEvent *event) {
setPageStep(event->size().width());
setPageStep(event->size().width());
}
void ResizableScrollBar::mousePressEvent(QMouseEvent *e) {
if (resize_init) {
QStyleOptionSlider opt;
initStyleOption(&opt);
if (resize_init) {
QStyleOptionSlider opt;
initStyleOption(&opt);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
resize_proc = true;
resize_start = e->pos().x();
resize_proc = true;
resize_start = e->pos().x();
resize_start_max = maximum();
resize_start_width = sr.width();
} else {
QScrollBar::mousePressEvent(e);
}
resize_start_max = maximum();
resize_start_width = sr.width();
} else {
QScrollBar::mousePressEvent(e);
}
}
void ResizableScrollBar::mouseMoveEvent(QMouseEvent *e) {
QStyleOptionSlider opt;
initStyleOption(&opt);
QStyleOptionSlider opt;
initStyleOption(&opt);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
QRect gr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarGroove, this);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
QRect gr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarGroove, this);
if (resize_proc) {
int diff = (e->pos().x() - resize_start);
if (resize_top) diff = -diff;
double scale = double(sr.width())/double(sr.width()+diff);
if (!qIsInf(scale) && !qIsNull(scale)) {
emit resize_move(scale);
resize_start = e->pos().x();
if (resize_proc) {
int diff = (e->pos().x() - resize_start);
if (resize_top) diff = -diff;
double scale = double(sr.width())/double(sr.width()+diff);
if (!qIsInf(scale) && !qIsNull(scale)) {
emit resize_move(scale);
resize_start = e->pos().x();
if (resize_top) {
int slider_min = gr.x();
int slider_max = gr.right() - (sr.width()+diff);
int val = QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x() - slider_min, slider_max - slider_min, opt.upsideDown);
if (resize_top) {
int slider_min = gr.x();
int slider_max = gr.right() - (sr.width()+diff);
int val = QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x() - slider_min, slider_max - slider_min, opt.upsideDown);
setValue(val);
} else {
setValue(qRound(value() * scale));
}
}
} else {
bool new_resize_init = false;
setValue(val);
} else {
setValue(qRound(value() * scale));
}
}
} else {
bool new_resize_init = false;
if ((orientation() == Qt::Horizontal && e->pos().x() > sr.left()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.left()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.top()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.top()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = true;
} else if ((orientation() == Qt::Horizontal && e->pos().x() > sr.right()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.right()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.bottom()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.bottom()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = false;
}
if ((orientation() == Qt::Horizontal && e->pos().x() > sr.left()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.left()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.top()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.top()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = true;
} else if ((orientation() == Qt::Horizontal && e->pos().x() > sr.right()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.right()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.bottom()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.bottom()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = false;
}
if (resize_init != new_resize_init) {
if (new_resize_init) {
setCursor(Qt::SizeHorCursor);
} else {
unsetCursor();
}
resize_init = new_resize_init;
}
if (resize_init != new_resize_init) {
if (new_resize_init) {
setCursor(Qt::SizeHorCursor);
} else {
unsetCursor();
}
resize_init = new_resize_init;
}
QScrollBar::mouseMoveEvent(e);
}
QScrollBar::mouseMoveEvent(e);
}
}
void ResizableScrollBar::mouseReleaseEvent(QMouseEvent *e) {
if (resize_proc) {
resize_proc = false;
} else {
QScrollBar::mouseReleaseEvent(e);
}
if (resize_proc) {
resize_proc = false;
} else {
QScrollBar::mouseReleaseEvent(e);
}
}