12using EffectsMenuGroups = std::vector<std::pair<TranslatableString, std::vector<TranslatableString>>>;
16 std::vector<const PluginDescriptor*>
plugins;
44 EffectsHandler(std::vector<TranslatableString>& effects) : effects(effects) { }
50 if(textContent.has_value() && tag ==
"Effect")
67 std::pair<TranslatableString, std::vector<TranslatableString>>&
group;
75 if(textContent.has_value() && tag ==
"Name")
83 effectsHandler = std::make_unique<EffectsHandler>(group.second);
84 return &*effectsHandler;
104 groups.resize(groups.size() + 1);
105 groupHandler = std::make_unique<GroupHandler>(groups.back());
106 return &*groupHandler;
136 const std::vector<CommandFlag> & flags,
139 const int namesCnt = (int)
names.size();
141 int groupCnt = namesCnt;
142 for (
int i = 0; i < namesCnt; i++)
145 while (i + 1 < namesCnt &&
names[i].Translation() ==
names[i + 1].Translation())
154 for (
int i = 0; i < namesCnt; i++)
157 if (i + 1 < namesCnt &&
names[i].Translation() ==
names[i + 1].Translation())
161 const auto translation =
name.Translation();
164 while (i < namesCnt &&
names[i].Translation() == translation)
204 std::vector<const PluginDescriptor*> & plugs,
209 size_t pluginCnt = plugs.size();
213 std::vector<CommandFlag> groupFlags;
215 for (
size_t i = 0; i < pluginCnt; i++)
225 if (sortBy == SortBy::PublisherName)
229 else if (sortBy == SortBy::TypeName )
239 groupNames.push_back(
245 groupPlugs.push_back(plug->
GetID());
249 if (groupNames.size() > 0)
252 table, groupNames, groupPlugs, groupFlags,
262 return [=](
MenuHelper::Group& items, std::vector<const PluginDescriptor*>& plugs)
268 std::vector<CommandFlag> groupFlags;
270 auto srcNames = p.second;
273 for(
auto&
name : srcNames)
277 return name == other->GetSymbol().Msgid();
279 if(it == plugs.end())
283 if(plug->IsEffectInteractive())
284 groupNames.push_back(
name +
XO(
"..."));
286 groupNames.push_back(
name );
288 groupPlugs.push_back(plug->GetID());
292 if (!groupNames.empty())
295 if (p.first.empty()) {
296 auto temp =
Items(
"");
298 groupNames, groupPlugs, groupFlags,
303 auto temp =
Menu(
"", p.first);
305 groupNames, groupPlugs, groupFlags,
316 std::vector<const PluginDescriptor*>& plugs,
323 const auto UnknownGroupName =
XO(
"Unknown");
326 std::vector<TranslatableString> path;
328 auto *parentTable = &table;
329 std::vector<TranslatableString>
names;
331 std::vector<CommandFlag> flags;
333 auto doAddGroup = [&]
339 const auto inSubmenu = !path.empty() && (
names.size() > 1);
342 auto items =
Items(
"");
344 parentTable->push_back(move(items));
349 parentTable->push_back(move(items));
357 for(
auto plug : plugs)
359 if(groupBy == GroupBy::Publisher)
361 const auto vendorName = effectManager.GetVendorName(plug->GetID());
362 if(path.empty() || path[0] != vendorName)
365 path = { vendorName };
368 else if(groupBy == GroupBy::Type)
370 const auto effectFamilyName = effectManager.GetEffectFamilyName(plug->GetID());
371 if(path.empty() || path[0] != effectFamilyName)
374 path = { effectFamilyName };
377 else if(groupBy == GroupBy::TypePublisher)
379 const auto effectFamilyName = effectManager.GetEffectFamilyName(plug->GetID());
380 const auto vendorName = effectManager.GetVendorName(plug->GetID());
381 if(path.empty() || path[0] != effectFamilyName)
384 path = { effectFamilyName, vendorName };
385 auto menu =
Menu(
"", effectFamilyName);
386 parentTable = menu.get();
389 else if(path[1] != vendorName)
392 path[1] = vendorName;
396 group.push_back(plug->GetID());
397 names.push_back(plug->GetSymbol().Msgid());
415 auto akey = em.GetVendorName(a->
GetID());
416 auto bkey = em.GetVendorName(b->
GetID());
419 akey =
XO(
"Uncategorized");
421 bkey =
XO(
"Uncategorized");
434 auto akey = em.GetVendorName(a->
GetID());
435 auto bkey = em.GetVendorName(b->
GetID());
453 auto akey = em.GetEffectFamilyName(a->
GetID());
454 auto bkey = em.GetEffectFamilyName(b->
GetID());
457 akey =
XO(
"Uncategorized");
459 bkey =
XO(
"Uncategorized");
476 auto akey = em.GetEffectFamilyName(a->
GetID());
477 auto bkey = em.GetEffectFamilyName(b->
GetID());
480 akey =
XO(
"Uncategorized");
482 bkey =
XO(
"Uncategorized");
494 auto aType = em.GetEffectFamilyName(a->
GetID());
495 auto bType = em.GetEffectFamilyName(b->
GetID());
496 auto aVendor = em.GetVendorName(a->
GetID());
497 auto bVendor = em.GetVendorName(b->
GetID());
500 aType =
XO(
"Uncategorized");
502 bType =
XO(
"Uncategorized");
504 aVendor =
XO(
"Unknown");
506 bVendor =
XO(
"Unknown");
537 auto pluginPath = wxFileName(plug->
GetPath());
538 pluginPath.MakeAbsolute();
539 return pluginPath.GetPath().StartsWith(applicationResourcePath.GetPath());
551 for(
auto&
name : p.second)
553 if(
name == plug->GetSymbol().Msgid())
567 const wxString& groupby,
573 std::vector<MenuSectionBuilder> sections;
575 auto MakeAddSortedItems = [=](
SortBy sortby)
577 return [=](
Group& items, std::vector<const PluginDescriptor*>& plugins)
583 auto MakeAddGroupedItems = [=](
GroupBy groupBy)
585 return [=](
Group& items, std::vector<const PluginDescriptor*>& plugins)
592 if(groupby ==
"default")
596 static auto effectMenuDefaults = [] {
602 sections.emplace_back(
605 [=](
auto plug) {
return IsBundledPlugin(plug) && groupsFilter(plug); },
609 sections.emplace_back(
614 MakeAddGroupedItems(GroupBy::Publisher)
619 sections.emplace_back(
624 MakeAddSortedItems(SortBy::Name)
626 sections.emplace_back(
631 MakeAddGroupedItems(GroupBy::Publisher)
635 else if(groupby ==
"sortby:publisher:name")
637 sections.emplace_back(
642 MakeAddSortedItems(SortBy::PublisherName)
644 sections.emplace_back(
649 MakeAddSortedItems(SortBy::PublisherName)
652 else if(groupby ==
"sortby:type:name")
654 sections.emplace_back(
659 MakeAddSortedItems(SortBy::TypeName)
661 sections.emplace_back(
666 MakeAddSortedItems(SortBy::TypeName)
669 else if(groupby ==
"groupby:publisher")
671 sections.emplace_back(
676 MakeAddGroupedItems(GroupBy::Publisher)
678 sections.emplace_back(
683 MakeAddGroupedItems(GroupBy::Publisher)
686 else if(groupby ==
"groupby:type")
688 sections.emplace_back(
693 MakeAddGroupedItems(GroupBy::Type)
695 sections.emplace_back(
700 MakeAddGroupedItems(GroupBy::Type)
703 else if(groupby ==
"groupby:type:publisher")
705 sections.emplace_back(
710 MakeAddGroupedItems(GroupBy::Type)
717 MakeAddGroupedItems(GroupBy::TypePublisher)
722 sections.emplace_back(
727 MakeAddSortedItems(SortBy::Name)
729 sections.emplace_back(
734 MakeAddSortedItems(SortBy::Name)
739 if(pred && !pred(plugin))
742 for(
auto& section : sections)
744 if(section.filter(&plugin))
746 section.plugins.push_back(&plugin);
752 for(
auto& section : sections)
754 if(section.compare !=
nullptr)
755 std::sort(section.plugins.begin(), section.plugins.end(), section.compare);
759 section.add(*group, section.plugins);
766 section.add(*group, section.plugins);
std::bitset< NCommandFlags > CommandFlag
const ReservedCommandFlag & NoiseReductionTimeSelectedFlag()
bool TranslationLess(const TranslatableString &a, const TranslatableString &b)
A commonly needed sort comparator, which depends on the language setting.
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
std::vector< TranslatableString > TranslatableStrings
std::vector< Attribute > AttributesList
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
const TranslatableString & Msgid() const
const wxString Translation() const
static EffectManager & Get()
TranslatableString GetVendorName(const PluginID &ID)
TranslatableString GetEffectFamilyName(const PluginID &ID)
bool IsHidden(const PluginID &ID)
const ComponentInterfaceSymbol & GetSymbol() const
PluginType GetPluginType() const
bool IsEffectDefault() const
bool IsEffectInteractive() const
const wxString & GetID() const
const PluginPath & GetPath() const
PluginManager maintains a list of all plug ins. That covers modules, effects, generators,...
Range EffectsOfType(EffectType type)
const PluginDescriptor * GetPlugin(const PluginID &ID) const
static PluginManager & Get()
Holds a msgid for the translation catalog; may also bind format arguments.
Reads a file and passes the results through an XMLTagHandler.
bool Parse(XMLTagHandler *baseHandler, const FilePath &fname)
This class is an interface which should be implemented by classes which wish to be able to load and s...
FILES_API FilePath ResourcesDir()
const MenuItems & menuItems()
AuthorizationHandler handler
auto push_back(Arg &&arg) -> std::enable_if_t< Traits< Base, Derived > ::template enables_item_type_v< Arg >, void >
Has variadic and range constructors that check types.
std::optional< std::string > textContent
void HandleXMLEndTag(const std::string_view &tag) override
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
std::vector< TranslatableString > & effects
EffectsHandler(std::vector< TranslatableString > &effects)
void HandleXMLContent(const std::string_view &text) override
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
void HandleXMLEndTag(const std::string_view &tag) override
std::unique_ptr< EffectsHandler > effectsHandler
std::optional< std::string > textContent
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
void HandleXMLContent(const std::string_view &text) override
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
std::pair< TranslatableString, std::vector< TranslatableString > > & group
GroupHandler(std::pair< TranslatableString, std::vector< TranslatableString > > &group)
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
std::unique_ptr< GroupHandler > groupHandler
EffectsMenuGroupsHandler(EffectsMenuGroups &groups)
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
EffectsMenuGroups & groups