Audacity 3.2.0
Typedefs | Functions
MenuHelper Namespace Reference

Typedefs

using Group = MenuRegistry::GroupItem< MenuRegistry::Traits >
 

Functions

void PopulateEffectsMenu (Group &menuItems, EffectType type, CommandFlag batchflags, const wxString &groupby, void(*onMenuCommand)(const CommandContext &), std::function< bool(const PluginDescriptor &)> pred={})
 

Typedef Documentation

◆ Group

Definition at line 11 of file MenuHelper.h.

Function Documentation

◆ PopulateEffectsMenu()

void MenuHelper::PopulateEffectsMenu ( Group menuItems,
EffectType  type,
CommandFlag  batchflags,
const wxString &  groupby,
void(*)(const CommandContext &)  onMenuCommand,
std::function< bool(const PluginDescriptor &)>  pred = {} 
)

The effects come from a plug in list This code iterates through the list, adding effects into the menu.

Definition at line 563 of file MenuHelper.cpp.

570{
572
573 std::vector<MenuSectionBuilder> sections;
574
575 auto MakeAddSortedItems = [=](SortBy sortby)
576 {
577 return [=](Group& items, std::vector<const PluginDescriptor*>& plugins)
578 {
579 return AddSortedEffectMenuItems(items, plugins, batchflags, sortby, onMenuCommand);
580 };
581 };
582
583 auto MakeAddGroupedItems = [=](GroupBy groupBy)
584 {
585 return [=](Group& items, std::vector<const PluginDescriptor*>& plugins)
586 {
587 return AddGroupedEffectMenuItems(items, plugins, batchflags, groupBy, onMenuCommand);
588 };
589 };
590
591 auto DefaultFilter = [](auto plug) { return IsEnabledPlugin(plug) && IsDefaultPlugin(plug); };
592 if(groupby == "default")
593 {
594 if(type == EffectTypeProcess)
595 {
596 static auto effectMenuDefaults = [] {
597 wxFileName path = wxFileName(FileNames::ResourcesDir(), wxT("EffectsMenuDefaults.xml"));
598 return LoadEffectsMenuGroups(path.GetFullPath());
599 }();
600 static auto groupsFilter = MakeGroupsFilter(effectMenuDefaults);
601
602 sections.emplace_back(
603 MenuSectionBuilder {
604 {},
605 [=](auto plug) { return IsBundledPlugin(plug) && groupsFilter(plug); },
606 nullptr,
607 MakeAddGroupItems(effectMenuDefaults, batchflags, onMenuCommand)
608 });
609 sections.emplace_back(
610 MenuSectionBuilder {
611 {},
614 MakeAddGroupedItems(GroupBy::Publisher)
615 });
616 }
617 else//Generators/Analyzers
618 {
619 sections.emplace_back(
620 MenuSectionBuilder {
621 {},
622 [](auto plug){ return IsEnabledPlugin(plug) && IsBundledPlugin(plug); } ,
624 MakeAddSortedItems(SortBy::Name)
625 });
626 sections.emplace_back(
627 MenuSectionBuilder {
628 {},
631 MakeAddGroupedItems(GroupBy::Publisher)
632 });
633 }
634 }
635 else if(groupby == "sortby:publisher:name")
636 {
637 sections.emplace_back(
638 MenuSectionBuilder {
639 {},
640 DefaultFilter,
642 MakeAddSortedItems(SortBy::PublisherName)
643 });
644 sections.emplace_back(
645 MenuSectionBuilder {
646 {},
649 MakeAddSortedItems(SortBy::PublisherName)
650 });
651 }
652 else if(groupby == "sortby:type:name")
653 {
654 sections.emplace_back(
655 MenuSectionBuilder {
656 {},
657 DefaultFilter,
659 MakeAddSortedItems(SortBy::TypeName)
660 });
661 sections.emplace_back(
662 MenuSectionBuilder {
663 {},
666 MakeAddSortedItems(SortBy::TypeName)
667 });
668 }
669 else if(groupby == "groupby:publisher")
670 {
671 sections.emplace_back(
672 MenuSectionBuilder {
673 {},
674 DefaultFilter,
676 MakeAddGroupedItems(GroupBy::Publisher)
677 });
678 sections.emplace_back(
679 MenuSectionBuilder {
680 {},
683 MakeAddGroupedItems(GroupBy::Publisher)
684 });
685 }
686 else if(groupby == "groupby:type")
687 {
688 sections.emplace_back(
689 MenuSectionBuilder {
690 {},
691 DefaultFilter,
693 MakeAddGroupedItems(GroupBy::Type)
694 });
695 sections.emplace_back(
696 MenuSectionBuilder {
697 {},
700 MakeAddGroupedItems(GroupBy::Type)
701 });
702 }
703 else if(groupby == "groupby:type:publisher")
704 {
705 sections.emplace_back(
706 MenuSectionBuilder {
707 {},
708 DefaultFilter,
710 MakeAddGroupedItems(GroupBy::Type)
711 });
712 sections.push_back(
713 MenuSectionBuilder {
714 {},
717 MakeAddGroupedItems(GroupBy::TypePublisher)
718 });
719 }
720 else //if(groupby == "sortby:name")
721 {
722 sections.emplace_back(
723 MenuSectionBuilder {
724 {},
725 DefaultFilter,
727 MakeAddSortedItems(SortBy::Name)
728 });
729 sections.emplace_back(
730 MenuSectionBuilder {
731 {},
734 MakeAddSortedItems(SortBy::Name)
735 });
736 }
737 for(auto& plugin : pm.EffectsOfType(type))
738 {
739 if(pred && !pred(plugin))
740 continue;
741
742 for(auto& section : sections)
743 {
744 if(section.filter(&plugin))
745 {
746 section.plugins.push_back(&plugin);
747 break;
748 }
749 }
750 }
751
752 for(auto& section : sections)
753 {
754 if(section.compare != nullptr)
755 std::sort(section.plugins.begin(), section.plugins.end(), section.compare);
756
757 if (menuItems.empty()) {
758 auto group = MenuRegistry::Items("");
759 section.add(*group, section.plugins);
760 if (group->empty())
761 continue;
762 menuItems.push_back(move(group));
763 }
764 else {
765 auto group = MenuRegistry::Section("");
766 section.add(*group, section.plugins);
767 if (group->empty())
768 continue;
769 menuItems.push_back(move(group));
770 }
771 }
772}
wxT("CloseDown"))
@ EffectTypeProcess
PluginManager maintains a list of all plug ins. That covers modules, effects, generators,...
Definition: PluginManager.h:51
Range EffectsOfType(EffectType type)
static PluginManager & Get()
FILES_API FilePath ResourcesDir()
MenuRegistry::GroupItem< MenuRegistry::Traits > Group
Definition: MenuHelper.h:11
constexpr auto Section
Definition: MenuRegistry.h:436
constexpr auto Items
Definition: MenuRegistry.h:427
EffectsMenuGroups LoadEffectsMenuGroups(const wxString &path)
Definition: MenuHelper.cpp:112
bool IsDefaultPlugin(const PluginDescriptor *plug)
Definition: MenuHelper.cpp:525
bool ComapareEffectsByTypeAndPublisher(const PluginDescriptor *a, const PluginDescriptor *b)
Definition: MenuHelper.cpp:491
void AddSortedEffectMenuItems(MenuHelper::Group &table, std::vector< const PluginDescriptor * > &plugs, CommandFlag batchflags, SortBy sortBy, void(*onMenuCommand)(const CommandContext &))
Definition: MenuHelper.cpp:202
bool CompareEffectsByPublisherAndName(const PluginDescriptor *a, const PluginDescriptor *b)
Definition: MenuHelper.cpp:430
bool CompareEffectsByPublisher(const PluginDescriptor *a, const PluginDescriptor *b)
Definition: MenuHelper.cpp:410
bool CompareEffectsByName(const PluginDescriptor *a, const PluginDescriptor *b)
Definition: MenuHelper.cpp:403
void AddGroupedEffectMenuItems(MenuHelper::Group &table, std::vector< const PluginDescriptor * > &plugs, CommandFlag batchflags, GroupBy groupBy, void(*onMenuCommand)(const CommandContext &))
Definition: MenuHelper.cpp:314
bool IsEnabledPlugin(const PluginDescriptor *plug)
Definition: MenuHelper.cpp:515
bool IsBundledPlugin(const PluginDescriptor *plug)
Definition: MenuHelper.cpp:532
auto MakeAddGroupItems(const EffectsMenuGroups &list, CommandFlag batchflags, void(*onMenuCommand)(const CommandContext &)) -> auto
Definition: MenuHelper.cpp:257
auto MakeGroupsFilter(const EffectsMenuGroups &list) -> auto
Definition: MenuHelper.cpp:542
bool CompareEffectsByType(const PluginDescriptor *a, const PluginDescriptor *b)
Definition: MenuHelper.cpp:473
auto push_back(Arg &&arg) -> std::enable_if_t< Traits< Base, Derived > ::template enables_item_type_v< Arg >, void >
Definition: Composite.h:105
Has variadic and range constructors that check types.
Definition: Registry.h:292

