Audacity  3.0.3
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 Registry::GroupItemGetRegistry () const
 
const std::shared_ptr< Registry::GroupItem > & 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 >
static Registry::BaseItemPtr Computed (const std::function< Registry::BaseItemPtr(Table &) > &factory)
 

Protected Member Functions

virtual void Populate ()=0
 
void Append (Registry::BaseItemPtr 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< Registry::GroupItemmTop
 
std::vector< Registry::GroupItem * > mStack
 
Identifier mId
 
TranslatableString mCaption
 
std::unique_ptr< Registry::GroupItemmRegistry
 

Private Member Functions

void RegisterItem (const Registry::Placement &placement, Registry::BaseItemPtr pItem)
 

Detailed Description

Definition at line 114 of file PopupMenuTable.h.

Member Typedef Documentation

◆ Entry

Definition at line 117 of file PopupMenuTable.h.

Constructor & Destructor Documentation

◆ PopupMenuTable()

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

Definition at line 120 of file PopupMenuTable.h.

120  {} )
121  : mId{ id }
122  , mCaption{ caption }
123  , mRegistry{ std::make_unique<Registry::TransparentGroupItem<>>( mId ) }
124  {}

Member Function Documentation

◆ 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 167 of file PopupMenuTable.cpp.

171 {
172  Append( std::make_unique<Entry>(
173  stringId, type, id, string, memFn, *this, init ) );
174 }

References Append().

Here is the call graph for this function:

◆ Append() [2/2]

void PopupMenuTable::Append ( Registry::BaseItemPtr  pItem)
protected

Definition at line 162 of file PopupMenuTable.cpp.

163 {
164  mStack.back()->items.push_back( std::move( pItem ) );
165 }

References mStack.

Referenced by Append(), and for().

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 214 of file PopupMenuTable.h.

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

◆ AppendItem()

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

Definition at line 202 of file PopupMenuTable.h.

205  {} )
206  { Append( stringId, PopupMenuTableEntry::Item, id, string, memFn, init ); }

◆ AppendRadioItem()

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

Definition at line 208 of file PopupMenuTable.h.

211  {} )
212  { Append( stringId, PopupMenuTableEntry::RadioItem, id, string, memFn, init ); }

◆ BeginSection()

void PopupMenuTable::BeginSection ( const Identifier name)
protected

Definition at line 176 of file PopupMenuTable.cpp.

177 {
178  auto uSection = std::make_unique< PopupMenuSection >( name );
179  auto section = uSection.get();
180  mStack.back()->items.push_back( std::move( uSection ) );
181  mStack.push_back( section );
182 }

References mStack, and name.

◆ BuildMenu()

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

Definition at line 190 of file PopupMenuTable.cpp.

192 {
193  // Rebuild as needed each time. That makes it safe in case of language change.
194  auto theMenu = std::make_unique<PopupMenuImpl>( pUserData );
195  ExtendMenu( *theMenu, *pTable );
196  return theMenu;
197 }

References ExtendMenu().

Referenced by CommonTrackControls::DoContextMenu(), WaveTrackVZoomHandle::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 132 of file PopupMenuTable.h.

132 { return mCaption; }

◆ Clear()

void PopupMenuTable::Clear ( )
inline

Definition at line 155 of file PopupMenuTable.h.

156  {
157  mTop.reset();
158  }

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

Here is the caller graph for this function:

◆ Computed()

template<typename Table >
static Registry::BaseItemPtr PopupMenuTable::Computed ( const std::function< Registry::BaseItemPtr(Table &) > &  factory)
inlinestatic

Definition at line 163 of file PopupMenuTable.h.

165  {
166  using namespace Registry;
167  return std::make_unique< ComputedItem >(
168  [factory]( Visitor &baseVisitor ){
169  auto &visitor = static_cast< PopupMenuVisitor& >( baseVisitor );
170  auto &table = static_cast< Table& >( visitor.mTable );
171  return factory( table );
172  }
173  );
174  }

References factory.

◆ EndSection()

void PopupMenuTable::EndSection ( )
protected

Definition at line 184 of file PopupMenuTable.cpp.

185 {
186  mStack.pop_back();
187 }

References mStack.

◆ ExtendMenu()

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

Definition at line 147 of file PopupMenuTable.cpp.

148 {
149  auto &theMenu = dynamic_cast<PopupMenuImpl&>(menu);
150 
151  PopupMenuBuilder visitor{ table, theMenu, theMenu.pUserData };
153  visitor, table.Get( theMenu.pUserData ).get(), table.GetRegistry() );
154 }

