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

A ToolBar that holds the VU Meter. More...

#include <MeterToolBar.h>

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

Public Member Functions

 MeterToolBar (AudacityProject &project, unsigned whichMeters, const TranslatableString &label, Identifier ID)
 
virtual ~MeterToolBar ()
 
bool ShownByDefault () const override
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
void Create (wxWindow *parent) override
 
void Populate () override
 
void ReCreateButtons () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
void UpdateControls ()
 
void OnSize (wxSizeEvent &event)
 
bool Expose (bool show) override
 
int GetInitialWidth () override
 Resizable toolbars should implement these. More...
 
int GetMinToolbarWidth () override
 
wxSize GetDockedSize () override
 
void ShowOutputGainDialog ()
 
void ShowInputGainDialog ()
 
void AdjustOutputGain (int adj)
 
void AdjustInputGain (int adj)
 
- 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 ()
 Methods for MeterToolBar. More...
 
static Identifier PlayID ()
 
static Identifier RecordID ()
 
static MeterToolBars GetToolBars (AudacityProject &project)
 
static ConstMeterToolBars GetToolBars (const AudacityProject &project)
 
static MeterToolBarGet (AudacityProject &project, bool forPlayMeterToolBar)
 
static const MeterToolBarGet (const AudacityProject &project, bool forPlayMeterToolBar)
 
- 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 RegenerateTooltips () override
 
void RebuildLayout (bool force)
 

Private Attributes

unsigned mWhichMeters
 
wxBoxSizer * mRootSizer {nullptr}
 
AButtonmPlaySetupButton {nullptr}
 
MeterPanelmPlayMeter {nullptr}
 
AButtonmRecordSetupButton {nullptr}
 
MeterPanelmRecordMeter {nullptr}
 

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

A ToolBar that holds the VU Meter.

Definition at line 38 of file MeterToolBar.h.

Constructor & Destructor Documentation

◆ MeterToolBar()

MeterToolBar::MeterToolBar ( AudacityProject project,
unsigned  whichMeters,
const TranslatableString label,
Identifier  ID 
)

Definition at line 148 of file MeterToolBar.cpp.

151: ToolBar(project, label, ID, true)
152, mWhichMeters{ whichMeters }
153{
154}
TranslatableString label
Definition: TagsEditor.cpp:165
const auto project
static Identifier ID()
Methods for MeterToolBar.
unsigned mWhichMeters
Definition: MeterToolBar.h:87
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328

◆ ~MeterToolBar()

MeterToolBar::~MeterToolBar ( )
virtual

Definition at line 156 of file MeterToolBar.cpp.

157{
158}

Member Function Documentation

◆ AdjustInputGain()

void MeterToolBar::AdjustInputGain ( int  adj)

Definition at line 490 of file MeterToolBar.cpp.

491{
492 if (adj < 0) {
493 mRecordMeter->Decrease(-adj);
494 }
495 else {
497 }
498
500}
void Decrease(float steps)
Definition: MeterPanel.cpp:888
void Increase(float steps)
Definition: MeterPanel.cpp:877
void UpdateSliderControl()
Definition: MeterPanel.cpp:478
MeterPanel * mRecordMeter
Definition: MeterToolBar.h:92

References MeterPanel::Decrease(), MeterPanel::Increase(), mRecordMeter, and MeterPanel::UpdateSliderControl().

Here is the call graph for this function:

◆ AdjustOutputGain()

void MeterToolBar::AdjustOutputGain ( int  adj)

Definition at line 478 of file MeterToolBar.cpp.

479{
480 if (adj < 0) {
481 mPlayMeter->Decrease(-adj);
482 }
483 else {
484 mPlayMeter->Increase(adj);
485 }
486
488}
MeterPanel * mPlayMeter
Definition: MeterToolBar.h:90

References MeterPanel::Decrease(), MeterPanel::Increase(), mPlayMeter, and MeterPanel::UpdateSliderControl().

Here is the call graph for this function:

◆ Create()

void MeterToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 194 of file MeterToolBar.cpp.

