mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Move MenuManager functions out of Project.cpp
This commit is contained in:
parent
7b67bc053e
commit
492a44894b
@ -741,3 +741,75 @@ void MenuCreator::RebuildAllMenuBars()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MenuManager::ReportIfActionNotAllowed
|
||||||
|
( AudacityProject &project,
|
||||||
|
const wxString & Name, CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask )
|
||||||
|
{
|
||||||
|
bool bAllowed = TryToMakeActionAllowed( project, flags, flagsRqd, mask );
|
||||||
|
if( bAllowed )
|
||||||
|
return true;
|
||||||
|
CommandManager* cm = project.GetCommandManager();
|
||||||
|
if (!cm) return false;
|
||||||
|
cm->TellUserWhyDisallowed( Name, flags & mask, flagsRqd & mask);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Determines if flags for command are compatible with current state.
|
||||||
|
/// If not, then try some recovery action to make it so.
|
||||||
|
/// @return whether compatible or not after any actions taken.
|
||||||
|
bool MenuManager::TryToMakeActionAllowed
|
||||||
|
( AudacityProject &project,
|
||||||
|
CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask )
|
||||||
|
{
|
||||||
|
bool bAllowed;
|
||||||
|
|
||||||
|
if( !flags )
|
||||||
|
flags = GetMenuManager(project).GetUpdateFlags(project);
|
||||||
|
|
||||||
|
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
||||||
|
if( bAllowed )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Why is action not allowed?
|
||||||
|
// 1's wherever a required flag is missing.
|
||||||
|
auto MissingFlags = (~flags & flagsRqd) & mask;
|
||||||
|
|
||||||
|
if( mStopIfWasPaused && (MissingFlags & AudioIONotBusyFlag ) ){
|
||||||
|
project.StopIfPaused();
|
||||||
|
// Hope this will now reflect stopped audio.
|
||||||
|
flags = GetMenuManager(project).GetUpdateFlags(project);
|
||||||
|
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
||||||
|
if( bAllowed )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//We can only make the action allowed if we select audio when no selection.
|
||||||
|
// IF not set up to select all audio when none, THEN return with failure.
|
||||||
|
if( mWhatIfNoSelection != 1 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Some effects disallow autoselection.
|
||||||
|
if( flagsRqd & NoAutoSelect )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Why is action still not allowed?
|
||||||
|
// 0's wherever a required flag is missing (or is don't care)
|
||||||
|
MissingFlags = (flags & ~flagsRqd) & mask;
|
||||||
|
|
||||||
|
// IF selecting all audio won't do any good, THEN return with failure.
|
||||||
|
if( !(flags & WaveTracksExistFlag) )
|
||||||
|
return false;
|
||||||
|
// returns if mask wants a zero in some flag and that's not present.
|
||||||
|
// logic seems a bit peculiar and worth revisiting.
|
||||||
|
if( (MissingFlags & ~( TimeSelectedFlag | WaveTracksSelectedFlag)) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// This was 'OnSelectAll'. Changing it to DoSelectSomething means if
|
||||||
|
// selecting all tracks is enough, we just do that.
|
||||||
|
SelectActions::DoSelectSomething(project);
|
||||||
|
flags = GetMenuManager(project).GetUpdateFlags(project);
|
||||||
|
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
||||||
|
return bAllowed;
|
||||||
|
}
|
||||||
|
@ -2345,78 +2345,6 @@ void AudacityProject::DoScroll()
|
|||||||
GetTrackPanel()->HandleCursorForPresentMouseState(); } );
|
GetTrackPanel()->HandleCursorForPresentMouseState(); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MenuManager::ReportIfActionNotAllowed
|
|
||||||
( AudacityProject &project,
|
|
||||||
const wxString & Name, CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask )
|
|
||||||
{
|
|
||||||
bool bAllowed = TryToMakeActionAllowed( project, flags, flagsRqd, mask );
|
|
||||||
if( bAllowed )
|
|
||||||
return true;
|
|
||||||
CommandManager* cm = project.GetCommandManager();
|
|
||||||
if (!cm) return false;
|
|
||||||
cm->TellUserWhyDisallowed( Name, flags & mask, flagsRqd & mask);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Determines if flags for command are compatible with current state.
|
|
||||||
/// If not, then try some recovery action to make it so.
|
|
||||||
/// @return whether compatible or not after any actions taken.
|
|
||||||
bool MenuManager::TryToMakeActionAllowed
|
|
||||||
( AudacityProject &project,
|
|
||||||
CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask )
|
|
||||||
{
|
|
||||||
bool bAllowed;
|
|
||||||
|
|
||||||
if( !flags )
|
|
||||||
flags = GetMenuManager(project).GetUpdateFlags(project);
|
|
||||||
|
|
||||||
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
|
||||||
if( bAllowed )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Why is action not allowed?
|
|
||||||
// 1's wherever a required flag is missing.
|
|
||||||
auto MissingFlags = (~flags & flagsRqd) & mask;
|
|
||||||
|
|
||||||
if( mStopIfWasPaused && (MissingFlags & AudioIONotBusyFlag ) ){
|
|
||||||
project.StopIfPaused();
|
|
||||||
// Hope this will now reflect stopped audio.
|
|
||||||
flags = GetMenuManager(project).GetUpdateFlags(project);
|
|
||||||
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
|
||||||
if( bAllowed )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//We can only make the action allowed if we select audio when no selection.
|
|
||||||
// IF not set up to select all audio when none, THEN return with failure.
|
|
||||||
if( mWhatIfNoSelection != 1 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Some effects disallow autoselection.
|
|
||||||
if( flagsRqd & NoAutoSelect )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Why is action still not allowed?
|
|
||||||
// 0's wherever a required flag is missing (or is don't care)
|
|
||||||
MissingFlags = (flags & ~flagsRqd) & mask;
|
|
||||||
|
|
||||||
// IF selecting all audio won't do any good, THEN return with failure.
|
|
||||||
if( !(flags & WaveTracksExistFlag) )
|
|
||||||
return false;
|
|
||||||
// returns if mask wants a zero in some flag and that's not present.
|
|
||||||
// logic seems a bit peculiar and worth revisiting.
|
|
||||||
if( (MissingFlags & ~( TimeSelectedFlag | WaveTracksSelectedFlag)) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// This was 'OnSelectAll'. Changing it to DoSelectSomething means if
|
|
||||||
// selecting all tracks is enough, we just do that.
|
|
||||||
SelectActions::DoSelectSomething(project);
|
|
||||||
flags = GetMenuManager(project).GetUpdateFlags(project);
|
|
||||||
bAllowed = ((flags & mask) == (flagsRqd & mask));
|
|
||||||
return bAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudacityProject::OnMenu(wxCommandEvent & event)
|
void AudacityProject::OnMenu(wxCommandEvent & event)
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
@ -553,7 +553,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
// LL: wxMac can't handle recreating the menus when this dialog is still active,
|
// LL: wxMac can't handle recreating the menus when this dialog is still active,
|
||||||
// so AudacityProject::UpdatePrefs() or any of the routines it calls must
|
// so AudacityProject::UpdatePrefs() or any of the routines it calls must
|
||||||
// not cause AudacityProject::RebuildMenuBar() to be executed.
|
// not cause MenuCreator::RebuildMenuBar() to be executed.
|
||||||
for (size_t i = 0; i < gAudacityProjects.size(); i++) {
|
for (size_t i = 0; i < gAudacityProjects.size(); i++) {
|
||||||
gAudacityProjects[i]->UpdatePrefs();
|
gAudacityProjects[i]->UpdatePrefs();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user