finished scrollable viewer playheads

This commit is contained in:
itsmattkc
2018-12-09 01:39:36 +11:00
parent 7f08925385
commit 5d89afb639
6 changed files with 35 additions and 17 deletions
+3 -13
View File
@@ -417,16 +417,6 @@ 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() {
bool draw = true;
@@ -442,7 +432,7 @@ void Timeline::repaint_timeline() {
draw = false;
}
} else if (config.autoscroll == AUTOSCROLL_SMOOTH_SCROLL) {
if (center_scroll_to_playhead()) {
if (center_scroll_to_playhead(ui->horizontalScrollBar, zoom, sequence->playhead)) {
draw = false;
}
}
@@ -458,7 +448,7 @@ void Timeline::repaint_timeline() {
if (sequence != NULL) {
long sequenceEndFrame = sequence->getEndFrame();
ui->horizontalScrollBar->setMaximum(qMax(0, getScreenPointFromFrame(zoom, sequenceEndFrame) - (ui->editAreas->width()/2)));
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, sequenceEndFrame, (ui->editAreas->width()/2));
if (last_frame != sequence->playhead) {
ui->audio_monitor->update();
@@ -579,7 +569,7 @@ void Timeline::set_zoom_value(double v) {
repaint_timeline();
// TODO find a way to gradually move towards target_scroll instead of just centering it?
center_scroll_to_playhead();
center_scroll_to_playhead(ui->horizontalScrollBar, zoom, sequence->playhead);
}
void Timeline::set_zoom(bool in) {
+1 -2
View File
@@ -227,8 +227,7 @@ private:
void set_zoom_value(double v);
QVector<QPushButton*> tool_buttons;
void decheck_tool_buttons(QObject* sender);
void set_tool(int tool);
bool center_scroll_to_playhead();
void set_tool(int tool);
long last_frame;
int scroll;
+3
View File
@@ -385,6 +385,7 @@ void Viewer::update_header_zoom() {
if (cached_end_frame != sequenceEndFrame) {
minimum_zoom = (sequenceEndFrame > 0) ? ((double) ui->headers->width() / (double) sequenceEndFrame) : 1;
ui->headers->update_zoom(qMax(ui->headers->get_zoom(), minimum_zoom));
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, sequenceEndFrame, ui->headers->width());
} else {
ui->headers->update();
}
@@ -427,6 +428,8 @@ void Viewer::set_zoom(bool in) {
} else {
ui->headers->update_zoom(qMax(minimum_zoom, ui->headers->get_zoom()*0.5));
}
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, seq->getEndFrame(), ui->headers->width());
center_scroll_to_playhead(ui->horizontalScrollBar, ui->headers->get_zoom(), seq->playhead);
}
void Viewer::set_media(int type, void* media) {
+9
View File
@@ -66,6 +66,15 @@
</item>
<item>
<widget class="QScrollBar" name="horizontalScrollBar">
<property name="maximum">
<number>0</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="pageStep">
<number>1826</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>