195{
196 ToolBar::Create(parent);
197
198 UpdatePrefs();
199
200 // Simulate a size event to set initial meter placement/size
201 wxSizeEvent dummy;
202 OnSize(dummy);
203}
void UpdatePrefs() override
void OnSize(wxSizeEvent &event)
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492

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

Here is the call graph for this function:

◆ EnableDisableButtons()

void MeterToolBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 64 of file MeterToolBar.h.

64{};

◆ Expose()

bool MeterToolBar::Expose ( bool  show)
overridevirtual

Reimplemented from ToolBar.

Definition at line 434 of file MeterToolBar.cpp.

435{
436 auto &projectAudioIO = ProjectAudioIO::Get( mProject );
437 if( show ) {
438 if( mPlayMeter ) {
439 projectAudioIO.SetPlaybackMeter( mPlayMeter->GetMeter() );
440 }
441
442 if( mRecordMeter ) {
443 projectAudioIO.SetCaptureMeter( mRecordMeter->GetMeter() );
444 }
445 } else {
446 if( mPlayMeter &&
447 projectAudioIO.GetPlaybackMeter() == mPlayMeter->GetMeter() ) {
448 projectAudioIO.SetPlaybackMeter( nullptr );
449 }
450
451 if( mRecordMeter &&
452 projectAudioIO.GetCaptureMeter() == mRecordMeter->GetMeter() ) {
453 projectAudioIO.SetCaptureMeter( nullptr );
454 }
455 }
456
457 return ToolBar::Expose( show );
458}
std::shared_ptr< Meter > GetMeter() const
static ProjectAudioIO & Get(AudacityProject &project)
AudacityProject & mProject
Definition: ToolBar.h:248
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:459

References ToolBar::Expose(), ProjectAudioIO::Get(), MeterPanelBase::GetMeter(), mPlayMeter, ToolBar::mProject, and mRecordMeter.

Here is the call graph for this function:

◆ Get() [1/2]

MeterToolBar & MeterToolBar::Get ( AudacityProject project,
bool  forPlayMeterToolBar 
)
static

Definition at line 176 of file MeterToolBar.cpp.

177{
178 auto& toolManager = ToolManager::Get(project);
179 const auto &toolBarID = forPlayMeterToolBar ? PlayID() : RecordID();
180 return *static_cast<MeterToolBar*>(toolManager.GetToolBar(toolBarID));
181}
A ToolBar that holds the VU Meter.
Definition: MeterToolBar.h:38
static Identifier PlayID()
static Identifier RecordID()
static ToolManager & Get(AudacityProject &project)

References ToolManager::Get(), PlayID(), project, and RecordID().

Referenced by Get(), GetToolBars(), anonymous_namespace{MeterToolBar.cpp}::OnInputGain(), anonymous_namespace{MeterToolBar.cpp}::OnInputGainDec(), anonymous_namespace{MeterToolBar.cpp}::OnInputGainInc(), anonymous_namespace{MeterToolBar.cpp}::OnOutputGain(), anonymous_namespace{MeterToolBar.cpp}::OnOutputGainDec(), and anonymous_namespace{MeterToolBar.cpp}::OnOutputGainInc().

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

◆ Get() [2/2]

const MeterToolBar & MeterToolBar::Get ( const AudacityProject project,
bool  forPlayMeterToolBar 
)
static

Definition at line 183 of file MeterToolBar.cpp.

184{
185 return Get(const_cast<AudacityProject&>(project), forPlayMeterToolBar);
186}
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 MeterToolBar & Get(AudacityProject &project, bool forPlayMeterToolBar)

References Get(), and project.

Here is the call graph for this function:

◆ GetDockedSize()

wxSize MeterToolBar::GetDockedSize ( )
inlineoverridevirtual

Reimplemented from ToolBar.

Definition at line 73 of file MeterToolBar.h.

73 {
74 return GetSmartDockedSize();
75 };
wxSize GetSmartDockedSize()
Definition: ToolBar.cpp:520

References ToolBar::GetSmartDockedSize().

Here is the call graph for this function:

◆ GetInitialWidth()

