mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-26 17:38:10 +02:00
Use an event so that ProjectSettings.cpp does not need TrackPanel.h
This commit is contained in:
parent
05efeeb5bd
commit
6dc5162614
@ -13,9 +13,19 @@ Paul Licameli split from AudacityProject.cpp
|
|||||||
#include "AudioIO.h"
|
#include "AudioIO.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
#include "Snap.h"
|
#include "Snap.h"
|
||||||
#include "TrackPanel.h"
|
|
||||||
#include "prefs/QualityPrefs.h"
|
#include "prefs/QualityPrefs.h"
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent);
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void Notify( AudacityProject &project, ProjectSettings::EventCode code )
|
||||||
|
{
|
||||||
|
wxCommandEvent e{ EVT_PROJECT_SETTINGS_CHANGE };
|
||||||
|
e.SetInt( static_cast<int>( code ) );
|
||||||
|
project.GetEventHandler()->ProcessEvent( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const AudacityProject::AttachedObjects::RegisteredFactory
|
static const AudacityProject::AttachedObjects::RegisteredFactory
|
||||||
sProjectSettingsKey{
|
sProjectSettingsKey{
|
||||||
[]( AudacityProject &project ){
|
[]( AudacityProject &project ){
|
||||||
@ -157,7 +167,7 @@ void ProjectSettings::SetSyncLock(bool flag)
|
|||||||
auto &project = mProject;
|
auto &project = mProject;
|
||||||
if (flag != mIsSyncLocked) {
|
if (flag != mIsSyncLocked) {
|
||||||
mIsSyncLocked = flag;
|
mIsSyncLocked = flag;
|
||||||
TrackPanel::Get( project ).Refresh(false);
|
Notify( project, ChangedSyncLock );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,17 @@ Paul Licameli split from AudacityProject.h
|
|||||||
#ifndef __AUDACITY_PROJECT_SETTINGS__
|
#ifndef __AUDACITY_PROJECT_SETTINGS__
|
||||||
#define __AUDACITY_PROJECT_SETTINGS__
|
#define __AUDACITY_PROJECT_SETTINGS__
|
||||||
|
|
||||||
|
#include <wx/event.h> // to declare custom event type
|
||||||
|
|
||||||
#include "ClientData.h" // to inherit
|
#include "ClientData.h" // to inherit
|
||||||
#include "Prefs.h" // to inherit
|
#include "Prefs.h" // to inherit
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
|
||||||
|
// Sent to the project when certain settings change
|
||||||
|
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
||||||
|
EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent);
|
||||||
|
|
||||||
///\brief Holds various per-project settings values, including the sample rate,
|
///\brief Holds various per-project settings values, including the sample rate,
|
||||||
/// and sends events to the project when certain values change
|
/// and sends events to the project when certain values change
|
||||||
class ProjectSettings final
|
class ProjectSettings final
|
||||||
@ -26,6 +32,11 @@ public:
|
|||||||
static ProjectSettings &Get( AudacityProject &project );
|
static ProjectSettings &Get( AudacityProject &project );
|
||||||
static const ProjectSettings &Get( const AudacityProject &project );
|
static const ProjectSettings &Get( const AudacityProject &project );
|
||||||
|
|
||||||
|
// Values retrievable from GetInt() of the event for settings change
|
||||||
|
enum EventCode : int {
|
||||||
|
ChangedSyncLock,
|
||||||
|
};
|
||||||
|
|
||||||
ProjectSettings( AudacityProject &project );
|
ProjectSettings( AudacityProject &project );
|
||||||
|
|
||||||
sampleFormat GetDefaultFormat() const { return mDefaultFormat; }
|
sampleFormat GetDefaultFormat() const { return mDefaultFormat; }
|
||||||
|
@ -70,6 +70,7 @@ is time to refresh some aspect of the screen.
|
|||||||
#include "AdornedRulerPanel.h"
|
#include "AdornedRulerPanel.h"
|
||||||
#include "KeyboardCapture.h"
|
#include "KeyboardCapture.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
|
#include "ProjectSettings.h"
|
||||||
#include "TrackPanelMouseEvent.h"
|
#include "TrackPanelMouseEvent.h"
|
||||||
#include "TrackPanelResizeHandle.h"
|
#include "TrackPanelResizeHandle.h"
|
||||||
//#define DEBUG_DRAW_TIMING 1
|
//#define DEBUG_DRAW_TIMING 1
|
||||||
@ -316,8 +317,11 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
|
|||||||
&TrackPanel::OnPlayback,
|
&TrackPanel::OnPlayback,
|
||||||
this);
|
this);
|
||||||
|
|
||||||
GetProject()->Bind(EVT_ODTASK_UPDATE, &TrackPanel::OnODTask, this);
|
auto theProject = GetProject();
|
||||||
GetProject()->Bind(EVT_ODTASK_COMPLETE, &TrackPanel::OnODTask, this);
|
theProject->Bind(EVT_ODTASK_UPDATE, &TrackPanel::OnODTask, this);
|
||||||
|
theProject->Bind(EVT_ODTASK_COMPLETE, &TrackPanel::OnODTask, this);
|
||||||
|
theProject->Bind(
|
||||||
|
EVT_PROJECT_SETTINGS_CHANGE, &TrackPanel::OnProjectSettingsChange, this);
|
||||||
|
|
||||||
UpdatePrefs();
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
@ -530,6 +534,18 @@ void TrackPanel::OnODTask(wxCommandEvent & WXUNUSED(event))
|
|||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackPanel::OnProjectSettingsChange( wxCommandEvent &event )
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
switch ( static_cast<ProjectSettings::EventCode>( event.GetInt() ) ) {
|
||||||
|
case ProjectSettings::ChangedSyncLock:
|
||||||
|
Refresh(false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double TrackPanel::GetScreenEndTime() const
|
double TrackPanel::GetScreenEndTime() const
|
||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
|
@ -289,6 +289,7 @@ class AUDACITY_DLL_API TrackPanel final
|
|||||||
void OnIdle(wxIdleEvent & event);
|
void OnIdle(wxIdleEvent & event);
|
||||||
void OnTimer(wxTimerEvent& event);
|
void OnTimer(wxTimerEvent& event);
|
||||||
void OnODTask(wxCommandEvent &event);
|
void OnODTask(wxCommandEvent &event);
|
||||||
|
void OnProjectSettingsChange(wxCommandEvent &event);
|
||||||
|
|
||||||
int GetLeftOffset() const { return GetLabelWidth() + 1;}
|
int GetLeftOffset() const { return GetLabelWidth() + 1;}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user