Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
PopupMenuTable Class Referenceabstract

#include <PopupMenuTable.h>

Inheritance diagram for PopupMenuTable:
[legend]
Collaboration diagram for PopupMenuTable:
[legend]

Classes

struct  AttachedItem
 

Public Types

using Entry = PopupMenuTableEntry
 

Public Member Functions

 PopupMenuTable (const Identifier &id, const TranslatableString &caption={})
 
const IdentifierId () const
 
const TranslatableStringCaption () const
 
const auto * GetRegistry () const
 
const auto & Get (void *pUserData)
 
void Clear ()
 
- Public Member Functions inherited from PopupMenuHandler
 PopupMenuHandler ()=default
 
 PopupMenuHandler (const PopupMenuHandler &)=delete
 
PopupMenuHandleroperator= (const PopupMenuHandler &)=delete
 
virtual void InitUserData (void *pUserData)=0
 Called before the menu items are appended. More...
 

Static Public Member Functions

static std::unique_ptr< PopupMenuBuildMenu (PopupMenuTable *pTable, void *pUserData=NULL)
 
static void ExtendMenu (PopupMenu &menu, PopupMenuTable &otherTable)
 
template<typename Table , typename Factory >
static auto Adapt (const Factory &factory)
 

Protected Member Functions

virtual void Populate ()=0
 
template<typename Ptr >
void Append (Ptr pItem)
 
void Append (const Identifier &stringId, PopupMenuTableEntry::Type type, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init)
 
void AppendItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void AppendRadioItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void AppendCheckItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void BeginSection (const Identifier &name)
 
void EndSection ()
 

Static Protected Member Functions

static TranslatableString MakeLabel (const TranslatableString &label, bool useExtra, const TranslatableString &extra)
 

Protected Attributes

std::shared_ptr< PopupSubMenumTop
 
std::vector< PopupMenuGroupItem * > mStack
 
Identifier mId
 
TranslatableString mCaption
 
std::unique_ptr< PopupMenuGroupItemmRegistry
 

Private Member Functions

template<typename Ptr >
void RegisterItem (const Registry::Placement &placement, Ptr pItem)
 

Detailed Description

Definition at line 121 of file PopupMenuTable.h.

Member Typedef Documentation

◆ Entry

Definition at line 124 of file PopupMenuTable.h.

Constructor & Destructor Documentation

◆ PopupMenuTable()

PopupMenuTable::PopupMenuTable ( const Identifier id,
const TranslatableString caption = {} 
)
inline

Definition at line 127 of file PopupMenuTable.h.

127 {})
128 : mId{ id }
129 , mCaption{ caption }
130 , mRegistry{
131 std::make_unique<PopupMenuGroupItem>(mId) }
132 {}
Identifier mId
std::unique_ptr< PopupMenuGroupItem > mRegistry
TranslatableString mCaption

Member Function Documentation

◆ Adapt()

template<typename Table , typename Factory >
static auto PopupMenuTable::Adapt ( const Factory &  factory)
inlinestatic

Definition at line 170 of file PopupMenuTable.h.

171 {
172 return [factory](PopupMenuTable &table){
173 return std::shared_ptr{ factory(static_cast<Table&>(table)) };
174 };
175 }
static RegisteredToolbarFactory factory

References factory.

◆ Append() [1/2]

void PopupMenuTable::Append ( const Identifier stringId,
PopupMenuTableEntry::Type  type,
int  id,
const TranslatableString string,
wxCommandEventFunction  memFn,
const PopupMenuTableEntry::InitFunction init 
)
protected

Definition at line 146 of file PopupMenuTable.cpp.

150{
151 Append( std::make_unique<Entry>(
152 stringId, type, id, string, memFn, *this, init ) );
153}
void Append(Ptr pItem)

References Append().

Here is the call graph for this function:

◆ Append() [2/2]

template<typename Ptr >
void PopupMenuTable::Append ( Ptr  pItem)
inlineprotected

Definition at line 199 of file PopupMenuTable.h.

199{ mStack.back()->push_back(std::move(pItem)); }
std::vector< PopupMenuGroupItem * > mStack

Referenced by Append().

Here is the caller graph for this function:

◆ AppendCheckItem()

void PopupMenuTable::AppendCheckItem ( const Identifier stringId,
int  id,
const TranslatableString string,
wxCommandEventFunction  memFn,
const PopupMenuTableEntry::InitFunction init = {} 
)
inlineprotected

Definition at line 219 of file PopupMenuTable.h.

221 {} )
222 { Append( stringId, PopupMenuTableEntry::CheckItem, id, string, memFn, init ); }
@ CheckItem

◆ AppendItem()

void PopupMenuTable::AppendItem ( const Identifier stringId,
int  id,
const TranslatableString string,
wxCommandEventFunction  memFn,
const PopupMenuTableEntry::InitFunction init = {} 
)
inlineprotected

Definition at line 207 of file PopupMenuTable.h.

210 {} )
211 { Append( stringId, PopupMenuTableEntry::Item, id, string, memFn, init ); }
@ Item

◆ AppendRadioItem()

void PopupMenuTable::AppendRadioItem ( const Identifier stringId,
int  id,
const TranslatableString string,
wxCommandEventFunction  memFn,
const PopupMenuTableEntry::InitFunction init = {} 
)
inlineprotected

Definition at line 213 of file PopupMenuTable.h.

216 {} )
217 { Append( stringId, PopupMenuTableEntry::RadioItem, id, string, memFn, init ); }
@ RadioItem

◆ BeginSection()

void PopupMenuTable::BeginSection ( const Identifier name)
protected

Definition at line 155 of file PopupMenuTable.cpp.

