| 549 | } |
| 550 | |
| 551 | void TrackPanel::ProcessUIHandleResult |
| 552 | (TrackPanelCell *pClickedCell, TrackPanelCell *pLatestCell, |
| 553 | UIHandle::Result refreshResult) |
| 554 | { |
| 555 | const auto panel = this; |
| 556 | auto pLatestTrack = FindTrack( pLatestCell ).get(); |
| 557 | |
| 558 | // This precaution checks that the track is not only nonnull, but also |
| 559 | // really owned by the track list |
| 560 | auto pClickedTrack = GetTracks()->Lock( |
| 561 | std::weak_ptr<Track>{ FindTrack( pClickedCell ) } |
| 562 | ).get(); |
| 563 | |
| 564 | // TODO: make a finer distinction between refreshing the track control area, |
| 565 | // and the waveform area. As it is, redraw both whenever you must redraw either. |
| 566 | |
| 567 | // Copy data from the underlying tracks to the pending tracks that are |
| 568 | // really displayed |
| 569 | PendingTracks::Get(*panel->GetProject()).UpdatePendingTracks(); |
| 570 | |
| 571 | using namespace RefreshCode; |
| 572 | |
| 573 | if (refreshResult & DestroyedCell) { |
| 574 | panel->UpdateViewIfNoTracks(); |
| 575 | // Beware stale pointer! |
| 576 | if (pLatestTrack == pClickedTrack) |
| 577 | pLatestTrack = nullptr; |
| 578 | pClickedTrack = nullptr; |
| 579 | } |
| 580 | |
| 581 | if (pClickedTrack && (refreshResult & RefreshCode::UpdateVRuler)) |
| 582 | panel->UpdateVRuler(pClickedTrack); |
| 583 | |
| 584 | if (refreshResult & RefreshCode::DrawOverlays) { |
| 585 | panel->DrawOverlays(false); |
| 586 | mRuler->DrawOverlays(false); |
| 587 | } |
| 588 | |
| 589 | // Refresh all if told to do so, or if told to refresh a track that |
| 590 | // is not known. |
| 591 | const bool refreshAll = |
| 592 | ( (refreshResult & RefreshAll) |
| 593 | || ((refreshResult & RefreshCell) && !pClickedTrack) |
| 594 | || ((refreshResult & RefreshLatestCell) && !pLatestTrack)); |
| 595 | |
| 596 | if (refreshAll) |
| 597 | panel->Refresh(false); |
| 598 | else { |
| 599 | if (refreshResult & RefreshCell) |
| 600 | panel->RefreshTrack(pClickedTrack); |
| 601 | if (refreshResult & RefreshLatestCell) |
| 602 | panel->RefreshTrack(pLatestTrack); |
| 603 | } |
| 604 | |
| 605 | if (refreshResult & FixScrollbars) |
| 606 | panel->MakeParentRedrawScrollbars(); |
| 607 | |
| 608 | if (refreshResult & Resize) |
nothing calls this directly
no test coverage detected