int MeterToolBar::GetInitialWidth ( )
overridevirtual

Resizable toolbars should implement these.

Reimplemented from ToolBar.

Definition at line 460 of file MeterToolBar.cpp.

461{
462 return (mWhichMeters ==
463 (kWithRecordMeter + kWithPlayMeter)) ? 338 : 290;
464}
constexpr int kWithPlayMeter
Definition: MeterToolBar.h:35
constexpr int kWithRecordMeter
Definition: MeterToolBar.h:34

References kWithPlayMeter, kWithRecordMeter, and mWhichMeters.

◆ GetMinToolbarWidth()

int MeterToolBar::GetMinToolbarWidth ( )
inlineoverridevirtual

Reimplemented from ToolBar.

Definition at line 72 of file MeterToolBar.h.

72{ return 150; }

◆ GetToolBars() [1/2]

MeterToolBars MeterToolBar::GetToolBars ( AudacityProject project)
static

Definition at line 160 of file MeterToolBar.cpp.

161{
162 return MeterToolBars{
163 Get(project, true),
164 Get(project, false)
165 };
166}
std::vector< std::reference_wrapper< MeterToolBar > > MeterToolBars
Definition: MeterToolBar.h:30

References Get(), and project.

Referenced by ProjectManager::OnTimer().

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

◆ GetToolBars() [2/2]

ConstMeterToolBars MeterToolBar::GetToolBars ( const AudacityProject project)
static

Definition at line 168 of file MeterToolBar.cpp.

169{
170 return ConstMeterToolBars{
171 Get(project, true),
172 Get(project, false)
173 };
174}
std::vector< std::reference_wrapper< const MeterToolBar > > ConstMeterToolBars
Definition: MeterToolBar.h:31

References Get(), and project.

Here is the call graph for this function:

◆ ID()

Identifier MeterToolBar::ID ( )
static

Methods for MeterToolBar.

Definition at line 132 of file MeterToolBar.cpp.

133{
134 return wxT("CombinedMeter");
135}
wxT("CloseDown"))

References wxT().

Here is the call graph for this function:

◆ OnSize()

void MeterToolBar::OnSize ( wxSizeEvent &  event)

Definition at line 425 of file MeterToolBar.cpp.

426{
427 event.Skip();
428
429 if(mRootSizer == nullptr)
430 return;// We can be resized before populating...protect against it
431 RebuildLayout(false);
432}
void RebuildLayout(bool force)
wxBoxSizer * mRootSizer
Definition: MeterToolBar.h:88

References mRootSizer, and RebuildLayout().

Referenced by Create().

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

◆ PlayID()

Identifier MeterToolBar::PlayID ( )
static

Definition at line 137 of file MeterToolBar.cpp.

138{
139 return wxT("PlayMeter");
140}

References wxT().

Referenced by Get().

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

◆ Populate()

void MeterToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 236 of file MeterToolBar.cpp.

