mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-31 08:58:43 +01:00
Prepare to decouple factories for TP & Ruler into their own sources
This commit is contained in:
@@ -1061,9 +1061,15 @@ enum {
|
||||
|
||||
HSBarID,
|
||||
VSBarID,
|
||||
TrackPanelID
|
||||
|
||||
NextID,
|
||||
};
|
||||
|
||||
int AudacityProject::NextWindowID()
|
||||
{
|
||||
return mNextWindowID++;
|
||||
}
|
||||
|
||||
|
||||
// PRL: This event type definition used to be in AudacityApp.h, which created
|
||||
// a bad compilation dependency. The event was never emitted anywhere. I
|
||||
@@ -1116,6 +1122,10 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
mUndoManager(std::make_unique<UndoManager>())
|
||||
, mCommandManager( std::make_unique<CommandManager>() )
|
||||
{
|
||||
auto &window = *this;
|
||||
|
||||
mNextWindowID = NextID;
|
||||
|
||||
if (!gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), &mRate, AudioIO::GetOptimalSupportedSampleRate())) {
|
||||
// The default given above can vary with host/devices. So unless there is an entry for
|
||||
// the default sample rate in audacity.cfg, Audacity can open with a rate which is different
|
||||
@@ -1215,7 +1225,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
//
|
||||
// Create the horizontal ruler
|
||||
//
|
||||
mRuler = safenew AdornedRulerPanel( this, mTopPanel,
|
||||
mRuler = safenew AdornedRulerPanel( this, window.GetTopPanel(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize( -1, AdornedRulerPanel::GetRulerHeight(false) ),
|
||||
@@ -1262,6 +1272,8 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
pPage->SetBackgroundColour(theTheme.Colour( clrMedium ));
|
||||
#endif
|
||||
|
||||
mMainPage = pPage;
|
||||
|
||||
{
|
||||
auto ubs = std::make_unique<wxBoxSizer>(wxVERTICAL);
|
||||
ubs->Add(mToolManager->GetTopDock(), 0, wxEXPAND | wxALIGN_TOP);
|
||||
@@ -1281,15 +1293,18 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
}
|
||||
bs->Layout();
|
||||
|
||||
wxASSERT( pPage ); // to justify safenew
|
||||
mTrackPanel = safenew TrackPanel(pPage,
|
||||
TrackPanelID,
|
||||
{
|
||||
auto mainPage = window.GetMainPage();
|
||||
wxASSERT( mainPage ); // to justify safenew
|
||||
mTrackPanel = safenew TrackPanel(mainPage,
|
||||
window.NextWindowID(),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
mTracks,
|
||||
&mViewInfo,
|
||||
this,
|
||||
mRuler);
|
||||
}
|
||||
mTrackPanel->UpdatePrefs();
|
||||
|
||||
mCursorOverlay = std::make_shared<EditCursorOverlay>(this);
|
||||
|
||||
@@ -191,6 +191,9 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
||||
const wxPoint & pos, const wxSize & size);
|
||||
virtual ~AudacityProject();
|
||||
|
||||
// Next available ID for sub-windows
|
||||
int NextWindowID();
|
||||
|
||||
using AttachedObject = PrefsListener;
|
||||
using AttachedObjectFactory =
|
||||
std::function< std::unique_ptr<AttachedObject>() >;
|
||||
@@ -327,6 +330,7 @@ public:
|
||||
bool GetDirty() { return mDirty; }
|
||||
void SetProjectTitle( int number =-1);
|
||||
|
||||
wxWindow *GetMainPage() { return mMainPage; }
|
||||
wxPanel *GetTopPanel() { return mTopPanel; }
|
||||
TrackPanel * GetTrackPanel() {return mTrackPanel;}
|
||||
const TrackPanel * GetTrackPanel() const {return mTrackPanel;}
|
||||
@@ -614,6 +618,7 @@ private:
|
||||
TrackPanel *mTrackPanel{};
|
||||
SelectionState mSelectionState{};
|
||||
std::unique_ptr<TrackFactory> mTrackFactory{};
|
||||
wxWindow * mMainPage;
|
||||
wxPanel * mMainPanel;
|
||||
wxScrollBar *mHsbar;
|
||||
wxScrollBar *mVsbar;
|
||||
@@ -622,6 +627,8 @@ public:
|
||||
wxScrollBar &GetVerticalScrollBar() { return *mVsbar; }
|
||||
|
||||
private:
|
||||
int mNextWindowID;
|
||||
|
||||
bool mAutoScrolling{ false };
|
||||
bool mActive{ true };
|
||||
bool mIconized;
|
||||
|
||||
Reference in New Issue
Block a user