Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
SpectralSelectionBar Class Referencefinal

(not quite a Toolbar) at foot of screen for setting and viewing the frequency selection range. More...

#include <SpectralSelectionBar.h>

Inheritance diagram for SpectralSelectionBar:
[legend]
Collaboration diagram for SpectralSelectionBar:
[legend]

Public Member Functions

 SpectralSelectionBar (AudacityProject &project)
 
virtual ~SpectralSelectionBar ()
 
bool ShownByDefault () const override
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
DockID DefaultDockID () const override
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
void Create (wxWindow *parent) override
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
void SetFrequencies (double bottom, double top)
 
void SetFrequencySelectionFormatName (const NumericFormatID &formatName)
 
void SetBandwidthSelectionFormatName (const NumericFormatID &formatName)
 
void RegenerateTooltips () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
 
virtual ~ToolBar ()
 
virtual bool ShownByDefault () const
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
virtual bool HideAfterReset () const
 Default implementation returns false. More...
 
virtual DockID DefaultDockID () const
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetIndex () const
 Get a value used for computing cascading positions of undocked bars. More...
 
void SetIndex (int index)
 Set a value used for computing cascading positions of undocked bars. More...
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
Identifier GetSection ()
 
ToolDockGetDock ()
 
void SetPreferredNeighbors (Identifier left, Identifier top={})
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
std::pair< Identifier, IdentifierPreferredNeighbors () const noexcept
 Defaults to (NoBarID, NoBarId) More...
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static Identifier ID ()
 
static SpectralSelectionBarGet (AudacityProject &project)
 
static const SpectralSelectionBarGet (const AudacityProject &project)
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static AButtonMakeButton (ToolBar *parent, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const TranslatableString &label)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
 
static void MakeButtonBackgroundsSmall ()
 
static void MakeButtonBackgroundsLarge ()
 

Private Member Functions

void ValuesToControls ()
 
void SetBounds ()
 
void OnFormatsChanged (ProjectNumericFormatsEvent)
 
void OnUpdate (wxCommandEvent &evt)
 
void OnCtrl (wxCommandEvent &evt)
 
void OnChoice (wxCommandEvent &evt)
 
void OnIdle (wxIdleEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 
void ModifySpectralSelection (bool done=false)
 

Private Attributes

Observer::Subscription mFormatsSubscription
 
bool mbCenterAndWidth
 
double mCenter
 
double mWidth
 
double mLow
 
double mHigh
 
NumericTextCtrlmCenterCtrl
 
NumericTextCtrlmWidthCtrl
 
NumericTextCtrlmLowCtrl
 
NumericTextCtrlmHighCtrl
 
wxChoice * mChoice
 
int mHeight
 

Additional Inherited Members

- Public Types inherited from ToolBar
enum  DockID { TopDockID = 1 , BotDockID = 2 }
 Identifies one of the docking areas for toolbars. More...
 
using Holder = wxWindowPtr< ToolBar >
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Populate ()=0
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Static Protected Member Functions inherited from ToolBar
static void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeMacRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
static void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Attributes inherited from ToolBar
AudacityProjectmProject
 
TranslatableString mLabel
 
Identifier mSection
 
int mIndex {0}
 

Detailed Description

(not quite a Toolbar) at foot of screen for setting and viewing the frequency selection range.

Definition at line 29 of file SpectralSelectionBar.h.

Constructor & Destructor Documentation

◆ SpectralSelectionBar()

SpectralSelectionBar::SpectralSelectionBar ( AudacityProject project)

Definition at line 93 of file SpectralSelectionBar.cpp.

94: ToolBar( project, XO("Spectral Selection"), ID() )
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)
98, mChoice(NULL)
99{
102}
XO("Cut/Copy/Paste")
const auto project
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
static ProjectNumericFormats & Get(AudacityProject &project)
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mWidthCtrl
NumericTextCtrl * mLowCtrl
static Identifier ID()
Observer::Subscription mFormatsSubscription
NumericTextCtrl * mHighCtrl
void OnFormatsChanged(ProjectNumericFormatsEvent)
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328

References ProjectNumericFormats::Get(), mFormatsSubscription, OnFormatsChanged(), project, and Observer::Publisher< Message, NotifyAll >::Subscribe().

Here is the call graph for this function:

◆ ~SpectralSelectionBar()