237{
239 SetBackgroundColour( theTheme.Colour( clrMedium ) );
240
242 //JKC: Record on left, playback on right. Left to right flow
243 //(maybe we should do it differently for Arabic language :-) )
246 mRecordSetupButton->SetName(_("Record Meter"));
247 mRecordSetupButton->SetToolTip(XO("Record Meter"));
249 theTheme.Image(bmpRecoloredUpSmall),
250 theTheme.Image(bmpRecoloredUpHiliteSmall),
251 theTheme.Image(bmpRecoloredDownSmall),
252 theTheme.Image(bmpRecoloredHiliteSmall),
253 theTheme.Image(bmpRecoloredUpSmall));
255 mRecordSetupButton->SetButtonType(AButton::Type::FrameButton);
257
259 this,
260 wxID_ANY,
261 true,
262 wxDefaultPosition,
263 wxSize( 260, toolbarSingle) );
264 /* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.*/
265 mRecordMeter->SetName( XO("Recording Level"));
266 /* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.
267 This is the name used in screen reader software, where having 'Meter' first
268 apparently is helpful to partially sighted people. */
269 mRecordMeter->SetLabel( XO("Meter-Record") );
270
271#if wxUSE_ACCESSIBILITY
272 auto meterButtonAcc = safenew MeterButtonAx(*mRecordSetupButton, *mRecordMeter);
273#endif
274 mRecordSetupButton->Bind(wxEVT_BUTTON, [=](wxCommandEvent&)
275 {
276#if wxUSE_ACCESSIBILITY
277 meterButtonAcc->SetSilent(true);
278#endif
280 mRecordMeter->ScreenToClient(
281 ClientToScreen(mRecordSetupButton->GetClientRect().GetBottomLeft())
282 )
283 );
284#if wxUSE_ACCESSIBILITY
285 /* if stop/start monitoring was chosen in the menu, then by this point
286 OnMonitoring has been called and variables which affect the accessibility
287 name have been updated so it's now ok for screen readers to read the name of
288 the button */
289 meterButtonAcc->SetSilent(false);
290#endif
291 });
292 }
293
297 mPlaySetupButton->SetName(_("Playback Meter"));
298 mPlaySetupButton->SetToolTip(XO("Playback Meter"));
300 theTheme.Image(bmpRecoloredUpSmall),
301 theTheme.Image(bmpRecoloredUpHiliteSmall),
302 theTheme.Image(bmpRecoloredDownSmall),
303 theTheme.Image(bmpRecoloredHiliteSmall),
304 theTheme.Image(bmpRecoloredUpSmall));
306 mPlaySetupButton->SetButtonType(AButton::Type::FrameButton);
308
309
311 this,
312 wxID_ANY,
313 false,
314 wxDefaultPosition,
315 wxSize( 260, toolbarSingle ) );
316 /* i18n-hint: (noun) The meter that shows the loudness of the audio playing.*/
317 mPlayMeter->SetName( XO("Playback Level"));
318 /* i18n-hint: (noun) The meter that shows the loudness of the audio playing.
319 This is the name used in screen reader software, where having 'Meter' first
320 apparently is helpful to partially sighted people. */
321 mPlayMeter->SetLabel( XO("Meter-Play"));
322
323#if wxUSE_ACCESSIBILITY
324 auto meterButtonAcc = safenew MeterButtonAx(*mPlaySetupButton, *mPlayMeter);
325#endif
326 mPlaySetupButton->Bind(wxEVT_BUTTON, [=](wxCommandEvent&)
327 {
328#if wxUSE_ACCESSIBILITY
329 meterButtonAcc->SetSilent(true);
330#endif
332 mPlayMeter->ScreenToClient(
333 ClientToScreen(mPlaySetupButton->GetClientRect().GetBottomLeft())
334 )
335 );
336#if wxUSE_ACCESSIBILITY
337 meterButtonAcc->SetSilent(false);
338#endif
339 });
340 }
341
342 RebuildLayout(true);
343
345
346 Layout();
347}
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:9
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define toolbarSingle
Definition: ToolBar.h:59
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
void SetButtonType(Type type)
Definition: AButton.cpp:147
void SetImages(const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
Definition: AButton.cpp:205
void SetToolTip(const TranslatableString &toolTip)
Definition: AButton.cpp:184
void SetIcon(const wxImage &icon)
Definition: AButton.cpp:226
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:189
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: MeterPanel.h:104
void ShowMenu(const wxPoint &pos)
void SetName(const TranslatableString &name)
AButton * mRecordSetupButton
Definition: MeterToolBar.h:91
void RegenerateTooltips() override
Definition: MeterToolBar.h:84
AButton * mPlaySetupButton
Definition: MeterToolBar.h:89
wxColour & Colour(int iIndex)
wxImage & Image(int iIndex)
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:837
void SetLabel(const TranslatableString &label)

References _, ThemeBase::Colour(), ThemeBase::Image(), kWithPlayMeter, kWithRecordMeter, ToolBar::MakeButtonBackgroundsSmall(), mPlayMeter, mPlaySetupButton, ToolBar::mProject, mRecordMeter, mRecordSetupButton, mWhichMeters, RebuildLayout(), RegenerateTooltips(), safenew, AButton::SetButtonType(), AButton::SetIcon(), AButton::SetImages(), wxPanelWrapper::SetLabel(), AButton::SetLabel(), MeterPanel::SetName(), AButton::SetToolTip(), MeterPanel::ShowMenu(), theTheme, toolbarSingle, and XO().

Here is the call graph for this function:

◆ RebuildLayout()

void MeterToolBar::RebuildLayout ( bool  force)
private

Definition at line 376 of file MeterToolBar.cpp.

377{
378 const auto size = GetSize();
379 const auto isHorizontal = size.x > size.y;
380
381 if(!force)
382 {
383 const auto sizerOrientation = mWhichMeters == kCombinedMeter
384 ? (isHorizontal ? wxVERTICAL : wxHORIZONTAL)
385 : (isHorizontal ? wxHORIZONTAL : wxVERTICAL);
386
387 if(mRootSizer->GetOrientation() == sizerOrientation)
388 {
389 Layout();
390 return;
391 }
392 }
393
394 if(mRootSizer != nullptr)
395 GetSizer()->Remove(mRootSizer);
396
397 std::unique_ptr<wxBoxSizer> playBarSizer;
398 std::unique_ptr<wxBoxSizer> recordBarSizer;
400 {
401 playBarSizer = std::make_unique<wxBoxSizer>(isHorizontal ? wxHORIZONTAL : wxVERTICAL);
402 playBarSizer->Add(mPlaySetupButton, 0, wxEXPAND);
403 playBarSizer->Add(mPlayMeter, 1, wxEXPAND);
404 }
406 {
407 recordBarSizer = std::make_unique<wxBoxSizer>(isHorizontal ? wxHORIZONTAL : wxVERTICAL);
408 recordBarSizer->Add(mRecordSetupButton, 0, wxEXPAND);
409 recordBarSizer->Add(mRecordMeter, 1, wxEXPAND);
410 }
411
412 if(playBarSizer && recordBarSizer)
413 {
414 Add(mRootSizer = safenew wxBoxSizer(isHorizontal ? wxVERTICAL : wxHORIZONTAL), 1, wxEXPAND);
415 mRootSizer->Add(playBarSizer.release());
416 mRootSizer->Add(recordBarSizer.release());
417 }
418 else if(playBarSizer)
419 Add(mRootSizer = playBarSizer.release(), 1, wxEXPAND);
420 else if(recordBarSizer)
421 Add(mRootSizer = recordBarSizer.release(), 1, wxEXPAND);
422}
constexpr int kCombinedMeter
Definition: MeterToolBar.h:36
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:709
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:701

References ToolBar::Add(), ToolBar::GetSizer(), kCombinedMeter, kWithPlayMeter, kWithRecordMeter, mPlayMeter, mPlaySetupButton, mRecordMeter, mRecordSetupButton, mRootSizer, mWhichMeters, safenew, and size.

Referenced by OnSize(), and Populate().

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

◆ RecordID()

Identifier MeterToolBar::RecordID ( )
static

Definition at line 142 of file MeterToolBar.cpp.

143{
144 return wxT("RecordMeter");
145}

References wxT().

Referenced by Get().

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

◆ ReCreateButtons()

void MeterToolBar::ReCreateButtons ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 205 of file MeterToolBar.cpp.

206{
207 MeterPanel::State playState{ false }, recordState{ false };
208
209 auto &projectAudioIO = ProjectAudioIO::Get( mProject );
210 if (mPlayMeter &&
211 projectAudioIO.GetPlaybackMeter() == mPlayMeter->GetMeter())
212 {
213 playState = mPlayMeter->SaveState();
214 projectAudioIO.SetPlaybackMeter( nullptr );
215 }
216
217 if (mRecordMeter &&
218 projectAudioIO.GetCaptureMeter() == mRecordMeter->GetMeter())
219 {
220 recordState = mRecordMeter->SaveState();
221 projectAudioIO.SetCaptureMeter( nullptr );
222 }
223
225
226 mPlayMeter->RestoreState(playState);
227 if( playState.mSaved ){
228 projectAudioIO.SetPlaybackMeter( mPlayMeter->GetMeter() );
229 }
230 mRecordMeter->RestoreState(recordState);
231 if( recordState.mSaved ){
232 projectAudioIO.SetCaptureMeter( mRecordMeter->GetMeter() );
233 }
234}
State SaveState()
void RestoreState(const State &state)
virtual void ReCreateButtons()
Definition: ToolBar.cpp:533

References ProjectAudioIO::Get(), MeterPanelBase::GetMeter(), mPlayMeter, ToolBar::mProject, mRecordMeter, ToolBar::ReCreateButtons(), MeterPanel::RestoreState(), and MeterPanel::SaveState().

Here is the call graph for this function:

◆ RegenerateTooltips()

void MeterToolBar::RegenerateTooltips ( )
inlineoverrideprivatevirtual

Implements ToolBar.

Definition at line 84 of file MeterToolBar.h.

84{}

Referenced by Populate(), and UpdatePrefs().

Here is the caller graph for this function:

◆ Repaint()

void MeterToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 63 of file MeterToolBar.h.

63{};

◆ ShowInputGainDialog()

void MeterToolBar::ShowInputGainDialog ( )

Definition at line 472 of file MeterToolBar.cpp.

References mRecordMeter, MeterPanel::ShowDialog(), and MeterPanel::UpdateSliderControl().

Here is the call graph for this function:

◆ ShownByDefault()

bool MeterToolBar::ShownByDefault ( ) const
overridevirtual

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

Reimplemented from ToolBar.

Definition at line 188 of file MeterToolBar.cpp.

189{
190 // The combined meter hides by default
192}

References kWithPlayMeter, kWithRecordMeter, and mWhichMeters.

◆ ShowOutputGainDialog()

void MeterToolBar::ShowOutputGainDialog ( )

Definition at line 466 of file MeterToolBar.cpp.

References mPlayMeter, MeterPanel::ShowDialog(), and MeterPanel::UpdateSliderControl().

Here is the call graph for this function:

◆ UpdateControls()

void MeterToolBar::UpdateControls ( )

Definition at line 367 of file MeterToolBar.cpp.

368{
369 if ( mPlayMeter )
371
372 if ( mRecordMeter )
374}

References mPlayMeter, mRecordMeter, and MeterPanel::UpdateSliderControl().

Here is the call graph for this function:

◆ UpdatePrefs()

void MeterToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 349 of file MeterToolBar.cpp.

350{
352
353 // Since the same widget is provides both the Recording Meter as
354 // well as the Playback Meter, we choose an appropriate label
355 // based on which it is
357 ? XO("Recording Meter")
358 : XO("Playback Meter");
359
360 // Set label to pull in language change
362
363 // Give base class a chance
365}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
void UpdatePrefs() override
Definition: ToolBar.cpp:622

References kWithRecordMeter, label, mWhichMeters, 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:

Member Data Documentation

◆ mPlayMeter

MeterPanel* MeterToolBar::mPlayMeter {nullptr}
private

◆ mPlaySetupButton

AButton* MeterToolBar::mPlaySetupButton {nullptr}
private

Definition at line 89 of file MeterToolBar.h.

Referenced by Populate(), and RebuildLayout().

◆ mRecordMeter

MeterPanel* MeterToolBar::mRecordMeter {nullptr}
private

◆ mRecordSetupButton

AButton* MeterToolBar::mRecordSetupButton {nullptr}
private

Definition at line 91 of file MeterToolBar.h.

Referenced by Populate(), and RebuildLayout().

◆ mRootSizer

wxBoxSizer* MeterToolBar::mRootSizer {nullptr}
private

Definition at line 88 of file MeterToolBar.h.

Referenced by OnSize(), and RebuildLayout().

◆ mWhichMeters

unsigned MeterToolBar::mWhichMeters
private

Definition at line 87 of file MeterToolBar.h.

Referenced by GetInitialWidth(), Populate(), RebuildLayout(), ShownByDefault(), and UpdatePrefs().


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