mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-26 15:23:48 +01:00
Recode the Apply button of Spectrogram Preferences so it is next to OK/Cancel
This commit is contained in:
@@ -75,6 +75,7 @@
|
|||||||
BEGIN_EVENT_TABLE(PrefsDialog, wxDialog)
|
BEGIN_EVENT_TABLE(PrefsDialog, wxDialog)
|
||||||
EVT_BUTTON(wxID_OK, PrefsDialog::OnOK)
|
EVT_BUTTON(wxID_OK, PrefsDialog::OnOK)
|
||||||
EVT_BUTTON(wxID_CANCEL, PrefsDialog::OnCancel)
|
EVT_BUTTON(wxID_CANCEL, PrefsDialog::OnCancel)
|
||||||
|
EVT_BUTTON(wxID_APPLY, PrefsDialog::OnApply)
|
||||||
EVT_TREE_KEY_DOWN(wxID_ANY, PrefsDialog::OnTreeKeyDown) // Handles key events when tree has focus
|
EVT_TREE_KEY_DOWN(wxID_ANY, PrefsDialog::OnTreeKeyDown) // Handles key events when tree has focus
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -108,6 +109,16 @@ int wxTreebookExt::SetSelection(size_t n)
|
|||||||
wxString Temp = wxString(mTitlePrefix) + GetPageText( n );
|
wxString Temp = wxString(mTitlePrefix) + GetPageText( n );
|
||||||
((wxDialog*)GetParent())->SetTitle( Temp );
|
((wxDialog*)GetParent())->SetTitle( Temp );
|
||||||
((wxDialog*)GetParent())->SetName( Temp );
|
((wxDialog*)GetParent())->SetName( Temp );
|
||||||
|
|
||||||
|
PrefsPanel *const panel = static_cast<PrefsPanel *>(GetPage(n));
|
||||||
|
const bool showApply = panel->ShowsApplyButton();
|
||||||
|
wxWindow *const applyButton = wxWindow::FindWindowById(wxID_APPLY, GetParent());
|
||||||
|
if (applyButton) { // might still be NULL during population
|
||||||
|
const bool changed = applyButton->Show(showApply);
|
||||||
|
if (changed)
|
||||||
|
GetParent()->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +266,13 @@ PrefsDialog::PrefsDialog
|
|||||||
}
|
}
|
||||||
S.EndVerticalLay();
|
S.EndVerticalLay();
|
||||||
|
|
||||||
S.AddStandardButtons(eOkButton | eCancelButton);
|
S.AddStandardButtons(eOkButton | eCancelButton | eApplyButton);
|
||||||
|
|
||||||
|
if (mUniquePage && !mUniquePage->ShowsApplyButton()) {
|
||||||
|
wxWindow *const applyButton =
|
||||||
|
wxWindow::FindWindowById(wxID_APPLY, GetParent());
|
||||||
|
applyButton->Show(false);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__WXGTK__)
|
#if defined(__WXGTK__)
|
||||||
if (mCategories)
|
if (mCategories)
|
||||||
@@ -343,6 +360,14 @@ void PrefsDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
|
|||||||
EndModal(false);
|
EndModal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrefsDialog::OnApply(wxCommandEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (mCategories)
|
||||||
|
static_cast<PrefsPanel*>(mCategories->GetCurrentPage())->Apply();
|
||||||
|
else
|
||||||
|
mUniquePage->Apply();
|
||||||
|
}
|
||||||
|
|
||||||
void PrefsDialog::OnTreeKeyDown(wxTreeEvent & event)
|
void PrefsDialog::OnTreeKeyDown(wxTreeEvent & event)
|
||||||
{
|
{
|
||||||
if(event.GetKeyCode() == WXK_RETURN)
|
if(event.GetKeyCode() == WXK_RETURN)
|
||||||
@@ -479,3 +504,16 @@ void PrefsDialog::RecordExpansionState()
|
|||||||
else
|
else
|
||||||
mFactories[0].expanded = true;
|
mFactories[0].expanded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrefsPanel::~PrefsPanel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefsPanel::Cancel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PrefsPanel::ShowsApplyButton()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class PrefsDialog:public wxDialog
|
|||||||
void OnCategoryChange(wxCommandEvent & e);
|
void OnCategoryChange(wxCommandEvent & e);
|
||||||
void OnOK(wxCommandEvent & e);
|
void OnOK(wxCommandEvent & e);
|
||||||
void OnCancel(wxCommandEvent & e);
|
void OnCancel(wxCommandEvent & e);
|
||||||
|
void OnApply(wxCommandEvent & e);
|
||||||
void OnTreeKeyDown(wxTreeEvent & e); // Used to dismiss the dialog when enter is pressed with focus on tree
|
void OnTreeKeyDown(wxTreeEvent & e); // Used to dismiss the dialog when enter is pressed with focus on tree
|
||||||
|
|
||||||
void SelectPageByName(wxString pageName);
|
void SelectPageByName(wxString pageName);
|
||||||
|
|||||||
@@ -50,15 +50,15 @@ class PrefsPanel:public wxPanel
|
|||||||
SetName(title); // Provide audible label
|
SetName(title); // Provide audible label
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~PrefsPanel()
|
virtual ~PrefsPanel();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Apply() = 0;
|
virtual bool Apply() = 0;
|
||||||
|
|
||||||
virtual void Cancel()
|
// If it returns True, the Apply button is added below the panel
|
||||||
{
|
// Default returns false
|
||||||
}
|
virtual bool ShowsApplyButton();
|
||||||
|
|
||||||
|
virtual void Cancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PrefsPanelFactory
|
class PrefsPanelFactory
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ enum {
|
|||||||
ID_SPECTRAL_SELECTION,
|
ID_SPECTRAL_SELECTION,
|
||||||
#endif
|
#endif
|
||||||
ID_DEFAULTS,
|
ID_DEFAULTS,
|
||||||
ID_APPLY,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void SpectrumPrefs::Populate(int windowSize)
|
void SpectrumPrefs::Populate(int windowSize)
|
||||||
@@ -289,12 +288,6 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
S.EndStatic();
|
S.EndStatic();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
S.StartMultiColumn(2, wxALIGN_RIGHT);
|
|
||||||
{
|
|
||||||
S.Id(ID_APPLY).AddButton(_("Appl&y"));
|
|
||||||
}
|
|
||||||
S.EndMultiColumn();
|
|
||||||
|
|
||||||
EnableDisableSTFTOnlyControls();
|
EnableDisableSTFTOnlyControls();
|
||||||
|
|
||||||
mPopulating = false;
|
mPopulating = false;
|
||||||
@@ -408,6 +401,17 @@ bool SpectrumPrefs::Apply()
|
|||||||
partner->SetDisplay(WaveTrack::Spectrum);
|
partner->SetDisplay(WaveTrack::Spectrum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOpenPage) {
|
||||||
|
TrackPanel *const tp = ::GetActiveProject()->GetTrackPanel();
|
||||||
|
tp->UpdateVRulers();
|
||||||
|
tp->Refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SpectrumPrefs::ShowsApplyButton()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,16 +472,6 @@ void SpectrumPrefs::EnableDisableSTFTOnlyControls()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectrumPrefs::OnApply(wxCommandEvent &)
|
|
||||||
{
|
|
||||||
if (Validate()) {
|
|
||||||
Apply();
|
|
||||||
TrackPanel *const tp = ::GetActiveProject()->GetTrackPanel();
|
|
||||||
tp->UpdateVRulers();
|
|
||||||
tp->Refresh(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
||||||
EVT_CHOICE(ID_WINDOW_SIZE, SpectrumPrefs::OnWindowSize)
|
EVT_CHOICE(ID_WINDOW_SIZE, SpectrumPrefs::OnWindowSize)
|
||||||
EVT_CHECKBOX(ID_DEFAULTS, SpectrumPrefs::OnDefaults)
|
EVT_CHECKBOX(ID_DEFAULTS, SpectrumPrefs::OnDefaults)
|
||||||
@@ -495,8 +489,6 @@ BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
|||||||
EVT_CHECKBOX(ID_GRAYSCALE, SpectrumPrefs::OnControl)
|
EVT_CHECKBOX(ID_GRAYSCALE, SpectrumPrefs::OnControl)
|
||||||
EVT_CHECKBOX(ID_SPECTRAL_SELECTION, SpectrumPrefs::OnControl)
|
EVT_CHECKBOX(ID_SPECTRAL_SELECTION, SpectrumPrefs::OnControl)
|
||||||
|
|
||||||
EVT_BUTTON(ID_APPLY, SpectrumPrefs::OnApply)
|
|
||||||
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt)
|
SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class SpectrumPrefs:public PrefsPanel
|
|||||||
SpectrumPrefs(wxWindow * parent, WaveTrack *wt);
|
SpectrumPrefs(wxWindow * parent, WaveTrack *wt);
|
||||||
virtual ~SpectrumPrefs();
|
virtual ~SpectrumPrefs();
|
||||||
virtual bool Apply();
|
virtual bool Apply();
|
||||||
|
virtual bool ShowsApplyButton();
|
||||||
virtual bool Validate();
|
virtual bool Validate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -55,7 +56,6 @@ class SpectrumPrefs:public PrefsPanel
|
|||||||
void OnWindowSize(wxCommandEvent &event);
|
void OnWindowSize(wxCommandEvent &event);
|
||||||
void OnDefaults(wxCommandEvent&);
|
void OnDefaults(wxCommandEvent&);
|
||||||
void OnAlgorithm(wxCommandEvent &);
|
void OnAlgorithm(wxCommandEvent &);
|
||||||
void OnApply(wxCommandEvent &);
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
void EnableDisableSTFTOnlyControls();
|
void EnableDisableSTFTOnlyControls();
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ WaveformPrefs::~WaveformPrefs()
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
ID_DEFAULTS = 10001,
|
ID_DEFAULTS = 10001,
|
||||||
ID_APPLY,
|
|
||||||
|
|
||||||
ID_SCALE,
|
ID_SCALE,
|
||||||
ID_RANGE,
|
ID_RANGE,
|
||||||
@@ -112,12 +111,6 @@ void WaveformPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
S.EndStatic();
|
S.EndStatic();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
S.StartMultiColumn(2, wxALIGN_RIGHT);
|
|
||||||
{
|
|
||||||
S.Id(ID_APPLY).AddButton(_("Appl&y"));
|
|
||||||
}
|
|
||||||
S.EndMultiColumn();
|
|
||||||
|
|
||||||
EnableDisableRange();
|
EnableDisableRange();
|
||||||
|
|
||||||
mPopulating = false;
|
mPopulating = false;
|
||||||
@@ -184,6 +177,17 @@ bool WaveformPrefs::Apply()
|
|||||||
partner->SetDisplay(WaveTrack::Waveform);
|
partner->SetDisplay(WaveTrack::Waveform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOpenPage) {
|
||||||
|
TrackPanel *const tp = ::GetActiveProject()->GetTrackPanel();
|
||||||
|
tp->UpdateVRulers();
|
||||||
|
tp->Refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WaveformPrefs::ShowsApplyButton()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,16 +223,6 @@ void WaveformPrefs::OnDefaults(wxCommandEvent &)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformPrefs::OnApply(wxCommandEvent &)
|
|
||||||
{
|
|
||||||
if (Validate()) {
|
|
||||||
Apply();
|
|
||||||
TrackPanel *const tp = ::GetActiveProject()->GetTrackPanel();
|
|
||||||
tp->UpdateVRulers();
|
|
||||||
tp->Refresh(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaveformPrefs::EnableDisableRange()
|
void WaveformPrefs::EnableDisableRange()
|
||||||
{
|
{
|
||||||
mRangeChoice->Enable
|
mRangeChoice->Enable
|
||||||
@@ -241,7 +235,6 @@ EVT_CHOICE(ID_SCALE, WaveformPrefs::OnScale)
|
|||||||
EVT_CHOICE(ID_RANGE, WaveformPrefs::OnControl)
|
EVT_CHOICE(ID_RANGE, WaveformPrefs::OnControl)
|
||||||
|
|
||||||
EVT_CHECKBOX(ID_DEFAULTS, WaveformPrefs::OnDefaults)
|
EVT_CHECKBOX(ID_DEFAULTS, WaveformPrefs::OnDefaults)
|
||||||
EVT_BUTTON(ID_APPLY, WaveformPrefs::OnApply)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
WaveformPrefsFactory::WaveformPrefsFactory(WaveTrack *wt)
|
WaveformPrefsFactory::WaveformPrefsFactory(WaveTrack *wt)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
WaveformPrefs(wxWindow * parent, WaveTrack *wt);
|
WaveformPrefs(wxWindow * parent, WaveTrack *wt);
|
||||||
virtual ~WaveformPrefs();
|
virtual ~WaveformPrefs();
|
||||||
virtual bool Apply();
|
virtual bool Apply();
|
||||||
|
virtual bool ShowsApplyButton();
|
||||||
virtual bool Validate();
|
virtual bool Validate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -35,7 +36,6 @@ private:
|
|||||||
void OnControl(wxCommandEvent&);
|
void OnControl(wxCommandEvent&);
|
||||||
void OnScale(wxCommandEvent&);
|
void OnScale(wxCommandEvent&);
|
||||||
void OnDefaults(wxCommandEvent&);
|
void OnDefaults(wxCommandEvent&);
|
||||||
void OnApply(wxCommandEvent &);
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
void EnableDisableRange();
|
void EnableDisableRange();
|
||||||
|
|||||||
Reference in New Issue
Block a user