mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-10 17:11:17 +02:00
Implement alpha-only diagnostic command to dump the menu tree...
... This demonstrates the possibility of visitation of the menu tree specifying other actions. This dumps the internal path identifiers of the registry -- not the user visible names. Note that lines don't exactly correspond with menu items, where there are command groups such as Align, or special steps such as population of the recent files sub-menu. Perhaps this should be adapted as another case of the GetInfo macro command.
This commit is contained in:
parent
356e5d545e
commit
27ffd9c8fb
@ -14,6 +14,7 @@
|
|||||||
#include "../Dependencies.h"
|
#include "../Dependencies.h"
|
||||||
#include "../FileNames.h"
|
#include "../FileNames.h"
|
||||||
#include "../HelpText.h"
|
#include "../HelpText.h"
|
||||||
|
#include "../Menus.h"
|
||||||
#include "../Prefs.h"
|
#include "../Prefs.h"
|
||||||
#include "../Project.h"
|
#include "../Project.h"
|
||||||
#include "../ProjectSelectionManager.h"
|
#include "../ProjectSelectionManager.h"
|
||||||
@ -35,7 +36,8 @@ namespace {
|
|||||||
|
|
||||||
void ShowDiagnostics(
|
void ShowDiagnostics(
|
||||||
AudacityProject &project, const wxString &info,
|
AudacityProject &project, const wxString &info,
|
||||||
const TranslatableString &description, const wxString &defaultPath)
|
const TranslatableString &description, const wxString &defaultPath,
|
||||||
|
bool fixedWidth = false)
|
||||||
{
|
{
|
||||||
auto &window = GetProjectFrame( project );
|
auto &window = GetProjectFrame( project );
|
||||||
wxDialogWrapper dlg( &window, wxID_ANY, description);
|
wxDialogWrapper dlg( &window, wxID_ANY, description);
|
||||||
@ -46,12 +48,21 @@ void ShowDiagnostics(
|
|||||||
S.StartVerticalLay();
|
S.StartVerticalLay();
|
||||||
{
|
{
|
||||||
text = S.Id(wxID_STATIC)
|
text = S.Id(wxID_STATIC)
|
||||||
.Style(wxTE_MULTILINE | wxTE_READONLY)
|
.Style(wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH)
|
||||||
.AddTextWindow(info);
|
.AddTextWindow("");
|
||||||
|
|
||||||
S.AddStandardButtons(eOkButton | eCancelButton);
|
S.AddStandardButtons(eOkButton | eCancelButton);
|
||||||
}
|
}
|
||||||
S.EndVerticalLay();
|
S.EndVerticalLay();
|
||||||
|
|
||||||
|
if (fixedWidth) {
|
||||||
|
auto style = text->GetDefaultStyle();
|
||||||
|
style.SetFontFamily( wxFONTFAMILY_TELETYPE );
|
||||||
|
text->SetDefaultStyle(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
*text << info;
|
||||||
|
|
||||||
dlg.FindWindowById(wxID_OK)->SetLabel(_("&Save"));
|
dlg.FindWindowById(wxID_OK)->SetLabel(_("&Save"));
|
||||||
dlg.SetSize(350, 450);
|
dlg.SetSize(350, 450);
|
||||||
|
|
||||||
@ -364,6 +375,54 @@ void OnCheckDependencies(const CommandContext &context)
|
|||||||
::ShowDependencyDialogIfNeeded(&project, false);
|
::ShowDependencyDialogIfNeeded(&project, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnMenuTree(const CommandContext &context)
|
||||||
|
{
|
||||||
|
auto &project = context.project;
|
||||||
|
|
||||||
|
using namespace MenuTable;
|
||||||
|
struct MyVisitor : Visitor
|
||||||
|
{
|
||||||
|
enum : unsigned { TAB = 3 };
|
||||||
|
void BeginGroup( GroupItem &item, const Path& ) override
|
||||||
|
{
|
||||||
|
Indent();
|
||||||
|
// using GET for alpha only diagnostic tool
|
||||||
|
info += item.name.GET();
|
||||||
|
Return();
|
||||||
|
indentation = wxString{ ' ', TAB * ++level };
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndGroup( GroupItem &, const Path& ) override
|
||||||
|
{
|
||||||
|
indentation = wxString{ ' ', TAB * --level };
|
||||||
|
}
|
||||||
|
|
||||||
|
void Visit( SingleItem &item, const Path& ) override
|
||||||
|
{
|
||||||
|
static const wxString separatorName{ '=', 20 };
|
||||||
|
|
||||||
|
Indent();
|
||||||
|
info += dynamic_cast<SeparatorItem*>(&item)
|
||||||
|
? separatorName
|
||||||
|
// using GET for alpha only diagnostic tool
|
||||||
|
: item.name.GET();
|
||||||
|
Return();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Indent() { info += indentation; }
|
||||||
|
void Return() { info += '\n'; }
|
||||||
|
|
||||||
|
unsigned level{};
|
||||||
|
wxString indentation;
|
||||||
|
wxString info;
|
||||||
|
} visitor;
|
||||||
|
|
||||||
|
MenuManager::Visit( visitor, project );
|
||||||
|
|
||||||
|
ShowDiagnostics( project, visitor.info,
|
||||||
|
XO("Menu Tree"), wxT("menutree.txt"), true );
|
||||||
|
}
|
||||||
|
|
||||||
void OnCheckForUpdates(const CommandContext &WXUNUSED(context))
|
void OnCheckForUpdates(const CommandContext &WXUNUSED(context))
|
||||||
{
|
{
|
||||||
::OpenInDefaultBrowser( VerCheckUrl());
|
::OpenInDefaultBrowser( VerCheckUrl());
|
||||||
@ -463,6 +522,14 @@ MenuTable::BaseItemSharedPtr HelpMenu()
|
|||||||
Command( wxT("CheckDeps"), XXO("Chec&k Dependencies..."),
|
Command( wxT("CheckDeps"), XXO("Chec&k Dependencies..."),
|
||||||
FN(OnCheckDependencies),
|
FN(OnCheckDependencies),
|
||||||
AudioIONotBusyFlag )
|
AudioIONotBusyFlag )
|
||||||
|
|
||||||
|
#ifdef IS_ALPHA
|
||||||
|
,
|
||||||
|
// Menu explorer. Perhaps this should become a macro command
|
||||||
|
Command( wxT("MenuTree"), XXO("Menu Tree..."),
|
||||||
|
FN(OnMenuTree),
|
||||||
|
AlwaysEnabledFlag )
|
||||||
|
#endif
|
||||||
),
|
),
|
||||||
|
|
||||||
#ifndef __WXMAC__
|
#ifndef __WXMAC__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user