mirror of
https://github.com/cookiengineer/audacity
synced 2026-02-23 14:41:27 +01:00
ProjectWindow does not depend on selection toolbars...
... Freeing SelectionBar and SpectralSelectionBar from cycles. Also fixing a minor problem: if two projects are open, and one is playing or recording, and you switch windows -- then the audio time in the selection bar of the other project could be updated.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,6 +88,7 @@ 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
|
||||
@@ -369,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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user