mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 16:49:41 +02:00
Toolbar related changes, and 6 files freed from big s.c.c. leaving 64
This commit is contained in:
commit
ee32c77f81
@ -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)
|
||||
|
@ -26,8 +26,6 @@ Paul Licameli split from AudacityProject.cpp
|
||||
#include "prefs/ThemePrefs.h"
|
||||
#include "prefs/TracksPrefs.h"
|
||||
#include "toolbars/ControlToolBar.h"
|
||||
#include "toolbars/SelectionBar.h"
|
||||
#include "toolbars/SpectralSelectionBar.h"
|
||||
#include "toolbars/ToolManager.h"
|
||||
#include "tracks/ui/Scrubbing.h"
|
||||
#include "widgets/wxPanelWrapper.h"
|
||||
@ -1696,7 +1694,6 @@ void ProjectWindow::TP_DisplaySelection()
|
||||
auto &ruler = AdornedRulerPanel::Get(project);
|
||||
auto &viewInfo = ViewInfo::Get( project );
|
||||
const auto &selectedRegion = viewInfo.selectedRegion;
|
||||
double audioTime;
|
||||
auto &playRegion = ViewInfo::Get( project ).playRegion;
|
||||
|
||||
auto gAudioIO = AudioIOBase::Get();
|
||||
@ -1705,18 +1702,6 @@ void ProjectWindow::TP_DisplaySelection()
|
||||
else
|
||||
// Cause ruler redraw anyway, because we may be zooming or scrolling
|
||||
ruler.Refresh();
|
||||
|
||||
if (gAudioIO->IsBusy())
|
||||
audioTime = gAudioIO->GetStreamTime();
|
||||
else
|
||||
audioTime = playRegion.GetStart();
|
||||
|
||||
SelectionBar::Get( project ).SetTimes(selectedRegion.t0(),
|
||||
selectedRegion.t1(), audioTime);
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
SpectralSelectionBar::Get( project ).SetFrequencies(
|
||||
selectedRegion.f0(), selectedRegion.f1());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,8 +56,6 @@
|
||||
#include <wx/tooltip.h>
|
||||
#include <wx/datetime.h>
|
||||
|
||||
#include "TranscriptionToolBar.h"
|
||||
|
||||
#include "../AColor.h"
|
||||
#include "../AdornedRulerPanel.h"
|
||||
#include "../AllThemeResources.h"
|
||||
@ -106,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;
|
||||
|
||||
@ -314,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
|
||||
}
|
||||
@ -476,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();
|
||||
@ -487,12 +486,6 @@ void ControlToolBar::EnableDisableButtons()
|
||||
// Only interested in audio type tracks
|
||||
bool tracks = p && TrackList::Get( *p ).Any<AudioTrack>(); // PRL: PlayableTrack ?
|
||||
|
||||
if (p) {
|
||||
const auto playAtSpeedTB = &TranscriptionToolBar::Get( *p );
|
||||
if (playAtSpeedTB)
|
||||
playAtSpeedTB->SetEnabled(CanStopAudioStream() && tracks && !recording);
|
||||
}
|
||||
|
||||
mPlay->SetEnabled(CanStopAudioStream() && tracks && !recording);
|
||||
mRecord->SetEnabled(
|
||||
CanStopAudioStream() &&
|
||||
@ -503,7 +496,6 @@ void ControlToolBar::EnableDisableButtons()
|
||||
mRewind->SetEnabled(IsPauseDown() || (!playing && !recording));
|
||||
mFF->SetEnabled(tracks && (IsPauseDown() || (!playing && !recording)));
|
||||
|
||||
//auto pProject = GetActiveProject();
|
||||
mPause->SetEnabled(CanStopAudioStream());
|
||||
}
|
||||
|
||||
@ -520,7 +512,7 @@ void ControlToolBar::SetPlay(bool down, PlayAppearance appearance)
|
||||
mPlay->SetAlternateIdx(0);
|
||||
}
|
||||
EnableDisableButtons();
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
UpdateStatusBar( &mProject );
|
||||
}
|
||||
|
||||
void ControlToolBar::SetStop(bool down)
|
||||
@ -618,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 );
|
||||
|
||||
@ -761,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;
|
||||
@ -795,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);
|
||||
@ -813,7 +802,7 @@ void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
|
||||
|
||||
void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
auto p = GetActiveProject();
|
||||
auto p = &mProject;
|
||||
|
||||
if (!CanStopAudioStream())
|
||||
return;
|
||||
@ -831,7 +820,7 @@ void ControlToolBar::OnStop(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
if (CanStopAudioStream()) {
|
||||
StopPlaying();
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
UpdateStatusBar( &mProject );
|
||||
}
|
||||
}
|
||||
|
||||
@ -840,7 +829,7 @@ bool ControlToolBar::CanStopAudioStream()
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
return (!gAudioIO->IsStreamActive() ||
|
||||
gAudioIO->IsMonitoring() ||
|
||||
gAudioIO->GetOwningProject() == GetActiveProject());
|
||||
gAudioIO->GetOwningProject() == &mProject );
|
||||
}
|
||||
|
||||
void ControlToolBar::PlayDefault()
|
||||
@ -856,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
|
||||
@ -1001,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.
|
||||
@ -1123,7 +1109,7 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
||||
}
|
||||
|
||||
// Success or not:
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
UpdateStatusBar( &mProject );
|
||||
});
|
||||
|
||||
auto transportTracks = tracks;
|
||||
@ -1314,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
|
||||
@ -1337,7 +1323,7 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
gAudioIO->SetPaused(mPaused);
|
||||
}
|
||||
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
UpdateStatusBar( &mProject );
|
||||
}
|
||||
|
||||
void ControlToolBar::OnRewind(wxCommandEvent & WXUNUSED(evt))
|
||||
@ -1345,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());
|
||||
}
|
||||
@ -1357,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());
|
||||
}
|
||||
@ -1371,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();
|
||||
@ -1427,7 +1413,7 @@ wxString ControlToolBar::StateForStatusBar()
|
||||
{
|
||||
wxString state;
|
||||
|
||||
auto pProject = GetActiveProject();
|
||||
auto pProject = &mProject;
|
||||
auto scrubState = pProject
|
||||
? Scrubber::Get( *pProject ).GetUntranslatedStateString()
|
||||
: wxString();
|
||||
@ -1457,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() &&
|
||||
@ -1470,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
|
||||
@ -1489,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;
|
||||
@ -1527,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);
|
||||
@ -1535,18 +1521,18 @@ 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();
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
#include "NoteTrack.h"
|
||||
#include "../NoteTrack.h"
|
||||
#endif
|
||||
|
||||
TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bool useMidi)
|
||||
@ -1572,3 +1558,8 @@ TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bo
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ TransportBarID,
|
||||
[]( 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);
|
||||
@ -871,3 +867,8 @@ void DeviceToolBar::ShowComboDialog(wxChoice *combo, const wxString &title)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ DeviceBarID,
|
||||
[]( 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,13 +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 &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 );
|
||||
@ -274,3 +271,18 @@ void MeterToolBar::SetDocked(ToolDock *dock, bool pushed) {
|
||||
Fit();
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory1{ RecordMeterBarID,
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{
|
||||
safenew MeterToolBar{ project, RecordMeterBarID } }; }
|
||||
};
|
||||
static RegisteredToolbarFactory factory2{ PlayMeterBarID,
|
||||
[]( AudacityProject &project ){
|
||||
return ToolBar::Holder{
|
||||
safenew MeterToolBar{ project, PlayMeterBarID } }; }
|
||||
};
|
||||
static RegisteredToolbarFactory factory3{ 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;
|
||||
@ -314,3 +314,8 @@ void MixerToolBar::SetToolTips()
|
||||
mOutputSlider->SetToolTipTemplate(_("Playback Volume (Unavailable; use system mixer.)"));
|
||||
}
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ MixerBarID,
|
||||
[]( 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 );
|
||||
@ -261,3 +261,8 @@ void ScrubbingToolBar::EnableDisableButtons()
|
||||
RegenerateTooltips();
|
||||
scrubber.CheckMenuItems();
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ ScrubbingBarID,
|
||||
[]( 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 );
|
||||
|
@ -56,8 +56,11 @@ with changes in the SelectionBar.
|
||||
#include "../AColor.h"
|
||||
#include "../KeyboardCapture.h"
|
||||
#include "../Prefs.h"
|
||||
#include "../Project.h"
|
||||
#include "../ProjectAudioIO.h"
|
||||
#include "../ProjectSettings.h"
|
||||
#include "../Snap.h"
|
||||
#include "../ViewInfo.h"
|
||||
#include "../AllThemeResources.h"
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
@ -96,6 +99,7 @@ BEGIN_EVENT_TABLE(SelectionBar, ToolBar)
|
||||
EVT_TEXT(EndTimeID, SelectionBar::OnChangedTime)
|
||||
EVT_CHOICE(SnapToID, SelectionBar::OnSnapTo)
|
||||
EVT_CHOICE(ChoiceID, SelectionBar::OnChoice )
|
||||
EVT_IDLE( SelectionBar::OnIdle )
|
||||
EVT_COMBOBOX(RateID, SelectionBar::OnRate)
|
||||
EVT_TEXT(RateID, SelectionBar::OnRate)
|
||||
|
||||
@ -103,8 +107,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 ),
|
||||
@ -578,6 +582,27 @@ void SelectionBar::OnChoice(wxCommandEvent & WXUNUSED(event))
|
||||
SelectionModeUpdated();
|
||||
}
|
||||
|
||||
void SelectionBar::OnIdle( wxIdleEvent &evt )
|
||||
{
|
||||
evt.Skip();
|
||||
auto &project = mProject;
|
||||
const auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
|
||||
double audioTime;
|
||||
|
||||
auto &projectAudioIO = ProjectAudioIO::Get( project );
|
||||
if ( projectAudioIO.IsAudioActive() ){
|
||||
auto gAudioIO = AudioIOBase::Get();
|
||||
audioTime = gAudioIO->GetStreamTime();
|
||||
}
|
||||
else {
|
||||
const auto &playRegion = ViewInfo::Get( project ).playRegion;
|
||||
audioTime = playRegion.GetStart();
|
||||
}
|
||||
|
||||
SetTimes(selectedRegion.t0(), selectedRegion.t1(), audioTime);
|
||||
}
|
||||
|
||||
void SelectionBar::SelectionModeUpdated()
|
||||
{
|
||||
// We just changed the mode. Remember it.
|
||||
@ -760,3 +785,8 @@ void SelectionBar::OnSnapTo(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
mListener->AS_SetSnapTo(mSnapTo->GetSelection());
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ SelectionBarID,
|
||||
[]( 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 );
|
||||
@ -79,6 +79,7 @@ class SelectionBar final : public ToolBar {
|
||||
void OnFocus(wxFocusEvent &event);
|
||||
void OnCaptureKey(wxCommandEvent &event);
|
||||
void OnSize(wxSizeEvent &evt);
|
||||
void OnIdle( wxIdleEvent &evt );
|
||||
|
||||
void ModifySelection(int newDriver, bool done = false);
|
||||
void UpdateRates();
|
||||
|
@ -55,8 +55,10 @@ with changes in the SpectralSelectionBar.
|
||||
#include <wx/statline.h>
|
||||
|
||||
#include "../Prefs.h"
|
||||
#include "../Project.h"
|
||||
#include "../AllThemeResources.h"
|
||||
#include "../SelectedRegion.h"
|
||||
#include "../ViewInfo.h"
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
#include "../widgets/WindowAccessible.h"
|
||||
@ -86,13 +88,15 @@ BEGIN_EVENT_TABLE(SpectralSelectionBar, ToolBar)
|
||||
EVT_CHOICE(OnChoiceID, SpectralSelectionBar::OnChoice)
|
||||
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, SpectralSelectionBar::OnUpdate)
|
||||
EVT_COMMAND(wxID_ANY, EVT_BANDWIDTHTEXTCTRL_UPDATED, SpectralSelectionBar::OnUpdate)
|
||||
EVT_IDLE( SpectralSelectionBar::OnIdle )
|
||||
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)
|
||||
@ -368,6 +372,14 @@ void SpectralSelectionBar::OnChoice(wxCommandEvent &)
|
||||
Updated();
|
||||
}
|
||||
|
||||
void SpectralSelectionBar::OnIdle( wxIdleEvent &evt )
|
||||
{
|
||||
evt.Skip();
|
||||
auto &project = mProject;
|
||||
const auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
SetFrequencies( selectedRegion.f0(), selectedRegion.f1() );
|
||||
}
|
||||
|
||||
void SpectralSelectionBar::OnUpdate(wxCommandEvent &evt)
|
||||
{
|
||||
int index = evt.GetInt();
|
||||
@ -491,4 +503,9 @@ void SpectralSelectionBar::SetBandwidthSelectionFormatName(const NumericFormatSy
|
||||
}
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ SpectralSelectionBarID,
|
||||
[]( 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 );
|
||||
@ -56,6 +56,7 @@ private:
|
||||
void OnUpdate(wxCommandEvent &evt);
|
||||
void OnCtrl(wxCommandEvent &evt);
|
||||
void OnChoice(wxCommandEvent &evt);
|
||||
void OnIdle( wxIdleEvent &evt );
|
||||
|
||||
void OnSize(wxSizeEvent &evt);
|
||||
|
||||
|
@ -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)
|
||||
@ -913,3 +916,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;
|
||||
@ -85,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
|
||||
@ -92,9 +96,11 @@ 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);
|
||||
ToolBar( AudacityProject &project,
|
||||
int type, const wxString & label, const wxString & section,
|
||||
bool resizable = false);
|
||||
virtual ~ToolBar();
|
||||
|
||||
bool AcceptsFocus() const override { return false; };
|
||||
@ -160,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);
|
||||
@ -214,6 +220,7 @@ class ToolBar /* not final */
|
||||
void OnMouseEvents(wxMouseEvent &event);
|
||||
|
||||
protected:
|
||||
AudacityProject &mProject;
|
||||
wxString mLabel;
|
||||
wxString mSection;
|
||||
int mType;
|
||||
@ -239,4 +246,13 @@ class ToolBar /* not final */
|
||||
friend class ToolBarResizer;
|
||||
};
|
||||
|
||||
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,16 @@ 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()) {
|
||||
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
|
||||
@ -276,3 +277,8 @@ void ToolsToolBar::Create(wxWindow * parent)
|
||||
ToolBar::Create(parent);
|
||||
UpdatePrefs();
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ ToolsBarID,
|
||||
[]( 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 );
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
#include "ControlToolBar.h"
|
||||
#include "../AllThemeResources.h"
|
||||
#include "../AudioIOBase.h"
|
||||
#include "../AudioIO.h"
|
||||
#include "../ImageManipulation.h"
|
||||
#include "../KeyboardCapture.h"
|
||||
#include "../Project.h"
|
||||
@ -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,8 +289,20 @@ void TranscriptionToolBar::Populate()
|
||||
|
||||
void TranscriptionToolBar::EnableDisableButtons()
|
||||
{
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
bool canStopAudioStream = (!gAudioIO->IsStreamActive() ||
|
||||
gAudioIO->IsMonitoring() ||
|
||||
gAudioIO->GetOwningProject() == p );
|
||||
bool recording = gAudioIO->GetNumCaptureChannels() > 0;
|
||||
|
||||
// Only interested in audio type tracks
|
||||
bool tracks = p && TrackList::Get( *p ).Any<AudioTrack>(); // PRL: PlayableTrack ?
|
||||
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();
|
||||
@ -331,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
|
||||
@ -410,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;
|
||||
}
|
||||
@ -453,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;
|
||||
}
|
||||
@ -560,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 ) {
|
||||
@ -592,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();
|
||||
@ -627,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);
|
||||
@ -662,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) {
|
||||
@ -699,7 +713,7 @@ void TranscriptionToolBar::OnSelectSound(wxCommandEvent & WXUNUSED(event))
|
||||
|
||||
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
|
||||
TrackList *tl = p->GetTracks();
|
||||
@ -738,7 +752,7 @@ void TranscriptionToolBar::OnSelectSilence(wxCommandEvent & WXUNUSED(event))
|
||||
}
|
||||
|
||||
mVk->AdjustThreshold(GetSensitivity());
|
||||
AudacityProject *p = GetActiveProject();
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
|
||||
TrackList *tl = p->GetTracks();
|
||||
@ -777,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()) {
|
||||
@ -828,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;
|
||||
@ -899,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()));
|
||||
}
|
||||
@ -980,3 +994,7 @@ void TranscriptionToolBar::AdjustPlaySpeed(float adj)
|
||||
OnSpeedSlider(e);
|
||||
}
|
||||
|
||||
static RegisteredToolbarFactory factory{ TranscriptionBarID,
|
||||
[]( 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