SpectralSelectionBar::~SpectralSelectionBar ( )
virtual

Definition at line 104 of file SpectralSelectionBar.cpp.

105{
106 // Do nothing, sizer deletes the controls
107}

Member Function Documentation

◆ Create()

void SpectralSelectionBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 130 of file SpectralSelectionBar.cpp.

131{
132 ToolBar::Create(parent);
133 UpdatePrefs();
134 mHeight = wxWindowBase::GetSizer()->GetSize().GetHeight();
135}
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492

References ToolBar::Create(), mHeight, and UpdatePrefs().

Here is the call graph for this function:

◆ DefaultDockID()

ToolBar::DockID SpectralSelectionBar::DefaultDockID ( ) const
overridevirtual

Which dock the toolbar defaults into. Default implementation chooses the top dock.

Reimplemented from ToolBar.

Definition at line 114 of file SpectralSelectionBar.cpp.

115{
116 return BotDockID;
117}
@ BotDockID
Definition: ToolBar.h:94

References ToolBar::BotDockID.

◆ EnableDisableButtons()

void SpectralSelectionBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 48 of file SpectralSelectionBar.h.

48{};

◆ Get() [1/2]

SpectralSelectionBar & SpectralSelectionBar::Get ( AudacityProject project)
static

Definition at line 119 of file SpectralSelectionBar.cpp.

120{
121 auto &toolManager = ToolManager::Get( project );
122 return *static_cast<SpectralSelectionBar*>(toolManager.GetToolBar(ID()));
123}
(not quite a Toolbar) at foot of screen for setting and viewing the frequency selection range.
static ToolManager & Get(AudacityProject &project)

References ToolManager::Get(), ID(), and project.

Referenced by Get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [2/2]

const SpectralSelectionBar & SpectralSelectionBar::Get ( const AudacityProject project)
static

Definition at line 125 of file SpectralSelectionBar.cpp.

126{
127 return Get( const_cast<AudacityProject&>( project )) ;
128}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static SpectralSelectionBar & Get(AudacityProject &project)

References Get(), and project.

Here is the call graph for this function:

◆ ID()

Identifier SpectralSelectionBar::ID ( )
static

Definition at line 88 of file SpectralSelectionBar.cpp.

89{
90 return wxT("SpectralSelection");
91}
wxT("CloseDown"))

References wxT().

Referenced by Get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ModifySpectralSelection()

void SpectralSelectionBar::ModifySpectralSelection ( bool  done = false)
private

Definition at line 268 of file SpectralSelectionBar.cpp.

269{
273
274 double bottom, top;
275 if (mbCenterAndWidth) {
278 if ((mCenter < 0 || mWidth < 0) &&
279 (mLow >= 0 || mHigh >= 0))
280 // Transition from defined spectral selection to undefined
282 else if (mCenter < 0 && mWidth < 0)
284 else {
285 if (mCenter < 0) {
286 mWidth = log(std::min(nyq, exp(mWidth)));
287 // Choose arbitrary center for the width
288 mCenter = sqrt(nyq);
289 }
290 else if (mWidth < 0) {
291 mCenter = std::max(1.0, std::min(nyq, mCenter));
292 // Choose arbitrary width for the center
293 const double ratio = std::min(mCenter, nyq / mCenter);
294 mWidth = log(ratio * ratio);
295 }
296 else {
297 mCenter = std::max(1.0, std::min(nyq, mCenter));
298 double ratio = std::min(mCenter, nyq / mCenter);
299 mWidth = std::min(2 * log(ratio), mWidth);
300 }
301
302 const double ratio = exp(mWidth / 2);
303 bottom = mCenter / ratio, top = mCenter * ratio;
304 }
305 }
306 else {
307 bottom = mLowCtrl->GetValue();
308 top = mHighCtrl->GetValue();
309
310 if (bottom >= 0)
311 bottom = std::min(nyq, bottom);
312 else
314
315 if (top >= 0)
316 top = std::min(nyq, top);
317 else
319 // These have to be in the right order.
320 if( bottom > top ){
321 // Oops. We must fix the order.
322 if( mLowCtrl->HasFocus() )
323 top = bottom;
324 else
325 bottom = top;
326 }
327 }
328
329
330 mLow = bottom;
331 mHigh = top;
332 //SetBounds();
333
334 // Notify project and track panel, which may change
335 // the values again, and call back to us in SetFrequencies()
336 manager.ModifySpectralSelection(nyq, bottom, top, done);
337}
int min(int a, int b)
static const AttachedProjectObjects::RegisteredFactory manager
const auto tracks
static ProjectSelectionManager & Get(AudacityProject &project)
static const int UndefinedFrequency
AudacityProject & mProject
Definition: ToolBar.h:248
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
static double ProjectNyquistFrequency(const AudacityProject &project)
Definition: WaveTrack.cpp:358
__finl float_x4 __vecc sqrt(const float_x4 &a)

