MCPcopy Create free account
hub / github.com/audacity/audacity / AddGroupedEffectMenuItems

Function AddGroupedEffectMenuItems

src/menus/MenuHelper.cpp:319–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319void AddGroupedEffectMenuItems(
320 MenuHelper::Group& table,
321 std::vector<const PluginDescriptor*>& plugs,
322 CommandFlag batchflags,
323 GroupBy groupBy,
324 void (*onMenuCommand)(const CommandContext&))
325{
326 using namespace MenuRegistry;
327
328 const auto UnknownGroupName = XO("Unknown");
329 auto& effectManager = EffectManager::Get();
330
331 std::vector<TranslatableString> path;
332
333 auto *parentTable = &table;
334 std::vector<TranslatableString> names;
335 PluginIDs group;
336 std::vector<CommandFlag> flags;
337
338 auto doAddGroup = [&]
339 {
340 using namespace MenuRegistry;
341 if(names.empty())
342 return;
343
344 const auto inSubmenu = !path.empty() && (names.size() > 1);
345 const auto label = inSubmenu ? path.back() : TranslatableString{};
346 if (label.empty()) {
347 auto items = Items("");
348 AddEffectMenuItemGroup(*items, names, group, flags, onMenuCommand);
349 parentTable->push_back(move(items));
350 }
351 else {
352 auto items = Menu("", label);
353 AddEffectMenuItemGroup(*items, names, group, flags, onMenuCommand);
354 parentTable->push_back(move(items));
355 }
356
357 names.clear();
358 group.clear();
359 flags.clear();
360 };
361
362 for(auto plug : plugs)
363 {
364 if(groupBy == GroupBy::Publisher)
365 {
366 const auto vendorName = effectManager.GetVendorName(plug->GetID());
367 if(path.empty() || path[0] != vendorName)
368 {
369 doAddGroup();
370 path = { vendorName };
371 }
372 }
373 else if(groupBy == GroupBy::Type)
374 {
375 const auto effectFamilyName = effectManager.GetEffectFamilyName(plug->GetID());
376 if(path.empty() || path[0] != effectFamilyName)

Callers 1

PopulateEffectsMenuMethod · 0.85

Calls 13

GetFunction · 0.85
AddEffectMenuItemGroupFunction · 0.85
moveFunction · 0.85
FixBatchFlagsFunction · 0.85
GetVendorNameMethod · 0.80
GetEffectFamilyNameMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45
GetIDMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected