Audacity  3.0.3
Public Member Functions | Public Attributes | List of all members
anonymous_namespace{Menus.cpp}::MenuItemVisitor Struct Reference
Inheritance diagram for anonymous_namespace{Menus.cpp}::MenuItemVisitor:
[legend]
Collaboration diagram for anonymous_namespace{Menus.cpp}::MenuItemVisitor:
[legend]

Public Member Functions

 MenuItemVisitor (AudacityProject &proj, CommandManager &man)
 
void DoBeginGroup (GroupItem &item, const Path &) override
 
void DoEndGroup (GroupItem &item, const Path &) override
 
void DoVisit (SingleItem &item, const Path &) override
 
void DoSeparator () override
 
- Public Member Functions inherited from ToolbarMenuVisitor
 ToolbarMenuVisitor (AudacityProject &p)
 
 operator AudacityProject & () const
 
- Public Member Functions inherited from MenuVisitor
void BeginGroup (Registry::GroupItem &item, const Path &path) final
 
void EndGroup (Registry::GroupItem &item, const Path &) final
 
void Visit (Registry::SingleItem &item, const Path &path) final
 
- Public Member Functions inherited from Registry::Visitor
virtual ~Visitor ()
 

Public Attributes

CommandManagermanager
 
std::vector< bool > flags
 
- Public Attributes inherited from ToolbarMenuVisitor
AudacityProjectproject
 

Additional Inherited Members

- Public Types inherited from Registry::Visitor
using Path = std::vector< Identifier >
 

Detailed Description

Definition at line 280 of file Menus.cpp.

Constructor & Destructor Documentation

◆ MenuItemVisitor()

anonymous_namespace{Menus.cpp}::MenuItemVisitor::MenuItemVisitor ( AudacityProject proj,
CommandManager man 
)
inline

Definition at line 282 of file Menus.cpp.

283  : ToolbarMenuVisitor(proj), manager( man ) {}

Member Function Documentation

◆ DoBeginGroup()

void anonymous_namespace{Menus.cpp}::MenuItemVisitor::DoBeginGroup ( GroupItem item,
const Path  
)
inlineoverridevirtual

Reimplemented from MenuVisitor.

Definition at line 285 of file Menus.cpp.

286  {
287  auto pItem = &item;
288  if (const auto pMenu =
289  dynamic_cast<MenuItem*>( pItem )) {
290  manager.BeginMenu( pMenu->title );
291  }
292  else
293  if (const auto pConditionalGroup =
294  dynamic_cast<ConditionalGroupItem*>( pItem )) {
295  const auto flag = pConditionalGroup->condition();
296  if (!flag)
298  // to avoid repeated call of condition predicate in EndGroup():
299  flags.push_back(flag);
300  }
301  else
302  if ( pItem->Transparent() ) {
303  }
304  else
305  if ( const auto pGroup = dynamic_cast<MenuSection*>( pItem ) ) {
306  }
307  else
308  wxASSERT( false );
309  }

References flag.

◆ DoEndGroup()

void anonymous_namespace{Menus.cpp}::MenuItemVisitor::DoEndGroup ( GroupItem item,
const Path  
)
inlineoverridevirtual

Reimplemented from MenuVisitor.

Definition at line 311 of file Menus.cpp.

312  {
313  auto pItem = &item;
314  if (const auto pMenu =
315  dynamic_cast<MenuItem*>( pItem )) {
316  manager.EndMenu();
317  }
318  else
319  if (const auto pConditionalGroup =
320  dynamic_cast<ConditionalGroupItem*>( pItem )) {
321  const bool flag = flags.back();
322  if (!flag)
324  flags.pop_back();
325  }
326  else
327  if ( pItem->Transparent() ) {
328  }
329  else
330  if ( const auto pGroup = dynamic_cast<MenuSection*>( pItem ) ) {
331  }
332  else
333  wxASSERT( false );
334  }

References flag.

◆ DoSeparator()

void anonymous_namespace{Menus.cpp}::MenuItemVisitor::DoSeparator ( )
inlineoverridevirtual

Reimplemented from MenuVisitor.

Definition at line 372 of file Menus.cpp.

