1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-21 08:27:13 +01:00
This commit is contained in:
Paul Licameli
2020-01-31 22:33:16 -05:00
parent c1d129ec98
commit 2c25a37994
22 changed files with 546 additions and 794 deletions

View File

@@ -2,7 +2,10 @@
#include "../Experimental.h"
#include "../CommonCommandFlags.h"
#include "../HistoryWindow.h"
#include "../LyricsWindow.h"
#include "../Menus.h"
#include "../MixerBoard.h"
#include "../Prefs.h"
#include "../Project.h"
#include "../ProjectHistory.h"
@@ -28,6 +31,25 @@
// private helper classes and functions
namespace {
AudacityProject::AttachedWindows::RegisteredFactory sMixerBoardKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
return safenew MixerBoardFrame( &parent );
}
};
AudacityProject::AttachedWindows::RegisteredFactory sHistoryWindowKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
auto &undoManager = UndoManager::Get( parent );
return safenew HistoryDialog( &parent, &undoManager );
}
};
AudacityProject::AttachedWindows::RegisteredFactory sLyricsWindowKey{
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
return safenew LyricsWindow( &parent );
}
};
double GetZoomOfSelection( const AudacityProject &project )
{
auto &viewInfo = ViewInfo::Get( project );
@@ -303,6 +325,34 @@ void OnGoSelEnd(const CommandContext &context)
selectedRegion.t1() - ((viewInfo.GetScreenEndTime() - viewInfo.h) / 2));
}
void OnHistory(const CommandContext &context)
{
auto &project = context.project;
auto historyWindow = &project.AttachedWindows::Get( sHistoryWindowKey );
historyWindow->Show();
historyWindow->Raise();
}
void OnKaraoke(const CommandContext &context)
{
auto &project = context.project;
auto lyricsWindow = &project.AttachedWindows::Get( sLyricsWindowKey );
lyricsWindow->Show();
lyricsWindow->Raise();
}
void OnMixerBoard(const CommandContext &context)
{
auto &project = context.project;
auto mixerBoardFrame = &project.AttachedWindows::Get( sMixerBoardKey );
mixerBoardFrame->Show();
mixerBoardFrame->Raise();
mixerBoardFrame->SetFocus();
}
void OnShowExtraMenus(const CommandContext &context)
{
auto &project = context.project;
@@ -382,11 +432,12 @@ static CommandHandlerObject &findCommandHandler(AudacityProject &project) {
#define FN(X) (& ViewActions::Handler :: X)
MenuTable::BaseItemSharedPtr ToolbarsMenu();
// Under /MenuBar
namespace {
using namespace MenuTable;
BaseItemSharedPtr ViewMenu()
MenuTable::BaseItemSharedPtr ViewMenu()
{
using namespace MenuTable;
using Options = CommandManager::Options;
static const auto checkOff = Options{}.CheckState( false );
@@ -436,7 +487,59 @@ BaseItemSharedPtr ViewMenu()
)
),
Section( "Windows" ),
Section( "Windows",
// History window should be available either for UndoAvailableFlag
// or RedoAvailableFlag,
// but we can't make the AddItem flags and mask have both,
// because they'd both have to be true for the
// command to be enabled.
// If user has Undone the entire stack, RedoAvailableFlag is on
// but UndoAvailableFlag is off.
// If user has done things but not Undone anything,
// RedoAvailableFlag is off but UndoAvailableFlag is on.
// So in either of those cases,
// (AudioIONotBusyFlag | UndoAvailableFlag | RedoAvailableFlag) mask
// would fail.
// The only way to fix this in the current architecture
// is to hack in special cases for RedoAvailableFlag
// in AudacityProject::UpdateMenus() (ugly)
// and CommandManager::HandleCommandEntry() (*really* ugly --
// shouldn't know about particular command names and flags).
// Here's the hack that would be necessary in
// AudacityProject::UpdateMenus(), if somebody decides to do it:
// // Because EnableUsingFlags requires all the flag bits match the
// // corresponding mask bits,
// // "UndoHistory" specifies only
// // AudioIONotBusyFlag | UndoAvailableFlag, because that
// // covers the majority of cases where it should be enabled.
// // If history is not empty but we've Undone the whole stack,
// // we also want to enable,
// // to show the Redo's on stack.
// // "UndoHistory" might already be enabled,
// // but add this check for RedoAvailableFlag.
// if (flags & RedoAvailableFlag)
// GetCommandManager()->Enable(wxT("UndoHistory"), true);
// So for now, enable the command regardless of stack.
// It will just show empty sometimes.
// FOR REDESIGN,
// clearly there are some limitations with the flags/mask bitmaps.
/* i18n-hint: Clicking this menu item shows the various editing steps
that have been taken.*/
Command( wxT("UndoHistory"), XXO("&History..."), FN(OnHistory),
AudioIONotBusyFlag() ),
Command( wxT("Karaoke"), XXO("&Karaoke..."), FN(OnKaraoke),
LabelTracksExistFlag() ),
Command( wxT("MixerBoard"), XXO("&Mixer Board..."), FN(OnMixerBoard),
PlayableTracksExistFlag() )
),
Section( "",
//////////////////////////////////////////////////////////////////////////
ToolbarsMenu()
),
Section( "Other",
Command( wxT("ShowExtraMenus"), XXO("&Extra Menus (on/off)"),
@@ -456,10 +559,4 @@ BaseItemSharedPtr ViewMenu()
}
AttachedItem sAttachment1{
wxT(""),
Shared( ViewMenu() )
};
}
#undef FN