added autoscrolling
This commit is contained in:
+6
-1
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+30
-1
@@ -33,7 +33,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>653</width>
|
||||
<height>16</height>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
@@ -187,8 +187,13 @@
|
||||
<addaction name="actionAudio_Scrubbing"/>
|
||||
<addaction name="actionEnable_Drop_on_Media_to_Replace"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionNo_autoscroll"/>
|
||||
<addaction name="actionPage_Autoscroll"/>
|
||||
<addaction name="actionSmooth_Auto_scroll"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionPreferences"/>
|
||||
<addaction name="actionCrash"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menuEdit"/>
|
||||
@@ -887,6 +892,30 @@
|
||||
<string>Footage Viewer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNo_autoscroll">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>No Auto-scroll</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPage_Autoscroll">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Page Auto-scroll</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSmooth_Auto_scroll">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Smooth Auto-scroll</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
||||
+43
-14
@@ -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) {
|
||||
|
||||
@@ -228,6 +228,7 @@ private:
|
||||
QVector<QPushButton*> tool_buttons;
|
||||
void decheck_tool_buttons(QObject* sender);
|
||||
void set_tool(int tool);
|
||||
bool center_scroll_to_playhead();
|
||||
long last_frame;
|
||||
int scroll;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user