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

#include <TimeSignatureToolBar.h>

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

Public Member Functions

 TimeSignatureToolBar (AudacityProject &project)
 
virtual ~TimeSignatureToolBar ()
 
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 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 TimeSignatureToolBarGet (AudacityProject &project)
 
static const TimeSignatureToolBarGet (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 OnSize (wxSizeEvent &evt)
 
void OnAudioIOEvent (const AudioIOEvent &event)
 
void AddTitle (const TranslatableString &Title, wxSizer *pSizer, int flags=wxEXPAND|wxRIGHT, int border=5, double fontMultiplier=1.0)
 

Private Attributes

Observer::Subscription mTimeSignatureChangedSubscription
 
Observer::Subscription mPlaybackStateChangedSubscription
 
wxWeakRef< SpinControlmTempoControl
 
wxWeakRef< SpinControlmUpperSignatureControl
 
wxWeakRef< wxComboBox > mLowerSignatureControl
 

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

Definition at line 32 of file TimeSignatureToolBar.h.

Constructor & Destructor Documentation

◆ TimeSignatureToolBar()

TimeSignatureToolBar::TimeSignatureToolBar ( AudacityProject project)

Definition at line 57 of file TimeSignatureToolBar.cpp.

58 : ToolBar(project, XO("Time Signature"), ID())
60 [this](auto settings)
61 {
62 if (mTempoControl)
63 mTempoControl->SetValue(settings.newTempo);
64
66 mUpperSignatureControl->SetValue(
67 settings.newUpperTimeSignature);
68
70 mLowerSignatureControl->SetValue(
71 wxString::Format("%d", settings.newLowerTimeSignature));
72 }))
74{
75}
XO("Cut/Copy/Paste")
const auto project
static Settings & settings()
Definition: TrackInfo.cpp:51
static AudioIO * Get()
Definition: AudioIO.cpp:126
static ProjectTimeSignature & Get(AudacityProject &project)
wxWeakRef< wxComboBox > mLowerSignatureControl
wxWeakRef< SpinControl > mTempoControl
static Identifier ID()
Observer::Subscription mTimeSignatureChangedSubscription
Observer::Subscription mPlaybackStateChangedSubscription
void OnAudioIOEvent(const AudioIOEvent &event)
wxWeakRef< SpinControl > mUpperSignatureControl
AudacityProject & mProject
Definition: ToolBar.h:247
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328

References mLowerSignatureControl, mTempoControl, mUpperSignatureControl, and settings().

Here is the call graph for this function:

◆ ~TimeSignatureToolBar()

TimeSignatureToolBar::~TimeSignatureToolBar ( )
virtualdefault

Member Function Documentation

◆ AddTitle()

void TimeSignatureToolBar::AddTitle ( const TranslatableString Title,
wxSizer *  pSizer,
int  flags = wxEXPAND | wxRIGHT,
int  border = 5,
double  fontMultiplier = 1.0 
)
private

Definition at line 252 of file TimeSignatureToolBar.cpp.

255{
256 const auto translated = Title.Translation();
257
258 auStaticText* pTitle = safenew auStaticText(this, translated);
259
260 pTitle->SetBackgroundColour(theTheme.Colour(clrMedium));
261 pTitle->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
262 pTitle->ScaleFont(fontMultiplier);
263
264 pSizer->Add(pTitle, 0, flags, border);
265}
#define safenew
Definition: MemoryX.h:10
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxColour & Colour(int iIndex)
is like wxStaticText, except it can be themed. wxStaticText can't be.
Definition: auStaticText.h:20
void ScaleFont(double scale)

References ThemeBase::Colour(), safenew, auStaticText::ScaleFont(), and theTheme.

Referenced by Populate().

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

◆ Create()

void TimeSignatureToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 100 of file TimeSignatureToolBar.cpp.

101{
102 ToolBar::Create(parent);
103 UpdatePrefs();
104}
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492

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

Here is the call graph for this function:

◆ DefaultDockID()

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

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

Reimplemented from ToolBar.

Definition at line 84 of file TimeSignatureToolBar.cpp.

85{
86 return BotDockID;
87}
@ BotDockID
Definition: ToolBar.h:93

References ToolBar::BotDockID.

◆ EnableDisableButtons()

void TimeSignatureToolBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 51 of file TimeSignatureToolBar.h.

51{};

◆ Get() [1/2]

