mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-24 16:38:07 +02:00
Construct all toolbars with back-reference to the project...
... and eliminate many uses of GetActiveProject
This commit is contained in:
parent
5751ddba4f
commit
c6f24d864b
@ -570,7 +570,8 @@ public:
|
||||
static std::shared_ptr<PlayheadHandle>
|
||||
HitTest( const AudacityProject *pProject, wxCoord xx )
|
||||
{
|
||||
if( ControlToolBar::IsTransportingPinned() &&
|
||||
if( ControlToolBar::Get( *pProject )
|
||||
.IsTransportingPinned() &&
|
||||
ProjectAudioIO::Get( *pProject ).IsAudioActive() )
|
||||
{
|
||||
const auto targetX = GetPlayHeadX( pProject );
|
||||
@ -1671,7 +1672,7 @@ void AdornedRulerPanel::UpdateButtonStates()
|
||||
auto common = [this]
|
||||
(AButton &button, const CommandID &commandName, const wxString &label) {
|
||||
TranslatedInternalString command{ commandName, label };
|
||||
ToolBar::SetButtonToolTip( button, &command, 1u );
|
||||
ToolBar::SetButtonToolTip( *mProject, button, &command, 1u );
|
||||
button.SetLabel(button.GetToolTipText());
|
||||
|
||||
button.UpdateStatus();
|
||||
@ -2068,7 +2069,7 @@ void AdornedRulerPanel::DoDrawIndicator
|
||||
dc->DrawPolygon( 3, tri );
|
||||
}
|
||||
else {
|
||||
bool pinned = ControlToolBar::IsTransportingPinned();
|
||||
bool pinned = ControlToolBar::Get( *mProject ).IsTransportingPinned();
|
||||
wxBitmap & bmp = theTheme.Bitmap( pinned ?
|
||||
(playing ? bmpPlayPointerPinned : bmpRecordPointerPinned) :
|
||||
(playing ? bmpPlayPointer : bmpRecordPointer)
|
||||
|
@ -104,8 +104,8 @@ END_EVENT_TABLE()
|
||||
// Note that we use the legacy "Control" string as the section because this
|
||||
// gets written to prefs and cannot be changed in prefs to maintain backwards
|
||||
// compatibility
|
||||
ControlToolBar::ControlToolBar()
|
||||
: ToolBar(TransportBarID, _("Transport"), wxT("Control"))
|
||||
ControlToolBar::ControlToolBar( AudacityProject &project )
|
||||
: ToolBar(project, TransportBarID, _("Transport"), wxT("Control"))
|
||||
{
|
||||
mPaused = false;
|
||||
|
||||
@ -312,7 +312,8 @@ void ControlToolBar::RegenerateTooltips()
|
||||
wxT("SelStart"), _("Select to Start") } );
|
||||
break;
|
||||
}
|
||||
ToolBar::SetButtonToolTip(*pCtrl, commands.data(), commands.size());
|
||||
ToolBar::SetButtonToolTip(
|
||||
mProject, *pCtrl, commands.data(), commands.size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -474,7 +475,7 @@ void ControlToolBar::Repaint( wxDC *dc )
|
||||
|
||||
void ControlToolBar::EnableDisableButtons()
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
bool paused = mPause->IsDown();
|
||||
bool playing = mPlay->IsDown();
|
||||
@ -495,7 +496,6 @@ void ControlToolBar::EnableDisableButtons()
|
||||
mRewind->SetEnabled(IsPauseDown() || (!playing && !recording));
|
||||
mFF->SetEnabled(tracks && (IsPauseDown() || (!playing && !recording)));
|
||||
|
||||
//auto pProject = GetActiveProject();
|
||||
mPause->SetEnabled(CanStopAudioStream());
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ void ControlToolBar::SetPlay(bool down, PlayAppearance appearance)
|
||||
mPlay->SetAlternateIdx(0);
|
||||
}
|
||||
EnableDisableButtons();
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
UpdateStatusBar( &mProject );
|
||||
}
|
||||
|
||||
void ControlToolBar::SetStop(bool down)
|
||||
@ -610,9 +610,7 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||
if (cutpreview && t0==t1)
|
||||
return -1; /* msmeyer: makes no sense */
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
if (!p)
|
||||
return -1; // Should never happen, but...
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
auto &tracks = TrackList::Get( *p );
|
||||
|
||||
@ -753,9 +751,8 @@ void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
|
||||
if (!CanStopAudioStream())
|
||||
return;
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
if (p)
|
||||
{
|
||||
|
||||
const auto &playRegion = ViewInfo::Get( *p ).playRegion;
|
||||
@ -787,7 +784,7 @@ void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
|
||||
// If so, "!CanStopAudioStream()" should probably apply.
|
||||
if (event.GetKeyCode() == WXK_SPACE) {
|
||||
if (gAudioIO->IsStreamActive(
|
||||
ProjectAudioIO::Get( *GetActiveProject() ).GetAudioIOToken()
|
||||
ProjectAudioIO::Get( mProject ).GetAudioIOToken()
|
||||
)) {
|
||||
SetPlay(false);
|
||||
SetStop(true);
|
||||
@ -805,7 +802,7 @@ void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
|
||||
|
||||
void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
auto p = GetActiveProject();
|
||||
auto p = &mProject;
|
||||
|
||||
if (!CanStopAudioStream())
|
||||
return;
|
||||
@ -823,7 +820,7 @@ void ControlToolBar::OnStop(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
if (CanStopAudioStream()) {
|
||||
StopPlaying();
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
UpdateStatusBar( &mProject );
|
||||
}
|
||||
}
|
||||
|
||||
@ -832,7 +829,7 @@ bool ControlToolBar::CanStopAudioStream()
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
return (!gAudioIO->IsStreamActive() ||
|
||||
gAudioIO->IsMonitoring() ||
|
||||
gAudioIO->GetOwningProject() == GetActiveProject());
|
||||
gAudioIO->GetOwningProject() == &mProject );
|
||||
}
|
||||
|
||||
void ControlToolBar::PlayDefault()
|
||||
@ -848,7 +845,7 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
||||
{
|
||||
StopScrolling();
|
||||
|
||||
AudacityProject *project = GetActiveProject();
|
||||
AudacityProject *project = &mProject;
|
||||
|
||||
if(project) {
|
||||
// Let scrubbing code do some appearance change
|
||||
@ -993,10 +990,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
// normally used for buttons.
|
||||
|
||||
// Code from CommandHandler start...
|
||||
AudacityProject * p = GetActiveProject();
|
||||
wxASSERT(p);
|
||||
if (!p)
|
||||
return;
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
bool altAppearance = mRecord->WasShiftDown();
|
||||
if (evt.GetInt() == 1) // used when called by keyboard shortcut. Default (0) ignored.
|
||||
@ -1115,7 +1109,7 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
||||
}
|
||||
|
||||
// Success or not:
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
UpdateStatusBar( &mProject );
|
||||
});
|
||||
|
||||
auto transportTracks = tracks;
|
||||
@ -1306,7 +1300,7 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
|
||||
|
||||
auto project = GetActiveProject();
|
||||
auto project = &mProject;
|
||||
auto &scrubber = Scrubber::Get( *project );
|
||||
|
||||
// Bug 1494 - Pausing a seek or scrub should just STOP as
|
||||
@ -1329,7 +1323,7 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
gAudioIO->SetPaused(mPaused);
|
||||
}
|
||||
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
UpdateStatusBar( &mProject );
|
||||
}
|
||||
|
||||
void ControlToolBar::OnRewind(wxCommandEvent & WXUNUSED(evt))
|
||||
@ -1337,8 +1331,8 @@ void ControlToolBar::OnRewind(wxCommandEvent & WXUNUSED(evt))
|
||||
mRewind->PushDown();
|
||||
mRewind->PopUp();
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
if (p) {
|
||||
AudacityProject *p = &mProject;
|
||||
{
|
||||
TransportActions::StopIfPaused( *p );
|
||||
ProjectWindow::Get( *p ).Rewind(mRewind->WasShiftDown());
|
||||
}
|
||||
@ -1349,9 +1343,9 @@ void ControlToolBar::OnFF(wxCommandEvent & WXUNUSED(evt))
|
||||
mFF->PushDown();
|
||||
mFF->PopUp();
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
if (p) {
|
||||
{
|
||||
TransportActions::StopIfPaused( *p );
|
||||
ProjectWindow::Get( *p ).SkipEnd(mFF->WasShiftDown());
|
||||
}
|
||||
@ -1363,8 +1357,8 @@ void ControlToolBar::SetupCutPreviewTracks(double WXUNUSED(playStart), double cu
|
||||
// STRONG-GUARANTEE (for state of mCutPreviewTracks)
|
||||
{
|
||||
ClearCutPreviewTracks();
|
||||
AudacityProject *p = GetActiveProject();
|
||||
if (p) {
|
||||
AudacityProject *p = &mProject;
|
||||
{
|
||||
auto trackRange = TrackList::Get( *p ).Selected< const PlayableTrack >();
|
||||
if( !trackRange.empty() ) {
|
||||
auto cutPreviewTracks = TrackList::Create();
|
||||
@ -1419,7 +1413,7 @@ wxString ControlToolBar::StateForStatusBar()
|
||||
{
|
||||
wxString state;
|
||||
|
||||
auto pProject = GetActiveProject();
|
||||
auto pProject = &mProject;
|
||||
auto scrubState = pProject
|
||||
? Scrubber::Get( *pProject ).GetUntranslatedStateString()
|
||||
: wxString();
|
||||
@ -1449,11 +1443,11 @@ void ControlToolBar::UpdateStatusBar(AudacityProject *pProject)
|
||||
.GetStatusBar()->SetStatusText(StateForStatusBar(), stateStatusBarField);
|
||||
}
|
||||
|
||||
bool ControlToolBar::IsTransportingPinned()
|
||||
bool ControlToolBar::IsTransportingPinned() const
|
||||
{
|
||||
if (!TracksPrefs::GetPinnedHeadPreference())
|
||||
return false;
|
||||
const auto &scrubber = Scrubber::Get( *::GetActiveProject() );
|
||||
const auto &scrubber = Scrubber::Get( mProject );
|
||||
return
|
||||
!(scrubber.HasMark() &&
|
||||
!scrubber.WasSpeedPlaying() &&
|
||||
@ -1462,15 +1456,15 @@ bool ControlToolBar::IsTransportingPinned()
|
||||
|
||||
void ControlToolBar::StartScrollingIfPreferred()
|
||||
{
|
||||
if (IsTransportingPinned())
|
||||
if ( IsTransportingPinned() )
|
||||
StartScrolling();
|
||||
#ifdef __WXMAC__
|
||||
else if (Scrubber::Get( *::GetActiveProject() ).HasMark()) {
|
||||
else if (Scrubber::Get( mProject ).HasMark()) {
|
||||
// PRL: cause many "unnecessary" refreshes. For reasons I don't understand,
|
||||
// doing this causes wheel rotation events (mapped from the double finger vertical
|
||||
// swipe) to be delivered more uniformly to the application, so that speed control
|
||||
// works better.
|
||||
ProjectWindow::Get( *::GetActiveProject() ).GetPlaybackScroller().Activate
|
||||
ProjectWindow::Get( mProject ).GetPlaybackScroller().Activate
|
||||
(ProjectWindow::PlaybackScroller::Mode::Refresh);
|
||||
}
|
||||
#endif
|
||||
@ -1481,7 +1475,7 @@ void ControlToolBar::StartScrollingIfPreferred()
|
||||
void ControlToolBar::StartScrolling()
|
||||
{
|
||||
using Mode = ProjectWindow::PlaybackScroller::Mode;
|
||||
const auto project = GetActiveProject();
|
||||
const auto project = &mProject;
|
||||
if (project) {
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
auto mode = Mode::Pinned;
|
||||
@ -1519,7 +1513,7 @@ void ControlToolBar::StartScrolling()
|
||||
|
||||
void ControlToolBar::StopScrolling()
|
||||
{
|
||||
const auto project = GetActiveProject();
|
||||
const auto project = &mProject;
|
||||
if(project)
|
||||
ProjectWindow::Get( *project ).GetPlaybackScroller().Activate
|
||||
(ProjectWindow::PlaybackScroller::Mode::Off);
|
||||
@ -1527,13 +1521,13 @@ void ControlToolBar::StopScrolling()
|
||||
|
||||
void ControlToolBar::CommitRecording()
|
||||
{
|
||||
const auto project = GetActiveProject();
|
||||
const auto project = &mProject;
|
||||
TrackList::Get( *project ).ApplyPendingTracks();
|
||||
}
|
||||
|
||||
void ControlToolBar::CancelRecording()
|
||||
{
|
||||
const auto project = GetActiveProject();
|
||||
const auto project = &mProject;
|
||||
TrackList::Get( *project ).ClearPendingTracks();
|
||||
}
|
||||
|
||||
@ -1566,5 +1560,6 @@ TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bo
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ TransportBarID,
|
||||
[](AudacityProject*){ return ToolBar::Holder{ safenew ControlToolBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew ControlToolBar{ project } }; }
|
||||
};
|
||||
|
@ -51,10 +51,10 @@ class ControlToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
ControlToolBar();
|
||||
ControlToolBar( AudacityProject &project );
|
||||
virtual ~ControlToolBar();
|
||||
|
||||
static bool IsTransportingPinned();
|
||||
bool IsTransportingPinned() const;
|
||||
|
||||
static ControlToolBar *Find( AudacityProject &project );
|
||||
static ControlToolBar &Get( AudacityProject &project );
|
||||
|
@ -72,8 +72,8 @@ static int DeviceToolbarPrefsID()
|
||||
}
|
||||
|
||||
//Standard contructor
|
||||
DeviceToolBar::DeviceToolBar()
|
||||
: ToolBar(DeviceBarID, _("Device"), wxT("Device"), true)
|
||||
DeviceToolBar::DeviceToolBar( AudacityProject &project )
|
||||
: ToolBar( project, DeviceBarID, _("Device"), wxT("Device"), true )
|
||||
{
|
||||
wxTheApp->Bind( EVT_RESCANNED_DEVICES,
|
||||
&DeviceToolBar::OnRescannedDevices, this );
|
||||
@ -351,12 +351,8 @@ void DeviceToolBar::EnableDisableButtons()
|
||||
// Here we should relinquish focus
|
||||
if (audioStreamActive) {
|
||||
wxWindow *focus = wxWindow::FindFocus();
|
||||
if (focus == mHost || focus == mInput || focus == mOutput || focus == mInputChannels) {
|
||||
AudacityProject *activeProject = GetActiveProject();
|
||||
if (activeProject) {
|
||||
TrackPanel::Get( *activeProject ).SetFocus();
|
||||
}
|
||||
}
|
||||
if (focus == mHost || focus == mInput || focus == mOutput || focus == mInputChannels)
|
||||
TrackPanel::Get( mProject ).SetFocus();
|
||||
}
|
||||
|
||||
mHost->Enable(!audioStreamActive);
|
||||
@ -873,5 +869,6 @@ void DeviceToolBar::ShowComboDialog(wxChoice *combo, const wxString &title)
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ DeviceBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew DeviceToolBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew DeviceToolBar{ project } }; }
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ class DeviceToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
DeviceToolBar();
|
||||
DeviceToolBar( AudacityProject &project );
|
||||
virtual ~DeviceToolBar();
|
||||
|
||||
static DeviceToolBar &Get( AudacityProject &project );
|
||||
|
@ -76,8 +76,8 @@ BEGIN_EVENT_TABLE( EditToolBar, ToolBar )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//Standard contructor
|
||||
EditToolBar::EditToolBar()
|
||||
: ToolBar(EditBarID, _("Edit"), wxT("Edit"))
|
||||
EditToolBar::EditToolBar( AudacityProject &project )
|
||||
: ToolBar(project, EditBarID, _("Edit"), wxT("Edit"))
|
||||
{
|
||||
}
|
||||
|
||||
@ -259,8 +259,7 @@ void EditToolBar::ForAllButtons(int Action)
|
||||
CommandManager* cm = nullptr;
|
||||
|
||||
if( Action & ETBActEnableDisable ){
|
||||
p = GetActiveProject();
|
||||
if (!p) return;
|
||||
p = &mProject;
|
||||
cm = &CommandManager::Get( *p );
|
||||
#ifdef OPTION_SYNC_LOCK_BUTTON
|
||||
bool bSyncLockTracks;
|
||||
@ -279,7 +278,8 @@ void EditToolBar::ForAllButtons(int Action)
|
||||
if( Action & ETBActTooltips ){
|
||||
TranslatedInternalString command{
|
||||
entry.commandName, wxGetTranslation(entry.untranslatedLabel) };
|
||||
ToolBar::SetButtonToolTip( *mButtons[entry.tool], &command, 1u );
|
||||
ToolBar::SetButtonToolTip( mProject,
|
||||
*mButtons[entry.tool], &command, 1u );
|
||||
}
|
||||
#endif
|
||||
if (cm) {
|
||||
@ -294,15 +294,15 @@ void EditToolBar::OnButton(wxCommandEvent &event)
|
||||
// Be sure the pop-up happens even if there are exceptions, except for buttons which toggle.
|
||||
auto cleanup = finally( [&] { mButtons[id]->InteractionOver();});
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
if (!p) return;
|
||||
AudacityProject *p = &mProject;
|
||||
auto &cm = CommandManager::Get( *p );
|
||||
|
||||
auto flags = MenuManager::Get(*p).GetUpdateFlags();
|
||||
const CommandContext context( *GetActiveProject() );
|
||||
const CommandContext context( *p );
|
||||
cm.HandleTextualCommand(EditToolbarButtonList[id].commandName, context, flags, NoFlagsSpecified);
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ EditBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew EditToolBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew EditToolBar{ project } }; }
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ class EditToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
EditToolBar();
|
||||
EditToolBar( AudacityProject &project );
|
||||
virtual ~EditToolBar();
|
||||
|
||||
void Create(wxWindow *parent) override;
|
||||
|
@ -48,11 +48,9 @@ BEGIN_EVENT_TABLE( MeterToolBar, ToolBar )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//Standard contructor
|
||||
MeterToolBar::MeterToolBar(AudacityProject *project, int type)
|
||||
: ToolBar(type, _("Combined Meter"), wxT("CombinedMeter"), true)
|
||||
MeterToolBar::MeterToolBar(AudacityProject &project, int type)
|
||||
: ToolBar(project, type, _("Combined Meter"), wxT("CombinedMeter"), true)
|
||||
{
|
||||
mProject = project;
|
||||
|
||||
if( mType == RecordMeterBarID ){
|
||||
mWhichMeters = kWithRecordMeter;
|
||||
mLabel = _("Recording Meter");
|
||||
@ -88,7 +86,7 @@ void MeterToolBar::ReCreateButtons()
|
||||
{
|
||||
MeterPanel::State playState{ false }, recordState{ false };
|
||||
|
||||
auto &projectAudioIO = ProjectAudioIO::Get( *mProject );
|
||||
auto &projectAudioIO = ProjectAudioIO::Get( mProject );
|
||||
if (mPlayMeter && projectAudioIO.GetPlaybackMeter() == mPlayMeter)
|
||||
{
|
||||
playState = mPlayMeter->SaveState();
|
||||
@ -116,13 +114,12 @@ void MeterToolBar::ReCreateButtons()
|
||||
void MeterToolBar::Populate()
|
||||
{
|
||||
SetBackgroundColour( theTheme.Colour( clrMedium ) );
|
||||
wxASSERT(mProject); // to justify safenew
|
||||
Add((mSizer = safenew wxGridBagSizer()), 1, wxEXPAND);
|
||||
|
||||
if( mWhichMeters & kWithRecordMeter ){
|
||||
//JKC: Record on left, playback on right. Left to right flow
|
||||
//(maybe we should do it differently for Arabic language :-) )
|
||||
mRecordMeter = safenew MeterPanel( mProject,
|
||||
mRecordMeter = safenew MeterPanel( &mProject,
|
||||
this,
|
||||
wxID_ANY,
|
||||
true,
|
||||
@ -138,7 +135,7 @@ void MeterToolBar::Populate()
|
||||
}
|
||||
|
||||
if( mWhichMeters & kWithPlayMeter ){
|
||||
mPlayMeter = safenew MeterPanel( mProject,
|
||||
mPlayMeter = safenew MeterPanel( &mProject,
|
||||
this,
|
||||
wxID_ANY,
|
||||
false,
|
||||
@ -229,7 +226,7 @@ void MeterToolBar::OnSize( wxSizeEvent & event) //WXUNUSED(event) )
|
||||
|
||||
bool MeterToolBar::Expose( bool show )
|
||||
{
|
||||
auto &projectAudioIO = ProjectAudioIO::Get( *mProject );
|
||||
auto &projectAudioIO = ProjectAudioIO::Get( mProject );
|
||||
if( show ) {
|
||||
if( mPlayMeter ) {
|
||||
projectAudioIO.SetPlaybackMeter( mPlayMeter );
|
||||
@ -275,14 +272,17 @@ void MeterToolBar::SetDocked(ToolDock *dock, bool pushed) {
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory1{ RecordMeterBarID,
|
||||
[](AudacityProject *parent){
|
||||
return ToolBar::Holder{ safenew MeterToolBar{ parent, RecordMeterBarID } }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{
|
||||
safenew MeterToolBar{ project, RecordMeterBarID } }; }
|
||||
};
|
||||
static RegisteredToolbarFactory factory2{ PlayMeterBarID,
|
||||
[](AudacityProject *parent){
|
||||
return ToolBar::Holder{ safenew MeterToolBar{ parent, PlayMeterBarID } }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{
|
||||
safenew MeterToolBar{ project, PlayMeterBarID } }; }
|
||||
};
|
||||
static RegisteredToolbarFactory factory3{ MeterBarID,
|
||||
[](AudacityProject *parent){
|
||||
return ToolBar::Holder{ safenew MeterToolBar{ parent, MeterBarID } }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{
|
||||
safenew MeterToolBar{ project, MeterBarID } }; }
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ class MeterToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
MeterToolBar(AudacityProject *project, int type);
|
||||
MeterToolBar(AudacityProject &project, int type);
|
||||
virtual ~MeterToolBar();
|
||||
|
||||
void Create(wxWindow *parent) override;
|
||||
@ -56,7 +56,6 @@ class MeterToolBar final : public ToolBar {
|
||||
private:
|
||||
void RegenerateTooltips() override;
|
||||
|
||||
AudacityProject *mProject;
|
||||
int mWhichMeters;
|
||||
wxGridBagSizer *mSizer;
|
||||
MeterPanel *mPlayMeter;
|
||||
|
@ -55,8 +55,8 @@ BEGIN_EVENT_TABLE(MixerToolBar, ToolBar)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//Standard contructor
|
||||
MixerToolBar::MixerToolBar()
|
||||
: ToolBar(MixerBarID, _("Mixer"), wxT("Mixer"), true)
|
||||
MixerToolBar::MixerToolBar( AudacityProject &project )
|
||||
: ToolBar(project, MixerBarID, _("Mixer"), wxT("Mixer"), true)
|
||||
{
|
||||
mInputSliderVolume = 0.0;
|
||||
mOutputSliderVolume = 0.0;
|
||||
@ -316,5 +316,6 @@ void MixerToolBar::SetToolTips()
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ MixerBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew MixerToolBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew MixerToolBar{ project } }; }
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ class MixerToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
MixerToolBar();
|
||||
MixerToolBar( AudacityProject &project );
|
||||
virtual ~MixerToolBar();
|
||||
|
||||
static MixerToolBar &Get( AudacityProject &project );
|
||||
|
@ -55,8 +55,8 @@ EVT_COMMAND_RANGE( STBFirstButton,
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//Standard contructor
|
||||
ScrubbingToolBar::ScrubbingToolBar()
|
||||
: ToolBar(ScrubbingBarID, _("Scrub"), wxT("Scrub"))
|
||||
ScrubbingToolBar::ScrubbingToolBar( AudacityProject &project )
|
||||
: ToolBar(project, ScrubbingBarID, _("Scrub"), wxT("Scrub"))
|
||||
{
|
||||
}
|
||||
|
||||
@ -147,10 +147,10 @@ void ScrubbingToolBar::RegenerateTooltips()
|
||||
(AButton &button, const wxString &label, const CommandID &cmd)
|
||||
{
|
||||
TranslatedInternalString command{ cmd, label };
|
||||
ToolBar::SetButtonToolTip( button, &command, 1u );
|
||||
ToolBar::SetButtonToolTip( mProject, button, &command, 1u );
|
||||
};
|
||||
|
||||
auto project = GetActiveProject();
|
||||
auto project = &mProject;
|
||||
if (project) {
|
||||
auto &scrubber = Scrubber::Get( *project );
|
||||
|
||||
@ -192,7 +192,7 @@ void ScrubbingToolBar::RegenerateTooltips()
|
||||
|
||||
void ScrubbingToolBar::OnButton(wxCommandEvent &event)
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
if (!p) return;
|
||||
auto &scrubber = Scrubber::Get( *p );
|
||||
|
||||
@ -222,7 +222,7 @@ void ScrubbingToolBar::EnableDisableButtons()
|
||||
const auto seekButton = mButtons[STBSeekID];
|
||||
seekButton->SetEnabled(true);
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
if (!p) return;
|
||||
|
||||
auto &scrubber = Scrubber::Get( *p );
|
||||
@ -263,5 +263,6 @@ void ScrubbingToolBar::EnableDisableButtons()
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ ScrubbingBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew ScrubbingToolBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew ScrubbingToolBar{ project } }; }
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ class ScrubbingToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
ScrubbingToolBar();
|
||||
ScrubbingToolBar( AudacityProject &project );
|
||||
virtual ~ScrubbingToolBar();
|
||||
|
||||
static ScrubbingToolBar &Get( AudacityProject &project );
|
||||
|
@ -103,8 +103,8 @@ BEGIN_EVENT_TABLE(SelectionBar, ToolBar)
|
||||
EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, SelectionBar::OnCaptureKey)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
SelectionBar::SelectionBar()
|
||||
: ToolBar(SelectionBarID, _("Selection"), wxT("Selection")),
|
||||
SelectionBar::SelectionBar( AudacityProject &project )
|
||||
: ToolBar(project, SelectionBarID, _("Selection"), wxT("Selection")),
|
||||
mListener(NULL), mRate(0.0),
|
||||
mStart(0.0), mEnd(0.0), mLength(0.0), mCenter(0.0), mAudio(0.0),
|
||||
mDrive1( StartTimeID), mDrive2( EndTimeID ),
|
||||
@ -762,5 +762,6 @@ void SelectionBar::OnSnapTo(wxCommandEvent & WXUNUSED(event))
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ SelectionBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew SelectionBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew SelectionBar{ project } }; }
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ class NumericTextCtrl;
|
||||
class SelectionBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
SelectionBar();
|
||||
SelectionBar( AudacityProject &project );
|
||||
virtual ~SelectionBar();
|
||||
|
||||
static SelectionBar &Get( AudacityProject &project );
|
||||
|
@ -91,8 +91,9 @@ END_EVENT_TABLE()
|
||||
static const wxString preferencePath
|
||||
(wxT("/GUI/Toolbars/SpectralSelection/CenterAndWidthChoice"));
|
||||
|
||||
SpectralSelectionBar::SpectralSelectionBar()
|
||||
: ToolBar(SpectralSelectionBarID, _("Spectral Selection"), wxT("SpectralSelection"))
|
||||
SpectralSelectionBar::SpectralSelectionBar( AudacityProject &project )
|
||||
: ToolBar( project,
|
||||
SpectralSelectionBarID, _("Spectral Selection"), wxT("SpectralSelection") )
|
||||
, mListener(NULL), mbCenterAndWidth(true)
|
||||
, mCenter(0.0), mWidth(0.0), mLow(0.0), mHigh(0.0)
|
||||
, mCenterCtrl(NULL), mWidthCtrl(NULL), mLowCtrl(NULL), mHighCtrl(NULL)
|
||||
@ -492,7 +493,8 @@ void SpectralSelectionBar::SetBandwidthSelectionFormatName(const NumericFormatSy
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ SpectralSelectionBarID,
|
||||
[](AudacityProject *){ return ToolBar::Holder{ safenew SpectralSelectionBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew SpectralSelectionBar{ project } }; }
|
||||
};
|
||||
|
||||
#endif // #ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
|
@ -29,7 +29,7 @@ class SpectralSelectionBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
SpectralSelectionBar();
|
||||
SpectralSelectionBar( AudacityProject &project );
|
||||
virtual ~SpectralSelectionBar();
|
||||
|
||||
static SpectralSelectionBar &Get( AudacityProject &project );
|
||||
|
@ -314,11 +314,13 @@ END_EVENT_TABLE()
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
ToolBar::ToolBar( int type,
|
||||
ToolBar::ToolBar( AudacityProject &project,
|
||||
int type,
|
||||
const wxString &label,
|
||||
const wxString §ion,
|
||||
bool resizable )
|
||||
: wxPanelWrapper()
|
||||
, mProject{ project }
|
||||
{
|
||||
// Save parameters
|
||||
mType = type;
|
||||
@ -842,10 +844,11 @@ void ToolBar::MakeAlternateImages(AButton &button, int idx,
|
||||
}
|
||||
|
||||
void ToolBar::SetButtonToolTip
|
||||
(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
|
||||
(AudacityProject &theProject,
|
||||
AButton &button, const TranslatedInternalString commands[], size_t nCommands)
|
||||
{
|
||||
wxString result;
|
||||
const auto project = GetActiveProject();
|
||||
const auto project = &theProject;
|
||||
const auto commandManager =
|
||||
project ? &CommandManager::Get( *project ) : nullptr;
|
||||
if (commandManager)
|
||||
|
@ -87,6 +87,8 @@ enum
|
||||
// How may pixels padding each side of a floating toolbar
|
||||
enum { ToolBarFloatMargin = 1 };
|
||||
|
||||
class AudacityProject;
|
||||
|
||||
class ToolBar /* not final */
|
||||
: public wxPanelWrapper
|
||||
, protected PrefsListener
|
||||
@ -96,7 +98,9 @@ class ToolBar /* not final */
|
||||
|
||||
using Holder = wxWindowPtr<ToolBar>;
|
||||
|
||||
ToolBar(int type, const wxString & label, const wxString & section, bool resizable = false);
|
||||
ToolBar( AudacityProject &project,
|
||||
int type, const wxString & label, const wxString & section,
|
||||
bool resizable = false);
|
||||
virtual ~ToolBar();
|
||||
|
||||
bool AcceptsFocus() const override { return false; };
|
||||
@ -162,7 +166,7 @@ class ToolBar /* not final */
|
||||
|
||||
static
|
||||
void SetButtonToolTip
|
||||
(AButton &button,
|
||||
(AudacityProject &project, AButton &button,
|
||||
// If a shortcut key is defined for the command, then it is appended,
|
||||
// parenthesized, after the translated name.
|
||||
const TranslatedInternalString commands[], size_t nCommands);
|
||||
@ -216,6 +220,7 @@ class ToolBar /* not final */
|
||||
void OnMouseEvents(wxMouseEvent &event);
|
||||
|
||||
protected:
|
||||
AudacityProject &mProject;
|
||||
wxString mLabel;
|
||||
wxString mSection;
|
||||
int mType;
|
||||
@ -241,10 +246,8 @@ class ToolBar /* not final */
|
||||
friend class ToolBarResizer;
|
||||
};
|
||||
|
||||
class AudacityProject;
|
||||
|
||||
struct RegisteredToolbarFactory {
|
||||
using Function = std::function< ToolBar::Holder( AudacityProject * ) >;
|
||||
using Function = std::function< ToolBar::Holder( AudacityProject & ) >;
|
||||
using Functions = std::vector< Function >;
|
||||
|
||||
RegisteredToolbarFactory( int id, const Function &function );
|
||||
|
@ -420,8 +420,14 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
|
||||
wxASSERT(parent);
|
||||
|
||||
size_t ii = 0;
|
||||
for (const auto &factory : RegisteredToolbarFactory::GetFactories())
|
||||
mBars[ii++] = factory( parent );
|
||||
for (const auto &factory : RegisteredToolbarFactory::GetFactories()) {
|
||||
if (factory) {
|
||||
mBars[ii] = factory( *parent );
|
||||
}
|
||||
else
|
||||
wxASSERT( false );
|
||||
++ii;
|
||||
}
|
||||
|
||||
// We own the timer
|
||||
mTimer.SetOwner( this );
|
||||
|
@ -71,8 +71,8 @@ BEGIN_EVENT_TABLE(ToolsToolBar, ToolBar)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//Standard constructor
|
||||
ToolsToolBar::ToolsToolBar()
|
||||
: ToolBar(ToolsBarID, _("Tools"), wxT("Tools"))
|
||||
ToolsToolBar::ToolsToolBar( AudacityProject &project )
|
||||
: ToolBar(project, ToolsBarID, _("Tools"), wxT("Tools"))
|
||||
{
|
||||
//Read the following wxASSERTs as documentating a design decision
|
||||
wxASSERT( selectTool == selectTool - firstTool );
|
||||
@ -148,7 +148,8 @@ void ToolsToolBar::RegenerateTooltips()
|
||||
for (const auto &entry : table) {
|
||||
TranslatedInternalString command{
|
||||
entry.commandName, wxGetTranslation(entry.untranslatedLabel) };
|
||||
ToolBar::SetButtonToolTip( *mTool[entry.tool], &command, 1u );
|
||||
ToolBar::SetButtonToolTip( mProject,
|
||||
*mTool[entry.tool], &command, 1u );
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -278,5 +279,6 @@ void ToolsToolBar::Create(wxWindow * parent)
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ ToolsBarID,
|
||||
[](AudacityProject*){ return ToolBar::Holder{ safenew ToolsToolBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew ToolsToolBar{ project } }; }
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ class ToolsToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
ToolsToolBar();
|
||||
ToolsToolBar( AudacityProject &project );
|
||||
virtual ~ToolsToolBar();
|
||||
|
||||
static ToolsToolBar &Get( AudacityProject &project );
|
||||
|
@ -94,8 +94,9 @@ END_EVENT_TABLE()
|
||||
; //semicolon enforces proper automatic indenting in emacs.
|
||||
|
||||
////Standard Constructor
|
||||
TranscriptionToolBar::TranscriptionToolBar()
|
||||
: ToolBar(TranscriptionBarID, _("Play-at-Speed"), wxT("Transcription"),true)
|
||||
TranscriptionToolBar::TranscriptionToolBar( AudacityProject &project )
|
||||
: ToolBar( project,
|
||||
TranscriptionBarID, _("Play-at-Speed"), wxT("Transcription"), true )
|
||||
{
|
||||
mPlaySpeed = 1.0 * 100.0;
|
||||
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
||||
@ -288,7 +289,7 @@ void TranscriptionToolBar::Populate()
|
||||
|
||||
void TranscriptionToolBar::EnableDisableButtons()
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
bool canStopAudioStream = (!gAudioIO->IsStreamActive() ||
|
||||
@ -301,7 +302,7 @@ void TranscriptionToolBar::EnableDisableButtons()
|
||||
SetEnabled( canStopAudioStream && tracks && !recording );
|
||||
|
||||
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
if (!p) return;
|
||||
// Is anything selected?
|
||||
auto selection = p->GetSel0() < p->GetSel1() && p->GetTracks()->Selected();
|
||||
@ -343,7 +344,8 @@ void TranscriptionToolBar::RegenerateTooltips()
|
||||
{ entry.commandName, wxGetTranslation(entry.untranslatedLabel) },
|
||||
{ entry.commandName2, wxGetTranslation(entry.untranslatedLabel2) },
|
||||
};
|
||||
ToolBar::SetButtonToolTip( *mButtons[entry.tool], commands, 2u );
|
||||
ToolBar::SetButtonToolTip( mProject,
|
||||
*mButtons[entry.tool], commands, 2u );
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
||||
@ -422,7 +424,7 @@ void TranscriptionToolBar::GetSamples(
|
||||
// GetSamples attempts to translate the start and end selection markers into sample indices
|
||||
// These selection numbers are doubles.
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
if (!p) {
|
||||
return;
|
||||
}
|
||||
@ -465,7 +467,7 @@ void TranscriptionToolBar::GetSamples(
|
||||
void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
|
||||
{
|
||||
// Can't do anything without an active project
|
||||
AudacityProject * p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
if (!p) {
|
||||
return;
|
||||
}
|
||||
@ -572,7 +574,7 @@ void TranscriptionToolBar::OnStartOn(wxCommandEvent & WXUNUSED(event))
|
||||
}
|
||||
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
auto t = *p->GetTracks()->Any< const WaveTrack >().begin();
|
||||
if(t ) {
|
||||
@ -604,7 +606,7 @@ void TranscriptionToolBar::OnStartOff(wxCommandEvent & WXUNUSED(event))
|
||||
return;
|
||||
}
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
SetButton(false, mButtons[TTB_StartOff]);
|
||||
auto t = *p->GetTracks()->Any< const WaveTrack >().begin();
|
||||
@ -639,7 +641,7 @@ void TranscriptionToolBar::OnEndOn(wxCommandEvent & WXUNUSED(event))
|
||||
}
|
||||
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
auto t = *p->GetTracks()->Any< const WaveTrack >().begin();
|
||||
if(t) {
|
||||
auto wt = static_cast<const WaveTrack*>(t);
|
||||
@ -674,7 +676,7 @@ void TranscriptionToolBar::OnEndOff(wxCommandEvent & WXUNUSED(event))
|
||||
return;
|
||||
}
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
auto t = *p->GetTracks()->Any< const WaveTrack >().begin();
|
||||
if(t) {
|
||||
@ -711,7 +713,7 @@ void TranscriptionToolBar::OnSelectSound(wxCommandEvent & WXUNUSED(event))
|
||||
|
||||
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
|
||||
TrackList *tl = p->GetTracks();
|
||||
@ -750,7 +752,7 @@ void TranscriptionToolBar::OnSelectSilence(wxCommandEvent & WXUNUSED(event))
|
||||
}
|
||||
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
|
||||
TrackList *tl = p->GetTracks();
|
||||
@ -789,7 +791,7 @@ void TranscriptionToolBar::OnCalibrate(wxCommandEvent & WXUNUSED(event))
|
||||
}
|
||||
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
TrackList *tl = p->GetTracks();
|
||||
if(auto wt = *tl->Any<const WaveTrack>().begin()) {
|
||||
@ -840,7 +842,7 @@ void TranscriptionToolBar::OnAutomateSelection(wxCommandEvent & WXUNUSED(event))
|
||||
wxBusyCursor busy;
|
||||
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
TrackList *tl = p->GetTracks();
|
||||
if(auto wt = *tl->Any<const WaveTrack>().begin()) {
|
||||
sampleCount start, len;
|
||||
@ -911,7 +913,7 @@ void TranscriptionToolBar::OnAutomateSelection(wxCommandEvent & WXUNUSED(event))
|
||||
|
||||
void TranscriptionToolBar::OnMakeLabel(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
SetButton(false, mButtons[TTB_MakeLabel]);
|
||||
p->DoAddLabel(SelectedRegion(p->GetSel0(), p->GetSel1()));
|
||||
}
|
||||
@ -993,6 +995,6 @@ void TranscriptionToolBar::AdjustPlaySpeed(float adj)
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ TranscriptionBarID,
|
||||
[](AudacityProject *){
|
||||
return ToolBar::Holder{ safenew TranscriptionToolBar }; }
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{ safenew TranscriptionToolBar{ project } }; }
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ class TranscriptionToolBar final : public ToolBar {
|
||||
|
||||
public:
|
||||
|
||||
TranscriptionToolBar();
|
||||
TranscriptionToolBar( AudacityProject &project );
|
||||
virtual ~TranscriptionToolBar();
|
||||
|
||||
static TranscriptionToolBar &Get( AudacityProject &project );
|
||||
|
Loading…
x
Reference in New Issue
Block a user