progress on sequence editing
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
#include "panels/project.h"
|
#include "panels/project.h"
|
||||||
#include "project/sequence.h"
|
#include "project/sequence.h"
|
||||||
#include "project/undo.h"
|
#include "project/undo.h"
|
||||||
|
#include "panels/timeline.h"
|
||||||
|
#include "playback/playback.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -74,21 +76,28 @@ void NewSequenceDialog::showEvent(QShowEvent *) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NewSequenceDialog::on_buttonBox_accepted() {
|
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) {
|
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();
|
ComboAction* ca = new ComboAction();
|
||||||
panel_project->new_sequence(ca, s, true, NULL);
|
panel_project->new_sequence(ca, s, true, NULL);
|
||||||
undo_stack.push(ca);
|
undo_stack.push(ca);
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class Project;
|
class Project;
|
||||||
|
class QTreeWidgetItem;
|
||||||
struct Sequence;
|
struct Sequence;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@@ -18,6 +19,7 @@ public:
|
|||||||
explicit NewSequenceDialog(QWidget *parent = 0);
|
explicit NewSequenceDialog(QWidget *parent = 0);
|
||||||
~NewSequenceDialog();
|
~NewSequenceDialog();
|
||||||
Sequence* existing_sequence;
|
Sequence* existing_sequence;
|
||||||
|
QTreeWidgetItem* existing_item;
|
||||||
void set_sequence_name(const QString& s);
|
void set_sequence_name(const QString& s);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -25,7 +27,6 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_buttonBox_accepted();
|
void on_buttonBox_accepted();
|
||||||
|
|
||||||
void on_comboBox_currentIndexChanged(int index);
|
void on_comboBox_currentIndexChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
+2
-4
@@ -158,10 +158,8 @@ void Project::open_properties() {
|
|||||||
NewSequenceDialog nsd(this);
|
NewSequenceDialog nsd(this);
|
||||||
Sequence* s = get_sequence_from_tree(item);
|
Sequence* s = get_sequence_from_tree(item);
|
||||||
nsd.existing_sequence = s;
|
nsd.existing_sequence = s;
|
||||||
if (nsd.exec() == QDialog::Accepted) {
|
nsd.existing_item = item;
|
||||||
set_sequence_of_tree(item, s);
|
nsd.exec();
|
||||||
panel_timeline->repaint_timeline(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1538,3 +1538,53 @@ void SetEnableCommand::redo() {
|
|||||||
clip->enabled = new_val;
|
clip->enabled = new_val;
|
||||||
mainWindow->setWindowModified(true);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -467,4 +467,30 @@ private:
|
|||||||
bool old_project_changed;
|
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
|
#endif // UNDO_H
|
||||||
|
|||||||
+11
-10
@@ -46,13 +46,17 @@ void KeyframeView::paintEvent(QPaintEvent*) {
|
|||||||
rows.clear();
|
rows.clear();
|
||||||
|
|
||||||
if (panel_effect_controls->selected_clips.size() > 0) {
|
if (panel_effect_controls->selected_clips.size() > 0) {
|
||||||
long effects_in = LONG_MAX;
|
visible_in = LONG_MAX;
|
||||||
long effects_out = 0;
|
visible_out = 0;
|
||||||
|
|
||||||
for (int j=0;j<panel_effect_controls->selected_clips.size();j++) {
|
for (int j=0;j<panel_effect_controls->selected_clips.size();j++) {
|
||||||
Clip* c = sequence->clips.at(panel_effect_controls->selected_clips.at(j));
|
Clip* c = sequence->clips.at(panel_effect_controls->selected_clips.at(j));
|
||||||
effects_in = qMin(effects_in, c->timeline_in);
|
visible_in = qMin(visible_in, c->timeline_in);
|
||||||
effects_out = qMax(effects_out, c->timeline_out);
|
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++) {
|
for (int i=0;i<c->effects.size();i++) {
|
||||||
Effect* e = c->effects.at(i);
|
Effect* e = c->effects.at(i);
|
||||||
if (e->container->is_expanded()) {
|
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);
|
int max_width = getScreenPointFromFrame(panel_effect_controls->zoom, visible_out - visible_in);
|
||||||
qDebug() << max_width << width();
|
|
||||||
if (max_width < width()) {
|
if (max_width < width()) {
|
||||||
p.fillRect(QRect(max_width, 0, width(), height()), QColor(0, 0, 0, 64));
|
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->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;
|
int playhead_x = getScreenPointFromFrame(panel_effect_controls->zoom, sequence->playhead-visible_in) - x_scroll;
|
||||||
if (dragging && panel_timeline->snapped) {
|
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.setPen(QColor(0, 0, 0));
|
||||||
p.setBrush(QColor(color, color, color));
|
p.setBrush(QColor(color, color, color));
|
||||||
p.drawPolygon(points, KEYFRAME_POINT_COUNT);
|
p.drawPolygon(points, KEYFRAME_POINT_COUNT);
|
||||||
|
qDebug() << "drew key at" << x << y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyframeView::mousePressEvent(QMouseEvent *event) {
|
void KeyframeView::mousePressEvent(QMouseEvent *event) {
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ double LabelSlider::value() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LabelSlider::set_default_value(double v) {
|
void LabelSlider::set_default_value(double v) {
|
||||||
|
if (internal_value == default_value) set = false; // TODO: CONTROVERSIAL - may be undesirable behaviour
|
||||||
|
|
||||||
default_value = v;
|
default_value = v;
|
||||||
if (!set) {
|
if (!set) {
|
||||||
set_value(v, false);
|
set_value(v, false);
|
||||||
|
|||||||
@@ -1009,10 +1009,10 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
|||||||
if (redraw) {
|
if (redraw) {
|
||||||
panel_timeline->repaint_timeline(true);
|
panel_timeline->repaint_timeline(true);
|
||||||
} else {
|
} else {
|
||||||
|
panel_timeline->update_effect_controls();
|
||||||
if (repaint) {
|
if (repaint) {
|
||||||
panel_timeline->repaint_timeline(false);
|
panel_timeline->repaint_timeline(false);
|
||||||
}
|
}
|
||||||
panel_timeline->update_effect_controls();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user