Audacity 3.2.0
Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper Class Referencefinal
Inheritance diagram for anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper:
[legend]
Collaboration diagram for anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper:
[legend]

Static Public Member Functions

static std::optional< wxString > PickEffect (AudacityProject &project, wxWindow *parent, const wxString &selectedEffectID)
 
- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Private Member Functions

void Populate (AudacityProject &project, Visitor< Traits > &visitor)
 
 EffectsMenuHelper ()
 
std::shared_ptr< MenuItemGetMenuItem ()
 
void UpdatePrefs () override
 
void UpdateEffectMenuItems ()
 

Static Private Member Functions

static EffectsMenuHelperGet ()
 

Private Attributes

std::shared_ptr< MenuRegistry::MenuItemmCachedMenu
 
Observer::Subscription mPluginsChangedSubscription
 

Additional Inherited Members

- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 

Detailed Description

Definition at line 107 of file RealtimeEffectPanel.cpp.

Constructor & Destructor Documentation

◆ EffectsMenuHelper()

anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::EffectsMenuHelper ( )
inlineprivate

Definition at line 166 of file RealtimeEffectPanel.cpp.

167 {
170 {
171 mCachedMenu.reset();
172 }
173 );
174 }
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
static PluginManager & Get()

References PluginManager::Get(), and Observer::Publisher< Message, NotifyAll >::Subscribe().

Here is the call graph for this function:

Member Function Documentation

◆ Get()

static EffectsMenuHelper & anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::Get ( )
inlinestaticprivate

Definition at line 151 of file RealtimeEffectPanel.cpp.

152 {
153 static EffectsMenuHelper helper;
154 return helper;
155 }

◆ GetMenuItem()

std::shared_ptr< MenuItem > anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::GetMenuItem ( )
inlineprivate

Definition at line 176 of file RealtimeEffectPanel.cpp.

177 {
178 if(!mCachedMenu)
180
181 assert(mCachedMenu);
182 if(mCachedMenu)
183 return mCachedMenu;
184 return {};
185 }

◆ PickEffect()

static std::optional< wxString > anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::PickEffect ( AudacityProject project,
wxWindow *  parent,
const wxString &  selectedEffectID 
)
inlinestatic

Definition at line 114 of file RealtimeEffectPanel.cpp.

115 {
116 wxMenu menu;
117 if(!selectedEffectID.empty())
118 {
119 //no need to handle language change since menu creates its own event loop
120 menu.Append(wxID_REMOVE, _("No Effect"));
121 menu.AppendSeparator();
122 }
123
124 RealtimeEffectsMenuVisitor visitor { menu };
125
126 Get().Populate(project, visitor);
127
128 int commandId = wxID_NONE;
129
130#if defined(__WXMSW__) || defined(__WXMAC__)
131 menu.AppendSeparator();
132 menu.Append(wxID_MORE, _("Get more effects..."));
133#endif
134 menu.Bind(wxEVT_MENU, [&](wxCommandEvent evt) { commandId = evt.GetId(); });
135
136 if(parent->PopupMenu(&menu, parent->GetClientRect().GetLeftBottom()) && commandId != wxID_NONE)
137 {
138 if(commandId == wxID_REMOVE)
139 return wxString {};
140 if(commandId == wxID_MORE)
141 OpenInDefaultBrowser("https://www.musehub.com");
142 else
143 return visitor.GetPluginID(commandId).GET();
144 }
145
146 return {};
147 }
#define _(s)
Definition: Internat.h:73
const auto project
void Populate(AudacityProject &project, Visitor< Traits > &visitor)
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
Definition: BasicUI.cpp:246

References _, BasicUI::Get(), BasicUI::OpenInDefaultBrowser(), and project.

Here is the call graph for this function:

◆ Populate()

void anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::Populate ( AudacityProject project,
Visitor< Traits > &  visitor 
)
inlineprivate

Definition at line 157 of file RealtimeEffectPanel.cpp.

158 {
159 auto cachedMenuItem = GetMenuItem();
160 if(!cachedMenuItem)
161 return;
162
163 VisitWithFunctions(visitor, cachedMenuItem.get(), {}, project);
164 }
void VisitWithFunctions(const VisitorFunctions< RegistryTraits > &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:623

References project, and Registry::VisitWithFunctions().

Here is the call graph for this function:

◆ UpdateEffectMenuItems()

void anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::UpdateEffectMenuItems ( )
inlineprivate

Definition at line 192 of file RealtimeEffectPanel.cpp.

193 {
194 using namespace MenuRegistry;
195 auto root = std::shared_ptr{ Menu("", TranslatableString{}) };
196
197 static auto realtimeEffectPredicate = [](const PluginDescriptor& desc)
198 {
199 return desc.IsEffectRealtime();
200 };
201
202 const auto groupby = RealtimeEffectsGroupBy.Read();
203
204 auto analyzeSection = Section("", Menu("", XO("Analyze")));
205 auto submenu =
206 static_cast<MenuItem*>(analyzeSection->begin()->get());
208 *submenu,
210 {}, groupby, nullptr,
211 realtimeEffectPredicate
212 );
213
214 if(!submenu->empty())
215 {
216 root->push_back(move(analyzeSection));
217 }
218
220 *root,
222 {}, groupby, nullptr,
223 realtimeEffectPredicate
224 );
225
226 mCachedMenu.swap(root);
227 }
@ EffectTypeAnalyze
@ EffectTypeProcess
ChoiceSetting RealtimeEffectsGroupBy
XO("Cut/Copy/Paste")
wxString Read() const
Definition: Prefs.cpp:388
Holds a msgid for the translation catalog; may also bind format arguments.
void PopulateEffectsMenu(Group &menuItems, EffectType type, CommandFlag batchflags, const wxString &groupby, void(*onMenuCommand)(const CommandContext &), std::function< bool(const PluginDescriptor &)> pred={})
Definition: MenuHelper.cpp:563
constexpr auto Section
Definition: MenuRegistry.h:436
constexpr auto Menu
Items will appear in a main toolbar menu or in a sub-menu.
Definition: MenuRegistry.h:445
const TranslatableString desc
Definition: ExportPCM.cpp:51

References anonymous_namespace{ExportPCM.cpp}::desc, EffectTypeAnalyze, EffectTypeProcess, MenuRegistry::Menu, MenuHelper::PopulateEffectsMenu(), ChoiceSetting::Read(), RealtimeEffectsGroupBy, MenuRegistry::Section, and XO().

Here is the call graph for this function:

◆ UpdatePrefs()

void anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::UpdatePrefs ( )
inlineoverrideprivatevirtual

Implements PrefsListener.

Definition at line 187 of file RealtimeEffectPanel.cpp.

188 {
189 mCachedMenu.reset();
190 }

Member Data Documentation

◆ mCachedMenu

std::shared_ptr<MenuRegistry::MenuItem> anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::mCachedMenu
private

Definition at line 110 of file RealtimeEffectPanel.cpp.

◆ mPluginsChangedSubscription

Observer::Subscription anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::mPluginsChangedSubscription
private

Definition at line 111 of file RealtimeEffectPanel.cpp.


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