mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-01 07:33:44 +02: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:
parent
c6f24d864b
commit
f0ae4c3858
@ -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,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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user