TimeSignatureToolBar & TimeSignatureToolBar::Get ( AudacityProject project)
static

Definition at line 89 of file TimeSignatureToolBar.cpp.

90{
91 auto &toolManager = ToolManager::Get( project );
92 return *static_cast<TimeSignatureToolBar*>(toolManager.GetToolBar(ID()));
93}
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 TimeSignatureToolBar & TimeSignatureToolBar::Get ( const AudacityProject project)
static

Definition at line 95 of file TimeSignatureToolBar.cpp.

96{
97 return Get( const_cast<AudacityProject&>( project )) ;
98}
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 TimeSignatureToolBar & Get(AudacityProject &project)

References Get(), and project.

Here is the call graph for this function:

◆ ID()

Identifier TimeSignatureToolBar::ID ( )
static

Definition at line 52 of file TimeSignatureToolBar.cpp.

53{
54 return wxT("TimeSignature");
55}
wxT("CloseDown"))

References wxT().

Referenced by Get().

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

◆ OnAudioIOEvent()

void TimeSignatureToolBar::OnAudioIOEvent ( const AudioIOEvent event)
private

Definition at line 237 of file TimeSignatureToolBar.cpp.

238{
239 switch(event.type)
240 {
243 {
244 if(mTempoControl)
245 mTempoControl->Enable(!event.on);
246 } break;
247 default: break;
248 }
249}
bool on
Definition: AudioIO.h:68
enum AudioIOEvent::Type type

References AudioIOEvent::CAPTURE, mTempoControl, AudioIOEvent::on, AudioIOEvent::PLAYBACK, and AudioIOEvent::type.

◆ OnSize()

void TimeSignatureToolBar::OnSize ( wxSizeEvent &  evt)
private

Definition at line 230 of file TimeSignatureToolBar.cpp.

231{
232 Refresh( true );
233
234 evt.Skip();
235}

◆ Populate()

void TimeSignatureToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 106 of file TimeSignatureToolBar.cpp.

