mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 16:49:41 +02:00
Registration of toolbar factory functions...
... reduces direct dependencies of ToolManager.cpp. This frees four files from cycles: DeviceToolBar EditToolBar MeterToolBar MixerToolBar Leaving 66 files still in the big s.c.c.
This commit is contained in:
parent
0a29afb933
commit
e6d7a72a73
@ -1572,3 +1572,7 @@ TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bo
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ TransportBarID,
|
||||
[](AudacityProject*){ return ToolBar::Holder{ safenew ControlToolBar }; }
|
||||
};
|
||||
|
@ -871,3 +871,7 @@ void DeviceToolBar::ShowComboDialog(wxChoice *combo, const wxString &title)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ DeviceBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew DeviceToolBar }; }
|
||||
};
|
||||
|
@ -303,4 +303,6 @@ void EditToolBar::OnButton(wxCommandEvent &event)
|
||||
cm.HandleTextualCommand(EditToolbarButtonList[id].commandName, context, flags, NoFlagsSpecified);
|
||||
}
|
||||
|
||||
|
||||
static RegisteredToolbarFactory factory{ EditBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew EditToolBar }; }
|
||||
};
|
||||
|
@ -274,3 +274,15 @@ void MeterToolBar::SetDocked(ToolDock *dock, bool pushed) {
|
||||
Fit();
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory1{ RecordMeterBarID,
|
||||
[](AudacityProject *parent){
|
||||
return ToolBar::Holder{ safenew MeterToolBar{ parent, RecordMeterBarID } }; }
|
||||
};
|
||||
static RegisteredToolbarFactory factory2{ PlayMeterBarID,
|
||||
[](AudacityProject *parent){
|
||||
return ToolBar::Holder{ safenew MeterToolBar{ parent, PlayMeterBarID } }; }
|
||||
};
|
||||
static RegisteredToolbarFactory factory3{ MeterBarID,
|
||||
[](AudacityProject *parent){
|
||||
return ToolBar::Holder{ safenew MeterToolBar{ parent, MeterBarID } }; }
|
||||
};
|
||||
|
@ -314,3 +314,7 @@ void MixerToolBar::SetToolTips()
|
||||
mOutputSlider->SetToolTipTemplate(_("Playback Volume (Unavailable; use system mixer.)"));
|
||||
}
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ MixerBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew MixerToolBar }; }
|
||||
};
|
||||
|
@ -261,3 +261,7 @@ void ScrubbingToolBar::EnableDisableButtons()
|
||||
RegenerateTooltips();
|
||||
scrubber.CheckMenuItems();
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ ScrubbingBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew ScrubbingToolBar }; }
|
||||
};
|
||||
|
@ -760,3 +760,7 @@ void SelectionBar::OnSnapTo(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
mListener->AS_SetSnapTo(mSnapTo->GetSelection());
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ SelectionBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew SelectionBar }; }
|
||||
};
|
||||
|
@ -491,4 +491,8 @@ void SpectralSelectionBar::SetBandwidthSelectionFormatName(const NumericFormatSy
|
||||
}
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ SpectralSelectionBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew SpectralSelectionBar }; }
|
||||
};
|
||||
|
||||
#endif // #ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
|
@ -913,3 +913,25 @@ int ToolBar::GetResizeGrabberWidth()
|
||||
{
|
||||
return RWIDTH;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
RegisteredToolbarFactory::Functions &GetFunctions()
|
||||
{
|
||||
static RegisteredToolbarFactory::Functions factories( ToolBarCount );
|
||||
return factories;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RegisteredToolbarFactory::RegisteredToolbarFactory(
|
||||
int id, const Function &function)
|
||||
{
|
||||
wxASSERT( id >= 0 && id < ToolBarCount );
|
||||
GetFunctions()[ id ] = function;
|
||||
}
|
||||
|
||||
auto RegisteredToolbarFactory::GetFactories() -> const Functions&
|
||||
{
|
||||
return GetFunctions();
|
||||
}
|
||||
|
@ -15,12 +15,14 @@
|
||||
|
||||
#include "../Experimental.h"
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <wx/defs.h>
|
||||
|
||||
#include "../Prefs.h"
|
||||
#include "../Theme.h"
|
||||
#include "../widgets/wxPanelWrapper.h" // to inherit
|
||||
#include <wx/windowptr.h>
|
||||
|
||||
class wxBoxSizer;
|
||||
class wxDC;
|
||||
@ -92,7 +94,7 @@ class ToolBar /* not final */
|
||||
|
||||
public:
|
||||
|
||||
using Holder = Destroy_ptr<ToolBar>;
|
||||
using Holder = wxWindowPtr<ToolBar>;
|
||||
|
||||
ToolBar(int type, const wxString & label, const wxString & section, bool resizable = false);
|
||||
virtual ~ToolBar();
|
||||
@ -239,4 +241,15 @@ class ToolBar /* not final */
|
||||
friend class ToolBarResizer;
|
||||
};
|
||||
|
||||
class AudacityProject;
|
||||
|
||||
struct RegisteredToolbarFactory {
|
||||
using Function = std::function< ToolBar::Holder( AudacityProject * ) >;
|
||||
using Functions = std::vector< Function >;
|
||||
|
||||
RegisteredToolbarFactory( int id, const Function &function );
|
||||
|
||||
static const Functions &GetFactories();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -52,17 +52,6 @@
|
||||
#include <wx/minifram.h>
|
||||
#include <wx/popupwin.h>
|
||||
|
||||
#include "ControlToolBar.h"
|
||||
#include "DeviceToolBar.h"
|
||||
#include "EditToolBar.h"
|
||||
#include "MeterToolBar.h"
|
||||
#include "MixerToolBar.h"
|
||||
#include "ScrubbingToolBar.h"
|
||||
#include "SelectionBar.h"
|
||||
#include "SpectralSelectionBar.h"
|
||||
#include "ToolsToolBar.h"
|
||||
#include "TranscriptionToolBar.h"
|
||||
|
||||
#include "../AColor.h"
|
||||
#include "../AllThemeResources.h"
|
||||
#include "../ImageManipulation.h"
|
||||
@ -429,20 +418,10 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
|
||||
// Create all of the toolbars
|
||||
// All have the project as parent window
|
||||
wxASSERT(parent);
|
||||
mBars[ ToolsBarID ] = ToolBar::Holder{ safenew ToolsToolBar() };
|
||||
mBars[ TransportBarID ] = ToolBar::Holder{ safenew ControlToolBar() };
|
||||
mBars[ RecordMeterBarID ] = ToolBar::Holder{ safenew MeterToolBar( parent, RecordMeterBarID ) };
|
||||
mBars[ PlayMeterBarID ] = ToolBar::Holder{ safenew MeterToolBar( parent, PlayMeterBarID ) };
|
||||
mBars[ MeterBarID ] = ToolBar::Holder{ safenew MeterToolBar( parent, MeterBarID ) };
|
||||
mBars[ EditBarID ] = ToolBar::Holder{ safenew EditToolBar() };
|
||||
mBars[ MixerBarID ] = ToolBar::Holder{ safenew MixerToolBar() };
|
||||
mBars[ TranscriptionBarID ] = ToolBar::Holder{ safenew TranscriptionToolBar() };
|
||||
mBars[ SelectionBarID ] = ToolBar::Holder{ safenew SelectionBar() };
|
||||
mBars[ DeviceBarID ] = ToolBar::Holder{ safenew DeviceToolBar() };
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
mBars[SpectralSelectionBarID] = ToolBar::Holder{ safenew SpectralSelectionBar() };
|
||||
#endif
|
||||
mBars[ ScrubbingBarID ] = ToolBar::Holder{ safenew ScrubbingToolBar() };
|
||||
|
||||
size_t ii = 0;
|
||||
for (const auto &factory : RegisteredToolbarFactory::GetFactories())
|
||||
mBars[ii++] = factory( parent );
|
||||
|
||||
// We own the timer
|
||||
mTimer.SetOwner( this );
|
||||
|
@ -276,3 +276,7 @@ void ToolsToolBar::Create(wxWindow * parent)
|
||||
ToolBar::Create(parent);
|
||||
UpdatePrefs();
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ ToolsBarID,
|
||||
[](AudacityProject*){ return ToolBar::Holder{ safenew ToolsToolBar }; }
|
||||
};
|
||||
|
@ -980,3 +980,7 @@ void TranscriptionToolBar::AdjustPlaySpeed(float adj)
|
||||
OnSpeedSlider(e);
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ TranscriptionBarID,
|
||||
[](AudacityProject *){
|
||||
return ToolBar::Holder{ safenew TranscriptionToolBar }; }
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user