basic undo support added
This commit is contained in:
@@ -161,3 +161,17 @@ void MainWindow::on_actionRipple_Delete_triggered()
|
||||
{
|
||||
panel_timeline->delete_selection(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_action_Undo_triggered()
|
||||
{
|
||||
if (panel_timeline->focused()) {
|
||||
panel_timeline->undo();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_Redo_triggered()
|
||||
{
|
||||
if (panel_timeline->focused()) {
|
||||
panel_timeline->redo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ private slots:
|
||||
|
||||
void on_actionRipple_Delete_triggered();
|
||||
|
||||
void on_action_Undo_triggered();
|
||||
|
||||
void on_action_Redo_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
void setup_layout();
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.6.1, 2018-06-07T15:46:16. -->
|
||||
<!-- Written by QtCreator 4.6.1, 2018-06-07T16:17:16. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
@@ -292,7 +292,7 @@
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">olive.pro</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">C:/Users/Matt/Documents/temp</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"></value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
|
||||
@@ -137,6 +137,22 @@ bool Timeline::focused() {
|
||||
return (ui->video_area->hasFocus() || ui->audio_area->hasFocus());
|
||||
}
|
||||
|
||||
void Timeline::undo() {
|
||||
if (sequence != NULL) {
|
||||
sequence->undo();
|
||||
ui->video_area->redraw_clips();
|
||||
ui->audio_area->redraw_clips();
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::redo() {
|
||||
if (sequence != NULL) {
|
||||
sequence->redo();
|
||||
ui->video_area->redraw_clips();
|
||||
ui->audio_area->redraw_clips();
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::repaint_timeline() {
|
||||
if (playing) {
|
||||
// playhead = playhead_start + (playback_timer.elapsed() * 0.001 * sequence->frame_rate);
|
||||
@@ -151,6 +167,9 @@ void Timeline::repaint_timeline() {
|
||||
}
|
||||
|
||||
void Timeline::redraw_all_clips() {
|
||||
// add current sequence to the undo stack
|
||||
sequence->undo_add_current();
|
||||
|
||||
ui->video_area->redraw_clips();
|
||||
ui->audio_area->redraw_clips();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ public:
|
||||
bool focused();
|
||||
void zoom_in();
|
||||
void zoom_out();
|
||||
void undo();
|
||||
void redo();
|
||||
void set_sequence(Sequence* s);
|
||||
|
||||
Sequence* sequence;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
Sequence::Sequence() {
|
||||
undo_pointer = -1;
|
||||
}
|
||||
|
||||
Sequence::~Sequence() {
|
||||
@@ -120,3 +121,29 @@ void Sequence::split_at_playhead(long frame) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::undo_add_current() {
|
||||
undo_pointer++;
|
||||
undo_stack.resize(undo_pointer);
|
||||
undo_stack.append(clips);
|
||||
qDebug() << "a pointer:" << undo_pointer << undo_stack.size();
|
||||
}
|
||||
|
||||
void Sequence::undo() {
|
||||
if (undo_pointer > 0) {
|
||||
undo_pointer--;
|
||||
clips = undo_stack[undo_pointer];
|
||||
} else {
|
||||
qDebug() << "[INFO] No more undos";
|
||||
}
|
||||
qDebug() << "u pointer:" << undo_pointer << undo_stack.size();
|
||||
}
|
||||
void Sequence::redo() {
|
||||
if (undo_pointer == undo_stack.size() - 1) {
|
||||
qDebug() << "[INFO] No more redos";
|
||||
} else {
|
||||
undo_pointer++;
|
||||
clips = undo_stack[undo_pointer];
|
||||
}
|
||||
qDebug() << "r pointer:" << undo_pointer << undo_stack.size();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef SEQUENCE_H
|
||||
#define SEQUENCE_H
|
||||
|
||||
#define UNDO_LIMIT 100
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include "project/clip.h"
|
||||
@@ -25,8 +27,16 @@ public:
|
||||
float frame_rate;
|
||||
int audio_frequency;
|
||||
int audio_layout;
|
||||
|
||||
void undo_add_current();
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
QList<Clip> clips;
|
||||
|
||||
QVector<QList<Clip>> undo_stack;
|
||||
int undo_pointer;
|
||||
int undo_stack_start;
|
||||
};
|
||||
|
||||
#endif // SEQUENCE_H
|
||||
|
||||
@@ -772,8 +772,8 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
if (panel_timeline->tool == TIMELINE_TOOL_EDIT || panel_timeline->tool == TIMELINE_TOOL_RAZOR) {
|
||||
QPoint mouse_pos = mapFromGlobal(QCursor::pos());
|
||||
int track = getTrackFromScreenPoint(mouse_pos.y());
|
||||
if (is_track_visible(track)) {
|
||||
int cursor_x = getScreenPointFromFrame(getFrameFromScreenPoint(mouse_pos.x(), false));
|
||||
if (is_track_visible(track)) {
|
||||
int cursor_x = getScreenPointFromFrame(getFrameFromScreenPoint(mouse_pos.x(), false));
|
||||
int cursor_y = getScreenPointFromTrack(track);
|
||||
|
||||
p.setPen(Qt::gray);
|
||||
|
||||
Reference in New Issue
Block a user