References ProjectSelectionManager::Get(), TrackList::Get(), NumericConverter::GetValue(), manager, mbCenterAndWidth, mCenter, mCenterCtrl, mHigh, mHighCtrl, min(), mLow, mLowCtrl, ToolBar::mProject, mWidth, mWidthCtrl, WaveTrack::ProjectNyquistFrequency(), staffpad::audio::simd::sqrt(), tracks, and SelectedRegion::UndefinedFrequency.

Referenced by OnCtrl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnChoice()

void SpectralSelectionBar::OnChoice ( wxCommandEvent &  evt)
private

Definition at line 344 of file SpectralSelectionBar.cpp.

345{
346 mbCenterAndWidth = (0 == mChoice->GetSelection());
348 gPrefs->Flush();
349
354
356
357 wxSize sz = GetMinSize();
358 sz.SetWidth(wxDefaultCoord);
359 SetMinSize(sz);
360 Layout();
361 Fit();
362 Updated();
363}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
static const wxString preferencePath(wxT("/GUI/Toolbars/SpectralSelection/CenterAndWidthChoice"))
void Updated()
Definition: ToolBar.cpp:684
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0

References audacity::BasicSettings::Flush(), gPrefs, mbCenterAndWidth, mCenterCtrl, mChoice, mHighCtrl, mLowCtrl, mWidthCtrl, preferencePath(), ToolBar::Updated(), ValuesToControls(), and audacity::BasicSettings::Write().

Here is the call graph for this function:

◆ OnCtrl()

void SpectralSelectionBar::OnCtrl ( wxCommandEvent &  evt)
private

Definition at line 339 of file SpectralSelectionBar.cpp.

340{
341 ModifySpectralSelection(event.GetInt() != 0);
342}
void ModifySpectralSelection(bool done=false)

References ModifySpectralSelection().

Here is the call graph for this function:

◆ OnFormatsChanged()

void SpectralSelectionBar::OnFormatsChanged ( ProjectNumericFormatsEvent  evt)
private

Definition at line 373 of file SpectralSelectionBar.cpp.

374{
375 auto &formats = ProjectNumericFormats::Get(mProject);
376 switch (evt.type) {
379 formats.GetFrequencySelectionFormatName());
382 formats.GetBandwidthSelectionFormatName());
383 default:
384 break;
385 }
386}
void SetBandwidthSelectionFormatName(const NumericFormatID &formatName)
void SetFrequencySelectionFormatName(const NumericFormatID &formatName)
enum ProjectNumericFormatsEvent::Type type

References ProjectNumericFormatsEvent::ChangedBandwidthFormat, ProjectNumericFormatsEvent::ChangedFrequencyFormat, ProjectNumericFormats::Get(), ToolBar::mProject, SetBandwidthSelectionFormatName(), SetFrequencySelectionFormatName(), and ProjectNumericFormatsEvent::type.

Referenced by SpectralSelectionBar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnIdle()

void SpectralSelectionBar::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 365 of file SpectralSelectionBar.cpp.

366{
367 evt.Skip();
368 auto &project = mProject;
369 const auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
370 SetFrequencies( selectedRegion.f0(), selectedRegion.f1() );
371}
void SetFrequencies(double bottom, double top)
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References ViewInfo::Get(), ToolBar::mProject, project, ViewInfo::selectedRegion, and SetFrequencies().

Here is the call graph for this function:

◆ OnSize()

void SpectralSelectionBar::OnSize ( wxSizeEvent &  evt)
private

Definition at line 261 of file SpectralSelectionBar.cpp.

262{
263 Refresh(true);
264
265 evt.Skip();
266}

◆ OnUpdate()

void SpectralSelectionBar::OnUpdate ( wxCommandEvent &  evt)
private

