Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
LabelTrackMenuTable Class Reference
Inheritance diagram for LabelTrackMenuTable:
[legend]
Collaboration diagram for LabelTrackMenuTable:
[legend]

Public Member Functions

void InitUserData (void *pUserData) override
 Called before the menu items are appended. More...
 
void OnSetFont (wxCommandEvent &)
 
- Public Member Functions inherited from PopupMenuTable
 PopupMenuTable (const Identifier &id, const TranslatableString &caption={})
 
const IdentifierId () const
 
const TranslatableStringCaption () const
 
const auto * GetRegistry () const
 
const auto & Get (void *pUserData)
 
void Clear ()
 
- Public Member Functions inherited from PopupMenuHandler
 PopupMenuHandler ()=default
 
 PopupMenuHandler (const PopupMenuHandler &)=delete
 
PopupMenuHandleroperator= (const PopupMenuHandler &)=delete
 
virtual void InitUserData (void *pUserData)=0
 Called before the menu items are appended. More...
 

Static Public Member Functions

static LabelTrackMenuTableInstance ()
 
- Static Public Member Functions inherited from PopupMenuTable
static std::unique_ptr< PopupMenuBuildMenu (PopupMenuTable *pTable, void *pUserData=NULL)
 
static void ExtendMenu (PopupMenu &menu, PopupMenuTable &otherTable)
 
template<typename Table , typename Factory >
static auto Adapt (const Factory &factory)
 

Public Attributes

CommonTrackControls::InitMenuDatampData {}
 

Private Member Functions

 LabelTrackMenuTable ()
 
 DECLARE_POPUP_MENU (LabelTrackMenuTable)
 

Additional Inherited Members

- Public Types inherited from PopupMenuTable
using Entry = PopupMenuTableEntry
 
- Protected Member Functions inherited from PopupMenuTable
virtual void Populate ()=0
 
template<typename Ptr >
void Append (Ptr pItem)
 
void Append (const Identifier &stringId, PopupMenuTableEntry::Type type, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init)
 
void AppendItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void AppendRadioItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void AppendCheckItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void BeginSection (const Identifier &name)
 
void EndSection ()
 
- Static Protected Member Functions inherited from PopupMenuTable
static TranslatableString MakeLabel (const TranslatableString &label, bool useExtra, const TranslatableString &extra)
 
- Protected Attributes inherited from PopupMenuTable
std::shared_ptr< PopupSubMenumTop
 
std::vector< PopupMenuGroupItem * > mStack
 
Identifier mId
 
TranslatableString mCaption
 
std::unique_ptr< PopupMenuGroupItemmRegistry
 

Detailed Description

Definition at line 37 of file LabelTrackControls.cpp.

Constructor & Destructor Documentation

◆ LabelTrackMenuTable()

LabelTrackMenuTable::LabelTrackMenuTable ( )
inlineprivate

Definition at line 39 of file LabelTrackControls.cpp.

40 : PopupMenuTable{ "LabelTrack" }
41 {}

Member Function Documentation

◆ DECLARE_POPUP_MENU()

LabelTrackMenuTable::DECLARE_POPUP_MENU ( LabelTrackMenuTable  )
private

◆ InitUserData()

void LabelTrackMenuTable::InitUserData ( void *  pUserData)
inlineoverridevirtual

Called before the menu items are appended.

Store context data, if needed. May be called more than once before the menu opens. Pointer remains valid for the duration of any callback, if PopupMenuTable::BuildMenu() is called and the result's Popup() is called before any other menus are built.

Implements PopupMenuHandler.

Definition at line 47 of file LabelTrackControls.cpp.

48 {
49 mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
50 }
CommonTrackControls::InitMenuData * mpData

References mpData.

◆ Instance()

LabelTrackMenuTable & LabelTrackMenuTable::Instance ( )
static

Definition at line 57 of file LabelTrackControls.cpp.

58{
59 static LabelTrackMenuTable instance;
60 return instance;
61}

Referenced by LabelTrackControls::GetMenuExtension().

Here is the caller graph for this function:

◆ OnSetFont()

void LabelTrackMenuTable::OnSetFont ( wxCommandEvent &  )

Definition at line 74 of file LabelTrackControls.cpp.

