void TrackList::RecalcPositions(TrackNodePointer node) { if ( isNull( node ) ) return; Track *t; int i = 0; int y = 0; auto prev = getPrev( node ); if ( !isNull( prev ) ) { t = prev.first->get(); i = t->GetIndex() + 1; y = t->GetY() + t->GetHeight(); } const auto theEnd = end(); for (auto n = Find( node.first->get() ); n != theEnd; ++n) { t = *n; t->SetIndex(i++); t->DoSetY(y); y += t->GetHeight(); } UpdatePendingTracks(); }
int TrackList::GetHeight() const { int height = 0; ConstTrackListIterator iter(this); for (Track *t = iter.First(); t; t = iter.Next()) height += t->GetHeight(); return height; }
TrackPanelResizeHandle::TrackPanelResizeHandle ( const std::shared_ptr<Track> &track, int y, const AudacityProject *pProject ) : mpTrack{ track } , mMouseClickY( y ) { auto tracks = pProject->GetTracks(); Track *prev = tracks->GetPrev(track.get()); Track *next = tracks->GetNext(track.get()); //STM: Determine whether we should rescale one or two tracks if (prev && prev->GetLink() == track.get()) { // mpTrack is the lower track mInitialTrackHeight = track->GetHeight(); mInitialActualHeight = track->GetActualHeight(); mInitialMinimized = track->GetMinimized(); mInitialUpperTrackHeight = prev->GetHeight(); mInitialUpperActualHeight = prev->GetActualHeight(); mMode = IsResizingBelowLinkedTracks; } else if (next && track->GetLink() == next) { // mpTrack is the upper track mInitialTrackHeight = next->GetHeight(); mInitialActualHeight = next->GetActualHeight(); mInitialMinimized = next->GetMinimized(); mInitialUpperTrackHeight = track->GetHeight(); mInitialUpperActualHeight = track->GetActualHeight(); mMode = IsResizingBetweenLinkedTracks; } else { // DM: Save the initial mouse location and the initial height mInitialTrackHeight = track->GetHeight(); mInitialActualHeight = track->GetActualHeight(); mInitialMinimized = track->GetMinimized(); mMode = IsResizing; } }
void TrackList::RecalcPositions(TrackNodePointer node) { if (isNull(node)) { return; } Track *t; int i = 0; int y = 0; #ifdef EXPERIMENTAL_OUTPUT_DISPLAY int cnt = 0; if (node->prev) { t = node->prev->t; i = t->GetIndex() + 1; if(MONO_WAVE_PAN(t)) y = t->GetY(true) + t->GetHeight(true); else y = t->GetY() + t->GetHeight(); } for (const TrackListNode *n = node; n; n = n->next) { t = n->t; if(MONO_WAVE_PAN(t)) cnt++; if(cnt != 2){ t->SetIndex(i++); t->SetY(y); y += t->GetHeight(); } if(cnt != 0){ t->SetY(y,true); y += t->GetHeight(true); } cnt = 0; } #else // EXPERIMENTAL_OUTPUT_DISPLAY if (hasPrev(node)) { auto prev = node; --prev; t = prev->get(); i = t->GetIndex() + 1; y = t->GetY() + t->GetHeight(); } const auto theEnd = end(); for (auto n = node; n != theEnd; ++n) { t = n->get(); t->SetIndex(i++); t->SetY(y); y += t->GetHeight(); } #endif // EXPERIMENTAL_OUTPUT_DISPLAY }
void TrackList::RecalcPositions(const TrackListNode *node) { Track *t; int i = 0; int y = 0; if (!node) { return; } #ifdef EXPERIMENTAL_OUTPUT_DISPLAY int cnt = 0; if (node->prev) { t = node->prev->t; i = t->GetIndex() + 1; if(MONO_WAVE_PAN(t)) y = t->GetY(true) + t->GetHeight(true); else y = t->GetY() + t->GetHeight(); } for (const TrackListNode *n = node; n; n = n->next) { t = n->t; if(MONO_WAVE_PAN(t)) cnt++; if(cnt != 2){ t->SetIndex(i++); t->SetY(y); y += t->GetHeight(); } if(cnt != 0){ t->SetY(y,true); y += t->GetHeight(true); } cnt = 0; } #else // EXPERIMENTAL_OUTPUT_DISPLAY if (node->prev) { t = node->prev->t; i = t->GetIndex() + 1; y = t->GetY() + t->GetHeight(); } for (const TrackListNode *n = node; n; n = n->next) { t = n->t; t->SetIndex(i++); t->SetY(y); y += t->GetHeight(); } #endif // EXPERIMENTAL_OUTPUT_DISPLAY }
bool AudacityPrintout::OnPrintPage(int page) { wxDC *dc = GetDC(); if (!dc) return false; int width, height; dc->GetSize(&width, &height); int rulerScreenHeight = 40; int screenTotalHeight = mTracks->GetHeight() + rulerScreenHeight; double scale = height / (double)screenTotalHeight; int rulerPageHeight = (int)(rulerScreenHeight * scale); Ruler ruler; ruler.SetBounds(0, 0, width, rulerPageHeight); ruler.SetOrientation(wxHORIZONTAL); ruler.SetRange(0.0, mTracks->GetEndTime()); ruler.SetFormat(Ruler::TimeFormat); ruler.SetLabelEdges(true); ruler.Draw(*dc); TrackArtist artist; artist.SetBackgroundBrushes(*wxWHITE_BRUSH, *wxWHITE_BRUSH, *wxWHITE_PEN, *wxWHITE_PEN); ViewInfo viewInfo; viewInfo.sel0 = viewInfo.sel1 = 0; viewInfo.vpos = 0; viewInfo.h = 0.0; viewInfo.screen = mTracks->GetEndTime() - viewInfo.h; viewInfo.total = viewInfo.screen; viewInfo.zoom = viewInfo.lastZoom = width / viewInfo.screen; int y = rulerPageHeight; TrackListIterator iter(mTracks); Track *n = iter.First(); while (n) { wxRect r; r.x = 0; r.y = y; r.width = width; r.height = (int)(n->GetHeight() * scale); switch(n->GetKind()) { case Track::Wave: switch (((WaveTrack *)n)->GetDisplay()) { case WaveTrack::WaveformDisplay: artist.DrawWaveform((WaveTrack *)n, *dc, r, &viewInfo, false, false, false, false, false); break; case WaveTrack::WaveformDBDisplay: artist.DrawWaveform((WaveTrack *)n, *dc, r, &viewInfo, false, false, false, true, false); break; case WaveTrack::SpectrumDisplay: artist.DrawSpectrum((WaveTrack *)n, *dc, r, &viewInfo, false); break; case WaveTrack::PitchDisplay: artist.DrawSpectrum((WaveTrack *)n, *dc, r, &viewInfo, true); break; } break; case Track::Note: artist.DrawNoteTrack((NoteTrack *)n, *dc, r, &viewInfo); break; case Track::Label: artist.DrawLabelTrack((LabelTrack *)n, *dc, r, &viewInfo); break; case Track::Time: artist.DrawTimeTrack((TimeTrack *)n, *dc, r, &viewInfo); break; } dc->SetPen(*wxBLACK_PEN); dc->DrawLine(0, r.y, width, r.y); n = iter.Next(); y += r.height; }; return true; }
bool AudacityPrintout::OnPrintPage(int WXUNUSED(page)) { wxDC *dc = GetDC(); if (!dc) return false; int width, height; dc->GetSize(&width, &height); int rulerScreenHeight = 40; int screenTotalHeight = mTracks->GetHeight() + rulerScreenHeight; double scale = height / (double)screenTotalHeight; int rulerPageHeight = (int)(rulerScreenHeight * scale); Ruler ruler; ruler.SetBounds(0, 0, width, rulerPageHeight); ruler.SetOrientation(wxHORIZONTAL); ruler.SetRange(0.0, mTracks->GetEndTime()); ruler.SetFormat(Ruler::TimeFormat); ruler.SetLabelEdges(true); ruler.Draw(*dc); TrackArtist artist; artist.SetBackgroundBrushes(*wxWHITE_BRUSH, *wxWHITE_BRUSH, *wxWHITE_PEN, *wxWHITE_PEN); const double screenDuration = mTracks->GetEndTime(); ZoomInfo zoomInfo(0.0, width / screenDuration); int y = rulerPageHeight; TrackListIterator iter(mTracks); Track *n = iter.First(); while (n) { wxRect r; r.x = 0; r.y = y; r.width = width; r.height = (int)(n->GetHeight() * scale); artist.DrawTrack(n, *dc, r, SelectedRegion(), zoomInfo, false, false, false, false); dc->SetPen(*wxBLACK_PEN); AColor::Line(*dc, 0, r.y, width, r.y); #ifdef EXPERIMENTAL_OUTPUT_DISPLAY if(MONO_WAVE_PAN(n)){ y += r.height; r.x = 0; r.y = y; r.width = width; r.height = (int)(n->GetHeight(true) * scale); artist.DrawTrack( n, *dc, r, SelectedRegion{}, zoomInfo, false, false, false, false); dc->SetPen(*wxBLACK_PEN); AColor::Line(*dc, 0, r.y, width, r.y); } #endif n = iter.Next(); y += r.height; }; return true; }
UIHandle::Result TrackPanelResizeHandle::Drag (const TrackPanelMouseEvent &evt, AudacityProject *pProject) { auto pTrack = pProject->GetTracks()->Lock(mpTrack); if ( !pTrack ) return RefreshCode::Cancelled; const wxMouseEvent &event = evt.event; TrackList *const tracks = pProject->GetTracks(); int delta = (event.m_y - mMouseClickY); // On first drag, jump out of minimized mode. Initial height // will be height of minimized track. // // This used to be in HandleResizeClick(), but simply clicking // on a resize border would switch the minimized state. if (pTrack->GetMinimized()) { Track *link = pTrack->GetLink(); pTrack->SetHeight(pTrack->GetHeight()); pTrack->SetMinimized(false); if (link) { link->SetHeight(link->GetHeight()); link->SetMinimized(false); // Initial values must be reset since they weren't based on the // minimized heights. mInitialUpperTrackHeight = link->GetHeight(); mInitialTrackHeight = pTrack->GetHeight(); } } // Common pieces of code for MONO_WAVE_PAN and otherwise. auto doResizeBelow = [&] (Track *prev, bool WXUNUSED(vStereo)) { double proportion = static_cast < double >(mInitialTrackHeight) / (mInitialTrackHeight + mInitialUpperTrackHeight); int newTrackHeight = static_cast < int > (mInitialTrackHeight + delta * proportion); int newUpperTrackHeight = static_cast < int > (mInitialUpperTrackHeight + delta * (1.0 - proportion)); //make sure neither track is smaller than its minimum height if (newTrackHeight < pTrack->GetMinimizedHeight()) newTrackHeight = pTrack->GetMinimizedHeight(); if (newUpperTrackHeight < prev->GetMinimizedHeight()) newUpperTrackHeight = prev->GetMinimizedHeight(); pTrack->SetHeight(newTrackHeight); prev->SetHeight(newUpperTrackHeight); }; auto doResizeBetween = [&] (Track *next, bool WXUNUSED(vStereo)) { int newUpperTrackHeight = mInitialUpperTrackHeight + delta; int newTrackHeight = mInitialTrackHeight - delta; // make sure neither track is smaller than its minimum height if (newTrackHeight < next->GetMinimizedHeight()) { newTrackHeight = next->GetMinimizedHeight(); newUpperTrackHeight = mInitialUpperTrackHeight + mInitialTrackHeight - next->GetMinimizedHeight(); } if (newUpperTrackHeight < pTrack->GetMinimizedHeight()) { newUpperTrackHeight = pTrack->GetMinimizedHeight(); newTrackHeight = mInitialUpperTrackHeight + mInitialTrackHeight - pTrack->GetMinimizedHeight(); } pTrack->SetHeight(newUpperTrackHeight); next->SetHeight(newTrackHeight); }; auto doResize = [&] { int newTrackHeight = mInitialTrackHeight + delta; if (newTrackHeight < pTrack->GetMinimizedHeight()) newTrackHeight = pTrack->GetMinimizedHeight(); pTrack->SetHeight(newTrackHeight); }; //STM: We may be dragging one or two (stereo) tracks. // If two, resize proportionally if we are dragging the lower track, and // adjust compensatively if we are dragging the upper track. switch( mMode ) { case IsResizingBelowLinkedTracks: { Track *prev = tracks->GetPrev(pTrack.get()); doResizeBelow(prev, false); break; } case IsResizingBetweenLinkedTracks: { Track *next = tracks->GetNext(pTrack.get()); doResizeBetween(next, false); break; } case IsResizing: { doResize(); break; } default: // don't refresh in this case. return RefreshCode::RefreshNone; } return RefreshCode::RefreshAll; }