Definition at line 388 of file SpectralSelectionBar.cpp.

389{
390 auto &formats = ProjectNumericFormats::Get(mProject);
391 wxWindow *w = FindFocus();
392 bool centerFocus = (w && w == mCenterCtrl);
393 bool widthFocus = (w && w == mWidthCtrl);
394 bool lowFocus = (w && w == mLowCtrl);
395 bool highFocus = (w && w == mHighCtrl);
396
397 evt.Skip(false);
398
399 // Save formats before recreating the controls so they resize properly
400 wxEventType type = evt.GetEventType();
401 if (type == EVT_FREQUENCYTEXTCTRL_UPDATED) {
402 formats.SetFrequencySelectionFormatName(evt.GetString());
403 // Then my subscription is called
404 }
405 else if (mbCenterAndWidth &&
406 type == EVT_BANDWIDTHTEXTCTRL_UPDATED) {
407 formats.SetBandwidthSelectionFormatName(evt.GetString());
408 // Then my subscription is called
409 }
410
411 // ReCreateButtons() will get rid of our sizers and controls
412 // so reset pointers first.
413 mCenterCtrl = mWidthCtrl = NULL;
414 mLowCtrl = mHighCtrl = NULL;
415
418
419
420 if (centerFocus) {
421 mCenterCtrl->SetFocus();
422 }
423 else if (widthFocus) {
424 mWidthCtrl->SetFocus();
425 }
426 else if (lowFocus) {
427 mLowCtrl->SetFocus();
428 }
429 else if (highFocus) {
430 mHighCtrl->SetFocus();
431 }
432
433 Updated();
434}
virtual void ReCreateButtons()
Definition: ToolBar.cpp:533
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:375

References BasicUI::FindFocus(), ProjectNumericFormats::Get(), mbCenterAndWidth, mCenterCtrl, mHighCtrl, mLowCtrl, ToolBar::mProject, mWidthCtrl, ToolBar::ReCreateButtons(), ToolBar::Updated(), and ValuesToControls().

Referenced by SetBandwidthSelectionFormatName(), SetFrequencySelectionFormatName(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Populate()

void SpectralSelectionBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 137 of file SpectralSelectionBar.cpp.

138{
139 SetBackgroundColour( theTheme.Colour( clrMedium ) );
141
142 auto &formats = ProjectNumericFormats::Get(mProject);
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);
147
148 //
149 // Top row, choice box
150 //
151
152 const wxString choices[2] = {
153 _("Center frequency and Width"),
154 _("Low and High Frequencies"),
155 };
156 mChoice = safenew wxChoice
157 (this, OnChoiceID, wxDefaultPosition, wxDefaultSize, 2, choices,
158 0, wxDefaultValidator, _("Show"));
159 mChoice->SetSelection(mbCenterAndWidth ? 0 : 1);
160#if wxUSE_ACCESSIBILITY
161 // so that name can be set on a standard control
162 mChoice->SetAccessible(safenew WindowAccessible(mChoice));
163#endif
164 mChoice->SetMinSize(wxSize(mChoice->GetBestSize().x, toolbarSingle));
165
166 mainSizer->Add(mChoice, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 6);
167
168 //
169 // Bottom row, split into two columns, each with one control
170 //
171
172 {
173 auto subSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
174
176 this, OnCenterID,
177 NumericConverterType_FREQUENCY(), frequencyFormatName, 0.0,
180 );
181 mCenterCtrl->SetName( XO("Center Frequency") );
182 subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
183
186 this, OnWidthID,
187 NumericConverterType_BANDWIDTH(), bandwidthFormatName, 0.0,
189 .InvalidValue( true, -1.0 )
190 );
191 mWidthCtrl->SetName( XO("Bandwidth") );
192 subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
193
196 this, OnLowID,
197 NumericConverterType_FREQUENCY(), frequencyFormatName, 0.0,
200 );
201 mLowCtrl->SetName( XO("Low Frequency") );
202 subSizer->Add(mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
203
206 this, OnHighID,
207 NumericConverterType_FREQUENCY(), frequencyFormatName, 0.0,
210 );
211 mHighCtrl->SetName( XO("High Frequency") );
212 subSizer->Add(mHighCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
213
218
219 mainSizer->Add(subSizer.release(), 0, wxALIGN_TOP, 0);
220 }
221
222 mainSizer->Layout();
223
224 Layout();
225
226 CallAfter([this]{
227 auto &formats = ProjectNumericFormats::Get(mProject);
229 formats.GetFrequencySelectionFormatName());
231 formats.GetBandwidthSelectionFormatName());
232 });
233}
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:10
const NumericConverterType & NumericConverterType_BANDWIDTH()
const NumericConverterType & NumericConverterType_FREQUENCY()
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define toolbarSingle
Definition: ToolBar.h:59
static FormatterContext ProjectContext(const AudacityProject &project)
bool Layout() override
void SetName(const TranslatableString &name)
wxColour & Colour(int iIndex)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:709
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
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.
Definition: BasicUI.cpp:213
Options & InvalidValue(bool has, double v=-1.0)