References Get(), GetRegistry(), and Registry::Visit().

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

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

◆ Get()

const std::shared_ptr< Registry::GroupItem >& PopupMenuTable::Get ( void *  pUserData)
inline

Definition at line 146 of file PopupMenuTable.h.

147  {
148  if ( pUserData )
149  this->InitUserData( pUserData );
150  if (!mTop)
151  Populate();
152  return mTop;
153  }

References PopupMenuHandler::InitUserData().

Referenced by ExtendMenu().

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

◆ GetRegistry()

const Registry::GroupItem* PopupMenuTable::GetRegistry ( ) const
inline

Definition at line 133 of file PopupMenuTable.h.

133 { return mRegistry.get(); }

Referenced by ExtendMenu().

Here is the caller graph for this function:

◆ Id()

const Identifier& PopupMenuTable::Id ( ) const
inline

Definition at line 131 of file PopupMenuTable.h.

131 { return mId; }

◆ MakeLabel()

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

Definition at line 183 of file PopupMenuTable.h.

185  {
186  return useExtra
187  ? XXO("%s (%s)").Format( label, extra )
188  : label;
189  }

References label, and XXO.

◆ Populate()

virtual void PopupMenuTable::Populate ( )
protectedpure virtual

◆ RegisterItem()

void PopupMenuTable::RegisterItem ( const Registry::Placement placement,
Registry::BaseItemPtr  pItem 
)
private

Definition at line 156 of file PopupMenuTable.cpp.

158 {
159  Registry::RegisterItem( *mRegistry, placement, std::move( pItem ) );
160 }

References mRegistry, and Registry::RegisterItem().

Referenced by PopupMenuTable::AttachedItem::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 225 of file PopupMenuTable.h.

◆ mId

Identifier PopupMenuTable::mId
protected

Definition at line 224 of file PopupMenuTable.h.

◆ mRegistry

std::unique_ptr<Registry::GroupItem> PopupMenuTable::mRegistry
protected

Definition at line 226 of file PopupMenuTable.h.

Referenced by RegisterItem().

◆ mStack

std::vector< Registry::GroupItem* > PopupMenuTable::mStack
protected

Definition at line 223 of file PopupMenuTable.h.

Referenced by Append(), BeginSection(), and EndSection().

◆ mTop

std::shared_ptr< Registry::GroupItem > PopupMenuTable::mTop
protected

Definition at line 222 of file PopupMenuTable.h.


The documentation for this class was generated from the following files:
PopupMenuTable::mRegistry
std::unique_ptr< Registry::GroupItem > mRegistry
Definition: PopupMenuTable.h:226
Registry::RegisterItem
void RegisterItem(GroupItem &registry, const Placement &placement, BaseItemPtr pItem)
Definition: Registry.cpp:750
Registry
Definition: Menus.h:35
PopupMenuTable::mStack
std::vector< Registry::GroupItem * > mStack
Definition: PopupMenuTable.h:223
PopupMenuTable::Populate
virtual void Populate()=0
PopupMenuTableEntry::Item
@ Item
Definition: PopupMenuTable.h:36
PopupMenuTableEntry::RadioItem
@ RadioItem
Definition: PopupMenuTable.h:36
Registry::Visitor
Definition: Registry.h:242
XXO
#define XXO(s)
Definition: Internat.h:44
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:817
label
TranslatableString label
Definition: Tags.cpp:756
PopupMenuVisitor
Definition: PopupMenuTable.h:101
name
const TranslatableString name
Definition: Distortion.cpp:98
PopupMenuHandler::InitUserData
virtual void InitUserData(void *pUserData)=0
Called before the menu items are appended.
PopupMenuTableEntry::CheckItem
@ CheckItem
Definition: PopupMenuTable.h:36
PopupMenuTable::mTop
std::shared_ptr< Registry::GroupItem > mTop
Definition: PopupMenuTable.h:222
Registry::Visit
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry)
Definition: Registry.cpp:713
PopupMenuTable::Append
void Append(Registry::BaseItemPtr pItem)
Definition: PopupMenuTable.cpp:162
PopupMenuTable::ExtendMenu
static void ExtendMenu(PopupMenu &menu, PopupMenuTable &otherTable)
Definition: PopupMenuTable.cpp:147
PopupMenuTable::mId
Identifier mId
Definition: PopupMenuTable.h:224
PopupMenuTable::mCaption
TranslatableString mCaption
Definition: PopupMenuTable.h:225