From 0c24d0d47a1a03a81ecfe4560fc64d47f0f15334 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 19 Apr 2020 20:20:29 -0400 Subject: [PATCH] Bug2242: printing of track imagess (and now, with sub-views) --- src/Printing.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/Printing.cpp b/src/Printing.cpp index 1b0cb1dbd..a6b3e415e 100644 --- a/src/Printing.cpp +++ b/src/Printing.cpp @@ -97,21 +97,39 @@ bool AudacityPrintout::OnPrintPage(int WXUNUSED(page)) int y = rulerPageHeight; for (auto n : mTracks->Any()) { + auto &view = TrackView::Get( *n ); wxRect r; r.x = 0; - r.y = y; + r.y = 0; r.width = width; - r.height = (int)(TrackView::Get( *n ).GetHeight() * scale); + auto trackHeight = (int)(view.GetHeight() * scale); + r.height = trackHeight; - TrackPanelDrawingContext context{ - *dc, {}, {}, &artist - }; - TrackView::Get( *n ).Draw( context, r, TrackArtist::PassTracks ); + const auto subViews = view.GetSubViews( r ); + if (subViews.empty()) + continue; + + auto iter = subViews.begin(), end = subViews.end(), next = iter; + auto yy = iter->first; + for ( ; iter != end; iter = next ) { + ++next; + auto nextY = ( next == end ) + ? trackHeight + : next->first; + r.y = y + yy; + r.SetHeight( nextY - yy ); + yy = nextY; + + TrackPanelDrawingContext context{ + *dc, {}, {}, &artist + }; + iter->second->Draw( context, r, TrackArtist::PassTracks ); + } dc->SetPen(*wxBLACK_PEN); - AColor::Line(*dc, 0, r.y, width, r.y); + AColor::Line(*dc, 0, y, width, y); - y += r.height; + y += trackHeight; }; return true;