107{
108#ifndef __WXGTK__
109 const auto tempoSigSize = wxSize(60, -1);
110 auto timeSigSize = wxSize(50, -1);
111#else
112 const auto tempoSigSize = wxSize(60, -1);
113 auto timeSigSize = wxSize(60, -1);
114#endif
115
116 auto& projectTimeSignature = ProjectTimeSignature::Get(mProject);
117
118 SetBackgroundColour( theTheme.Colour( clrMedium ) );
119
120 auto sizer = safenew wxFlexGridSizer(2, 5, 1);
121 Add(sizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5);
122
123 AddTitle(XO("Tempo"), sizer);
124 AddTitle(XO("Time Signature"), sizer);
125
127 this, wxID_ANY, projectTimeSignature.GetTempo(), 1.0, 999.0, 1.0, true,
128 wxDefaultPosition, tempoSigSize);
129
130 mTempoControl->SetName(XO("Tempo"));
131
132 sizer->Add(mTempoControl, 0, wxEXPAND | wxRIGHT, 5);
133
134 auto tempoSizer = safenew wxBoxSizer(wxHORIZONTAL);
135 sizer->Add(tempoSizer, 0, wxEXPAND | wxRIGHT, 5);
136
138 this, wxID_ANY, projectTimeSignature.GetUpperTimeSignature(), 1.0, 128.0, 1.0, false,
139 wxDefaultPosition, timeSigSize);
140
141 mUpperSignatureControl->SetName(XO("Upper Time Signature"));
142
143 tempoSizer->Add(mUpperSignatureControl, 0, wxEXPAND | wxRIGHT, 5);
144
145 AddTitle(
146 Verbatim(L"/"), tempoSizer, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5, 1.5);
147
148 timeSigSize.y = mUpperSignatureControl->GetSize().y;
149
150 mLowerSignatureControl = safenew wxComboBox(
151 this, wxID_ANY,
152 wxString::Format(
153 "%d", ProjectTimeSignature::Get(mProject).GetLowerTimeSignature()),
154 wxDefaultPosition, timeSigSize,
155 wxArrayStringEx { L"2", L"4", L"8", L"16", L"32", L"64" },
156 wxCB_READONLY);
157
158 mLowerSignatureControl->SetName(XO("Lower Time Signature").Translation());
159
160 tempoSizer->Add(mLowerSignatureControl, 0, wxEXPAND | wxRIGHT, 5);
161
162 mTempoControl->Bind(
163 wxEVT_SPINCTRL,
164 [this](auto)
165 {
166 const auto tempo = mTempoControl->GetValue();
167
169
171 XO("Tempo Changed"), XO("Tempo Changed"), UndoPush::CONSOLIDATE);
172 });
173
175 wxEVT_SPINCTRL,
176 [this](auto)
177 {
178 const auto upper = int(mUpperSignatureControl->GetValue());
179
181
183 XO("Upper Time Signature Changed"),
184 XO("Upper Time Signature Changed"), UndoPush::CONSOLIDATE);
185 });
186
188 wxEVT_COMBOBOX,
189 [this](auto)
190 {
191 long value;
192
193 if (!mLowerSignatureControl->GetValue().ToLong(&value))
194 return;
195
197
199 XO("Lower Time Signature Changed"),
200 XO("Lower Time Signature Changed"), UndoPush::CONSOLIDATE);
201 });
202
203#if wxUSE_ACCESSIBILITY
205 mUpperSignatureControl->SetAccessible(
207 mLowerSignatureControl->SetAccessible(
209#endif
210
212 Fit();
213 Layout();
214}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
void SetUpperTimeSignature(int upperTimeSignature)
void SetLowerTimeSignature(int lowerTimeSignature)
void SetTempo(double tempo)
void AddTitle(const TranslatableString &Title, wxSizer *pSizer, int flags=wxEXPAND|wxRIGHT, int border=5, double fontMultiplier=1.0)
void RegenerateTooltips() override
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 ...
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

References ToolBar::Add(), AddTitle(), ThemeBase::Colour(), CONSOLIDATE, ProjectTimeSignature::Get(), ProjectHistory::Get(), mLowerSignatureControl, ToolBar::mProject, mTempoControl, mUpperSignatureControl, ProjectHistory::PushState(), RegenerateTooltips(), safenew, ProjectTimeSignature::SetLowerTimeSignature(), ProjectTimeSignature::SetTempo(), ProjectTimeSignature::SetUpperTimeSignature(), theTheme, Verbatim(), and XO().

Here is the call graph for this function:

◆ RegenerateTooltips()

void TimeSignatureToolBar::RegenerateTooltips ( )
overridevirtual

Implements ToolBar.

Definition at line 226 of file TimeSignatureToolBar.cpp.

227{
228}

Referenced by Populate(), and UpdatePrefs().

Here is the caller graph for this function:

◆ Repaint()

void TimeSignatureToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 50 of file TimeSignatureToolBar.h.

50{};

◆ ShownByDefault()

bool TimeSignatureToolBar::ShownByDefault ( ) const
overridevirtual

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

Reimplemented from ToolBar.

Definition at line 79 of file TimeSignatureToolBar.cpp.

80{
81 return true;
82}

◆ UpdatePrefs()

void TimeSignatureToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 216 of file TimeSignatureToolBar.cpp.

217{
218 // Set label to pull in language change
219 SetLabel(XO("Time Signature"));
220
222 // Give base class a chance
224}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
void UpdatePrefs() override
Definition: ToolBar.cpp:622

References 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

◆ mLowerSignatureControl

wxWeakRef<wxComboBox> TimeSignatureToolBar::mLowerSignatureControl
private

Definition at line 71 of file TimeSignatureToolBar.h.

Referenced by Populate(), and TimeSignatureToolBar().

◆ mPlaybackStateChangedSubscription

Observer::Subscription TimeSignatureToolBar::mPlaybackStateChangedSubscription
private

Definition at line 67 of file TimeSignatureToolBar.h.

◆ mTempoControl

wxWeakRef<SpinControl> TimeSignatureToolBar::mTempoControl
private

Definition at line 69 of file TimeSignatureToolBar.h.

Referenced by OnAudioIOEvent(), Populate(), and TimeSignatureToolBar().

◆ mTimeSignatureChangedSubscription

Observer::Subscription TimeSignatureToolBar::mTimeSignatureChangedSubscription
private

Definition at line 66 of file TimeSignatureToolBar.h.

◆ mUpperSignatureControl

wxWeakRef<SpinControl> TimeSignatureToolBar::mUpperSignatureControl
private

Definition at line 70 of file TimeSignatureToolBar.h.

Referenced by Populate(), and TimeSignatureToolBar().


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