diff --git a/panels/timeline.cpp b/panels/timeline.cpp index a84211137..d1ab37705 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -475,6 +475,19 @@ void Timeline::select_all() { } } +void Timeline::scroll_to_frame(long frame) { + if (sequence != NULL) { + int screen_point = getTimelineScreenPointFromFrame(frame); + int min_x = timeline_area->width()*0.1; + int max_x = timeline_area->width()*0.9; + if (screen_point < min_x) { + horizontalScrollBar->setValue(getScreenPointFromFrame(zoom, frame) - min_x); + } else if (screen_point > max_x) { + horizontalScrollBar->setValue(getScreenPointFromFrame(zoom, frame) - max_x); + } + } +} + void Timeline::resizeEvent(QResizeEvent *event) { if (sequence != NULL) set_sb_max(); } diff --git a/panels/timeline.h b/panels/timeline.h index 278aacbb3..7714df242 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -203,6 +203,8 @@ public: QPushButton* toolTransitionButton; QPushButton* snappingButton; + void scroll_to_frame(long frame); + void resizeEvent(QResizeEvent *event); public slots: void repaint_timeline(); diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 397364e13..8ee03decf 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -237,6 +237,7 @@ bool frame_rate_is_droppable(float rate) { void Viewer::seek(long p) { pause(); seq->playhead = p; + if (main_sequence) panel_timeline->scroll_to_frame(p); update_parents(); reset_all_audio(); audio_scrub = true;