Audacity  2.2.2
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:
ToolBar wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 MeterToolBar (AudacityProject *project, int type)
 Methods for MeterToolBar. More...
 
virtual ~MeterToolBar ()
 
void Create (wxWindow *parent) override
 
void Populate () override
 
void ReCreateButtons () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
void OnSize (wxSizeEvent &event)
 
bool Expose (bool show) override
 
int GetInitialWidth () override
 Resizable toolbars should implement these. More...
 
int GetMinToolbarWidth () override
 
wxSize GetDockedSize () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (int type, const wxString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
int GetType ()
 
wxString GetTitle ()
 
wxString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const wxString &label) override
 
void SetDocked (ToolDock *dock, bool pushed)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
- 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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void RegenerateTooltips () override
 

Private Attributes

AudacityProjectmProject
 
int mWhichMeters
 
wxGridBagSizer * mSizer
 
MeterPanelmPlayMeter
 
MeterPanelmRecordMeter
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = Destroy_ptr< ToolBar >
 
- 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 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 (AButton &button, const TranslatedInternalString commands[], size_t nCommands)
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeButtonBackgroundsLarge ()
 
void MakeButtonBackgroundsSmall ()
 
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 Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Attributes inherited from ToolBar
wxString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

A ToolBar that holds the VU Meter.

Definition at line 32 of file MeterToolBar.h.

Constructor & Destructor Documentation

MeterToolBar::MeterToolBar ( AudacityProject project,
int  type 
)

Methods for MeterToolBar.

Definition at line 50 of file MeterToolBar.cpp.

References _(), kWithPlayMeter, kWithRecordMeter, PlayMeterBarID, and RecordMeterBarID.

51 : ToolBar(type, _("Combined Meter"), wxT("CombinedMeter"), true)
52 {
53  mProject = project;
54 
55  if( mType == RecordMeterBarID ){
57  mLabel = _("Recording Meter");
58  mSection = wxT("RecordMeter");
59  } else if( mType == PlayMeterBarID ){
61  mLabel = _("Playback Meter");
62  mSection = wxT("PlayMeter");
63  } else {
65  }
66  mSizer = NULL;
67  mPlayMeter = NULL;
68  mRecordMeter = NULL;
69 }
MeterPanel * mRecordMeter
Definition: MeterToolBar.h:62
AudacityProject * mProject
Definition: MeterToolBar.h:58
const int kWithRecordMeter
Definition: MeterToolBar.h:29
MeterPanel * mPlayMeter
Definition: MeterToolBar.h:61
int mType
Definition: ToolBar.h:215
wxString mLabel
Definition: ToolBar.h:213
wxString mSection
Definition: ToolBar.h:214
wxGridBagSizer * mSizer
Definition: MeterToolBar.h:60
const int kWithPlayMeter
Definition: MeterToolBar.h:30
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
ToolBar(int type, const wxString &label, const wxString &section, bool resizable=false)
Definition: ToolBar.cpp:311
MeterToolBar::~MeterToolBar ( )
virtual

Definition at line 71 of file MeterToolBar.cpp.

72 {
73 }

Member Function Documentation

void MeterToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 75 of file MeterToolBar.cpp.

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

76 {
77  ToolBar::Create(parent);
78 
79  // Simulate a size event to set initial meter placement/size
80  wxSizeEvent dummy;
81  OnSize(dummy);
82 }
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:442
void OnSize(wxSizeEvent &event)
void MeterToolBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 44 of file MeterToolBar.h.

44 {};
bool MeterToolBar::Expose ( bool  show)
overridevirtual

Reimplemented from ToolBar.

Definition at line 239 of file MeterToolBar.cpp.

References ToolBar::Expose(), AudacityProject::GetCaptureMeter(), AudacityProject::GetPlaybackMeter(), mPlayMeter, mProject, mRecordMeter, AudacityProject::SetCaptureMeter(), and AudacityProject::SetPlaybackMeter().

240 {
241  if( show ) {
242  if( mPlayMeter ) {
244  }
245 
246  if( mRecordMeter ) {
248  }
249  } else {
251  mProject->SetPlaybackMeter( NULL );
252  }
253 
255  mProject->SetCaptureMeter( NULL );
256  }
257  }
258 
259  return ToolBar::Expose( show );
260 }
MeterPanel * mRecordMeter
Definition: MeterToolBar.h:62
AudacityProject * mProject
Definition: MeterToolBar.h:58
MeterPanel * mPlayMeter
Definition: MeterToolBar.h:61
virtual bool Expose(bool show=true)
Definition: ToolBar.cpp:415
MeterPanel * GetCaptureMeter()
Definition: Project.cpp:5104
void SetCaptureMeter(MeterPanel *capture)
Definition: Project.cpp:5109
MeterPanel * GetPlaybackMeter()
Definition: Project.cpp:5090
void SetPlaybackMeter(MeterPanel *playback)
Definition: Project.cpp:5095
wxSize MeterToolBar::GetDockedSize ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 262 of file MeterToolBar.cpp.