75{
76 // Small helper class to enumerate all fonts in the system
77 // We use this because the default implementation of
78 // wxFontEnumerator::GetFacenames() has changed between wx2.6 and 2.8
79 class FontEnumerator : public wxFontEnumerator
80 {
81 public:
82 explicit FontEnumerator(wxArrayString* fontNames) :
83 mFontNames(fontNames) {}
84
85 bool OnFacename(const wxString& font) override
86 {
87 mFontNames->push_back(font);
88 return true;
89 }
90
91 private:
92 wxArrayString* mFontNames;
93 };
94
95 wxArrayString facenames;
96 FontEnumerator fontEnumerator(&facenames);
97 fontEnumerator.EnumerateFacenames(wxFONTENCODING_SYSTEM, false);
98
99 wxString facename = gPrefs->Read(wxT("/GUI/LabelFontFacename"), wxT(""));
100
101 // Correct for empty facename, or bad preference file:
102 // get the name of a really existing font, to highlight by default
103 // in the list box
104 facename = LabelTrackView::GetFont(facename).GetFaceName();
105
106 long fontsize = gPrefs->Read(wxT("/GUI/LabelFontSize"),
107 static_cast<int>(LabelTrackView::DefaultFontSize));
108
109 /* i18n-hint: (noun) This is the font for the label track.*/
110 wxDialogWrapper dlg(mpData->pParent, wxID_ANY, XO("Label Track Font"));
111 dlg.SetName();
112 ShuttleGui S(&dlg, eIsCreating);
113 wxListBox *lb;
114 wxSpinCtrl *sc;
115
116 S.StartVerticalLay(true);
117 {
118 S.StartMultiColumn(2, wxEXPAND);
119 {
120 S.SetStretchyRow(0);
121 S.SetStretchyCol(1);
122
123 /* i18n-hint: (noun) The name of the typeface*/
124 S.AddPrompt(XXO("Face name"));
125 lb = safenew wxListBox(S.GetParent(), wxID_ANY,
126 wxDefaultPosition,
127 wxDefaultSize,
128 facenames,
129 wxLB_SINGLE);
130
131 lb->SetSelection( make_iterator_range( facenames ).index( facename ));
132 S
133 .Name(XO("Face name"))
134 .Position( wxALIGN_LEFT | wxEXPAND | wxALL )
135 .AddWindow(lb);
136
137 /* i18n-hint: (noun) The size of the typeface*/
138 S.AddPrompt(XXO("Face size"));
139 sc = safenew wxSpinCtrl(S.GetParent(), wxID_ANY,
140 wxString::Format(wxT("%ld"), fontsize),
141 wxDefaultPosition,
142 wxDefaultSize,
143 wxSP_ARROW_KEYS,
144 8, 48, fontsize);
145 S
146 .Name(XO("Face size"))
147 .Position( wxALIGN_LEFT | wxALL )
148 .AddWindow(sc);
149 }
150 S.EndMultiColumn();
151 S.AddStandardButtons();
152 }
153 S.EndVerticalLay();
154
155 dlg.Layout();
156 dlg.Fit();
157 dlg.CenterOnParent();
158 if (dlg.ShowModal() == wxID_CANCEL)
159 return;
160
161 gPrefs->Write(wxT("/GUI/LabelFontFacename"), lb->GetStringSelection());
162 gPrefs->Write(wxT("/GUI/LabelFontSize"), sc->GetValue());
163 gPrefs->Flush();
164
166
168}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: IteratorX.h:210
#define safenew
Definition: MemoryX.h:10
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
@ eIsCreating
Definition: ShuttleGui.h:37
#define S(N)
Definition: ToChars.cpp:64
static wxFont GetFont(const wxString &faceName, int size=DefaultFontSize)
static void ResetFont()
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0

References LabelTrackView::DefaultFontSize, eIsCreating, audacity::BasicSettings::Flush(), LabelTrackView::GetFont(), gPrefs, make_iterator_range(), audacity::BasicSettings::Read(), RefreshCode::RefreshAll, LabelTrackView::ResetFont(), S, safenew, wxDialogWrapper::SetName(), audacity::BasicSettings::Write(), wxT(), XO(), and XXO().

Here is the call graph for this function:

Member Data Documentation

◆ mpData

CommonTrackControls::InitMenuData* LabelTrackMenuTable::mpData {}

Definition at line 52 of file LabelTrackControls.cpp.

Referenced by InitUserData().


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