373  {
375  }

◆ DoVisit()

void anonymous_namespace{Menus.cpp}::MenuItemVisitor::DoVisit ( SingleItem item,
const Path  
)
inlineoverridevirtual

Reimplemented from MenuVisitor.

Definition at line 336 of file Menus.cpp.

337  {
338  const auto pCurrentMenu = manager.CurrentMenu();
339  if ( !pCurrentMenu ) {
340  // There may have been a mistake in the placement hint that registered
341  // this single item. It's not within any menu.
342  wxASSERT( false );
343  return;
344  }
345  auto pItem = &item;
346  if (const auto pCommand =
347  dynamic_cast<CommandItem*>( pItem )) {
349  pCommand->name, pCommand->label_in,
350  pCommand->finder, pCommand->callback,
351  pCommand->flags, pCommand->options
352  );
353  }
354  else
355  if (const auto pCommandList =
356  dynamic_cast<CommandGroupItem*>( pItem ) ) {
357  manager.AddItemList(pCommandList->name,
358  pCommandList->items.data(), pCommandList->items.size(),
359  pCommandList->finder, pCommandList->callback,
360  pCommandList->flags, pCommandList->isEffect);
361  }
362  else
363  if (const auto pSpecial =
364  dynamic_cast<SpecialItem*>( pItem )) {
365  wxASSERT( pCurrentMenu );
366  pSpecial->fn( project, *pCurrentMenu );
367  }
368  else
369  wxASSERT( false );
370  }

Member Data Documentation

◆ flags

std::vector<bool> anonymous_namespace{Menus.cpp}::MenuItemVisitor::flags

Definition at line 378 of file Menus.cpp.

◆ manager

CommandManager& anonymous_namespace{Menus.cpp}::MenuItemVisitor::manager

Definition at line 377 of file Menus.cpp.


The documentation for this struct was generated from the following file:
flag
static std::once_flag flag
Definition: WaveformView.cpp:1119
anonymous_namespace{Menus.cpp}::MenuItemVisitor::manager
CommandManager & manager
Definition: Menus.cpp:377
ToolbarMenuVisitor::ToolbarMenuVisitor
ToolbarMenuVisitor(AudacityProject &p)
Definition: CommandManager.h:410
CommandManager::AddItem
void AddItem(AudacityProject &project, const CommandID &name, const TranslatableString &label_in, CommandHandlerFinder finder, CommandFunctorPointer callback, CommandFlag flags, const Options &options={})
Definition: CommandManager.cpp:546
MenuTable::SpecialItem
Definition: CommandManager.h:566
CommandManager::EndMenu
void EndMenu()
This attaches a menu, if it's main, to the menubar.
Definition: CommandManager.cpp:437
MenuTable::ConditionalGroupItem
Definition: CommandManager.h:453
CommandManager::BeginMenu
wxMenu * BeginMenu(const TranslatableString &tName)
Definition: CommandManager.cpp:424
anonymous_namespace{Menus.cpp}::MenuItemVisitor::flags
std::vector< bool > flags
Definition: Menus.cpp:378
ToolbarMenuVisitor::project
AudacityProject & project
Definition: CommandManager.h:412
CommandManager::AddItemList
void AddItemList(const CommandID &name, const ComponentInterfaceSymbol items[], size_t nItems, CommandHandlerFinder finder, CommandFunctorPointer callback, CommandFlag flags, bool bIsEffect=false)
Definition: CommandManager.cpp:606
MenuTable::MenuItem
Definition: CommandManager.h:432
CommandManager::CurrentMenu
wxMenu * CurrentMenu() const
Definition: CommandManager.cpp:520
MenuTable::CommandGroupItem
Definition: CommandManager.h:532
MenuTable::CommandItem
Definition: CommandManager.h:498
CommandManager::EndOccultCommands
void EndOccultCommands()
Definition: CommandManager.cpp:1616
CommandManager::AddSeparator
void AddSeparator()
Definition: CommandManager.cpp:647
MenuTable::MenuSection
Definition: CommandManager.h:420
CommandManager::BeginOccultCommands
void BeginOccultCommands()
Definition: CommandManager.cpp:1603