mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
Simplify specification of command item groups in Tracks menu
This commit is contained in:
parent
6d5bc21d50
commit
b32940d931
@ -128,13 +128,12 @@ CommandItem::CommandItem(const wxString &name_,
|
||||
CommandItem::~CommandItem() {}
|
||||
|
||||
CommandGroupItem::CommandGroupItem(const wxString &name_,
|
||||
const ComponentInterfaceSymbol items_[],
|
||||
size_t nItems_,
|
||||
std::initializer_list< ComponentInterfaceSymbol > items_,
|
||||
CommandHandlerFinder finder_,
|
||||
CommandFunctorPointer callback_,
|
||||
CommandFlag flags_,
|
||||
bool isEffect_)
|
||||
: name{ name_ }, items{ items_, items_ + nItems_ }
|
||||
: name{ name_ }, items{ items_ }
|
||||
, finder{ finder_ }, callback{ callback_ }
|
||||
, flags{ flags_ }, isEffect{ isEffect_ }
|
||||
{}
|
||||
|
@ -528,8 +528,7 @@ namespace MenuTable {
|
||||
|
||||
struct CommandGroupItem final : BaseItem {
|
||||
CommandGroupItem(const wxString &name_,
|
||||
const ComponentInterfaceSymbol items_[],
|
||||
size_t nItems_,
|
||||
std::initializer_list< ComponentInterfaceSymbol > items_,
|
||||
CommandHandlerFinder finder_,
|
||||
CommandFunctorPointer callback_,
|
||||
CommandFlag flags_,
|
||||
@ -620,12 +619,12 @@ namespace MenuTable {
|
||||
|
||||
inline std::unique_ptr<CommandGroupItem> CommandGroup(
|
||||
const wxString &name,
|
||||
const ComponentInterfaceSymbol items[], size_t nItems,
|
||||
std::initializer_list< ComponentInterfaceSymbol > items,
|
||||
CommandHandlerFinder finder, CommandFunctorPointer callback,
|
||||
CommandFlag flags, bool isEffect = false)
|
||||
{
|
||||
return std::make_unique<CommandGroupItem>(
|
||||
name, items, nItems, finder, callback, flags, isEffect
|
||||
name, items, finder, callback, flags, isEffect
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -133,8 +133,16 @@ enum {
|
||||
kAlignTogether
|
||||
};
|
||||
|
||||
constexpr size_t kAlignLabelsCount = 5;
|
||||
|
||||
static const std::initializer_list< ComponentInterfaceSymbol > alignLabels{
|
||||
{ wxT("StartToZero"), XO("Start to &Zero") },
|
||||
{ wxT("StartToSelStart"), XO("Start to &Cursor/Selection Start") },
|
||||
{ wxT("StartToSelEnd"), XO("Start to Selection &End") },
|
||||
{ wxT("EndToSelStart"), XO("End to Cu&rsor/Selection Start") },
|
||||
{ wxT("EndToSelEnd"), XO("End to Selection En&d") },
|
||||
};
|
||||
|
||||
const size_t kAlignLabelsCount = alignLabels.end() - alignLabels.begin();
|
||||
|
||||
void DoAlign
|
||||
(AudacityProject &project, int index, bool moveSel)
|
||||
{
|
||||
@ -1530,38 +1538,20 @@ MenuTable::BaseItemPtr TracksMenu( AudacityProject & )
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Menu( _("&Align Tracks"), //_("Just Move Tracks"),
|
||||
[]{
|
||||
// Mutual alignment of tracks independent of selection or zero
|
||||
static const ComponentInterfaceSymbol alignLabelsNoSync[] = {
|
||||
// Mutual alignment of tracks independent of selection or zero
|
||||
CommandGroup(wxT("Align"),
|
||||
{
|
||||
{ wxT("EndToEnd"), XO("&Align End to End") },
|
||||
{ wxT("Together"), XO("Align &Together") },
|
||||
};
|
||||
return CommandGroup(wxT("Align"),
|
||||
alignLabelsNoSync, 2u, FN(OnAlignNoSync),
|
||||
AudioIONotBusyFlag | TracksSelectedFlag);
|
||||
}(),
|
||||
},
|
||||
FN(OnAlignNoSync), AudioIONotBusyFlag | TracksSelectedFlag),
|
||||
|
||||
Separator(),
|
||||
|
||||
[]{
|
||||
// Alignment commands using selection or zero
|
||||
static const ComponentInterfaceSymbol alignLabels[] = {
|
||||
{ wxT("StartToZero"), XO("Start to &Zero") },
|
||||
{ wxT("StartToSelStart"), XO("Start to &Cursor/Selection Start")
|
||||
},
|
||||
{ wxT("StartToSelEnd"), XO("Start to Selection &End") },
|
||||
{ wxT("EndToSelStart"), XO("End to Cu&rsor/Selection Start")
|
||||
},
|
||||
{ wxT("EndToSelEnd"), XO("End to Selection En&d") },
|
||||
};
|
||||
static_assert(
|
||||
kAlignLabelsCount == WXSIZEOF(alignLabels),
|
||||
"incorrect count"
|
||||
);
|
||||
return CommandGroup(wxT("Align"),
|
||||
alignLabels, kAlignLabelsCount, FN(OnAlign),
|
||||
AudioIONotBusyFlag | TracksSelectedFlag);
|
||||
}(),
|
||||
CommandGroup(wxT("Align"),
|
||||
alignLabels,
|
||||
FN(OnAlign), AudioIONotBusyFlag | TracksSelectedFlag),
|
||||
|
||||
Separator(),
|
||||
|
||||
@ -1577,7 +1567,7 @@ MenuTable::BaseItemPtr TracksMenu( AudacityProject & )
|
||||
// TODO: Can these labels be made clearer?
|
||||
// Do we need this sub-menu at all?
|
||||
Menu( _("Move Sele&ction and Tracks"), {
|
||||
CommandGroup(wxT("AlignMove"), alignLabels, kAlignLabelsCount,
|
||||
CommandGroup(wxT("AlignMove"), alignLabels,
|
||||
FN(OnAlignMoveSel), AudioIONotBusyFlag | TracksSelectedFlag),
|
||||
} ),
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user