References anonymous_namespace{MenuHelper.cpp}::AddGroupedEffectMenuItems(), anonymous_namespace{MenuHelper.cpp}::AddSortedEffectMenuItems(), anonymous_namespace{MenuHelper.cpp}::ComapareEffectsByTypeAndPublisher(), anonymous_namespace{MenuHelper.cpp}::CompareEffectsByName(), anonymous_namespace{MenuHelper.cpp}::CompareEffectsByPublisher(), anonymous_namespace{MenuHelper.cpp}::CompareEffectsByPublisherAndName(), anonymous_namespace{MenuHelper.cpp}::CompareEffectsByType(), PluginManager::EffectsOfType(), EffectTypeProcess, PluginManager::Get(), anonymous_namespace{MenuHelper.cpp}::IsBundledPlugin(), anonymous_namespace{MenuHelper.cpp}::IsDefaultPlugin(), anonymous_namespace{MenuHelper.cpp}::IsEnabledPlugin(), MenuRegistry::Items, anonymous_namespace{MenuHelper.cpp}::LoadEffectsMenuGroups(), anonymous_namespace{MenuHelper.cpp}::MakeAddGroupItems(), anonymous_namespace{MenuHelper.cpp}::MakeGroupsFilter(), anonymous_namespace{Scrubbing.cpp}::menuItems(), Composite::Builder< Base, Derived, BaseArgs >::push_back(), FileNames::ResourcesDir(), MenuRegistry::Section, and wxT().

Referenced by anonymous_namespace{PluginMenus.cpp}::AnalyzeMenu(), anonymous_namespace{PluginMenus.cpp}::EffectMenu(), anonymous_namespace{PluginMenus.cpp}::GenerateMenu(), anonymous_namespace{PluginMenus.cpp}::ToolsMenu(), and anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::UpdateEffectMenuItems().

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