1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-19 23:21:33 +01:00

Spectral SelectionBar tweaks from Paul Limaceli.

- Center and Width now the default
- Above choice persists.
- Accessibility changes (focus was lost on changing choice)
This commit is contained in:
james.k.crook@gmail.com
2014-11-10 21:09:28 +00:00
parent a68093ae60
commit c900da7a56

View File

@@ -51,6 +51,7 @@ with changes in the SpectralSelectionBar.
#include "SpectralSelectionBar.h" #include "SpectralSelectionBar.h"
#include "../AudacityApp.h" #include "../AudacityApp.h"
#include "../Prefs.h"
#include "../SelectedRegion.h" #include "../SelectedRegion.h"
#include "../widgets/NumericTextCtrl.h" #include "../widgets/NumericTextCtrl.h"
@@ -78,9 +79,12 @@ BEGIN_EVENT_TABLE(SpectralSelectionBar, ToolBar)
EVT_COMMAND(wxID_ANY, EVT_LOGFREQUENCYTEXTCTRL_UPDATED, SpectralSelectionBar::OnUpdate) EVT_COMMAND(wxID_ANY, EVT_LOGFREQUENCYTEXTCTRL_UPDATED, SpectralSelectionBar::OnUpdate)
END_EVENT_TABLE() END_EVENT_TABLE()
static const wxString preferencePath
(wxT("/GUI/Toolbars/SpectralSelection/CenterAndWidthChoice"));
SpectralSelectionBar::SpectralSelectionBar() SpectralSelectionBar::SpectralSelectionBar()
: ToolBar(SpectralSelectionBarID, _("SpectralSelection"), wxT("SpectralSelection")) : ToolBar(SpectralSelectionBarID, _("SpectralSelection"), wxT("SpectralSelection"))
, mListener(NULL), mbCenterAndWidth(false) , mListener(NULL), mbCenterAndWidth(true)
, mCenter(0.0), mWidth(0.0), mLow(0.0), mHigh(0.0) , mCenter(0.0), mWidth(0.0), mLow(0.0), mHigh(0.0)
, mCenterCtrl(NULL), mWidthCtrl(NULL), mLowCtrl(NULL), mHighCtrl(NULL) , mCenterCtrl(NULL), mWidthCtrl(NULL), mLowCtrl(NULL), mHighCtrl(NULL)
, mChoice(NULL) , mChoice(NULL)
@@ -99,6 +103,8 @@ void SpectralSelectionBar::Create(wxWindow * parent)
void SpectralSelectionBar::Populate() void SpectralSelectionBar::Populate()
{ {
gPrefs->Read(preferencePath, &mbCenterAndWidth, true);
// This will be inherited by all children: // This will be inherited by all children:
SetFont(wxFont(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); SetFont(wxFont(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
@@ -127,7 +133,7 @@ void SpectralSelectionBar::Populate()
}; };
mChoice = new wxChoice mChoice = new wxChoice
(this, OnChoiceID, wxDefaultPosition, wxDefaultSize, 2, choices, (this, OnChoiceID, wxDefaultPosition, wxDefaultSize, 2, choices,
0, wxDefaultValidator, _("Spectral Selection Specifications")); 0, wxDefaultValidator, _("Spectral Selection"));
mChoice->SetSelection(mbCenterAndWidth ? 0 : 1); mChoice->SetSelection(mbCenterAndWidth ? 0 : 1);
mainSizer->Add(mChoice, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND, 5); mainSizer->Add(mChoice, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND, 5);
@@ -267,7 +273,10 @@ void SpectralSelectionBar::OnCtrl(wxCommandEvent & event)
void SpectralSelectionBar::OnChoice(wxCommandEvent &) void SpectralSelectionBar::OnChoice(wxCommandEvent &)
{ {
mbCenterAndWidth = (0 == mChoice->GetSelection()); mbCenterAndWidth = (0 == mChoice->GetSelection());
gPrefs->Write(preferencePath, mbCenterAndWidth);
gPrefs->Flush();
ToolBar::ReCreateButtons(); ToolBar::ReCreateButtons();
mChoice->SetFocus();
ValuesToControls(); ValuesToControls();
Updated(); Updated();
} }