mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-20 17:41:13 +02:00
Bug2184: should not grey Effect menu when selection is point
This commit is contained in:
@@ -583,11 +583,11 @@ void MenuManager::UpdateMenus( bool checkActive )
|
||||
//to actually do the 'select all' to make the command valid.
|
||||
|
||||
for ( const auto &enabler : Enablers() ) {
|
||||
auto actual = enabler.actualFlags();
|
||||
if (
|
||||
enabler.applicable( project ) &&
|
||||
(flags & enabler.actualFlags) == enabler.actualFlags
|
||||
enabler.applicable( project ) && (flags & actual) == actual
|
||||
)
|
||||
flags2 |= enabler.possibleFlags;
|
||||
flags2 |= enabler.possibleFlags();
|
||||
}
|
||||
|
||||
auto &commandManager = CommandManager::Get( project );
|
||||
@@ -654,13 +654,14 @@ bool MenuManager::TryToMakeActionAllowed(
|
||||
auto iter = enablers.begin(), end = enablers.end();
|
||||
while ((flags & flagsRqd) != flagsRqd && iter != end) {
|
||||
const auto &enabler = *iter;
|
||||
auto actual = enabler.actualFlags();
|
||||
auto MissingFlags = (~flags & flagsRqd);
|
||||
if (
|
||||
// Do we have the right precondition?
|
||||
(flags & enabler.actualFlags) == enabler.actualFlags
|
||||
(flags & actual) == actual
|
||||
&&
|
||||
// Can we get the condition we need?
|
||||
(MissingFlags & enabler.possibleFlags) == MissingFlags
|
||||
(MissingFlags & enabler.possibleFlags()) == MissingFlags
|
||||
) {
|
||||
// Then try the function
|
||||
enabler.tryEnable( project, flagsRqd );
|
||||
|
@@ -1089,8 +1089,8 @@ void ProjectAudioManager::DoPlayStopSelect()
|
||||
#include "CommonCommandFlags.h"
|
||||
|
||||
static RegisteredMenuItemEnabler stopIfPaused{{
|
||||
PausedFlag,
|
||||
AudioIONotBusyFlag,
|
||||
[]{ return PausedFlag; },
|
||||
[]{ return AudioIONotBusyFlag; },
|
||||
[]( const AudacityProject &project ){
|
||||
return MenuManager::Get( project ).mStopIfWasPaused; },
|
||||
[]( AudacityProject &project, CommandFlag ){
|
||||
|
@@ -101,12 +101,17 @@ public:
|
||||
// then the enabler will be invoked (unless the menu item is constructed with
|
||||
// the useStrictFlags option, or the applicability test first returns false).
|
||||
// The item's full set of required flags is passed to the function.
|
||||
|
||||
// Computation of the flags is delayed inside a function -- because often you
|
||||
// need to name a statically allocated CommandFlag, or a bitwise OR of some,
|
||||
// while they may not have been initialized yet, during static initialization.
|
||||
struct MenuItemEnabler {
|
||||
using Flags = std::function< CommandFlag() >;
|
||||
using Test = std::function< bool( const AudacityProject& ) >;
|
||||
using Action = std::function< void( AudacityProject&, CommandFlag ) >;
|
||||
|
||||
const CommandFlag &actualFlags;
|
||||
const CommandFlag &possibleFlags;
|
||||
const Flags actualFlags;
|
||||
const Flags possibleFlags;
|
||||
Test applicable;
|
||||
Action tryEnable;
|
||||
};
|
||||
|
@@ -1172,23 +1172,23 @@ auto selectAll = []( AudacityProject &project, CommandFlag flagsRqd ){
|
||||
};
|
||||
|
||||
RegisteredMenuItemEnabler selectTracks{{
|
||||
TracksExistFlag,
|
||||
TracksSelectedFlag,
|
||||
[]{ return TracksExistFlag; },
|
||||
[]{ return TracksSelectedFlag; },
|
||||
canSelectAll,
|
||||
selectAll
|
||||
}};
|
||||
|
||||
RegisteredMenuItemEnabler selectWaveTracks{{
|
||||
WaveTracksExistFlag,
|
||||
TimeSelectedFlag | WaveTracksSelectedFlag | CutCopyAvailableFlag,
|
||||
[]{ return WaveTracksExistFlag; },
|
||||
[]{ return TimeSelectedFlag | WaveTracksSelectedFlag | CutCopyAvailableFlag; },
|
||||
canSelectAll,
|
||||
selectAll
|
||||
}};
|
||||
|
||||
// Also enable select for the noise reduction case.
|
||||
RegisteredMenuItemEnabler selectWaveTracks2{{
|
||||
WaveTracksExistFlag,
|
||||
NoiseReductionTimeSelectedFlag | WaveTracksSelectedFlag | CutCopyAvailableFlag,
|
||||
[]{ return WaveTracksExistFlag; },
|
||||
[]{ return NoiseReductionTimeSelectedFlag | WaveTracksSelectedFlag | CutCopyAvailableFlag; },
|
||||
canSelectAll,
|
||||
selectAll
|
||||
}};
|
||||
|
Reference in New Issue
Block a user