progress on sequence editing

This commit is contained in:
itsmattkc
2018-10-12 20:41:22 +11:00
parent cdbec85a81
commit 2e577330b9
8 changed files with 113 additions and 26 deletions
+19 -10
View File
@@ -5,6 +5,8 @@
#include "panels/project.h"
#include "project/sequence.h"
#include "project/undo.h"
#include "panels/timeline.h"
#include "playback/playback.h"
#include <QVariant>
#include <QDebug>
@@ -74,21 +76,28 @@ void NewSequenceDialog::showEvent(QShowEvent *) {
}
void NewSequenceDialog::on_buttonBox_accepted() {
Sequence* s = (existing_sequence != NULL) ? existing_sequence : new Sequence();
s->name = ui->lineEdit->text();
s->width = ui->width_numeric->value();
s->height = ui->height_numeric->value();
s->frame_rate = ui->frame_rate_combobox->currentData().toDouble();
s->audio_frequency = ui->audio_frequency_combobox->currentData().toInt();
s->audio_layout = AV_CH_LAYOUT_STEREO;
if (existing_sequence == NULL) {
Sequence* s = new Sequence();
s->name = ui->lineEdit->text();
s->width = ui->width_numeric->value();
s->height = ui->height_numeric->value();
s->frame_rate = ui->frame_rate_combobox->currentData().toDouble();
s->audio_frequency = ui->audio_frequency_combobox->currentData().toInt();
s->audio_layout = AV_CH_LAYOUT_STEREO;
ComboAction* ca = new ComboAction();
panel_project->new_sequence(ca, s, true, NULL);
undo_stack.push(ca);
} else {
// TODO make editing undoable
EditSequenceCommand* esc = new EditSequenceCommand(existing_item, existing_sequence);
esc->name = ui->lineEdit->text();
esc->width = ui->width_numeric->value();
esc->height = ui->height_numeric->value();
esc->frame_rate = ui->frame_rate_combobox->currentData().toDouble();
esc->audio_frequency = ui->audio_frequency_combobox->currentData().toInt();
esc->audio_layout = AV_CH_LAYOUT_STEREO;
undo_stack.push(esc);
}
}
+2 -1
View File
@@ -4,6 +4,7 @@
#include <QDialog>
class Project;
class QTreeWidgetItem;
struct Sequence;
namespace Ui {
@@ -18,6 +19,7 @@ public:
explicit NewSequenceDialog(QWidget *parent = 0);
~NewSequenceDialog();
Sequence* existing_sequence;
QTreeWidgetItem* existing_item;
void set_sequence_name(const QString& s);
protected:
@@ -25,7 +27,6 @@ protected:
private slots:
void on_buttonBox_accepted();
void on_comboBox_currentIndexChanged(int index);
private:
+2 -4
View File
@@ -158,10 +158,8 @@ void Project::open_properties() {
NewSequenceDialog nsd(this);
Sequence* s = get_sequence_from_tree(item);
nsd.existing_sequence = s;
if (nsd.exec() == QDialog::Accepted) {
set_sequence_of_tree(item, s);
panel_timeline->repaint_timeline(true);
}
nsd.existing_item = item;
nsd.exec();
}
break;
default:
+50
View File
@@ -1538,3 +1538,53 @@ void SetEnableCommand::redo() {
clip->enabled = new_val;
mainWindow->setWindowModified(true);
}
EditSequenceCommand::EditSequenceCommand(QTreeWidgetItem* i, Sequence *s) :
item(i),
seq(s),
old_project_changed(mainWindow->isWindowModified()),
old_name(s->name),
old_width(s->width),
old_height(s->height),
old_frame_rate(s->frame_rate),
old_audio_frequency(s->audio_frequency),
old_audio_layout(s->audio_layout)
{}
void EditSequenceCommand::undo() {
seq->name = old_name;
seq->width = old_width;
seq->height = old_height;
seq->frame_rate = old_frame_rate;
seq->audio_frequency = old_audio_frequency;
seq->audio_layout = old_audio_layout;
update();
}
void EditSequenceCommand::redo() {
seq->name = name;
seq->width = width;
seq->height = height;
seq->frame_rate = frame_rate;
seq->audio_frequency = audio_frequency;
seq->audio_layout = audio_layout;
update();
}
void EditSequenceCommand::update() {
// update tooltip
set_sequence_of_tree(item, seq);
for (int i=0;i<seq->clips.size();i++) {
// TODO shift in/out/clipin points to match new frame rate
// BUT ALSO copy/paste must need a similar routine, no?
// See if one exists or if you have to make one, make it
// re-usable
seq->clips.at(i)->refresh();
}
if (sequence == seq) {
set_sequence(seq);
}
}
+26
View File
@@ -467,4 +467,30 @@ private:
bool old_project_changed;
};
class EditSequenceCommand : public QUndoCommand {
public:
EditSequenceCommand(QTreeWidgetItem *i, Sequence* s);
void undo();
void redo();
void update();
QString name;
int width;
int height;
double frame_rate;
int audio_frequency;
int audio_layout;
private:
QTreeWidgetItem* item;
Sequence* seq;
bool old_project_changed;
QString old_name;
int old_width;
int old_height;
double old_frame_rate;
int old_audio_frequency;
int old_audio_layout;
};
#endif // UNDO_H
+11 -10
View File
@@ -46,13 +46,17 @@ void KeyframeView::paintEvent(QPaintEvent*) {
rows.clear();
if (panel_effect_controls->selected_clips.size() > 0) {
long effects_in = LONG_MAX;
long effects_out = 0;
visible_in = LONG_MAX;
visible_out = 0;
for (int j=0;j<panel_effect_controls->selected_clips.size();j++) {
Clip* c = sequence->clips.at(panel_effect_controls->selected_clips.at(j));
effects_in = qMin(effects_in, c->timeline_in);
effects_out = qMax(effects_out, c->timeline_out);
Clip* c = sequence->clips.at(panel_effect_controls->selected_clips.at(j));
visible_in = qMin(visible_in, c->timeline_in);
visible_out = qMax(visible_out, c->timeline_out);
}
for (int j=0;j<panel_effect_controls->selected_clips.size();j++) {
Clip* c = sequence->clips.at(panel_effect_controls->selected_clips.at(j));
for (int i=0;i<c->effects.size();i++) {
Effect* e = c->effects.at(i);
if (e->container->is_expanded()) {
@@ -77,16 +81,12 @@ void KeyframeView::paintEvent(QPaintEvent*) {
}
}
visible_in = effects_in;
visible_out = effects_out;
int max_width = getScreenPointFromFrame(panel_effect_controls->zoom, visible_out - visible_in);
qDebug() << max_width << width();
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));
header->set_visible_in(effects_in);
header->set_visible_in(visible_in);
int playhead_x = getScreenPointFromFrame(panel_effect_controls->zoom, sequence->playhead-visible_in) - x_scroll;
if (dragging && panel_timeline->snapped) {
@@ -150,6 +150,7 @@ void KeyframeView::draw_keyframe(QPainter &p, int x, int y, bool darker) {
p.setPen(QColor(0, 0, 0));
p.setBrush(QColor(color, color, color));
p.drawPolygon(points, KEYFRAME_POINT_COUNT);
qDebug() << "drew key at" << x << y;
}
void KeyframeView::mousePressEvent(QMouseEvent *event) {
+2
View File
@@ -75,6 +75,8 @@ double LabelSlider::value() {
}
void LabelSlider::set_default_value(double v) {
if (internal_value == default_value) set = false; // TODO: CONTROVERSIAL - may be undesirable behaviour
default_value = v;
if (!set) {
set_value(v, false);
+1 -1
View File
@@ -1009,10 +1009,10 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
if (redraw) {
panel_timeline->repaint_timeline(true);
} else {
panel_timeline->update_effect_controls();
if (repaint) {
panel_timeline->repaint_timeline(false);
}
panel_timeline->update_effect_controls();
}
}
}