diff --git a/io/config.cpp b/io/config.cpp
index 155d11b91..02ab90cdf 100644
--- a/io/config.cpp
+++ b/io/config.cpp
@@ -28,7 +28,8 @@ Config::Config()
recording_mode(2),
enable_seek_to_import(false),
enable_audio_scrubbing(true),
- drop_on_media_to_replace(true)
+ drop_on_media_to_replace(true),
+ autoscroll(AUTOSCROLL_PAGE_SCROLL)
{}
void Config::load(QString path) {
@@ -99,6 +100,9 @@ void Config::load(QString path) {
} else if (stream.name() == "DropFileOnMediaToReplace") {
stream.readNext();
drop_on_media_to_replace = (stream.text() == "1");
+ } else if (stream.name() == "Autoscroll") {
+ stream.readNext();
+ autoscroll = stream.text().toInt();
}
}
}
@@ -143,6 +147,7 @@ void Config::save(QString path) {
stream.writeTextElement("EnableSeekToImport", QString::number(enable_seek_to_import));
stream.writeTextElement("AudioScrubbing", QString::number(enable_audio_scrubbing));
stream.writeTextElement("DropFileOnMediaToReplace", QString::number(drop_on_media_to_replace));
+ stream.writeTextElement("Autoscroll", QString::number(autoscroll));
stream.writeEndElement(); // configuration
stream.writeEndDocument(); // doc
diff --git a/io/config.h b/io/config.h
index a8a7cddab..fe3b68ce6 100644
--- a/io/config.h
+++ b/io/config.h
@@ -13,6 +13,10 @@
#define RECORD_MODE_MONO 1
#define RECORD_MODE_STEREO 2
+#define AUTOSCROLL_NO_SCROLL 0
+#define AUTOSCROLL_PAGE_SCROLL 1
+#define AUTOSCROLL_SMOOTH_SCROLL 2
+
struct Config {
Config();
bool saved_layout;
@@ -35,6 +39,7 @@ struct Config {
bool enable_seek_to_import;
bool enable_audio_scrubbing;
bool drop_on_media_to_replace;
+ int autoscroll;
void load(QString path);
void save(QString path);
diff --git a/mainwindow.cpp b/mainwindow.cpp
index c39ed8d6c..aebb9fbad 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -680,6 +680,10 @@ void MainWindow::toolMenu_About_To_Be_Shown() {
ui->actionEnable_Seek_to_Import->setChecked(config.enable_seek_to_import);
ui->actionAudio_Scrubbing->setChecked(config.enable_audio_scrubbing);
ui->actionEnable_Drop_on_Media_to_Replace->setChecked(config.drop_on_media_to_replace);
+
+ ui->actionNo_autoscroll->setChecked(config.autoscroll == AUTOSCROLL_NO_SCROLL);
+ ui->actionPage_Autoscroll->setChecked(config.autoscroll == AUTOSCROLL_PAGE_SCROLL);
+ ui->actionSmooth_Auto_scroll->setChecked(config.autoscroll == AUTOSCROLL_SMOOTH_SCROLL);
}
void MainWindow::on_actionEdit_Tool_Selects_Links_triggered() {
@@ -991,3 +995,15 @@ void MainWindow::on_actionPasteInsert_triggered() {
panel_timeline->paste(true);
}
}
+
+void MainWindow::on_actionNo_autoscroll_triggered() {
+ config.autoscroll = AUTOSCROLL_NO_SCROLL;
+}
+
+void MainWindow::on_actionPage_Autoscroll_triggered() {
+ config.autoscroll = AUTOSCROLL_PAGE_SCROLL;
+}
+
+void MainWindow::on_actionSmooth_Auto_scroll_triggered() {
+ config.autoscroll = AUTOSCROLL_SMOOTH_SCROLL;
+}
diff --git a/mainwindow.h b/mainwindow.h
index 7c28588a9..d4f4052c1 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -205,6 +205,12 @@ private slots:
void on_actionPasteInsert_triggered();
+ void on_actionNo_autoscroll_triggered();
+
+ void on_actionPage_Autoscroll_triggered();
+
+ void on_actionSmooth_Auto_scroll_triggered();
+
private:
Ui::MainWindow *ui;
void setup_layout(bool reset);
diff --git a/mainwindow.ui b/mainwindow.ui
index 0fe17ee90..66260f4ce 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -33,7 +33,7 @@
0
0
653
- 16
+ 19
@@ -887,6 +892,30 @@
Footage Viewer
+
+
+ true
+
+
+ No Auto-scroll
+
+
+
+
+ true
+
+
+ Page Auto-scroll
+
+
+
+
+ true
+
+
+ Smooth Auto-scroll
+
+
diff --git a/panels/timeline.cpp b/panels/timeline.cpp
index 05419e760..daa781fae 100644
--- a/panels/timeline.cpp
+++ b/panels/timeline.cpp
@@ -415,21 +415,51 @@ bool Timeline::focused() {
return (sequence != NULL && (ui->headers->hasFocus() || ui->video_area->hasFocus() || ui->audio_area->hasFocus()));
}
+bool Timeline::center_scroll_to_playhead() {
+ // returns true is the scroll was changed, false if not
+ int target_scroll = qMin(ui->horizontalScrollBar->maximum(), qMax(0, getScreenPointFromFrame(zoom, sequence->playhead)-(ui->editAreas->width()>>1)));
+ if (target_scroll == ui->horizontalScrollBar->value()) {
+ return false;
+ }
+ ui->horizontalScrollBar->setValue(target_scroll);
+ return true;
+}
+
void Timeline::repaint_timeline() {
- ui->headers->update();
- ui->video_area->update();
- ui->audio_area->update();
+ bool draw = true;
- if (sequence != NULL) {
- long sequenceEndFrame = sequence->getEndFrame();
+ if (sequence != NULL
+ && !ui->horizontalScrollBar->isSliderDown()
+ && panel_sequence_viewer->playing) {
+ // auto scroll
+ if (config.autoscroll == AUTOSCROLL_PAGE_SCROLL) {
+ if (panel_timeline->getTimelineScreenPointFromFrame(sequence->playhead) > (ui->editAreas->width() - ui->videoScrollbar->width())) {
+ ui->horizontalScrollBar->setValue(getScreenPointFromFrame(zoom, sequence->playhead));
+ draw = false;
+ }
+ } else if (config.autoscroll == AUTOSCROLL_SMOOTH_SCROLL) {
+ if (center_scroll_to_playhead()) {
+ draw = false;
+ }
+ }
+ }
- ui->horizontalScrollBar->setMaximum(qMax(0, getScreenPointFromFrame(zoom, sequenceEndFrame) - (ui->editAreas->width()/2)));
+ if (draw) {
+ ui->headers->update();
+ ui->video_area->update();
+ ui->audio_area->update();
- if (last_frame != sequence->playhead) {
- ui->audio_monitor->update();
- last_frame = sequence->playhead;
- }
- }
+ if (sequence != NULL) {
+ long sequenceEndFrame = sequence->getEndFrame();
+
+ ui->horizontalScrollBar->setMaximum(qMax(0, getScreenPointFromFrame(zoom, sequenceEndFrame) - (ui->editAreas->width()/2)));
+
+ if (last_frame != sequence->playhead) {
+ ui->audio_monitor->update();
+ last_frame = sequence->playhead;
+ }
+ }
+ }
}
void Timeline::select_all() {
@@ -540,9 +570,8 @@ void Timeline::set_zoom_value(double v) {
ui->headers->update_zoom(zoom);
repaint_timeline();
- // TODO find a way to gradually move towards target_scroll instead of just setting it?
- int target_scroll = getScreenPointFromFrame(zoom, sequence->playhead)-(ui->editAreas->width()>>1);
- ui->horizontalScrollBar->setValue(target_scroll);
+ // TODO find a way to gradually move towards target_scroll instead of just centering it?
+ center_scroll_to_playhead();
}
void Timeline::set_zoom(bool in) {
diff --git a/panels/timeline.h b/panels/timeline.h
index 3bf1a9b10..779029108 100644
--- a/panels/timeline.h
+++ b/panels/timeline.h
@@ -228,6 +228,7 @@ private:
QVector tool_buttons;
void decheck_tool_buttons(QObject* sender);
void set_tool(int tool);
+ bool center_scroll_to_playhead();
long last_frame;
int scroll;