mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 00:19:27 +02:00
All things with an UpdatePrefs() message listen for an event...
... Still to do, improve the handling of updates of only subsets of the prefs
This commit is contained in:
parent
cc635e0498
commit
62899a32f4
@ -893,6 +893,9 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* project,
|
|||||||
wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
|
wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
|
||||||
&AdornedRulerPanel::OnRecordStartStop,
|
&AdornedRulerPanel::OnRecordStartStop,
|
||||||
this);
|
this);
|
||||||
|
|
||||||
|
// Delay until after CommandManager has been populated:
|
||||||
|
this->CallAfter( &AdornedRulerPanel::UpdatePrefs );
|
||||||
}
|
}
|
||||||
|
|
||||||
AdornedRulerPanel::~AdornedRulerPanel()
|
AdornedRulerPanel::~AdornedRulerPanel()
|
||||||
@ -1797,8 +1800,11 @@ void AdornedRulerPanel::OnAutoScroll(wxCommandEvent&)
|
|||||||
gPrefs->Write(wxT("/GUI/AutoScroll"), false);
|
gPrefs->Write(wxT("/GUI/AutoScroll"), false);
|
||||||
else
|
else
|
||||||
gPrefs->Write(wxT("/GUI/AutoScroll"), true);
|
gPrefs->Write(wxT("/GUI/AutoScroll"), true);
|
||||||
mProject->UpdatePrefs();
|
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
|
|
||||||
|
wxTheApp->AddPendingEvent(wxCommandEvent{
|
||||||
|
EVT_PREFS_UPDATE, ViewInfo::UpdateScrollPrefsID() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "CellularPanel.h"
|
#include "CellularPanel.h"
|
||||||
#include "widgets/Ruler.h" // member variable
|
#include "widgets/Ruler.h" // member variable
|
||||||
|
#include "Prefs.h"
|
||||||
|
|
||||||
class ViewInfo;
|
class ViewInfo;
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
@ -20,7 +21,9 @@ class SnapManager;
|
|||||||
class TrackList;
|
class TrackList;
|
||||||
|
|
||||||
// This is an Audacity Specific ruler panel.
|
// This is an Audacity Specific ruler panel.
|
||||||
class AUDACITY_DLL_API AdornedRulerPanel final : public CellularPanel
|
class AUDACITY_DLL_API AdornedRulerPanel final
|
||||||
|
: public CellularPanel
|
||||||
|
, private PrefsListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AdornedRulerPanel(AudacityProject *project,
|
AdornedRulerPanel(AudacityProject *project,
|
||||||
@ -53,7 +56,7 @@ public:
|
|||||||
|
|
||||||
void InvalidateRuler();
|
void InvalidateRuler();
|
||||||
|
|
||||||
void UpdatePrefs();
|
void UpdatePrefs() override;
|
||||||
void ReCreateButtons();
|
void ReCreateButtons();
|
||||||
|
|
||||||
void RegenerateTooltips();
|
void RegenerateTooltips();
|
||||||
|
@ -51,14 +51,6 @@
|
|||||||
|
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
|
|
||||||
PrefsListener::~PrefsListener()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrefsListener::UpdatePrefs()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuManager &GetMenuManager(AudacityProject &project)
|
MenuManager &GetMenuManager(AudacityProject &project)
|
||||||
{ return *project.mMenuManager; }
|
{ return *project.mMenuManager; }
|
||||||
|
|
||||||
@ -70,6 +62,11 @@ MenuCreator::~MenuCreator()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuManager::MenuManager()
|
||||||
|
{
|
||||||
|
UpdatePrefs();
|
||||||
|
}
|
||||||
|
|
||||||
void MenuManager::UpdatePrefs()
|
void MenuManager::UpdatePrefs()
|
||||||
{
|
{
|
||||||
bool bSelectAllIfNone;
|
bool bSelectAllIfNone;
|
||||||
@ -388,6 +385,7 @@ CommandFlag MenuManager::GetFocusedFrame(AudacityProject &project)
|
|||||||
return AlwaysEnabledFlag;
|
return AlwaysEnabledFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CommandFlag MenuManager::GetUpdateFlags
|
CommandFlag MenuManager::GetUpdateFlags
|
||||||
(AudacityProject &project, bool checkActive)
|
(AudacityProject &project, bool checkActive)
|
||||||
{
|
{
|
||||||
|
14
src/Menus.h
14
src/Menus.h
@ -13,6 +13,7 @@
|
|||||||
#include "audacity/Types.h"
|
#include "audacity/Types.h"
|
||||||
|
|
||||||
#include <wx/string.h> // member variable
|
#include <wx/string.h> // member variable
|
||||||
|
#include "Prefs.h"
|
||||||
|
|
||||||
class wxArrayString;
|
class wxArrayString;
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
@ -32,13 +33,6 @@ enum EffectType : int;
|
|||||||
typedef wxString PluginID;
|
typedef wxString PluginID;
|
||||||
typedef wxArrayString PluginIDs;
|
typedef wxArrayString PluginIDs;
|
||||||
|
|
||||||
class PrefsListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~PrefsListener();
|
|
||||||
virtual void UpdatePrefs(); // default is no-op
|
|
||||||
};
|
|
||||||
|
|
||||||
class MenuCreator
|
class MenuCreator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -56,9 +50,11 @@ public:
|
|||||||
PluginID mLastEffect{};
|
PluginID mLastEffect{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class MenuManager : public MenuCreator
|
class MenuManager final : public MenuCreator, private PrefsListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MenuManager();
|
||||||
|
|
||||||
static void ModifyUndoMenuItems(AudacityProject &project);
|
static void ModifyUndoMenuItems(AudacityProject &project);
|
||||||
static void ModifyToolbarMenus(AudacityProject &project);
|
static void ModifyToolbarMenus(AudacityProject &project);
|
||||||
// Calls ModifyToolbarMenus() on all projects
|
// Calls ModifyToolbarMenus() on all projects
|
||||||
@ -72,7 +68,7 @@ public:
|
|||||||
// inactive project as it is needlessly expensive.
|
// inactive project as it is needlessly expensive.
|
||||||
CommandFlag GetUpdateFlags(
|
CommandFlag GetUpdateFlags(
|
||||||
AudacityProject &project, bool checkActive = false);
|
AudacityProject &project, bool checkActive = false);
|
||||||
void UpdatePrefs();
|
void UpdatePrefs() override;
|
||||||
|
|
||||||
// Command Handling
|
// Command Handling
|
||||||
bool ReportIfActionNotAllowed(
|
bool ReportIfActionNotAllowed(
|
||||||
|
@ -356,8 +356,6 @@ void MixerTrackCluster::UpdatePrefs()
|
|||||||
{
|
{
|
||||||
this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
|
this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
|
||||||
mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
|
mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
|
||||||
if (mMeter)
|
|
||||||
mMeter->UpdatePrefs(); // in case meter range has changed
|
|
||||||
HandleResize(); // in case prefs "/GUI/Solo" changed
|
HandleResize(); // in case prefs "/GUI/Solo" changed
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include "widgets/ASlider.h" // to inherit
|
#include "widgets/ASlider.h" // to inherit
|
||||||
#include "commands/CommandManagerWindowClasses.h"
|
#include "commands/CommandManagerWindowClasses.h"
|
||||||
|
|
||||||
|
#include "Prefs.h"
|
||||||
|
|
||||||
class wxArrayString;
|
class wxArrayString;
|
||||||
class wxBitmapButton;
|
class wxBitmapButton;
|
||||||
class wxImage;
|
class wxImage;
|
||||||
@ -188,7 +190,7 @@ public:
|
|||||||
class MixerBoardFrame;
|
class MixerBoardFrame;
|
||||||
class TrackList;
|
class TrackList;
|
||||||
|
|
||||||
class MixerBoard final : public wxWindow
|
class MixerBoard final : public wxWindow, private PrefsListener
|
||||||
{
|
{
|
||||||
friend class MixerBoardFrame;
|
friend class MixerBoardFrame;
|
||||||
|
|
||||||
@ -198,7 +200,7 @@ public:
|
|||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize);
|
const wxSize& size = wxDefaultSize);
|
||||||
|
|
||||||
void UpdatePrefs();
|
void UpdatePrefs() override;
|
||||||
|
|
||||||
// Add clusters for any tracks we're not yet showing.
|
// Add clusters for any tracks we're not yet showing.
|
||||||
// Update pointers for tracks we're aleady showing.
|
// Update pointers for tracks we're aleady showing.
|
||||||
|
@ -71,6 +71,31 @@ int gMenusDirty = 0;
|
|||||||
|
|
||||||
wxDEFINE_EVENT(EVT_PREFS_UPDATE, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_PREFS_UPDATE, wxCommandEvent);
|
||||||
|
|
||||||
|
PrefsListener::PrefsListener()
|
||||||
|
{
|
||||||
|
wxTheApp->Bind(EVT_PREFS_UPDATE, &PrefsListener::OnEvent, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrefsListener::~PrefsListener()
|
||||||
|
{
|
||||||
|
// Explicit unbinding is needed because this is not a wxEvtHandler
|
||||||
|
wxTheApp->Unbind(EVT_PREFS_UPDATE, &PrefsListener::OnEvent, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefsListener::UpdateSelectedPrefs( int )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefsListener::OnEvent( wxCommandEvent &evt )
|
||||||
|
{
|
||||||
|
evt.Skip();
|
||||||
|
auto id = evt.GetId();
|
||||||
|
if (id <= 0)
|
||||||
|
UpdatePrefs();
|
||||||
|
else
|
||||||
|
UpdateSelectedPrefs( id );
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Copy one entry from one wxConfig object to another
|
// Copy one entry from one wxConfig object to another
|
||||||
static void CopyEntry(wxString path, wxConfigBase *src, wxConfigBase *dst, wxString entry)
|
static void CopyEntry(wxString path, wxConfigBase *src, wxConfigBase *dst, wxString entry)
|
||||||
|
21
src/Prefs.h
21
src/Prefs.h
@ -164,4 +164,25 @@ private:
|
|||||||
// changes
|
// changes
|
||||||
wxDECLARE_EVENT(EVT_PREFS_UPDATE, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_PREFS_UPDATE, wxCommandEvent);
|
||||||
|
|
||||||
|
// Invoke UpdatePrefs() when Preference dialog commits changes.
|
||||||
|
class PrefsListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PrefsListener();
|
||||||
|
virtual ~PrefsListener();
|
||||||
|
|
||||||
|
// Called when all preferences should be updated.
|
||||||
|
virtual void UpdatePrefs() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when only selected preferences are to be updated.
|
||||||
|
// id is some value generated by wxNewId() that identifies the portion
|
||||||
|
// of preferences.
|
||||||
|
// Default function does nothing.
|
||||||
|
virtual void UpdateSelectedPrefs( int id );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnEvent(wxCommandEvent&);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1497,7 +1497,6 @@ void AudacityProject::UpdatePrefsVariables()
|
|||||||
{
|
{
|
||||||
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true);
|
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true);
|
||||||
gPrefs->Read(wxT("/AudioFiles/NormalizeOnLoad"),&mNormalizeOnLoad, false);
|
gPrefs->Read(wxT("/AudioFiles/NormalizeOnLoad"),&mNormalizeOnLoad, false);
|
||||||
gPrefs->Read(wxT("/GUI/AutoScroll"), &mViewInfo.bUpdateTrackIndicator, true);
|
|
||||||
gPrefs->Read(wxT("/GUI/EmptyCanBeDirty"), &mEmptyCanBeDirty, true );
|
gPrefs->Read(wxT("/GUI/EmptyCanBeDirty"), &mEmptyCanBeDirty, true );
|
||||||
gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &mShowSplashScreen, true);
|
gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &mShowSplashScreen, true);
|
||||||
gPrefs->Read(wxT("/GUI/Solo"), &mSoloPref, wxT("Simple"));
|
gPrefs->Read(wxT("/GUI/Solo"), &mSoloPref, wxT("Simple"));
|
||||||
@ -1531,20 +1530,6 @@ void AudacityProject::UpdatePrefs()
|
|||||||
UpdatePrefsVariables();
|
UpdatePrefsVariables();
|
||||||
|
|
||||||
SetProjectTitle();
|
SetProjectTitle();
|
||||||
|
|
||||||
{
|
|
||||||
ObjectFactorySetLocker locker;
|
|
||||||
for( const auto &pObject : mAttachedObjects )
|
|
||||||
pObject->UpdatePrefs();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetMenuManager(*this).UpdatePrefs();
|
|
||||||
|
|
||||||
mTrackPanel->UpdatePrefs();
|
|
||||||
mToolManager->UpdatePrefs();
|
|
||||||
mRuler->UpdatePrefs();
|
|
||||||
if (mMixerBoard)
|
|
||||||
mMixerBoard->UpdatePrefs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudacityProject::RedrawProject(const bool bForceWaveTracks /*= false*/)
|
void AudacityProject::RedrawProject(const bool bForceWaveTracks /*= false*/)
|
||||||
@ -3633,8 +3618,6 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
|||||||
NumericConverter::LookupFormat( NumericConverter::BANDWIDTH, value ) );
|
NumericConverter::LookupFormat( NumericConverter::BANDWIDTH, value ) );
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
mViewInfo.UpdatePrefs();
|
|
||||||
|
|
||||||
if (longVpos != 0) {
|
if (longVpos != 0) {
|
||||||
// PRL: It seems this must happen after SetSnapTo
|
// PRL: It seems this must happen after SetSnapTo
|
||||||
mViewInfo.vpos = longVpos;
|
mViewInfo.vpos = longVpos;
|
||||||
@ -5530,10 +5513,8 @@ LyricsWindow* AudacityProject::GetLyricsWindow(bool create)
|
|||||||
|
|
||||||
MixerBoardFrame* AudacityProject::GetMixerBoardFrame(bool create)
|
MixerBoardFrame* AudacityProject::GetMixerBoardFrame(bool create)
|
||||||
{
|
{
|
||||||
if (create && !mMixerBoardFrame) {
|
if (create && !mMixerBoardFrame)
|
||||||
mMixerBoardFrame = safenew MixerBoardFrame{ this };
|
mMixerBoardFrame = safenew MixerBoardFrame{ this };
|
||||||
mMixerBoard = mMixerBoardFrame->mMixerBoard;
|
|
||||||
}
|
|
||||||
return mMixerBoardFrame;
|
return mMixerBoardFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "Experimental.h"
|
#include "Experimental.h"
|
||||||
|
|
||||||
#include "Track.h"
|
#include "Track.h"
|
||||||
|
#include "Prefs.h"
|
||||||
#include "SelectionState.h"
|
#include "SelectionState.h"
|
||||||
#include "ViewInfo.h"
|
#include "ViewInfo.h"
|
||||||
#include "commands/CommandManagerWindowClasses.h"
|
#include "commands/CommandManagerWindowClasses.h"
|
||||||
@ -171,14 +172,13 @@ class WaveTrack;
|
|||||||
|
|
||||||
class MenuManager;
|
class MenuManager;
|
||||||
|
|
||||||
class PrefsListener;
|
|
||||||
|
|
||||||
class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
||||||
public TrackPanelListener,
|
public TrackPanelListener,
|
||||||
public SelectionBarListener,
|
public SelectionBarListener,
|
||||||
public SpectralSelectionBarListener,
|
public SpectralSelectionBarListener,
|
||||||
public XMLTagHandler,
|
public XMLTagHandler,
|
||||||
public AudioIOListener
|
public AudioIOListener,
|
||||||
|
private PrefsListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudacityProject(wxWindow * parent, wxWindowID id,
|
AudacityProject(wxWindow * parent, wxWindowID id,
|
||||||
@ -188,7 +188,7 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
|||||||
// Next available ID for sub-windows
|
// Next available ID for sub-windows
|
||||||
int NextWindowID();
|
int NextWindowID();
|
||||||
|
|
||||||
using AttachedObject = PrefsListener;
|
using AttachedObject = wxObject;
|
||||||
using AttachedObjectFactory =
|
using AttachedObjectFactory =
|
||||||
std::function< std::unique_ptr<AttachedObject>() >;
|
std::function< std::unique_ptr<AttachedObject>() >;
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ public:
|
|||||||
int GetProjectNumber(){ return mProjectNo;};
|
int GetProjectNumber(){ return mProjectNo;};
|
||||||
static int CountUnnamed();
|
static int CountUnnamed();
|
||||||
static void RefreshAllTitles(bool bShowProjectNumbers );
|
static void RefreshAllTitles(bool bShowProjectNumbers );
|
||||||
void UpdatePrefs();
|
void UpdatePrefs() override;
|
||||||
void UpdatePrefsVariables();
|
void UpdatePrefsVariables();
|
||||||
void RedrawProject(const bool bForceWaveTracks = false);
|
void RedrawProject(const bool bForceWaveTracks = false);
|
||||||
void RefreshCursor();
|
void RefreshCursor();
|
||||||
@ -627,7 +627,6 @@ private:
|
|||||||
HistoryWindow *mHistoryWindow{};
|
HistoryWindow *mHistoryWindow{};
|
||||||
LyricsWindow* mLyricsWindow{};
|
LyricsWindow* mLyricsWindow{};
|
||||||
MixerBoardFrame* mMixerBoardFrame{};
|
MixerBoardFrame* mMixerBoardFrame{};
|
||||||
MixerBoard* mMixerBoard{};
|
|
||||||
|
|
||||||
Destroy_ptr<FreqWindow> mFreqWindow;
|
Destroy_ptr<FreqWindow> mFreqWindow;
|
||||||
Destroy_ptr<ContrastDialog> mContrastDialog;
|
Destroy_ptr<ContrastDialog> mContrastDialog;
|
||||||
|
@ -77,6 +77,7 @@ audio tracks.
|
|||||||
#include "LabelTrack.h"
|
#include "LabelTrack.h"
|
||||||
#include "TimeTrack.h"
|
#include "TimeTrack.h"
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
|
#include "prefs/GUIPrefs.h"
|
||||||
#include "prefs/GUISettings.h"
|
#include "prefs/GUISettings.h"
|
||||||
#include "prefs/SpectrogramSettings.h"
|
#include "prefs/SpectrogramSettings.h"
|
||||||
#include "prefs/TracksPrefs.h"
|
#include "prefs/TracksPrefs.h"
|
||||||
@ -142,7 +143,6 @@ TrackArtist::TrackArtist( TrackPanel *parent_ )
|
|||||||
mdBrange = ENV_DB_RANGE;
|
mdBrange = ENV_DB_RANGE;
|
||||||
mShowClipping = false;
|
mShowClipping = false;
|
||||||
mSampleDisplay = 1;// Stem plots by default.
|
mSampleDisplay = 1;// Stem plots by default.
|
||||||
UpdatePrefs();
|
|
||||||
|
|
||||||
SetColours(0);
|
SetColours(0);
|
||||||
vruler = std::make_unique<Ruler>();
|
vruler = std::make_unique<Ruler>();
|
||||||
@ -3267,15 +3267,22 @@ void TrackArt::DrawTimeTrack(TrackPanelDrawingContext &context,
|
|||||||
track->GetDisplayLog(), dbRange, lower, upper, false );
|
track->GetDisplayLog(), dbRange, lower, upper, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackArtist::UpdateSelectedPrefs( int id )
|
||||||
|
{
|
||||||
|
if( id == ShowClippingPrefsID())
|
||||||
|
mShowClipping = gPrefs->Read(wxT("/GUI/ShowClipping"), mShowClipping);
|
||||||
|
}
|
||||||
|
|
||||||
void TrackArtist::UpdatePrefs()
|
void TrackArtist::UpdatePrefs()
|
||||||
{
|
{
|
||||||
mdBrange = gPrefs->Read(ENV_DB_KEY, mdBrange);
|
mdBrange = gPrefs->Read(ENV_DB_KEY, mdBrange);
|
||||||
mShowClipping = gPrefs->Read(wxT("/GUI/ShowClipping"), mShowClipping);
|
|
||||||
mSampleDisplay = TracksPrefs::SampleViewChoice();
|
mSampleDisplay = TracksPrefs::SampleViewChoice();
|
||||||
|
|
||||||
mbShowTrackNameInTrack =
|
mbShowTrackNameInTrack =
|
||||||
gPrefs->ReadBool(wxT("/GUI/ShowTrackNameInWaveform"), false);
|
gPrefs->ReadBool(wxT("/GUI/ShowTrackNameInWaveform"), false);
|
||||||
|
|
||||||
|
UpdateSelectedPrefs( ShowClippingPrefsID() );
|
||||||
|
|
||||||
SetColours(0);
|
SetColours(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <wx/brush.h> // member variable
|
#include <wx/brush.h> // member variable
|
||||||
#include <wx/pen.h> // member variables
|
#include <wx/pen.h> // member variables
|
||||||
#include "audacity/Types.h"
|
#include "audacity/Types.h"
|
||||||
|
#include "Prefs.h"
|
||||||
|
|
||||||
class wxRect;
|
class wxRect;
|
||||||
|
|
||||||
@ -157,7 +158,7 @@ namespace TrackArt {
|
|||||||
const wxRect & rect, int x0, int y0, int cy, bool top);
|
const wxRect & rect, int x0, int y0, int cy, bool top);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AUDACITY_DLL_API TrackArtist {
|
class AUDACITY_DLL_API TrackArtist final : private PrefsListener {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackArtist( TrackPanel *parent_ );
|
TrackArtist( TrackPanel *parent_ );
|
||||||
@ -174,7 +175,8 @@ public:
|
|||||||
|
|
||||||
void SetColours(int iColorIndex);
|
void SetColours(int iColorIndex);
|
||||||
|
|
||||||
void UpdatePrefs();
|
void UpdatePrefs() override;
|
||||||
|
void UpdateSelectedPrefs( int id ) override;
|
||||||
|
|
||||||
void UpdateVRuler(const Track *t, const wxRect & rect);
|
void UpdateVRuler(const Track *t, const wxRect & rect);
|
||||||
|
|
||||||
|
@ -273,6 +273,8 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
|
|||||||
wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
|
wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
|
||||||
&TrackPanel::OnPlayback,
|
&TrackPanel::OnPlayback,
|
||||||
this);
|
this);
|
||||||
|
|
||||||
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -319,16 +321,8 @@ wxString TrackPanel::gSoloPref;
|
|||||||
|
|
||||||
void TrackPanel::UpdatePrefs()
|
void TrackPanel::UpdatePrefs()
|
||||||
{
|
{
|
||||||
gPrefs->Read(wxT("/GUI/AutoScroll"), &mViewInfo->bUpdateTrackIndicator,
|
|
||||||
true);
|
|
||||||
gPrefs->Read(wxT("/GUI/Solo"), &gSoloPref, wxT("Simple"));
|
gPrefs->Read(wxT("/GUI/Solo"), &gSoloPref, wxT("Simple"));
|
||||||
|
|
||||||
mViewInfo->UpdatePrefs();
|
|
||||||
|
|
||||||
if (mTrackArtist) {
|
|
||||||
mTrackArtist->UpdatePrefs();
|
|
||||||
}
|
|
||||||
|
|
||||||
// All vertical rulers must be recalculated since the minimum and maximum
|
// All vertical rulers must be recalculated since the minimum and maximum
|
||||||
// frequences may have been changed.
|
// frequences may have been changed.
|
||||||
UpdateVRulers();
|
UpdateVRulers();
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <wx/timer.h> // to inherit
|
#include <wx/timer.h> // to inherit
|
||||||
|
|
||||||
#include "HitTestResult.h"
|
#include "HitTestResult.h"
|
||||||
|
#include "Prefs.h"
|
||||||
|
|
||||||
#include "SelectedRegion.h"
|
#include "SelectedRegion.h"
|
||||||
|
|
||||||
@ -210,6 +211,8 @@ namespace TrackInfo
|
|||||||
wxWindow *pParent);
|
wxWindow *pParent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Non-member, namespace function relying on TrackPanel to invoke it
|
||||||
|
// when it handles preference update events
|
||||||
void UpdatePrefs( wxWindow *pParent );
|
void UpdatePrefs( wxWindow *pParent );
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -251,6 +254,7 @@ enum : int {
|
|||||||
class AUDACITY_DLL_API TrackPanel final
|
class AUDACITY_DLL_API TrackPanel final
|
||||||
: public CellularPanel
|
: public CellularPanel
|
||||||
, public NonKeystrokeInterceptingWindow
|
, public NonKeystrokeInterceptingWindow
|
||||||
|
, private PrefsListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TrackPanel(wxWindow * parent,
|
TrackPanel(wxWindow * parent,
|
||||||
@ -264,7 +268,7 @@ class AUDACITY_DLL_API TrackPanel final
|
|||||||
|
|
||||||
virtual ~ TrackPanel();
|
virtual ~ TrackPanel();
|
||||||
|
|
||||||
void UpdatePrefs();
|
void UpdatePrefs() override;
|
||||||
void ApplyUpdatedTheme();
|
void ApplyUpdatedTheme();
|
||||||
|
|
||||||
void OnPaint(wxPaintEvent & event);
|
void OnPaint(wxPaintEvent & event);
|
||||||
|
@ -146,6 +146,14 @@ ViewInfo::ViewInfo(double start, double screenDuration, double pixelsPerSecond)
|
|||||||
UpdatePrefs();
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewInfo::UpdateSelectedPrefs( int id )
|
||||||
|
{
|
||||||
|
if (id == UpdateScrollPrefsID())
|
||||||
|
gPrefs->Read(wxT("/GUI/AutoScroll"), &bUpdateTrackIndicator,
|
||||||
|
true);
|
||||||
|
ZoomInfo::UpdateSelectedPrefs( id );
|
||||||
|
}
|
||||||
|
|
||||||
void ViewInfo::UpdatePrefs()
|
void ViewInfo::UpdatePrefs()
|
||||||
{
|
{
|
||||||
ZoomInfo::UpdatePrefs();
|
ZoomInfo::UpdatePrefs();
|
||||||
@ -155,6 +163,8 @@ void ViewInfo::UpdatePrefs()
|
|||||||
#endif
|
#endif
|
||||||
gPrefs->Read(wxT("/GUI/AdjustSelectionEdges"), &bAdjustSelectionEdges,
|
gPrefs->Read(wxT("/GUI/AdjustSelectionEdges"), &bAdjustSelectionEdges,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
UpdateSelectedPrefs( UpdateScrollPrefsID() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewInfo::SetBeforeScreenWidth(wxInt64 beforeWidth, wxInt64 screenWidth, double lowerBoundTime)
|
void ViewInfo::SetBeforeScreenWidth(wxInt64 beforeWidth, wxInt64 screenWidth, double lowerBoundTime)
|
||||||
@ -206,3 +216,9 @@ void ViewInfo::OnTimer(wxCommandEvent &event)
|
|||||||
// Propagate the message to other listeners bound to this
|
// Propagate the message to other listeners bound to this
|
||||||
this->ProcessEvent( event );
|
this->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ViewInfo::UpdateScrollPrefsID()
|
||||||
|
{
|
||||||
|
static int value = wxNewId();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <wx/event.h> // inherit wxEvtHandler
|
#include <wx/event.h> // inherit wxEvtHandler
|
||||||
#include "SelectedRegion.h"
|
#include "SelectedRegion.h"
|
||||||
#include "MemoryX.h"
|
#include "MemoryX.h"
|
||||||
|
#include "Prefs.h"
|
||||||
|
|
||||||
|
|
||||||
class Track;
|
class Track;
|
||||||
@ -31,6 +32,7 @@ class Track;
|
|||||||
class AUDACITY_DLL_API ZoomInfo /* not final */
|
class AUDACITY_DLL_API ZoomInfo /* not final */
|
||||||
// Note that ViewInfo inherits from ZoomInfo but there are no virtual functions.
|
// Note that ViewInfo inherits from ZoomInfo but there are no virtual functions.
|
||||||
// That's okay if we pass always by reference and never copy, suffering "slicing."
|
// That's okay if we pass always by reference and never copy, suffering "slicing."
|
||||||
|
: protected PrefsListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZoomInfo(double start, double pixelsPerSecond);
|
ZoomInfo(double start, double pixelsPerSecond);
|
||||||
@ -40,7 +42,7 @@ public:
|
|||||||
ZoomInfo(const ZoomInfo&) PROHIBITED;
|
ZoomInfo(const ZoomInfo&) PROHIBITED;
|
||||||
ZoomInfo& operator= (const ZoomInfo&) PROHIBITED;
|
ZoomInfo& operator= (const ZoomInfo&) PROHIBITED;
|
||||||
|
|
||||||
void UpdatePrefs();
|
void UpdatePrefs() override;
|
||||||
|
|
||||||
int vpos; // vertical scroll pos
|
int vpos; // vertical scroll pos
|
||||||
|
|
||||||
@ -146,7 +148,9 @@ class AUDACITY_DLL_API ViewInfo final
|
|||||||
public:
|
public:
|
||||||
ViewInfo(double start, double screenDuration, double pixelsPerSecond);
|
ViewInfo(double start, double screenDuration, double pixelsPerSecond);
|
||||||
|
|
||||||
void UpdatePrefs();
|
static int UpdateScrollPrefsID();
|
||||||
|
void UpdatePrefs() override;
|
||||||
|
void UpdateSelectedPrefs( int id ) override;
|
||||||
|
|
||||||
double GetBeforeScreenWidth() const
|
double GetBeforeScreenWidth() const
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "../TrackPanel.h"
|
#include "../TrackPanel.h"
|
||||||
#include "../commands/CommandContext.h"
|
#include "../commands/CommandContext.h"
|
||||||
#include "../commands/CommandManager.h"
|
#include "../commands/CommandManager.h"
|
||||||
|
#include "../prefs/GUIPrefs.h"
|
||||||
#include "../prefs/TracksPrefs.h"
|
#include "../prefs/TracksPrefs.h"
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_EFFECTS_RACK
|
#ifdef EXPERIMENTAL_EFFECTS_RACK
|
||||||
@ -367,7 +368,10 @@ void OnShowClipping(const CommandContext &context)
|
|||||||
gPrefs->Write(wxT("/GUI/ShowClipping"), checked);
|
gPrefs->Write(wxT("/GUI/ShowClipping"), checked);
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
commandManager->Check(wxT("ShowClipping"), checked);
|
commandManager->Check(wxT("ShowClipping"), checked);
|
||||||
trackPanel->UpdatePrefs();
|
|
||||||
|
wxTheApp->AddPendingEvent(wxCommandEvent{
|
||||||
|
EVT_PREFS_UPDATE, ShowClippingPrefsID() });
|
||||||
|
|
||||||
trackPanel->Refresh(false);
|
trackPanel->Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,6 +366,12 @@ wxString GUIPrefs::GetLang()
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ShowClippingPrefsID()
|
||||||
|
{
|
||||||
|
static int value = wxNewId();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
PrefsPanel::Factory
|
PrefsPanel::Factory
|
||||||
GUIPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
GUIPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||||
{
|
{
|
||||||
|
@ -67,4 +67,7 @@ class GUIPrefs final : public PrefsPanel
|
|||||||
|
|
||||||
/// A PrefsPanel::Factory that creates one GUIPrefs panel.
|
/// A PrefsPanel::Factory that creates one GUIPrefs panel.
|
||||||
extern PrefsPanel::Factory GUIPrefsFactory;
|
extern PrefsPanel::Factory GUIPrefsFactory;
|
||||||
|
|
||||||
|
int ShowClippingPrefsID();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -850,9 +850,6 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
|
|||||||
// LL: wxMac can't handle recreating the menus when this dialog is still active,
|
// LL: wxMac can't handle recreating the menus when this dialog is still active,
|
||||||
// so AudacityProject::UpdatePrefs() or any of the routines it calls must
|
// so AudacityProject::UpdatePrefs() or any of the routines it calls must
|
||||||
// not cause MenuCreator::RebuildMenuBar() to be executed.
|
// not cause MenuCreator::RebuildMenuBar() to be executed.
|
||||||
for (size_t i = 0; i < gAudacityProjects.size(); i++) {
|
|
||||||
gAudacityProjects[i]->UpdatePrefs();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxTheApp->AddPendingEvent(wxCommandEvent{ EVT_PREFS_UPDATE });
|
wxTheApp->AddPendingEvent(wxCommandEvent{ EVT_PREFS_UPDATE });
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ ControlToolBar::~ControlToolBar()
|
|||||||
void ControlToolBar::Create(wxWindow * parent)
|
void ControlToolBar::Create(wxWindow * parent)
|
||||||
{
|
{
|
||||||
ToolBar::Create(parent);
|
ToolBar::Create(parent);
|
||||||
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a convenience function that allows for button creation in
|
// This is a convenience function that allows for button creation in
|
||||||
|
@ -64,6 +64,12 @@ BEGIN_EVENT_TABLE(DeviceToolBar, ToolBar)
|
|||||||
EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, DeviceToolBar::OnCaptureKey)
|
EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, DeviceToolBar::OnCaptureKey)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
static int DeviceToolbarPrefsID()
|
||||||
|
{
|
||||||
|
static int value = wxNewId();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
//Standard contructor
|
//Standard contructor
|
||||||
DeviceToolBar::DeviceToolBar()
|
DeviceToolBar::DeviceToolBar()
|
||||||
: ToolBar(DeviceBarID, _("Device"), wxT("Device"), true)
|
: ToolBar(DeviceBarID, _("Device"), wxT("Device"), true)
|
||||||
@ -313,6 +319,13 @@ void DeviceToolBar::UpdatePrefs()
|
|||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceToolBar::UpdateSelectedPrefs( int id )
|
||||||
|
{
|
||||||
|
if (id == DeviceToolbarPrefsID())
|
||||||
|
UpdatePrefs();
|
||||||
|
ToolBar::UpdateSelectedPrefs( id );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DeviceToolBar::EnableDisableButtons()
|
void DeviceToolBar::EnableDisableButtons()
|
||||||
{
|
{
|
||||||
@ -773,10 +786,8 @@ void DeviceToolBar::OnChoice(wxCommandEvent &event)
|
|||||||
gAudioIO->HandleDeviceChange();
|
gAudioIO->HandleDeviceChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update all projects' DeviceToolBar.
|
wxTheApp->AddPendingEvent(wxCommandEvent{
|
||||||
for (size_t i = 0; i < gAudacityProjects.size(); i++) {
|
EVT_PREFS_UPDATE, DeviceToolbarPrefsID() });
|
||||||
gAudacityProjects[i]->GetDeviceToolBar()->UpdatePrefs();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceToolBar::ShowInputDialog()
|
void DeviceToolBar::ShowInputDialog()
|
||||||
|
@ -29,6 +29,7 @@ class DeviceToolBar final : public ToolBar {
|
|||||||
void Create(wxWindow * parent) override;
|
void Create(wxWindow * parent) override;
|
||||||
|
|
||||||
void UpdatePrefs() override;
|
void UpdatePrefs() override;
|
||||||
|
void UpdateSelectedPrefs( int ) override;
|
||||||
|
|
||||||
void DeinitChildren();
|
void DeinitChildren();
|
||||||
void Populate() override;
|
void Populate() override;
|
||||||
|
@ -89,6 +89,7 @@ EditToolBar::~EditToolBar()
|
|||||||
void EditToolBar::Create(wxWindow * parent)
|
void EditToolBar::Create(wxWindow * parent)
|
||||||
{
|
{
|
||||||
ToolBar::Create(parent);
|
ToolBar::Create(parent);
|
||||||
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditToolBar::AddSeparator()
|
void EditToolBar::AddSeparator()
|
||||||
|
@ -78,6 +78,8 @@ void MeterToolBar::Create(wxWindow * parent)
|
|||||||
{
|
{
|
||||||
ToolBar::Create(parent);
|
ToolBar::Create(parent);
|
||||||
|
|
||||||
|
UpdatePrefs();
|
||||||
|
|
||||||
// Simulate a size event to set initial meter placement/size
|
// Simulate a size event to set initial meter placement/size
|
||||||
wxSizeEvent dummy;
|
wxSizeEvent dummy;
|
||||||
OnSize(dummy);
|
OnSize(dummy);
|
||||||
@ -156,18 +158,6 @@ void MeterToolBar::Populate()
|
|||||||
|
|
||||||
void MeterToolBar::UpdatePrefs()
|
void MeterToolBar::UpdatePrefs()
|
||||||
{
|
{
|
||||||
if( mPlayMeter )
|
|
||||||
{
|
|
||||||
mPlayMeter->UpdatePrefs();
|
|
||||||
mPlayMeter->Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mRecordMeter )
|
|
||||||
{
|
|
||||||
mRecordMeter->UpdatePrefs();
|
|
||||||
mRecordMeter->Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
RegenerateTooltips();
|
RegenerateTooltips();
|
||||||
|
|
||||||
// Set label to pull in language change
|
// Set label to pull in language change
|
||||||
@ -175,8 +165,6 @@ void MeterToolBar::UpdatePrefs()
|
|||||||
|
|
||||||
// Give base class a chance
|
// Give base class a chance
|
||||||
ToolBar::UpdatePrefs();
|
ToolBar::UpdatePrefs();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeterToolBar::RegenerateTooltips()
|
void MeterToolBar::RegenerateTooltips()
|
||||||
|
@ -67,6 +67,7 @@ MixerToolBar::~MixerToolBar()
|
|||||||
void MixerToolBar::Create(wxWindow *parent)
|
void MixerToolBar::Create(wxWindow *parent)
|
||||||
{
|
{
|
||||||
ToolBar::Create(parent);
|
ToolBar::Create(parent);
|
||||||
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixerToolBar::Populate()
|
void MixerToolBar::Populate()
|
||||||
|
@ -68,6 +68,7 @@ ScrubbingToolBar::~ScrubbingToolBar()
|
|||||||
void ScrubbingToolBar::Create(wxWindow * parent)
|
void ScrubbingToolBar::Create(wxWindow * parent)
|
||||||
{
|
{
|
||||||
ToolBar::Create(parent);
|
ToolBar::Create(parent);
|
||||||
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is a convenience function that allows for button creation in
|
/// This is a convenience function that allows for button creation in
|
||||||
|
@ -132,6 +132,7 @@ SelectionBar::~SelectionBar()
|
|||||||
void SelectionBar::Create(wxWindow * parent)
|
void SelectionBar::Create(wxWindow * parent)
|
||||||
{
|
{
|
||||||
ToolBar::Create(parent);
|
ToolBar::Create(parent);
|
||||||
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -504,7 +505,8 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
|
|||||||
// Save format name before recreating the controls so they resize properly
|
// Save format name before recreating the controls so they resize properly
|
||||||
{
|
{
|
||||||
auto format = mStartTime->GetBuiltinName(index);
|
auto format = mStartTime->GetBuiltinName(index);
|
||||||
mListener->AS_SetSelectionFormat(format);
|
if (mListener)
|
||||||
|
mListener->AS_SetSelectionFormat(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegenerateTooltips();
|
RegenerateTooltips();
|
||||||
|
@ -107,6 +107,7 @@ SpectralSelectionBar::~SpectralSelectionBar()
|
|||||||
void SpectralSelectionBar::Create(wxWindow * parent)
|
void SpectralSelectionBar::Create(wxWindow * parent)
|
||||||
{
|
{
|
||||||
ToolBar::Create(parent);
|
ToolBar::Create(parent);
|
||||||
|
UpdatePrefs();
|
||||||
mHeight = wxWindowBase::GetSizer()->GetSize().GetHeight();
|
mHeight = wxWindowBase::GetSizer()->GetSize().GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,12 +371,14 @@ void SpectralSelectionBar::OnUpdate(wxCommandEvent &evt)
|
|||||||
if (type == EVT_FREQUENCYTEXTCTRL_UPDATED) {
|
if (type == EVT_FREQUENCYTEXTCTRL_UPDATED) {
|
||||||
NumericTextCtrl *frequencyCtrl = (mbCenterAndWidth ? mCenterCtrl : mLowCtrl);
|
NumericTextCtrl *frequencyCtrl = (mbCenterAndWidth ? mCenterCtrl : mLowCtrl);
|
||||||
auto frequencyFormatName = frequencyCtrl->GetBuiltinName(index);
|
auto frequencyFormatName = frequencyCtrl->GetBuiltinName(index);
|
||||||
mListener->SSBL_SetFrequencySelectionFormatName(frequencyFormatName);
|
if (mListener)
|
||||||
|
mListener->SSBL_SetFrequencySelectionFormatName(frequencyFormatName);
|
||||||
}
|
}
|
||||||
else if (mbCenterAndWidth &&
|
else if (mbCenterAndWidth &&
|
||||||
type == EVT_BANDWIDTHTEXTCTRL_UPDATED) {
|
type == EVT_BANDWIDTHTEXTCTRL_UPDATED) {
|
||||||
auto bandwidthFormatName = mWidthCtrl->GetBuiltinName(index);
|
auto bandwidthFormatName = mWidthCtrl->GetBuiltinName(index);
|
||||||
mListener->SSBL_SetBandwidthSelectionFormatName(bandwidthFormatName);
|
if (mListener)
|
||||||
|
mListener->SSBL_SetBandwidthSelectionFormatName(bandwidthFormatName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToolBar::ReCreateButtons() will get rid of our sizers and controls
|
// ToolBar::ReCreateButtons() will get rid of our sizers and controls
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
|
|
||||||
|
#include "../Prefs.h"
|
||||||
#include "../Theme.h"
|
#include "../Theme.h"
|
||||||
#include "../widgets/wxPanelWrapper.h" // to inherit
|
#include "../widgets/wxPanelWrapper.h" // to inherit
|
||||||
|
|
||||||
@ -84,7 +85,9 @@ enum
|
|||||||
// How may pixels padding each side of a floating toolbar
|
// How may pixels padding each side of a floating toolbar
|
||||||
enum { ToolBarFloatMargin = 1 };
|
enum { ToolBarFloatMargin = 1 };
|
||||||
|
|
||||||
class ToolBar /* not final */ : public wxPanelWrapper
|
class ToolBar /* not final */
|
||||||
|
: public wxPanelWrapper
|
||||||
|
, protected PrefsListener
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -101,7 +104,7 @@ class ToolBar /* not final */ : public wxPanelWrapper
|
|||||||
virtual void Create(wxWindow *parent);
|
virtual void Create(wxWindow *parent);
|
||||||
virtual void EnableDisableButtons() = 0;
|
virtual void EnableDisableButtons() = 0;
|
||||||
virtual void ReCreateButtons();
|
virtual void ReCreateButtons();
|
||||||
virtual void UpdatePrefs();
|
void UpdatePrefs() override;
|
||||||
virtual void RegenerateTooltips() = 0;
|
virtual void RegenerateTooltips() = 0;
|
||||||
|
|
||||||
int GetType();
|
int GetType();
|
||||||
|
@ -1091,21 +1091,6 @@ void ToolManager::LayoutToolBars()
|
|||||||
mBotDock->LayoutToolBars();
|
mBotDock->LayoutToolBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Tell the toolbars that preferences have been updated
|
|
||||||
//
|
|
||||||
void ToolManager::UpdatePrefs()
|
|
||||||
{
|
|
||||||
for( int ndx = 0; ndx < ToolBarCount; ndx++ )
|
|
||||||
{
|
|
||||||
ToolBar *bar = mBars[ ndx ].get();
|
|
||||||
if( bar )
|
|
||||||
{
|
|
||||||
bar->UpdatePrefs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle toolbar dragging
|
// Handle toolbar dragging
|
||||||
//
|
//
|
||||||
|
@ -48,7 +48,6 @@ class ToolManager final : public wxEvtHandler, public wxEventFilter
|
|||||||
~ToolManager();
|
~ToolManager();
|
||||||
|
|
||||||
void LayoutToolBars();
|
void LayoutToolBars();
|
||||||
void UpdatePrefs();
|
|
||||||
|
|
||||||
bool IsDocked( int type );
|
bool IsDocked( int type );
|
||||||
|
|
||||||
|
@ -258,3 +258,9 @@ void ToolsToolBar::OnTool(wxCommandEvent & evt)
|
|||||||
IsDown(multiTool));
|
IsDown(multiTool));
|
||||||
gPrefs->Flush();
|
gPrefs->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolsToolBar::Create(wxWindow * parent)
|
||||||
|
{
|
||||||
|
ToolBar::Create(parent);
|
||||||
|
UpdatePrefs();
|
||||||
|
}
|
||||||
|
@ -68,6 +68,7 @@ class ToolsToolBar final : public ToolBar {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void Create(wxWindow * parent) override;
|
||||||
void RegenerateTooltips() override;
|
void RegenerateTooltips() override;
|
||||||
wxImage *MakeToolImage(wxImage *tool, wxImage *mask, int style);
|
wxImage *MakeToolImage(wxImage *tool, wxImage *mask, int style);
|
||||||
static AButton *MakeTool(
|
static AButton *MakeTool(
|
||||||
|
@ -98,7 +98,6 @@ class TranscriptionToolBar final : public ToolBar {
|
|||||||
//void Populate() override;
|
//void Populate() override;
|
||||||
//void Repaint(wxDC * WXUNUSED(dc)) override {}
|
//void Repaint(wxDC * WXUNUSED(dc)) override {}
|
||||||
//void EnableDisableButtons() override;
|
//void EnableDisableButtons() override;
|
||||||
//void UpdatePrefs() override;
|
|
||||||
|
|
||||||
//void OnFocus(wxFocusEvent &event);
|
//void OnFocus(wxFocusEvent &event);
|
||||||
//void OnCaptureKey(wxCommandEvent &event);
|
//void OnCaptureKey(wxCommandEvent &event);
|
||||||
|
@ -253,9 +253,6 @@ bool MeterUpdateQueue::Get(MeterUpdateMsg &msg)
|
|||||||
// How many pixels between items?
|
// How many pixels between items?
|
||||||
const static int gap = 2;
|
const static int gap = 2;
|
||||||
|
|
||||||
// Event used to notify all meters of preference changes
|
|
||||||
wxDEFINE_EVENT(EVT_METER_PREFERENCES_CHANGED, wxCommandEvent);
|
|
||||||
|
|
||||||
const static wxChar *PrefStyles[] =
|
const static wxChar *PrefStyles[] =
|
||||||
{
|
{
|
||||||
wxT("AutomaticStereo"),
|
wxT("AutomaticStereo"),
|
||||||
@ -348,11 +345,6 @@ MeterPanel::MeterPanel(AudacityProject *project,
|
|||||||
mPeakPeakPen = wxPen(theTheme.Colour( clrMeterPeak), 1, wxPENSTYLE_SOLID);
|
mPeakPeakPen = wxPen(theTheme.Colour( clrMeterPeak), 1, wxPENSTYLE_SOLID);
|
||||||
mDisabledPen = wxPen(theTheme.Colour( clrMeterDisabledPen), 1, wxPENSTYLE_SOLID);
|
mDisabledPen = wxPen(theTheme.Colour( clrMeterDisabledPen), 1, wxPENSTYLE_SOLID);
|
||||||
|
|
||||||
// Register for our preference update event
|
|
||||||
wxTheApp->Bind(EVT_METER_PREFERENCES_CHANGED,
|
|
||||||
&MeterPanel::OnMeterPrefsUpdated,
|
|
||||||
this);
|
|
||||||
|
|
||||||
if (mIsInput) {
|
if (mIsInput) {
|
||||||
wxTheApp->Bind(EVT_AUDIOIO_MONITOR,
|
wxTheApp->Bind(EVT_AUDIOIO_MONITOR,
|
||||||
&MeterPanel::OnAudioIOStatus,
|
&MeterPanel::OnAudioIOStatus,
|
||||||
@ -457,6 +449,20 @@ void MeterPanel::UpdatePrefs()
|
|||||||
Reset(mRate, false);
|
Reset(mRate, false);
|
||||||
|
|
||||||
mLayoutValid = false;
|
mLayoutValid = false;
|
||||||
|
|
||||||
|
Refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int MeterPrefsID()
|
||||||
|
{
|
||||||
|
static int value = wxNewId();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeterPanel::UpdateSelectedPrefs(int id)
|
||||||
|
{
|
||||||
|
if (id == MeterPrefsID())
|
||||||
|
UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeterPanel::OnErase(wxEraseEvent & WXUNUSED(event))
|
void MeterPanel::OnErase(wxEraseEvent & WXUNUSED(event))
|
||||||
@ -1964,15 +1970,6 @@ void MeterPanel::OnMonitor(wxCommandEvent & WXUNUSED(event))
|
|||||||
StartMonitoring();
|
StartMonitoring();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeterPanel::OnMeterPrefsUpdated(wxCommandEvent & evt)
|
|
||||||
{
|
|
||||||
evt.Skip();
|
|
||||||
|
|
||||||
UpdatePrefs();
|
|
||||||
|
|
||||||
Refresh(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
|
void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxTextCtrl *rate;
|
wxTextCtrl *rate;
|
||||||
@ -2099,9 +2096,8 @@ void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
|
|||||||
// Currently, there are 2 playback meters and 2 record meters and any number of
|
// Currently, there are 2 playback meters and 2 record meters and any number of
|
||||||
// mixerboard meters, so we have to send out an preferences updated message to
|
// mixerboard meters, so we have to send out an preferences updated message to
|
||||||
// ensure they all update themselves.
|
// ensure they all update themselves.
|
||||||
wxCommandEvent e(EVT_METER_PREFERENCES_CHANGED);
|
wxTheApp->AddPendingEvent(wxCommandEvent{
|
||||||
e.SetEventObject(this);
|
EVT_PREFS_UPDATE, MeterPrefsID() });
|
||||||
GetParent()->GetEventHandler()->ProcessEvent(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,14 +22,11 @@
|
|||||||
#include <wx/timer.h> // member variable
|
#include <wx/timer.h> // member variable
|
||||||
|
|
||||||
#include "../SampleFormat.h"
|
#include "../SampleFormat.h"
|
||||||
|
#include "../Prefs.h"
|
||||||
#include "Ruler.h" // member variable
|
#include "Ruler.h" // member variable
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
|
||||||
// Event used to notify all meters of preference changes
|
|
||||||
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
|
||||||
EVT_METER_PREFERENCES_CHANGED, wxCommandEvent);
|
|
||||||
|
|
||||||
// Increase this when we add support for multichannel meters
|
// Increase this when we add support for multichannel meters
|
||||||
// (most of the code is already there)
|
// (most of the code is already there)
|
||||||
const int kMaxMeterBars = 2;
|
const int kMaxMeterBars = 2;
|
||||||
@ -94,7 +91,7 @@ class MeterAx;
|
|||||||
\brief MeterPanel is a panel that paints the meter used for monitoring
|
\brief MeterPanel is a panel that paints the meter used for monitoring
|
||||||
or playback.
|
or playback.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
class MeterPanel final : public wxPanelWrapper
|
class MeterPanel final : public wxPanelWrapper, private PrefsListener
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(MeterPanel)
|
DECLARE_DYNAMIC_CLASS(MeterPanel)
|
||||||
|
|
||||||
@ -124,7 +121,6 @@ class MeterPanel final : public wxPanelWrapper
|
|||||||
|
|
||||||
void SetFocusFromKbd() override;
|
void SetFocusFromKbd() override;
|
||||||
|
|
||||||
void UpdatePrefs();
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
Style GetStyle() const { return mStyle; }
|
Style GetStyle() const { return mStyle; }
|
||||||
@ -192,6 +188,9 @@ class MeterPanel final : public wxPanelWrapper
|
|||||||
int GetDBRange() const { return mDB ? mDBRange : -1; }
|
int GetDBRange() const { return mDB ? mDBRange : -1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void UpdatePrefs() override;
|
||||||
|
void UpdateSelectedPrefs( int ) override;
|
||||||
|
|
||||||
static bool s_AcceptsFocus;
|
static bool s_AcceptsFocus;
|
||||||
struct Resetter { void operator () (bool *p) const { if(p) *p = false; } };
|
struct Resetter { void operator () (bool *p) const { if(p) *p = false; } };
|
||||||
using TempAllowFocus = std::unique_ptr<bool, Resetter>;
|
using TempAllowFocus = std::unique_ptr<bool, Resetter>;
|
||||||
@ -232,7 +231,6 @@ class MeterPanel final : public wxPanelWrapper
|
|||||||
void ShowMenu(const wxPoint & pos);
|
void ShowMenu(const wxPoint & pos);
|
||||||
void OnMonitor(wxCommandEvent &evt);
|
void OnMonitor(wxCommandEvent &evt);
|
||||||
void OnPreferences(wxCommandEvent &evt);
|
void OnPreferences(wxCommandEvent &evt);
|
||||||
void OnMeterPrefsUpdated(wxCommandEvent &evt);
|
|
||||||
|
|
||||||
wxString Key(const wxString & key) const;
|
wxString Key(const wxString & key) const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user