156{
157 auto uSection = std::make_unique< PopupMenuSection >( name );
158 auto section = uSection.get();
159 mStack.back()->push_back( std::move( uSection ) );
160 mStack.push_back( section );
161}
const TranslatableString name
Definition: Distortion.cpp:76

References mStack, and name.

◆ BuildMenu()

std::unique_ptr< PopupMenu > PopupMenuTable::BuildMenu ( PopupMenuTable pTable,
void *  pUserData = NULL 
)
static

Definition at line 169 of file PopupMenuTable.cpp.

171{
172 // Rebuild as needed each time. That makes it safe in case of language change.
173 auto theMenu = std::make_unique<PopupMenuImpl>( pUserData );
174 ExtendMenu( *theMenu, *pTable );
175 return theMenu;
176}
static void ExtendMenu(PopupMenu &menu, PopupMenuTable &otherTable)

References ExtendMenu().

Referenced by CommonTrackControls::DoContextMenu(), WaveChannelVZoomHandle::DoRelease(), NoteTrackVZoomHandle::Release(), and TimeTrackVZoomHandle::Release().

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

◆ Caption()

const TranslatableString & PopupMenuTable::Caption ( ) const
inline

Definition at line 140 of file PopupMenuTable.h.

140{ return mCaption; }

Referenced by WaveTrackMenuTable::OnMergeStereo().

Here is the caller graph for this function:

◆ Clear()

void PopupMenuTable::Clear ( )
inline

Definition at line 163 of file PopupMenuTable.h.

164 {
165 mTop.reset();
166 }
std::shared_ptr< PopupSubMenu > mTop

Referenced by NoteTrackVRulerMenuTable::UpdatePrefs(), WaveChannelVRulerMenuTable::UpdatePrefs(), and TrackMenuTable::UpdatePrefs().

Here is the caller graph for this function:

◆ EndSection()

void PopupMenuTable::EndSection ( )
protected

Definition at line 163 of file PopupMenuTable.cpp.

164{
165 mStack.pop_back();
166}

References mStack.

◆ ExtendMenu()

void PopupMenuTable::ExtendMenu ( PopupMenu menu,
PopupMenuTable otherTable 
)
static

Definition at line 137 of file PopupMenuTable.cpp.

138{
139 auto &theMenu = dynamic_cast<PopupMenuImpl&>(menu);
140
141 PopupMenuBuilder visitor{ table, theMenu, theMenu.pUserData };
142 Registry::VisitWithFunctions(visitor, table.Get(theMenu.pUserData).get(),
143 table.GetRegistry(), table);
144}
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 Get(), GetRegistry(), and Registry::VisitWithFunctions().

Referenced by BuildMenu(), and CommonTrackControls::DoContextMenu().

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

◆ Get()

const auto & PopupMenuTable::Get ( void *  pUserData)
inline

Definition at line 154 of file PopupMenuTable.h.

155 {
156 if ( pUserData )
157 this->InitUserData( pUserData );
158 if (!mTop)
159 Populate();
160 return mTop;
161 }
virtual void InitUserData(void *pUserData)=0
Called before the menu items are appended.
virtual void Populate()=0

Referenced by ExtendMenu().

Here is the caller graph for this function:

◆ GetRegistry()

const auto * PopupMenuTable::GetRegistry ( ) const
inline

Definition at line 141 of file PopupMenuTable.h.

141{ return mRegistry.get(); }

Referenced by ExtendMenu().

Here is the caller graph for this function:

◆ Id()

const Identifier & PopupMenuTable::Id ( ) const
inline

Definition at line 139 of file PopupMenuTable.h.

139{ return mId; }

◆ MakeLabel()

static TranslatableString PopupMenuTable::MakeLabel ( const TranslatableString label,
bool  useExtra,
const TranslatableString extra 
)
inlinestaticprotected

Definition at line 187 of file PopupMenuTable.h.

189 {
190 return useExtra
191 ? XXO("%s (%s)").Format( label, extra )
192 : label;
193 }
XXO("&Cut/Copy/Paste Toolbar")
TranslatableString label
Definition: TagsEditor.cpp:165

References label, and XXO().

Here is the call graph for this function:

◆ Populate()

virtual void PopupMenuTable::Populate ( )
protectedpure virtual

◆ RegisterItem()

template<typename Ptr >
void PopupMenuTable::RegisterItem ( const Registry::Placement placement,
Ptr  pItem 
)
inlineprivate

Definition at line 178 of file PopupMenuTable.h.

180 {
181 Registry::RegisterItem(*mRegistry, placement, move(pItem));
182 }
void RegisterItem(GroupItem< RegistryTraits > &registry, const Placement &placement, std::unique_ptr< Item > pItem)
Definition: Registry.h:371

References Registry::RegisterItem().

Referenced by PopupMenuTable::AttachedItem< Ptr >::AttachedItem().

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

Member Data Documentation

◆ mCaption

TranslatableString PopupMenuTable::mCaption
protected

Definition at line 230 of file PopupMenuTable.h.

◆ mId

Identifier PopupMenuTable::mId
protected

Definition at line 229 of file PopupMenuTable.h.

◆ mRegistry

std::unique_ptr<PopupMenuGroupItem> PopupMenuTable::mRegistry
protected

Definition at line 231 of file PopupMenuTable.h.

◆ mStack

std::vector<PopupMenuGroupItem*> PopupMenuTable::mStack
protected

Definition at line 228 of file PopupMenuTable.h.

Referenced by BeginSection(), and EndSection().

◆ mTop

std::shared_ptr<PopupSubMenu> PopupMenuTable::mTop
protected

Definition at line 227 of file PopupMenuTable.h.


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