|
17 | 17 |
|
18 | 18 | #include <ScopicFlowCore/ClavierInteractionController.h> |
19 | 19 | #include <ScopicFlowCore/ClavierViewModel.h> |
20 | | -#include <ScopicFlowCore/ClipViewModel.h> |
21 | 20 | #include <ScopicFlowCore/LabelSequenceInteractionController.h> |
22 | 21 | #include <ScopicFlowCore/NoteEditLayerInteractionController.h> |
23 | | -#include <ScopicFlowCore/NoteViewModel.h> |
24 | 22 | #include <ScopicFlowCore/ParameterEditorInteractionController.h> |
25 | 23 | #include <ScopicFlowCore/PhonemeSequenceInteractionController.h> |
26 | 24 | #include <ScopicFlowCore/RangeIndicatorInteractionController.h> |
27 | | -#include <ScopicFlowCore/RangeSequenceViewModel.h> |
28 | 25 | #include <ScopicFlowCore/ScrollBehaviorViewModel.h> |
29 | 26 | #include <ScopicFlowCore/TimeLayoutViewModel.h> |
30 | 27 | #include <ScopicFlowCore/TimeManipulator.h> |
31 | 28 | #include <ScopicFlowCore/TimeViewModel.h> |
32 | 29 | #include <ScopicFlowCore/TimelineInteractionController.h> |
33 | | -#include <ScopicFlowCore/private/SliceableViewModelManipulatorInterface_p.h> |
34 | 30 |
|
35 | 31 | #include <dspxmodelORM/Clip.h> |
36 | 32 | #include <dspxmodelORM/ClipSequence.h> |
@@ -415,46 +411,31 @@ namespace VisualEditor { |
415 | 411 |
|
416 | 412 | void PianoRollPanelInterfacePrivate::prepareVerticalPageTurn(double start, double length) { |
417 | 413 | verticalPageTurn.reset(); |
418 | | - if (!Internal::EditorPreference::pianoRollAutoPageVerticalAdjustment()) |
| 414 | + if (!editingClip || !Internal::EditorPreference::pianoRollAutoPageVerticalAdjustment()) |
419 | 415 | return; |
420 | 416 |
|
421 | 417 | auto editArea = pianoRollView->property("centerEditArea").value<QQuickItem *>(); |
422 | 418 | const VerticalView current{clavierViewModel->start(), clavierViewModel->pixelDensity()}; |
423 | 419 | if (!editArea || editArea->height() <= 0 || current.pixelDensity <= 0 || length <= 0) |
424 | 420 | return; |
425 | 421 |
|
426 | | - auto context = ProjectViewModelContext::of(windowHandle); |
427 | | - auto editingTrack = editingClip && editingClip->clipSequence() ? editingClip->clipSequence()->track() : nullptr; |
| 422 | + const double clipPosition = editingClip->position(); |
| 423 | + const double visibleStart = std::max(start, clipPosition); |
| 424 | + const double visibleEnd = std::min(start + length, clipPosition + editingClip->clipLength()); |
| 425 | + if (visibleStart >= visibleEnd) |
| 426 | + return; |
| 427 | + |
| 428 | + const double offset = static_cast<double>(editingClip->clipStart()) - clipPosition; |
| 429 | + const int first = static_cast<int>(std::floor(visibleStart + offset)); |
| 430 | + const int last = static_cast<int>(std::ceil(visibleEnd + offset)); |
| 431 | + const auto pageNotes = editingClip->notes()->slice(first, last - first); |
428 | 432 | int minKey = 128; |
429 | 433 | int maxKey = -1; |
430 | | - for (int row = 0; row < trackOverlaySelectorModel->rowCount(); ++row) { |
431 | | - auto item = qobject_cast<Internal::TrackOverlaySelectorItem *>(trackOverlaySelectorModel->index(row, 0).data().value<QObject *>()); |
432 | | - if (!item || (!item->overlayVisible() && item->track() != editingTrack)) |
433 | | - continue; |
434 | | - |
435 | | - auto clips = context->getSingingClipPerTrackSequenceViewModel(item->track()); |
436 | | - if (!clips) |
| 434 | + for (auto note : pageNotes) { |
| 435 | + if (note->length() <= 0) |
437 | 436 | continue; |
438 | | - const auto clipItems = clips->items(); |
439 | | - for (auto clipItem : clipItems) { |
440 | | - auto clip = qobject_cast<sflow::ClipViewModel *>(clipItem); |
441 | | - auto notes = clip ? clip->associatedNoteSequence() : nullptr; |
442 | | - auto sliceable = notes ? notes->property("iSliceable").value<sflow::SliceableViewModelManipulatorInterface *>() : nullptr; |
443 | | - if (!sliceable) |
444 | | - continue; |
445 | | - |
446 | | - const double offset = static_cast<double>(clip->clipStart()) - clip->position(); |
447 | | - const int first = static_cast<int>(std::floor(start + offset)); |
448 | | - const int last = static_cast<int>(std::ceil(start + length + offset)); |
449 | | - const auto pageNotes = sliceable->slice(first, last - first); |
450 | | - for (auto noteItem : pageNotes) { |
451 | | - auto note = qobject_cast<sflow::NoteViewModel *>(noteItem); |
452 | | - if (!note) |
453 | | - continue; |
454 | | - minKey = std::min(minKey, note->key()); |
455 | | - maxKey = std::max(maxKey, note->key()); |
456 | | - } |
457 | | - } |
| 437 | + minKey = std::min(minKey, note->keyNumber()); |
| 438 | + maxKey = std::max(maxKey, note->keyNumber()); |
458 | 439 | } |
459 | 440 | if (maxKey < minKey) |
460 | 441 | return; |
@@ -789,6 +770,7 @@ namespace VisualEditor { |
789 | 770 | Q_D(PianoRollPanelInterface); |
790 | 771 | if (d->editingClip == clip) |
791 | 772 | return; |
| 773 | + d->verticalPageTurn.reset(); |
792 | 774 | disconnect(d->editingClipConnection); |
793 | 775 | d->editingClipConnection = {}; |
794 | 776 | d->editingClip = clip; |
|
0 commit comments