trying to fix undo bug

This commit is contained in:
itsmattkc
2018-06-14 00:51:14 -07:00
parent 124b76d58c
commit f8ce6c08f8
14 changed files with 38 additions and 39 deletions
+3 -3
View File
@@ -29,7 +29,7 @@ class TransformEffect : public Effect {
public:
TransformEffect(Clip* c);
void process_gl(int* anchor_x, int* anchor_y);
Effect* copy();
Effect* copy(Clip* c);
QSpinBox* position_x;
QSpinBox* position_y;
@@ -52,7 +52,7 @@ class VolumeEffect : public Effect {
public:
VolumeEffect(Clip* c);
void process_audio(uint8_t* samples, int nb_bytes);
Effect* copy();
Effect* copy(Clip* c);
void load(QXmlStreamReader* stream);
void save(QXmlStreamWriter* stream);
@@ -63,7 +63,7 @@ class PanEffect : public Effect {
public:
PanEffect(Clip* c);
void process_audio(uint8_t* samples, int nb_bytes);
Effect* copy();
Effect* copy(Clip* c);
void load(QXmlStreamReader* stream);
void save(QXmlStreamWriter* stream);
+2 -2
View File
@@ -25,8 +25,8 @@ PanEffect::PanEffect(Clip* c) : Effect(c) {
pan_val->setValue(0);
}
Effect* PanEffect::copy() {
PanEffect* p = new PanEffect(parent_clip);
Effect* PanEffect::copy(Clip* c) {
PanEffect* p = new PanEffect(c);
p->pan_val->setValue(pan_val->value());
return p;
}
+2 -2
View File
@@ -93,8 +93,8 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c) {
connect(uniform_scale_box, SIGNAL(toggled(bool)), this, SLOT(field_changed()));
}
Effect* TransformEffect::copy() {
TransformEffect* t = new TransformEffect(parent_clip);
Effect* TransformEffect::copy(Clip* c) {
TransformEffect* t = new TransformEffect(c);
t->position_x->setValue(position_x->value());
t->position_y->setValue(position_y->value());
t->scale_x->setValue(scale_x->value());
+2 -2
View File
@@ -25,8 +25,8 @@ VolumeEffect::VolumeEffect(Clip* c) : Effect(c) {
volume_val->setValue(100);
}
Effect* VolumeEffect::copy() {
VolumeEffect* v = new VolumeEffect(parent_clip);
Effect* VolumeEffect::copy(Clip* c) {
VolumeEffect* v = new VolumeEffect(c);
v->volume_val->setValue(volume_val->value());
return v;
}
+1 -1
View File
@@ -1,6 +1,6 @@
#include "previewgenerator.h"
PreviewGenerator::PreviewGenerator(QWidget* parent) : QThread(parent)
PreviewGenerator::PreviewGenerator(QObject* parent) : QThread(parent)
{
}
+1 -1
View File
@@ -6,7 +6,7 @@
class PreviewGenerator : public QThread
{
public:
PreviewGenerator(QWidget* parent = 0);
PreviewGenerator(QObject* parent = 0);
void run() override;
};
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.6.1, 2018-06-13T22:15:23. -->
<!-- Written by QtCreator 4.6.1, 2018-06-13T17:04:15. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
+2 -2
View File
@@ -164,8 +164,8 @@ void Timeline::redraw_all_clips() {
sequence->undo_add_current();
project_changed = true;
ui->video_area->redraw_clips();
ui->audio_area->redraw_clips();
ui->video_area->redraw_clips();
ui->audio_area->redraw_clips();
}
void Timeline::select_all() {
+2 -2
View File
@@ -18,7 +18,7 @@ Clip::Clip() {
Clip* Clip::copy() {
Clip* copy = new Clip();
copy->name = name;
copy->name = QString(name);
copy->clip_in = clip_in;
copy->timeline_in = timeline_in;
copy->timeline_out = timeline_out;
@@ -31,7 +31,7 @@ Clip* Clip::copy() {
copy->media_stream = media_stream;
for (int i=0;i<effects.size();i++) {
copy->effects.append(effects.at(i)->copy());
copy->effects.append(effects.at(i)->copy(copy));
}
return copy;
+1 -2
View File
@@ -20,7 +20,6 @@ struct AVPacket;
struct SwsContext;
struct SwrContext;
class QOpenGLTexture;
class QPixmap;
struct ClipCache {
AVFrame** frames;
@@ -50,7 +49,7 @@ struct Clip
uint8_t color_b;
long getLength();
// inherited information (should be copied in copy())
// inherited information (should be set to the same references in copy())
Media* media; // attached media
MediaStream* media_stream;
Sequence* sequence;
+3 -3
View File
@@ -28,9 +28,9 @@ void Effect::field_changed() {
panel_viewer->viewer_widget->update();
}
Effect* Effect::copy() {return NULL;}
void Effect::load(QXmlStreamReader* stream) {}
void Effect::save(QXmlStreamWriter *stream) {}
Effect* Effect::copy(Clip*) {return NULL;}
void Effect::load(QXmlStreamReader*) {}
void Effect::save(QXmlStreamWriter*) {}
void Effect::process_gl(int*, int*) {}
void Effect::process_audio(uint8_t*, int) {}
+1 -1
View File
@@ -24,7 +24,7 @@ public:
QWidget* ui;
Clip* parent_clip;
virtual Effect* copy();
virtual Effect* copy(Clip* c);
virtual void load(QXmlStreamReader* stream);
virtual void save(QXmlStreamWriter* stream);
+4 -4
View File
@@ -95,8 +95,8 @@ void Sequence::undo_add_current() {
undo_stack.removeFirst();
} else {
undo_pointer++;
for (int i=undo_stack.size()-1;i>undo_pointer;i--) {
delete undo_stack[i];
while (undo_stack.size() > undo_pointer+1) {
delete undo_stack.last();
undo_stack.removeLast();
}
}
@@ -115,9 +115,9 @@ void Sequence::set_undo(int i) {
}
clips.clear();
QVector<Clip*>* copy_from_list = undo_stack[undo_pointer];
QVector<Clip*>* copy_from_list = undo_stack.at(undo_pointer);
for (int i=0;i<copy_from_list->size();i++) {
add_clip(copy_from_list->at(i));
add_clip(copy_from_list->at(i)->copy());
}
}
+13 -13
View File
@@ -761,26 +761,26 @@ void TimelineWidget::redraw_clips() {
video_track_limit = clip->track;
} else if (clip->track > audio_track_limit) {
audio_track_limit = clip->track;
}
}
QRect clip_rect(panel_timeline->getScreenPointFromFrame(clip->timeline_in), getScreenPointFromTrack(clip->track), clip->getLength() * panel_timeline->zoom, track_height);
clip_painter.fillRect(clip_rect, QColor(clip->color_r, clip->color_g, clip->color_b));
clip_painter.setPen(Qt::white);
clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.topLeft());
clip_painter.drawLine(clip_rect.topLeft(), clip_rect.topRight());
clip_painter.setPen(Qt::white);
clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.topLeft());
clip_painter.drawLine(clip_rect.topLeft(), clip_rect.topRight());
clip_painter.setPen(Qt::gray);
clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.bottomRight());
clip_painter.drawLine(clip_rect.bottomRight(), clip_rect.topRight());
clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.bottomRight());
clip_painter.drawLine(clip_rect.bottomRight(), clip_rect.topRight());
if (color_brightness(clip->color_r, clip->color_g, clip->color_b) > 160) {
clip_painter.setPen(Qt::black);
} else {
clip_painter.setPen(Qt::white);
}
QRect text_rect(clip_rect.left() + CLIP_TEXT_PADDING, clip_rect.top() + CLIP_TEXT_PADDING, clip_rect.width() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING, clip_rect.height() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING);
clip_painter.setPen(Qt::black);
} else {
clip_painter.setPen(Qt::white);
}
QRect text_rect(clip_rect.left() + CLIP_TEXT_PADDING, clip_rect.top() + CLIP_TEXT_PADDING, clip_rect.width() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING, clip_rect.height() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING);
clip_painter.drawText(text_rect, 0, clip->name, &text_rect);
}
}
}
}
// Draw track lines
if (show_track_lines) {