References _, ToolBar::Add(), BasicUI::CallAfter(), ThemeBase::Colour(), ProjectNumericFormats::Get(), gPrefs, NumericTextCtrl::Options::InvalidValue(), NumericTextCtrl::Layout(), mbCenterAndWidth, mCenterCtrl, mChoice, mHighCtrl, mLowCtrl, ToolBar::mProject, mWidthCtrl, NumericConverterType_BANDWIDTH(), NumericConverterType_FREQUENCY(), OnCenterID, OnChoiceID, OnHighID, OnLowID, OnWidthID, preferencePath(), FormatterContext::ProjectContext(), audacity::BasicSettings::Read(), safenew, SetBandwidthSelectionFormatName(), SetFrequencySelectionFormatName(), NumericTextCtrl::SetName(), theTheme, toolbarSingle, SelectedRegion::UndefinedFrequency, and XO().

Here is the call graph for this function:

◆ RegenerateTooltips()

void SpectralSelectionBar::RegenerateTooltips ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 55 of file SpectralSelectionBar.h.

55{};

Referenced by UpdatePrefs().

Here is the caller graph for this function:

◆ Repaint()

void SpectralSelectionBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 47 of file SpectralSelectionBar.h.

47{};

◆ SetBandwidthSelectionFormatName()

void SpectralSelectionBar::SetBandwidthSelectionFormatName ( const NumericFormatID formatName)

Definition at line 497 of file SpectralSelectionBar.cpp.

499{
500 if (mbCenterAndWidth) {
501 bool changed =
502 mWidthCtrl->SetFormatName(formatName);
503 // Test first whether changed, to avoid infinite recursion from OnUpdate
504 if (changed) {
505 wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
506 e.SetString(mWidthCtrl->GetFormatName().GET());
507 OnUpdate(e);
508 }
509 }
510}
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
NumericFormatID GetFormatName() const
bool SetFormatName(const NumericFormatID &formatName)
void OnUpdate(wxCommandEvent &evt)

References Identifier::GET(), NumericConverter::GetFormatName(), mbCenterAndWidth, mWidthCtrl, OnUpdate(), and NumericTextCtrl::SetFormatName().

