1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-13 16:16:33 +01:00
Files
audacity/src/menus/ToolbarMenus.cpp
James Crook bc621158b8 Update OnResetConfig
Now it resets the toolbars, and fixes three common 'stuck-in-a-mode' issues.

Paul wrote: "I would move that function [OnResetToolBars(context)] into ToolManager.cpp so it can be called from ToolBarMenus.cpp and HelpMenus.cpp, with neither of those two dependent on the other."
2020-05-31 12:22:08 +01:00

78 lines
1.7 KiB
C++

#include "../Audacity.h"
#include "../Menus.h"
#include "../ProjectSettings.h"
#include "../commands/CommandContext.h"
#include "../commands/CommandManager.h"
#include "../toolbars/ToolManager.h"
/// Namespace for functions for View Toolbar menu
namespace ToolbarActions {
// exported helper functions
// none
// Menu handler functions
struct Handler : CommandHandlerObject {
void OnResetToolBars(const CommandContext &context)
{
ToolManager::OnResetToolBars(context);
}
}; // struct Handler
} // namespace
static CommandHandlerObject &findCommandHandler(AudacityProject &) {
// Handler is not stateful. Doesn't need a factory registered with
// AudacityProject.
static ToolbarActions::Handler instance;
return instance;
};
// Menu definitions
#define FN(X) (& ToolbarActions::Handler :: X)
namespace{
using namespace MenuTable;
auto ToolbarCheckFn( int toolbarId ) -> CommandManager::CheckFn
{
return [toolbarId](AudacityProject &project){
auto &toolManager = ToolManager::Get( project );
return toolManager.IsVisible(toolbarId);
};
}
BaseItemSharedPtr ToolbarsMenu()
{
using Options = CommandManager::Options;
static BaseItemSharedPtr menu{
( FinderScope{ findCommandHandler },
Section( wxT("Toolbars"),
Menu( wxT("Toolbars"), XXO("&Toolbars"),
Section( "Reset",
/* i18n-hint: (verb)*/
Command( wxT("ResetToolbars"), XXO("Reset Toolb&ars"),
FN(OnResetToolBars), AlwaysEnabledFlag )
),
Section( "Other" )
)
) ) };
return menu;
}
AttachedItem sAttachment1{
Placement{ wxT("View/Other"), { OrderingHint::Begin } },
Shared( ToolbarsMenu() )
};
}
#undef FN