mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Reimplement the rejection of select-all-on-none for certain commands...
... Specify it in the menu descriptions. Don't put special ad hoc logic in Menus.cpp.
This commit is contained in:
@@ -542,6 +542,7 @@ void CommandManager::AddItem(const CommandID &name,
|
||||
hasDialog,
|
||||
options.accel, CurrentMenu(), finder, callback,
|
||||
{}, 0, 0, options.bIsEffect, cookedParameter);
|
||||
entry->useStrictFlags = options.useStrictFlags;
|
||||
int ID = entry->id;
|
||||
wxString label = GetLabelWithDisabledAccel(entry);
|
||||
|
||||
@@ -955,17 +956,26 @@ void CommandManager::Enable(const wxString &name, bool enabled)
|
||||
Enable(entry, enabled);
|
||||
}
|
||||
|
||||
void CommandManager::EnableUsingFlags(CommandFlag flags, CommandMask mask)
|
||||
void CommandManager::EnableUsingFlags(
|
||||
CommandFlag flags, CommandFlag strictFlags, CommandMask mask)
|
||||
{
|
||||
// strictFlags are a subset of flags. strictFlags represent the real
|
||||
// conditions now, but flags are the conditions that could be made true.
|
||||
// Some commands use strict flags only, refusing the chance to fix
|
||||
// conditions
|
||||
wxASSERT( (strictFlags & ~flags).none() );
|
||||
|
||||
for(const auto &entry : mCommandList) {
|
||||
if (entry->multi && entry->index != 0)
|
||||
continue;
|
||||
if( entry->isOccult )
|
||||
continue;
|
||||
|
||||
auto useFlags = entry->useStrictFlags ? strictFlags : flags;
|
||||
|
||||
auto combinedMask = (mask & entry->mask);
|
||||
if (combinedMask.any()) {
|
||||
bool enable = ((flags & combinedMask) ==
|
||||
bool enable = ((useFlags & combinedMask) ==
|
||||
(entry->flags & combinedMask));
|
||||
Enable(entry.get(), enable);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ struct CommandListEntry
|
||||
bool hasDialog;
|
||||
CommandFlag flags;
|
||||
CommandMask mask;
|
||||
bool useStrictFlags{ false };
|
||||
};
|
||||
|
||||
using MenuBarList = std::vector < MenuBarListEntry >;
|
||||
@@ -164,6 +165,8 @@ class AUDACITY_DLL_API CommandManager final
|
||||
{ longName = value; return std::move(*this); }
|
||||
Options &&IsGlobal () &&
|
||||
{ global = true; return std::move(*this); }
|
||||
Options &&UseStrictFlags () &&
|
||||
{ useStrictFlags = true; return std::move(*this); }
|
||||
|
||||
const wxChar *accel{ wxT("") };
|
||||
int check{ -1 }; // default value means it's not a check item
|
||||
@@ -172,6 +175,7 @@ class AUDACITY_DLL_API CommandManager final
|
||||
CommandMask mask{ NoFlagsSpecified };
|
||||
wxString longName{}; // translated
|
||||
bool global{ false };
|
||||
bool useStrictFlags{ false };
|
||||
};
|
||||
|
||||
void AddItemList(const CommandID & name,
|
||||
@@ -218,7 +222,8 @@ class AUDACITY_DLL_API CommandManager final
|
||||
// Modifying menus
|
||||
//
|
||||
|
||||
void EnableUsingFlags(CommandFlag flags, CommandMask mask);
|
||||
void EnableUsingFlags(
|
||||
CommandFlag flags, CommandFlag strictFlags, CommandMask mask);
|
||||
void Enable(const wxString &name, bool enabled);
|
||||
void Check(const CommandID &name, bool checked);
|
||||
void Modify(const wxString &name, const wxString &newLabel);
|
||||
|
||||
Reference in New Issue
Block a user