Referenced by OnFormatsChanged(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBounds()

void SpectralSelectionBar::SetBounds ( )
private

Definition at line 455 of file SpectralSelectionBar.cpp.

456{
457 if (mHigh >= 0)
459 else
461
462 if (mLow >= 0)
464 else
466}
void SetMinValue(double minValue)
void SetMaxValue(double maxValue)

References mHigh, mHighCtrl, mLow, mLowCtrl, NumericConverter::ResetMaxValue(), NumericConverter::ResetMinValue(), NumericConverter::SetMaxValue(), and NumericConverter::SetMinValue().

Here is the call graph for this function:

◆ SetFrequencies()

void SpectralSelectionBar::SetFrequencies ( double  bottom,
double  top 
)

Definition at line 468 of file SpectralSelectionBar.cpp.

469{
470 if ( mLow != bottom || mHigh != top ) {
471 mLow = bottom;
472 mHigh = top;
473
474 if (bottom > 0 && top >= bottom)
475 mWidth = log(top / bottom), mCenter = sqrt(top * bottom);
476 else
477 mWidth = mCenter = -1.0;
478
480 }
481}

References mCenter, mHigh, mLow, mWidth, staffpad::audio::simd::sqrt(), and ValuesToControls().

Referenced by OnIdle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFrequencySelectionFormatName()

void SpectralSelectionBar::SetFrequencySelectionFormatName ( const NumericFormatID formatName)

Definition at line 483 of file SpectralSelectionBar.cpp.

485{
487 bool changed =
488 frequencyCtrl->SetFormatName(formatName);
489 // Test first whether changed, to avoid infinite recursion from OnUpdate
490 if (changed) {
491 wxCommandEvent e(EVT_FREQUENCYTEXTCTRL_UPDATED);
492 e.SetString(frequencyCtrl->GetFormatName().GET());
493 OnUpdate(e);
494 }
495}

References Identifier::GET(), NumericConverter::GetFormatName(), mbCenterAndWidth, mCenterCtrl, mLowCtrl, OnUpdate(), and NumericTextCtrl::SetFormatName().

Referenced by OnFormatsChanged(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShownByDefault()

bool SpectralSelectionBar::ShownByDefault ( ) const
overridevirtual

Whether the toolbar should be shown by default. Default implementation returns true.

Reimplemented from ToolBar.

Definition at line 109 of file SpectralSelectionBar.cpp.

110{
111 return false;
112}

◆ UpdatePrefs()

void SpectralSelectionBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 235 of file SpectralSelectionBar.cpp.

236{
237 {
238 wxCommandEvent e(EVT_FREQUENCYTEXTCTRL_UPDATED);
239 e.SetString(
241 ->GetFormatName().GET());
242 OnUpdate(e);
243 }
244
246 {
247 wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
248 e.SetString(mWidthCtrl->GetFormatName().GET());
249 OnUpdate(e);
250 }
251
252 // Set label to pull in language change
253 SetLabel(XO("Spectral Selection"));
254
256
257 // Give base class a chance
259}
void RegenerateTooltips() override
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
void UpdatePrefs() override
Definition: ToolBar.cpp:622

References Identifier::GET(), NumericConverter::GetFormatName(), mbCenterAndWidth, mCenterCtrl, mLowCtrl, mWidthCtrl, OnUpdate(), RegenerateTooltips(), ToolBar::SetLabel(), ToolBar::UpdatePrefs(), and XO().

Referenced by Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ValuesToControls()

void SpectralSelectionBar::ValuesToControls ( )
private

Definition at line 436 of file SpectralSelectionBar.cpp.

437{
438 if (mbCenterAndWidth) {
441 }
442 else {
443 //Bug 1633
444 //The controls may not be able to show mHigh, e.g.
445 //if set to Hz, and in that case we should either show invalid
446 //or 'do the best we can' and truncate.
447 //If we set bounds we instead clip to the mHigh to mLow,
448 //So no SetBounds, for now.
449 //SetBounds();
452 }
453}
void SetValue(double newValue)

References mbCenterAndWidth, mCenter, mCenterCtrl, mHigh, mHighCtrl, mLow, mLowCtrl, mWidth, mWidthCtrl, and NumericTextCtrl::SetValue().

Referenced by OnChoice(), OnUpdate(), and SetFrequencies().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mbCenterAndWidth

bool SpectralSelectionBar::mbCenterAndWidth
private

◆ mCenter

double SpectralSelectionBar::mCenter
private

◆ mCenterCtrl

NumericTextCtrl* SpectralSelectionBar::mCenterCtrl
private

◆ mChoice

wxChoice* SpectralSelectionBar::mChoice
private

Definition at line 81 of file SpectralSelectionBar.h.

Referenced by OnChoice(), and Populate().

◆ mFormatsSubscription

Observer::Subscription SpectralSelectionBar::mFormatsSubscription
private

Definition at line 71 of file SpectralSelectionBar.h.

Referenced by SpectralSelectionBar().

◆ mHeight

int SpectralSelectionBar::mHeight
private

Definition at line 83 of file SpectralSelectionBar.h.

Referenced by Create().

◆ mHigh

double SpectralSelectionBar::mHigh
private

◆ mHighCtrl

NumericTextCtrl * SpectralSelectionBar::mHighCtrl
private

◆ mLow

double SpectralSelectionBar::mLow
private

◆ mLowCtrl

NumericTextCtrl * SpectralSelectionBar::mLowCtrl
private

◆ mWidth

double SpectralSelectionBar::mWidth
private

◆ mWidthCtrl

NumericTextCtrl * SpectralSelectionBar::mWidthCtrl
private

The documentation for this class was generated from the following files: