1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-16 08:34:10 +02:00

Give TrackArtist a back-pointer to TrackPanel

This commit is contained in:
Paul Licameli 2018-11-05 10:45:03 -05:00
parent 9bb235c274
commit 50cf2e9a1f
7 changed files with 25 additions and 10 deletions

View File

@ -46,9 +46,10 @@ class AudacityPrintout final : public wxPrintout
{ {
public: public:
AudacityPrintout(wxString title, AudacityPrintout(wxString title,
TrackList *tracks): TrackList *tracks, TrackPanel &panel):
wxPrintout(title), wxPrintout(title),
mTracks(tracks) mTracks(tracks)
, mPanel(panel)
{ {
} }
bool OnPrintPage(int page); bool OnPrintPage(int page);
@ -58,6 +59,7 @@ class AudacityPrintout final : public wxPrintout
int *selPageFrom, int *selPageTo); int *selPageFrom, int *selPageTo);
private: private:
TrackPanel &mPanel;
TrackList *mTracks; TrackList *mTracks;
}; };
@ -84,7 +86,7 @@ bool AudacityPrintout::OnPrintPage(int WXUNUSED(page))
ruler.SetLabelEdges(true); ruler.SetLabelEdges(true);
ruler.Draw(*dc); ruler.Draw(*dc);
TrackArtist artist; TrackArtist artist( &mPanel );
artist.SetBackgroundBrushes(*wxWHITE_BRUSH, *wxWHITE_BRUSH, artist.SetBackgroundBrushes(*wxWHITE_BRUSH, *wxWHITE_BRUSH,
*wxWHITE_PEN, *wxWHITE_PEN); *wxWHITE_PEN, *wxWHITE_PEN);
const double screenDuration = mTracks->GetEndTime(); const double screenDuration = mTracks->GetEndTime();
@ -144,12 +146,14 @@ void HandlePageSetup(wxWindow *parent)
gPrintData() = pageSetupDialog.GetPageSetupData().GetPrintData(); gPrintData() = pageSetupDialog.GetPageSetupData().GetPrintData();
} }
void HandlePrint(wxWindow *parent, const wxString &name, TrackList *tracks) void HandlePrint(
wxWindow *parent, const wxString &name, TrackList *tracks,
TrackPanel &panel)
{ {
wxPrintDialogData printDialogData(gPrintData()); wxPrintDialogData printDialogData(gPrintData());
wxPrinter printer(&printDialogData); wxPrinter printer(&printDialogData);
AudacityPrintout printout(name, tracks); AudacityPrintout printout(name, tracks, panel);
if (!printer.Print(parent, &printout, true)) { if (!printer.Print(parent, &printout, true)) {
if (wxPrinter::GetLastError() == wxPRINTER_ERROR) { if (wxPrinter::GetLastError() == wxPRINTER_ERROR) {
AudacityMessageBox(_("There was a problem printing."), AudacityMessageBox(_("There was a problem printing."),

View File

@ -16,9 +16,12 @@
class wxWindow; class wxWindow;
class TrackList; class TrackList;
class TrackPanel;
void HandlePageSetup(wxWindow *parent); void HandlePageSetup(wxWindow *parent);
void HandlePrint(wxWindow *parent, const wxString &name, TrackList *tracks); void HandlePrint(
wxWindow *parent, const wxString &name, TrackList *tracks,
TrackPanel &panel);
#endif // __AUDACITY_PRINTING__ #endif // __AUDACITY_PRINTING__

View File

@ -164,7 +164,8 @@ int TrackArt::GetBottom(NoteTrack *t, const wxRect &rect)
*/ */
#endif // USE_MIDI #endif // USE_MIDI
TrackArtist::TrackArtist() TrackArtist::TrackArtist( TrackPanel *parent_ )
: parent( parent_ )
{ {
mdBrange = ENV_DB_RANGE; mdBrange = ENV_DB_RANGE;
mShowClipping = false; mShowClipping = false;

View File

@ -36,6 +36,7 @@ class NoteTrack;
class LabelTrack; class LabelTrack;
class TimeTrack; class TimeTrack;
class TrackList; class TrackList;
class TrackPanel;
class Ruler; class Ruler;
class SelectedRegion; class SelectedRegion;
class ZoomInfo; class ZoomInfo;
@ -151,7 +152,7 @@ namespace TrackArt {
class AUDACITY_DLL_API TrackArtist { class AUDACITY_DLL_API TrackArtist {
public: public:
TrackArtist(); TrackArtist( TrackPanel *parent_ );
~TrackArtist(); ~TrackArtist();
static TrackArtist *Get( TrackPanelDrawingContext & ); static TrackArtist *Get( TrackPanelDrawingContext & );
@ -169,6 +170,8 @@ public:
void UpdateVRuler(const Track *t, const wxRect & rect); void UpdateVRuler(const Track *t, const wxRect & rect);
TrackPanel *parent;
// Preference values // Preference values
float mdBrange; // "/GUI/EnvdBRange" float mdBrange; // "/GUI/EnvdBRange"
long mShowClipping; // "/GUI/ShowClipping" long mShowClipping; // "/GUI/ShowClipping"

View File

@ -237,7 +237,7 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
mRedrawAfterStop = false; mRedrawAfterStop = false;
mTrackArtist = std::make_unique<TrackArtist>(); mTrackArtist = std::make_unique<TrackArtist>( this );
mTimeCount = 0; mTimeCount = 0;
mTimer.parent = this; mTimer.parent = this;

View File

@ -3051,7 +3051,11 @@ void EqualizationPanel::OnPaint(wxPaintEvent & WXUNUSED(event))
if( mEffect->mDraw->GetValue() ) if( mEffect->mDraw->GetValue() )
{ {
ZoomInfo zoomInfo( 0.0, mEnvRect.width-1 ); ZoomInfo zoomInfo( 0.0, mEnvRect.width-1 );
TrackArtist artist;
// Back pointer to TrackPanel won't be needed in the one drawing
// function we use here
TrackArtist artist( nullptr );
artist.pZoomInfo = &zoomInfo; artist.pZoomInfo = &zoomInfo;
TrackPanelDrawingContext context{ memDC, {}, {}, &artist }; TrackPanelDrawingContext context{ memDC, {}, {}, &artist };
mEffect->mEnvelope->DrawPoints( mEffect->mEnvelope->DrawPoints(

View File

@ -532,7 +532,7 @@ void OnPrint(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto name = project.GetName(); auto name = project.GetName();
auto tracks = project.GetTracks(); auto tracks = project.GetTracks();
HandlePrint(&project, name, tracks); HandlePrint(&project, name, tracks, *project.GetTrackPanel());
} }
void OnExit(const CommandContext &WXUNUSED(context) ) void OnExit(const CommandContext &WXUNUSED(context) )