37#include <wx/checkbox.h>
38#include <wx/combobox.h>
39#include <wx/settings.h>
41#include <wx/valtext.h>
44#include <wx/statline.h>
56#if wxUSE_ACCESSIBILITY
60#include "../widgets/NumericTextCtrl.h"
86(
wxT("/GUI/Toolbars/SpectralSelection/CenterAndWidthChoice"));
90 return wxT(
"SpectralSelection");
95, mbCenterAndWidth(true)
96, mCenter(0.0), mWidth(0.0), mLow(0.0), mHigh(0.0)
97, mCenterCtrl(NULL), mWidthCtrl(NULL), mLowCtrl(NULL), mHighCtrl(NULL)
134 mHeight = wxWindowBase::GetSizer()->GetSize().GetHeight();
143 auto frequencyFormatName = formats.GetFrequencySelectionFormatName();
144 auto bandwidthFormatName = formats.GetBandwidthSelectionFormatName();
145 wxFlexGridSizer *mainSizer =
safenew wxFlexGridSizer(1, 1, 1);
146 Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5);
152 const wxString choices[2] = {
153 _(
"Center frequency and Width"),
154 _(
"Low and High Frequencies"),
157 (
this,
OnChoiceID, wxDefaultPosition, wxDefaultSize, 2, choices,
158 0, wxDefaultValidator,
_(
"Show"));
160#if wxUSE_ACCESSIBILITY
166 mainSizer->Add(
mChoice, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 6);
173 auto subSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
182 subSizer->Add(
mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
192 subSizer->Add(
mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
202 subSizer->Add(
mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
212 subSizer->Add(
mHighCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
219 mainSizer->Add(subSizer.release(), 0, wxALIGN_TOP, 0);
229 formats.GetFrequencySelectionFormatName());
231 formats.GetBandwidthSelectionFormatName());
238 wxCommandEvent e(EVT_FREQUENCYTEXTCTRL_UPDATED);
241 ->GetFormatName().GET());
247 wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
294 mWidth = log(ratio * ratio);
302 const double ratio = exp(
mWidth / 2);
336 manager.ModifySpectralSelection(nyq, bottom, top, done);
357 wxSize sz = GetMinSize();
358 sz.SetWidth(wxDefaultCoord);
379 formats.GetFrequencySelectionFormatName());
382 formats.GetBandwidthSelectionFormatName());
394 bool lowFocus = (w && w ==
mLowCtrl);
400 wxEventType type = evt.GetEventType();
401 if (type == EVT_FREQUENCYTEXTCTRL_UPDATED) {
402 formats.SetFrequencySelectionFormatName(evt.GetString());
406 type == EVT_BANDWIDTHTEXTCTRL_UPDATED) {
407 formats.SetBandwidthSelectionFormatName(evt.GetString());
423 else if (widthFocus) {
429 else if (highFocus) {
474 if (bottom > 0 && top >= bottom)
491 wxCommandEvent e(EVT_FREQUENCYTEXTCTRL_UPDATED);
505 wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
522 wxT(
"ShowSpectralSelectionTB"),
XXO(
"Spe&ctral Selection Toolbar")
XXO("&Cut/Copy/Paste Toolbar")
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
const NumericConverterType & NumericConverterType_BANDWIDTH()
const NumericConverterType & NumericConverterType_FREQUENCY()
audacity::BasicSettings * gPrefs
an object holding per-project preferred sample rate
static const AttachedProjectObjects::RegisteredFactory manager
static RegisteredToolbarFactory factory
@ SpectralSelectionBarFirstID
IMPLEMENT_CLASS(SpectralSelectionBar, ToolBar)
static const wxString preferencePath(wxT("/GUI/Toolbars/SpectralSelection/CenterAndWidthChoice"))
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
static FormatterContext ProjectContext(const AudacityProject &project)
An explicitly nonlocalized string, not meant for the user to see.
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
void SetMinValue(double minValue)
void SetMaxValue(double maxValue)
NumericFormatID GetFormatName() const
bool SetFormatName(const NumericFormatID &formatName)
void SetName(const TranslatableString &name)
void SetValue(double newValue)
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
static ProjectSelectionManager & Get(AudacityProject &project)
static const int UndefinedFrequency
(not quite a Toolbar) at foot of screen for setting and viewing the frequency selection range.
void UpdatePrefs() override
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mWidthCtrl
SpectralSelectionBar(AudacityProject &project)
void SetBandwidthSelectionFormatName(const NumericFormatID &formatName)
void SetFrequencies(double bottom, double top)
NumericTextCtrl * mLowCtrl
void SetFrequencySelectionFormatName(const NumericFormatID &formatName)
void OnChoice(wxCommandEvent &evt)
void OnSize(wxSizeEvent &evt)
void Create(wxWindow *parent) override
void OnUpdate(wxCommandEvent &evt)
Observer::Subscription mFormatsSubscription
void OnIdle(wxIdleEvent &evt)
void RegenerateTooltips() override
bool ShownByDefault() const override
Whether the toolbar should be shown by default. Default implementation returns true.
DockID DefaultDockID() const override
Which dock the toolbar defaults into. Default implementation chooses the top dock.
NumericTextCtrl * mHighCtrl
void OnCtrl(wxCommandEvent &evt)
void ModifySpectralSelection(bool done=false)
static SpectralSelectionBar & Get(AudacityProject &project)
virtual ~SpectralSelectionBar()
void OnFormatsChanged(ProjectNumericFormatsEvent)
wxColour & Colour(int iIndex)
static TrackList & Get(AudacityProject &project)
NotifyingSelectedRegion selectedRegion
static ViewInfo & Get(AudacityProject &project)
static double ProjectNyquistFrequency(const AudacityProject &project)
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
AttachedToolBarMenuItem sAttachment
__finl float_x4 __vecc sqrt(const float_x4 &a)
Options & InvalidValue(bool has, double v=-1.0)