References toolbarGap, and toolbarSingle.

263 {
264  const int tbs = toolbarSingle + toolbarGap;
265  wxSize sz = GetSize();
266  wxSize sz2 = GetMinSize();
267  sz.x = wxMax( sz.x, sz2.x );
268  sz.y = wxMax( sz.y, sz2.y );
269  // 50 is the size where we switch from expanded to compact.
270  if( sz.y < 50 )
271  sz.y = tbs-1;
272  else
273  sz.y = 2 * tbs -1;
274  return sz;
275 }
#define toolbarGap
Definition: ToolBar.h:59
#define toolbarSingle
Definition: ToolBar.h:54
int MeterToolBar::GetInitialWidth ( )
inlineoverridevirtual

Resizable toolbars should implement these.

Reimplemented from ToolBar.

Definition at line 50 of file MeterToolBar.h.

References kWithPlayMeter, kWithRecordMeter, and mWhichMeters.

50  {return (mWhichMeters ==
51  (kWithRecordMeter + kWithPlayMeter)) ? 338 : 460;} // Separate bars used to be smaller.
const int kWithRecordMeter
Definition: MeterToolBar.h:29
const int kWithPlayMeter
Definition: MeterToolBar.h:30
int MeterToolBar::GetMinToolbarWidth ( )
inlineoverridevirtual

Reimplemented from ToolBar.

Definition at line 52 of file MeterToolBar.h.

52 { return 50; }
void MeterToolBar::OnSize ( wxSizeEvent &  event)

Definition at line 190 of file MeterToolBar.cpp.

References ToolBar::GetSizer(), mPlayMeter, mRecordMeter, and mSizer.

Referenced by Create().

191 {
192  event.Skip();
193  int width, height;
194 
195  // We can be resized before populating...protect against it
196  if( !mSizer ) {
197  return;
198  }
199 
200  // Update the layout
201  Layout();
202 
203  // Get the usable area
204  wxSize sz = GetSizer()->GetSize();
205  width = sz.x; height = sz.y;
206 
207  int nMeters =
208  ((mRecordMeter ==NULL) ? 0:1) +
209  ((mPlayMeter ==NULL) ? 0:1);
210 
211  bool bHorizontal = ( width > height );
212  bool bEndToEnd = ( nMeters > 1 ) && wxMin( width, height ) < (60 * nMeters);
213 
214  // Default location for second meter
215  wxGBPosition pos( 0, 0 );
216  // If 2 meters, share the height or width.
217  if( nMeters > 1 ){
218  if( bHorizontal ^ bEndToEnd ){
219  height /= nMeters;
220  pos = wxGBPosition( 1, 0 );
221  } else {
222  width /= nMeters;
223  pos = wxGBPosition( 0, 1 );
224  }
225  }
226 
227  if( mRecordMeter ) {
228  mRecordMeter->SetMinSize( wxSize( width, height ));
229  }
230  if( mPlayMeter ) {
231  mPlayMeter->SetMinSize( wxSize( width, height));
232  mSizer->SetItemPosition( mPlayMeter, pos );
233  }
234 
235  // And make it happen
236  Layout();
237 }
MeterPanel * mRecordMeter
Definition: MeterToolBar.h:62
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:607
MeterPanel * mPlayMeter
Definition: MeterToolBar.h:61
wxGridBagSizer * mSizer
Definition: MeterToolBar.h:60
void MeterToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 112 of file MeterToolBar.cpp.

References _(), ToolBar::Add(), ThemeBase::Colour(), kWithPlayMeter, kWithRecordMeter, mPlayMeter, mProject, mRecordMeter, mSizer, mWhichMeters, RegenerateTooltips(), safenew, and theTheme.

113 {
114  SetBackgroundColour( theTheme.Colour( clrMedium ) );
115  wxASSERT(mProject); // to justify safenew
116  Add((mSizer = safenew wxGridBagSizer()), 1, wxEXPAND);
117 
119  //JKC: Record on left, playback on right. Left to right flow
120  //(maybe we should do it differently for Arabic language :-) )
122  this,
123  wxID_ANY,
124  true,
125  wxDefaultPosition,
126  wxSize( 260, 28 ) );
127  /* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.*/
128  mRecordMeter->SetName( _("Record Meter"));
129  /* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.
130  This is the name used in screen reader software, where having 'Meter' first
131  apparently is helpful to partially sighted people. */
132  mRecordMeter->SetLabel( _("Meter-Record") );
133  mSizer->Add( mRecordMeter, wxGBPosition( 0, 0 ), wxDefaultSpan, wxEXPAND );
134  }
135 
138  this,
139  wxID_ANY,
140  false,
141  wxDefaultPosition,
142  wxSize( 260, 28 ) );
143  /* i18n-hint: (noun) The meter that shows the loudness of the audio playing.*/
144  mPlayMeter->SetName( _("Play Meter"));
145  /* i18n-hint: (noun) The meter that shows the loudness of the audio playing.
146  This is the name used in screen reader software, where having 'Meter' first
147  apparently is helpful to partially sighted people. */
148  mPlayMeter->SetLabel( _("Meter-Play"));
149  mSizer->Add( mPlayMeter, wxGBPosition( (mWhichMeters & kWithRecordMeter)?1:0, 0 ), wxDefaultSpan, wxEXPAND );
150  }
151 
153 }
MeterPanel * mRecordMeter
Definition: MeterToolBar.h:62
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
AudacityProject * mProject
Definition: MeterToolBar.h:58
const int kWithRecordMeter
Definition: MeterToolBar.h:29
MeterPanel * mPlayMeter
Definition: MeterToolBar.h:61
void RegenerateTooltips() override
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: Meter.h:97
#define safenew
Definition: Audacity.h:230
wxGridBagSizer * mSizer
Definition: MeterToolBar.h:60
const int kWithPlayMeter
Definition: MeterToolBar.h:30
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:615
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void MeterToolBar::ReCreateButtons ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 84 of file MeterToolBar.cpp.

