Difference between revisions of "Toolbox/Menus"

From Audacity Wiki
Jump to: navigation, search
(Making images for documentation.)
(Construction.)
 
Line 5: Line 5:
 
==Constructing Menus==
 
==Constructing Menus==
  
  Blah de blah...
+
Here's the top level of the Help menu.
 +
 
 +
[[File:HelpMenu.png]]
 +
 
 +
Here, below, is the definition of menus from [https://doxy.audacityteam.org/_help_menus_8cpp_source.html HelpMenus.cpp] that creates it. The three sections of the menu are named "Basic", "Other" and "" (i.e no name) which is to make it easier for other menu definitions to add additional menu items in later in the appropriate section of the menu. XXO( "something" ) are the text strings that appear in the menu and are translated.  wxT("something") are the command IDs that are used by scripting and that are supposed not to change if we change the visible name of the command.  FN(OnSomething) are the names of the functions called for that menu item.
 +
 
 +
  487 // Menu definitions
 +
  488
 +
  489 #define FN(X) (& HelpActions::Handler :: X)
 +
  490
 +
  491 namespace {
 +
  492 using namespace MenuTable;
 +
  493 BaseItemSharedPtr HelpMenu()
 +
  494 {
 +
  495    static BaseItemSharedPtr menu{
 +
  496    ( FinderScope{ findCommandHandler },
 +
  497    Menu( wxT("Help"), XO("&Help"),
 +
  498      Section( "Basic",
 +
  512          Command( wxT("QuickHelp"), XXO("&Quick Help..."), FN(OnQuickHelp),
 +
  513            AlwaysEnabledFlag ),
 +
  514          Command( wxT("Manual"), XXO("&Manual..."), FN(OnManual),
 +
  515            AlwaysEnabledFlag )
 +
  517      ),
 +
  518
 +
  522      Section
 +
  524      ( "Other",
 +
  525          Menu( wxT("Diagnostics"), XO("&Diagnostics"),
 +
  526            Command( wxT("DeviceInfo"), XXO("Au&dio Device Info..."),
 +
  527                FN(OnAudioDeviceInfo),
 +
  528                AudioIONotBusyFlag() ),
 +
  529      #ifdef EXPERIMENTAL_MIDI_OUT
 +
  530            Command( wxT("MidiDeviceInfo"), XXO("&MIDI Device Info..."),
 +
  531                FN(OnMidiDeviceInfo),
 +
  532                AudioIONotBusyFlag() ),
 +
  533      #endif
 +
  534            Command( wxT("Log"), XXO("Show &Log..."), FN(OnShowLog),
 +
  535                AlwaysEnabledFlag ),
 +
  536      #if defined(EXPERIMENTAL_CRASH_REPORT)
 +
  537            Command( wxT("CrashReport"), XXO("&Generate Support Data..."),
 +
  538                FN(OnCrashReport), AlwaysEnabledFlag ),
 +
  539      #endif
 +
  540            Command( wxT("CheckDeps"), XXO("Chec&k Dependencies..."),
 +
  541                FN(OnCheckDependencies),
 +
  542                AudioIONotBusyFlag() )
 +
  543
 +
  551          )
 +
  553      ),
 +
  554
 +
  555      Section( "",
 +
  559
 +
  562          Command( wxT("Updates"), XXO("&Check for Updates..."),
 +
  563            FN(OnCheckForUpdates),
 +
  564            AlwaysEnabledFlag ),
 +
  566          Command( wxT("About"), XXO("&About Audacity..."), FN(OnAbout),
 +
  567            AlwaysEnabledFlag )
 +
  568      )
 +
  569    ) ) };
 +
  570    return menu;
 +
  571 }
 +
  572
 +
  573 AttachedItem sAttachment1{
 +
  574    wxT(""),
 +
  575    Shared( HelpMenu() )
 +
  576 };
 +
  577
 +
  578 }
 +
  579
 +
  580 #undef FN
 +
 
 +
 
 +
 
  
 
==Making Images of the Menus==
 
==Making Images of the Menus==

Latest revision as of 09:51, 13 March 2020

This page of developer code and/or digital audio documentation is part of a collection of pages for learning about our code. We aim to increasingly add interactive diagrams to these pages and over time connect better to the doxygen documentation.


Constructing Menus

Here's the top level of the Help menu.

HelpMenu.png

Here, below, is the definition of menus from HelpMenus.cpp that creates it. The three sections of the menu are named "Basic", "Other" and "" (i.e no name) which is to make it easier for other menu definitions to add additional menu items in later in the appropriate section of the menu. XXO( "something" ) are the text strings that appear in the menu and are translated. wxT("something") are the command IDs that are used by scripting and that are supposed not to change if we change the visible name of the command. FN(OnSomething) are the names of the functions called for that menu item.

 487 // Menu definitions
 488 
 489 #define FN(X) (& HelpActions::Handler :: X)
 490 
 491 namespace {
 492 using namespace MenuTable;
 493 BaseItemSharedPtr HelpMenu()
 494 {
 495    static BaseItemSharedPtr menu{
 496    ( FinderScope{ findCommandHandler },
 497    Menu( wxT("Help"), XO("&Help"),
 498       Section( "Basic",
 512          Command( wxT("QuickHelp"), XXO("&Quick Help..."), FN(OnQuickHelp),
 513             AlwaysEnabledFlag ),
 514          Command( wxT("Manual"), XXO("&Manual..."), FN(OnManual),
 515             AlwaysEnabledFlag )
 517       ),
 518 
 522       Section
 524       ( "Other",
 525          Menu( wxT("Diagnostics"), XO("&Diagnostics"),
 526             Command( wxT("DeviceInfo"), XXO("Au&dio Device Info..."),
 527                FN(OnAudioDeviceInfo),
 528                AudioIONotBusyFlag() ),
 529       #ifdef EXPERIMENTAL_MIDI_OUT
 530             Command( wxT("MidiDeviceInfo"), XXO("&MIDI Device Info..."),
 531                FN(OnMidiDeviceInfo),
 532                AudioIONotBusyFlag() ),
 533       #endif
 534             Command( wxT("Log"), XXO("Show &Log..."), FN(OnShowLog),
 535                AlwaysEnabledFlag ),
 536       #if defined(EXPERIMENTAL_CRASH_REPORT)
 537             Command( wxT("CrashReport"), XXO("&Generate Support Data..."),
 538                FN(OnCrashReport), AlwaysEnabledFlag ),
 539       #endif
 540             Command( wxT("CheckDeps"), XXO("Chec&k Dependencies..."),
 541                FN(OnCheckDependencies),
 542                AudioIONotBusyFlag() )
 543 
 551          )
 553       ),
 554 
 555       Section( "",
 559 
 562          Command( wxT("Updates"), XXO("&Check for Updates..."),
 563             FN(OnCheckForUpdates),
 564             AlwaysEnabledFlag ),
 566          Command( wxT("About"), XXO("&About Audacity..."), FN(OnAbout),
 567             AlwaysEnabledFlag )
 568       )
 569    ) ) };
 570    return menu;
 571 }
 572 
 573 AttachedItem sAttachment1{
 574    wxT(""),
 575    Shared( HelpMenu() )
 576 };
 577 
 578 }
 579 
 580 #undef FN



Making Images of the Menus

A JSON description of the Audacity menus is available in this wiki at WIT_Audacity_Menus. This description is obtained by invoking the GetInfo command in Audacity. WIT pulls the description from the wiki and uses it in constructing the images and image maps in the manual.

Relevant Classes

Here are some more classes relevant to menus.