mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-03 06:03:13 +02:00
Eliminate the confusing mask from CommandManager entries...
... In fact it was only ever different from flags when flags had the special NoAutoSelect and mask did not. Now put that bit in the mask too, and make the special NoAutoSelect always true in MenuManager::GetUpdateFlags(). This still preserves the intended effects of NoAutoSelect.
This commit is contained in:
parent
64650b9a55
commit
0f2278d394
@ -689,7 +689,7 @@ const ReservedCommandFlag
|
||||
}
|
||||
},
|
||||
NoAutoSelect{
|
||||
[](const AudacityProject &){ return false; }
|
||||
[](const AudacityProject &){ return true; }
|
||||
} // jkc
|
||||
;
|
||||
|
||||
|
@ -525,10 +525,6 @@ void CommandManager::AddItem(const CommandID &name,
|
||||
|
||||
wxASSERT( flags != NoFlagsSpecified );
|
||||
|
||||
auto mask = options.mask;
|
||||
if (mask == NoFlagsSpecified)
|
||||
mask = flags;
|
||||
|
||||
CommandParameter cookedParameter;
|
||||
const auto ¶meter = options.parameter;
|
||||
if( parameter.empty() )
|
||||
@ -546,7 +542,7 @@ void CommandManager::AddItem(const CommandID &name,
|
||||
int ID = entry->id;
|
||||
wxString label = GetLabelWithDisabledAccel(entry);
|
||||
|
||||
SetCommandFlags(name, flags, mask);
|
||||
SetCommandFlags(name, flags);
|
||||
|
||||
|
||||
auto checkmark = options.check;
|
||||
@ -589,7 +585,7 @@ void CommandManager::AddItemList(const CommandID & name,
|
||||
i,
|
||||
cnt,
|
||||
bIsEffect);
|
||||
entry->mask = entry->flags = flags;
|
||||
entry->flags = flags;
|
||||
CurrentMenu()->Append(entry->id, GetLabel(entry));
|
||||
mbSeparatorAllowed = true;
|
||||
}
|
||||
@ -618,7 +614,7 @@ void CommandManager::AddCommand(const CommandID &name,
|
||||
|
||||
NewIdentifier(name, label_in, label_in, false, accel, NULL, finder, callback, {}, 0, 0, false, {});
|
||||
|
||||
SetCommandFlags(name, flags, flags);
|
||||
SetCommandFlags(name, flags);
|
||||
}
|
||||
|
||||
void CommandManager::AddGlobalCommand(const CommandID &name,
|
||||
@ -635,7 +631,6 @@ void CommandManager::AddGlobalCommand(const CommandID &name,
|
||||
entry->enabled = false;
|
||||
entry->isGlobal = true;
|
||||
entry->flags = AlwaysEnabledFlag;
|
||||
entry->mask = AlwaysEnabledFlag;
|
||||
}
|
||||
|
||||
void CommandManager::AddSeparator()
|
||||
@ -764,7 +759,7 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn,
|
||||
entry->multi = multi;
|
||||
entry->index = index;
|
||||
entry->count = count;
|
||||
entry->flags = entry->mask = AlwaysEnabledFlag;
|
||||
entry->flags = AlwaysEnabledFlag;
|
||||
entry->enabled = true;
|
||||
entry->skipKeydown = (accel.Find(wxT("\tskipKeydown")) != wxNOT_FOUND);
|
||||
entry->wantKeyup = (accel.Find(wxT("\twantKeyup")) != wxNOT_FOUND) || entry->skipKeydown;
|
||||
@ -973,9 +968,8 @@ void CommandManager::EnableUsingFlags(
|
||||
|
||||
auto useFlags = entry->useStrictFlags ? strictFlags : flags;
|
||||
|
||||
if (entry->mask.any()) {
|
||||
bool enable = ((useFlags & entry->mask) ==
|
||||
(entry->flags & entry->mask));
|
||||
if (entry->flags.any()) {
|
||||
bool enable = ((useFlags & entry->flags) == entry->flags);
|
||||
Enable(entry.get(), enable);
|
||||
}
|
||||
}
|
||||
@ -1265,7 +1259,7 @@ bool CommandManager::HandleCommandEntry(const CommandListEntry * entry,
|
||||
|
||||
auto proj = GetActiveProject();
|
||||
|
||||
auto combinedMask = (mask & entry->mask);
|
||||
auto combinedMask = (mask & entry->flags);
|
||||
if (combinedMask.any()) {
|
||||
|
||||
wxASSERT( proj );
|
||||
@ -1621,13 +1615,11 @@ void CommandManager::EndOccultCommands()
|
||||
}
|
||||
|
||||
void CommandManager::SetCommandFlags(const CommandID &name,
|
||||
CommandFlag flags, CommandMask mask)
|
||||
CommandFlag flags)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (entry) {
|
||||
if (entry)
|
||||
entry->flags = flags;
|
||||
entry->mask = mask;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__WXDEBUG__)
|
||||
|
@ -81,7 +81,6 @@ struct CommandListEntry
|
||||
bool isEffect;
|
||||
bool hasDialog;
|
||||
CommandFlag flags;
|
||||
CommandMask mask;
|
||||
bool useStrictFlags{ false };
|
||||
};
|
||||
|
||||
@ -159,8 +158,6 @@ class AUDACITY_DLL_API CommandManager final
|
||||
{ bIsEffect = true; return std::move(*this); }
|
||||
Options &&Parameter (const CommandParameter &value) &&
|
||||
{ parameter = value; return std::move(*this); }
|
||||
Options &&Mask (CommandMask value) &&
|
||||
{ mask = value; return std::move(*this); }
|
||||
Options &&LongName (const wxString &value) &&
|
||||
{ longName = value; return std::move(*this); }
|
||||
Options &&IsGlobal () &&
|
||||
@ -172,7 +169,6 @@ class AUDACITY_DLL_API CommandManager final
|
||||
int check{ -1 }; // default value means it's not a check item
|
||||
bool bIsEffect{ false };
|
||||
CommandParameter parameter{};
|
||||
CommandMask mask{ NoFlagsSpecified };
|
||||
wxString longName{}; // translated
|
||||
bool global{ false };
|
||||
bool useStrictFlags{ false };
|
||||
@ -216,7 +212,7 @@ class AUDACITY_DLL_API CommandManager final
|
||||
void EndOccultCommands();
|
||||
|
||||
|
||||
void SetCommandFlags(const CommandID &name, CommandFlag flags, CommandMask mask);
|
||||
void SetCommandFlags(const CommandID &name, CommandFlag flags);
|
||||
|
||||
//
|
||||
// Modifying menus
|
||||
|
@ -1135,12 +1135,10 @@ MenuTable::BaseItemPtr EditMenu( AudacityProject & )
|
||||
/* i18n-hint: (verb)*/
|
||||
Command( wxT("Cut"), XXO("Cu&t"), FN(OnCut),
|
||||
AudioIONotBusyFlag | CutCopyAvailableFlag | NoAutoSelect,
|
||||
Options{ wxT("Ctrl+X") }
|
||||
.Mask( AudioIONotBusyFlag | CutCopyAvailableFlag ) ),
|
||||
wxT("Ctrl+X") ),
|
||||
Command( wxT("Delete"), XXO("&Delete"), FN(OnDelete),
|
||||
AudioIONotBusyFlag | NoAutoSelect,
|
||||
Options{ wxT("Ctrl+K") }
|
||||
.Mask( AudioIONotBusyFlag ) ),
|
||||
wxT("Ctrl+K") ),
|
||||
/* i18n-hint: (verb)*/
|
||||
Command( wxT("Copy"), XXO("&Copy"), FN(OnCopy),
|
||||
AudioIONotBusyFlag | CutCopyAvailableFlag, wxT("Ctrl+C") ),
|
||||
@ -1224,10 +1222,10 @@ MenuTable::BaseItemPtr ExtraEditMenu( AudacityProject & )
|
||||
return Menu( _("&Edit"),
|
||||
Command( wxT("DeleteKey"), XXO("&Delete Key"), FN(OnDelete),
|
||||
(flags | NoAutoSelect),
|
||||
Options{ wxT("Backspace") }.Mask( flags ) ),
|
||||
wxT("Backspace") ),
|
||||
Command( wxT("DeleteKey2"), XXO("Delete Key&2"), FN(OnDelete),
|
||||
(flags | NoAutoSelect),
|
||||
Options{ wxT("Delete") }.Mask( flags ) )
|
||||
wxT("Delete") )
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user