mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 16:40:07 +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() {}
|
CommandItem::~CommandItem() {}
|
||||||
|
|
||||||
CommandGroupItem::CommandGroupItem(const wxString &name_,
|
CommandGroupItem::CommandGroupItem(const wxString &name_,
|
||||||
const ComponentInterfaceSymbol items_[],
|
std::initializer_list< ComponentInterfaceSymbol > items_,
|
||||||
size_t nItems_,
|
|
||||||
CommandHandlerFinder finder_,
|
CommandHandlerFinder finder_,
|
||||||
CommandFunctorPointer callback_,
|
CommandFunctorPointer callback_,
|
||||||
CommandFlag flags_,
|
CommandFlag flags_,
|
||||||
bool isEffect_)
|
bool isEffect_)
|
||||||
: name{ name_ }, items{ items_, items_ + nItems_ }
|
: name{ name_ }, items{ items_ }
|
||||||
, finder{ finder_ }, callback{ callback_ }
|
, finder{ finder_ }, callback{ callback_ }
|
||||||
, flags{ flags_ }, isEffect{ isEffect_ }
|
, flags{ flags_ }, isEffect{ isEffect_ }
|
||||||
{}
|
{}
|
||||||
|
@ -528,8 +528,7 @@ namespace MenuTable {
|
|||||||
|
|
||||||
struct CommandGroupItem final : BaseItem {
|
struct CommandGroupItem final : BaseItem {
|
||||||
CommandGroupItem(const wxString &name_,
|
CommandGroupItem(const wxString &name_,
|
||||||
const ComponentInterfaceSymbol items_[],
|
std::initializer_list< ComponentInterfaceSymbol > items_,
|
||||||
size_t nItems_,
|
|
||||||
CommandHandlerFinder finder_,
|
CommandHandlerFinder finder_,
|
||||||
CommandFunctorPointer callback_,
|
CommandFunctorPointer callback_,
|
||||||
CommandFlag flags_,
|
CommandFlag flags_,
|
||||||
@ -620,12 +619,12 @@ namespace MenuTable {
|
|||||||
|
|
||||||
inline std::unique_ptr<CommandGroupItem> CommandGroup(
|
inline std::unique_ptr<CommandGroupItem> CommandGroup(
|
||||||
const wxString &name,
|
const wxString &name,
|
||||||
const ComponentInterfaceSymbol items[], size_t nItems,
|
std::initializer_list< ComponentInterfaceSymbol > items,
|
||||||
CommandHandlerFinder finder, CommandFunctorPointer callback,
|
CommandHandlerFinder finder, CommandFunctorPointer callback,
|
||||||
CommandFlag flags, bool isEffect = false)
|
CommandFlag flags, bool isEffect = false)
|
||||||
{
|
{
|
||||||
return std::make_unique<CommandGroupItem>(
|
return std::make_unique<CommandGroupItem>(
|
||||||
name, items, nItems, finder, callback, flags, isEffect
|
name, items, finder, callback, flags, isEffect
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,8 +133,16 @@ enum {
|
|||||||
kAlignTogether
|
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
|
void DoAlign
|
||||||
(AudacityProject &project, int index, bool moveSel)
|
(AudacityProject &project, int index, bool moveSel)
|
||||||
{
|
{
|
||||||
@ -1530,38 +1538,20 @@ MenuTable::BaseItemPtr TracksMenu( AudacityProject & )
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Menu( _("&Align Tracks"), //_("Just Move Tracks"),
|
Menu( _("&Align Tracks"), //_("Just Move Tracks"),
|
||||||
[]{
|
// Mutual alignment of tracks independent of selection or zero
|
||||||
// Mutual alignment of tracks independent of selection or zero
|
CommandGroup(wxT("Align"),
|
||||||
static const ComponentInterfaceSymbol alignLabelsNoSync[] = {
|
{
|
||||||
{ wxT("EndToEnd"), XO("&Align End to End") },
|
{ wxT("EndToEnd"), XO("&Align End to End") },
|
||||||
{ wxT("Together"), XO("Align &Together") },
|
{ wxT("Together"), XO("Align &Together") },
|
||||||
};
|
},
|
||||||
return CommandGroup(wxT("Align"),
|
FN(OnAlignNoSync), AudioIONotBusyFlag | TracksSelectedFlag),
|
||||||
alignLabelsNoSync, 2u, FN(OnAlignNoSync),
|
|
||||||
AudioIONotBusyFlag | TracksSelectedFlag);
|
|
||||||
}(),
|
|
||||||
|
|
||||||
Separator(),
|
Separator(),
|
||||||
|
|
||||||
[]{
|
|
||||||
// Alignment commands using selection or zero
|
// Alignment commands using selection or zero
|
||||||
static const ComponentInterfaceSymbol alignLabels[] = {
|
CommandGroup(wxT("Align"),
|
||||||
{ wxT("StartToZero"), XO("Start to &Zero") },
|
alignLabels,
|
||||||
{ wxT("StartToSelStart"), XO("Start to &Cursor/Selection Start")
|
FN(OnAlign), AudioIONotBusyFlag | TracksSelectedFlag),
|
||||||
},
|
|
||||||
{ 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);
|
|
||||||
}(),
|
|
||||||
|
|
||||||
Separator(),
|
Separator(),
|
||||||
|
|
||||||
@ -1577,7 +1567,7 @@ MenuTable::BaseItemPtr TracksMenu( AudacityProject & )
|
|||||||
// TODO: Can these labels be made clearer?
|
// TODO: Can these labels be made clearer?
|
||||||
// Do we need this sub-menu at all?
|
// Do we need this sub-menu at all?
|
||||||
Menu( _("Move Sele&ction and Tracks"), {
|
Menu( _("Move Sele&ction and Tracks"), {
|
||||||
CommandGroup(wxT("AlignMove"), alignLabels, kAlignLabelsCount,
|
CommandGroup(wxT("AlignMove"), alignLabels,
|
||||||
FN(OnAlignMoveSel), AudioIONotBusyFlag | TracksSelectedFlag),
|
FN(OnAlignMoveSel), AudioIONotBusyFlag | TracksSelectedFlag),
|
||||||
} ),
|
} ),
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user