|
1 | | -#include "TimelineView.h" |
| 1 | +#include "TimelineView.h" |
2 | 2 | #include "AutomationLaneItem.h" |
3 | 3 | #include "AutomationLaneHeader.h" |
4 | 4 | #include "AutomationPointItem.h" |
@@ -266,10 +266,16 @@ TimelineView::TimelineView(EditManager* editMgr, QWidget* parent) |
266 | 266 | loopOverlayItem_->setVisible(false); |
267 | 267 | } |
268 | 268 |
|
269 | | - // Sync ruler scroll with graphics view horizontal scroll |
| 269 | + // Sync ruler scroll with graphics view horizontal scroll, and expand scene if near edge |
270 | 270 | connect(graphicsView_->horizontalScrollBar(), &QScrollBar::valueChanged, |
271 | 271 | this, [this](int val) { |
272 | 272 | ruler_->setScrollX(val); |
| 273 | + QRectF sr = scene_->sceneRect(); |
| 274 | + double viewRight = val + graphicsView_->viewport()->width(); |
| 275 | + if (viewRight > sr.width() - 200.0) { |
| 276 | + double newWidth = sr.width() + 800.0; |
| 277 | + scene_->setSceneRect(0, 0, newWidth, sr.height()); |
| 278 | + } |
273 | 279 | }); |
274 | 280 |
|
275 | 281 | // Sync track header vertical scroll with timeline vertical scroll |
@@ -896,13 +902,14 @@ void TimelineView::rebuildClips() |
896 | 902 | int numTracks = tracks.size(); |
897 | 903 | qDebug() << "[rebuildClips] numTracks:" << numTracks; |
898 | 904 |
|
899 | | - double totalBeats = 200.0; |
| 905 | + double beatsPerBar = editMgr_ ? editMgr_->getTimeSigNumerator() : 4; |
| 906 | + double totalBeats = beatsPerBar * 200.0; |
900 | 907 | for (auto* track : tracks) { |
901 | 908 | for (auto* clip : track->getClips()) { |
902 | 909 | auto& ts = clip->edit.tempoSequence; |
903 | 910 | auto endTime = clip->getPosition().getEnd(); |
904 | 911 | const double endBeat = ts.toBeats(endTime).inBeats(); |
905 | | - totalBeats = std::max(totalBeats, endBeat + 16.0); |
| 912 | + totalBeats = std::max(totalBeats, endBeat + beatsPerBar * 8.0); |
906 | 913 | } |
907 | 914 | } |
908 | 915 | double sceneWidth = totalBeats * pixelsPerBeat_; |
|
0 commit comments