References AudacityProject::GetCaptureMeter(), AudacityProject::GetPlaybackMeter(), mPlayMeter, mProject, mRecordMeter, ToolBar::ReCreateButtons(), MeterPanel::RestoreState(), MeterPanel::SaveState(), AudacityProject::SetCaptureMeter(), and AudacityProject::SetPlaybackMeter().

85 {
86  MeterPanel::State playState{ false }, recordState{ false };
87 
89  {
90  playState = mPlayMeter->SaveState();
91  mProject->SetPlaybackMeter( NULL );
92  }
93 
95  {
96  recordState = mRecordMeter->SaveState();
97  mProject->SetCaptureMeter( NULL );
98  }
99 
101 
102  mPlayMeter->RestoreState(playState);
103  if( playState.mSaved ){
105  }
106  mRecordMeter->RestoreState(recordState);
107  if( recordState.mSaved ){
109  }
110 }
MeterPanel * mRecordMeter
Definition: MeterToolBar.h:62
AudacityProject * mProject
Definition: MeterToolBar.h:58
virtual void ReCreateButtons()
Definition: ToolBar.cpp:463
MeterPanel * mPlayMeter
Definition: MeterToolBar.h:61
MeterPanel * GetCaptureMeter()
Definition: Project.cpp:5104
void SetCaptureMeter(MeterPanel *capture)
Definition: Project.cpp:5109
void RestoreState(const State &state)
Definition: Meter.cpp:1834
MeterPanel * GetPlaybackMeter()
Definition: Project.cpp:5090
void SetPlaybackMeter(MeterPanel *playback)
Definition: Project.cpp:5095
State SaveState()
Definition: Meter.cpp:1829
void MeterToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 180 of file MeterToolBar.cpp.

References _(), mPlayMeter, and mRecordMeter.

Referenced by Populate(), and UpdatePrefs().

181 {
182 #if wxUSE_TOOLTIPS
183  if( mPlayMeter )
184  mPlayMeter->SetToolTip( _("Playback Level") );
185  if( mRecordMeter )
186  mRecordMeter->SetToolTip( _("Recording Level") );
187 #endif
188 }
MeterPanel * mRecordMeter
Definition: MeterToolBar.h:62
MeterPanel * mPlayMeter
Definition: MeterToolBar.h:61
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void MeterToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 43 of file MeterToolBar.h.

43 {};
void MeterToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 155 of file MeterToolBar.cpp.

References _(), mPlayMeter, mRecordMeter, RegenerateTooltips(), ToolBar::SetLabel(), ToolBar::UpdatePrefs(), and MeterPanel::UpdatePrefs().

156 {
157  if( mPlayMeter )
158  {
160  mPlayMeter->Refresh();
161  }
162 
163  if( mRecordMeter )
164  {
166  mRecordMeter->Refresh();
167  }
168 
170 
171  // Set label to pull in language change
172  SetLabel(_("Meter"));
173 
174  // Give base class a chance
176 
177 
178 }
MeterPanel * mRecordMeter
Definition: MeterToolBar.h:62
virtual void UpdatePrefs()
Definition: ToolBar.cpp:539
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:378
MeterPanel * mPlayMeter
Definition: MeterToolBar.h:61
void RegenerateTooltips() override
void UpdatePrefs()
Definition: Meter.cpp:340
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand

Member Data Documentation

MeterPanel* MeterToolBar::mPlayMeter
private
AudacityProject* MeterToolBar::mProject
private

Definition at line 58 of file MeterToolBar.h.

Referenced by Expose(), Populate(), and ReCreateButtons().

MeterPanel* MeterToolBar::mRecordMeter
private
wxGridBagSizer* MeterToolBar::mSizer
private

Definition at line 60 of file MeterToolBar.h.

Referenced by OnSize(), and Populate().

int MeterToolBar::mWhichMeters
private

Definition at line 59 of file MeterToolBar.h.

Referenced by GetInitialWidth(), and Populate().


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