Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder Class Reference
Inheritance diagram for anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder:
[legend]
Collaboration diagram for anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder:
[legend]

Public Member Functions

 PopupMenuBuilder (PopupMenuTable &table, PopupMenuImpl &menu, void *pUserData)
 
- Public Member Functions inherited from MenuRegistry::Visitor< PopupMenuTableTraits >
 Visitor (VisitorFunctions< PopupMenuTableTraits > functions, std::function< void()> doSeparator)
 
- Public Member Functions inherited from Registry::VisitorFunctions< PopupMenuTableTraits >
 VisitorFunctions (Visitors &&visitors)
 Type-erasing constructor. More...
 
void BeginGroup (const GroupItem< PopupMenuTableTraits > &item, const Path &path) const
 Call-through for a decorating pre-visitor. More...
 
void Visit (const SingleItem &item, const Path &path) const
 Call-through for a decorating leaf-visitor. More...
 
void EndGroup (const GroupItem< PopupMenuTableTraits > &item, const Path &path) const
 Call-through for a decorating post-visitor. More...
 
- Public Member Functions inherited from MenuRegistry::detail::VisitorBase
std::pair< bool, bool > ShouldBeginGroup (const ItemProperties *pProperties)
 
void AfterBeginGroup (const ItemProperties *pProperties)
 
bool ShouldEndGroup (const ItemProperties *pProperties)
 
bool ShouldDoSeparator ()
 

Public Attributes

std::vector< std::unique_ptr< PopupMenuImpl > > mMenus
 
PopupMenuImplmMenu
 
PopupMenuImplmRoot
 
void *const mpUserData
 
- Public Attributes inherited from MenuRegistry::detail::VisitorBase
std::vector< bool > firstItem
 
std::vector< bool > needSeparator
 

Additional Inherited Members

- Public Types inherited from Registry::VisitorFunctions< PopupMenuTableTraits >
using NodeTypes = detail::VisitedNodeTypes< PopupMenuTableTraits >
 
using LeafTypes = detail::VisitedLeafTypes< PopupMenuTableTraits >
 

Detailed Description

Definition at line 53 of file PopupMenuTable.cpp.

Constructor & Destructor Documentation

◆ PopupMenuBuilder()

anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder::PopupMenuBuilder ( PopupMenuTable table,
PopupMenuImpl menu,
void *  pUserData 
)
inline

Definition at line 55 of file PopupMenuTable.cpp.

57 [this](const PopupSubMenu &item, const auto &){
58 if (!item.caption.empty()) {
59 auto newMenu =
60 std::make_unique<PopupMenuImpl>(mMenu->pUserData);
61 mMenu = newMenu.get();
62 mMenus.push_back(std::move(newMenu));
63 }
64 },
65
66 [this](const PopupMenuTableEntry &entry, const auto &){
67 switch (entry.type) {
69 {
70 mMenu->Append(entry.id, entry.caption.Translation());
71 break;
72 }
74 {
75 mMenu->AppendRadioItem(entry.id, entry.caption.Translation());
76 break;
77 }
79 {
80 mMenu->AppendCheckItem(entry.id, entry.caption.Translation());
81 break;
82 }
83 default:
84 assert(false);
85 break;
86 }
87
88 // This call is necessary for externally registered items, else
89 // harmlessly redundant
90 entry.handler.InitUserData(mpUserData);
91
92 if (entry.init)
93 entry.init(entry.handler, *mMenu, entry.id);
94
95 mMenu->Bind(
96 wxEVT_COMMAND_MENU_SELECTED, entry.func, &entry.handler, entry.id);
97 },
98
99 [this](const PopupSubMenu &item, const auto &){
100 if (!item.caption.empty()) {
101 auto subMenu = std::move(mMenus.back());
102 mMenus.pop_back();
103 mMenu = mMenus.empty() ? mRoot : mMenus.back().get();
104 mMenu->AppendSubMenu(subMenu.release(), item.caption.Translation());
105 }
106 }},
107
108 [this]() {
109 mMenu->AppendSeparator();
110 }
111 }
112 , mMenu{ &menu }
113 , mRoot{ mMenu }
114 , mpUserData{ pUserData }
115 {}
static ProjectFileIORegistry::AttributeWriterEntry entry
wxString Translation() const
std::vector< std::unique_ptr< PopupMenuImpl > > mMenus
@ Item
@ CheckItem
@ RadioItem
TranslatableString caption

References PopupSubMenu::caption, PopupMenuTableEntry::CheckItem, TranslatableString::empty(), entry, PopupMenuTableEntry::Item, PopupMenuTableEntry::RadioItem, and TranslatableString::Translation().

Here is the call graph for this function:

Member Data Documentation

◆ mMenu

PopupMenuImpl* anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder::mMenu

Definition at line 118 of file PopupMenuTable.cpp.

◆ mMenus

std::vector< std::unique_ptr<PopupMenuImpl> > anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder::mMenus

Definition at line 117 of file PopupMenuTable.cpp.

◆ mpUserData

void* const anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder::mpUserData

Definition at line 119 of file PopupMenuTable.cpp.

◆ mRoot

PopupMenuImpl * anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder::mRoot

Definition at line 118 of file PopupMenuTable.cpp.


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