2582 enh repeat last process (#722)
* Enhancement: Add Repeat Last Process * add include UndoManager.h
This commit is contained in:
parent
8aaecdc596
commit
549dacf054
|
@ -238,11 +238,32 @@ const ReservedCommandFlag&
|
||||||
}
|
}
|
||||||
}; return flag; }
|
}; return flag; }
|
||||||
const ReservedCommandFlag&
|
const ReservedCommandFlag&
|
||||||
HasLastEffectFlag() { static ReservedCommandFlag flag{
|
HasLastGeneratorFlag() { static ReservedCommandFlag flag{
|
||||||
[](const AudacityProject &project){
|
[](const AudacityProject &project){
|
||||||
return !MenuManager::Get( project ).mLastEffect.empty();
|
return !MenuManager::Get( project ).mLastGenerator.empty();
|
||||||
}
|
}
|
||||||
}; return flag; }
|
}; return flag; }
|
||||||
|
const ReservedCommandFlag&
|
||||||
|
HasLastEffectFlag() { static ReservedCommandFlag flag{
|
||||||
|
[](const AudacityProject &project) {
|
||||||
|
return !MenuManager::Get(project).mLastEffect.empty();
|
||||||
|
}
|
||||||
|
}; return flag;
|
||||||
|
}
|
||||||
|
const ReservedCommandFlag&
|
||||||
|
HasLastAnalyzerFlag() { static ReservedCommandFlag flag{
|
||||||
|
[](const AudacityProject &project) {
|
||||||
|
return !MenuManager::Get(project).mLastAnalyzer.empty();
|
||||||
|
}
|
||||||
|
}; return flag;
|
||||||
|
}
|
||||||
|
const ReservedCommandFlag&
|
||||||
|
HasLastToolFlag() { static ReservedCommandFlag flag{
|
||||||
|
[](const AudacityProject &project) {
|
||||||
|
return !MenuManager::Get(project).mLastTool.empty();
|
||||||
|
}
|
||||||
|
}; return flag;
|
||||||
|
}
|
||||||
const ReservedCommandFlag&
|
const ReservedCommandFlag&
|
||||||
UndoAvailableFlag() { static ReservedCommandFlag flag{
|
UndoAvailableFlag() { static ReservedCommandFlag flag{
|
||||||
[](const AudacityProject &project){
|
[](const AudacityProject &project){
|
||||||
|
|
|
@ -38,7 +38,10 @@ extern AUDACITY_DLL_API const ReservedCommandFlag
|
||||||
extern AUDACITY_DLL_API const ReservedCommandFlag
|
extern AUDACITY_DLL_API const ReservedCommandFlag
|
||||||
&LabelTracksExistFlag(),
|
&LabelTracksExistFlag(),
|
||||||
&UnsavedChangesFlag(),
|
&UnsavedChangesFlag(),
|
||||||
|
&HasLastGeneratorFlag(),
|
||||||
&HasLastEffectFlag(),
|
&HasLastEffectFlag(),
|
||||||
|
&HasLastAnalyzerFlag(),
|
||||||
|
&HasLastToolFlag(),
|
||||||
&UndoAvailableFlag(),
|
&UndoAvailableFlag(),
|
||||||
&RedoAvailableFlag(),
|
&RedoAvailableFlag(),
|
||||||
&ZoomInAvailableFlag(),
|
&ZoomInAvailableFlag(),
|
||||||
|
|
|
@ -30,6 +30,7 @@ class ViewInfo;
|
||||||
enum EffectType : int;
|
enum EffectType : int;
|
||||||
|
|
||||||
typedef wxString PluginID;
|
typedef wxString PluginID;
|
||||||
|
typedef wxString MacroID;
|
||||||
typedef wxArrayString PluginIDs;
|
typedef wxArrayString PluginIDs;
|
||||||
|
|
||||||
namespace Registry{ class Visitor; }
|
namespace Registry{ class Visitor; }
|
||||||
|
@ -48,7 +49,11 @@ public:
|
||||||
CommandFlag mLastFlags;
|
CommandFlag mLastFlags;
|
||||||
|
|
||||||
// Last effect applied to this project
|
// Last effect applied to this project
|
||||||
|
PluginID mLastGenerator{};
|
||||||
PluginID mLastEffect{};
|
PluginID mLastEffect{};
|
||||||
|
PluginID mLastAnalyzer{};
|
||||||
|
PluginID mLastTool{};
|
||||||
|
bool mLastToolIsMacro;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ToolbarMenuVisitor;
|
struct ToolbarMenuVisitor;
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
kSkipState = 0x02,
|
kSkipState = 0x02,
|
||||||
// Flag used to disable "Repeat Last Effect"
|
// Flag used to disable "Repeat Last Effect"
|
||||||
kDontRepeatLast = 0x04,
|
kDontRepeatLast = 0x04,
|
||||||
|
// Flag used to disable "Select All during Repeat Generator Effect"
|
||||||
|
kRepeatGen = 0x08,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Get the singleton instance of the EffectManager. Probably not safe
|
/** Get the singleton instance of the EffectManager. Probably not safe
|
||||||
|
|
|
@ -1882,7 +1882,10 @@ wxDialog *EffectUI::DialogFactory( wxWindow &parent, EffectHostInterface *pHost,
|
||||||
if (flags & EffectManager::kConfigured)
|
if (flags & EffectManager::kConfigured)
|
||||||
{
|
{
|
||||||
ProjectAudioManager::Get( project ).Stop();
|
ProjectAudioManager::Get( project ).Stop();
|
||||||
SelectUtilities::SelectAllIfNone( project );
|
//Don't Select All if repeating Generator Effect
|
||||||
|
if (!(flags & EffectManager::kConfigured)) {
|
||||||
|
SelectUtilities::SelectAllIfNone(project);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto nTracksOriginally = tracks.size();
|
auto nTracksOriginally = tracks.size();
|
||||||
|
@ -1951,15 +1954,29 @@ wxDialog *EffectUI::DialogFactory( wxWindow &parent, EffectHostInterface *pHost,
|
||||||
|
|
||||||
if (!(flags & EffectManager::kDontRepeatLast))
|
if (!(flags & EffectManager::kDontRepeatLast))
|
||||||
{
|
{
|
||||||
// Only remember a successful effect, don't remember insert,
|
// Remember a successful generator, effect, analyzer, or tool Process
|
||||||
// or analyze effects.
|
|
||||||
if (type == EffectTypeProcess) {
|
|
||||||
auto shortDesc = em.GetCommandName(ID);
|
auto shortDesc = em.GetCommandName(ID);
|
||||||
MenuManager::Get(project).mLastEffect = ID;
|
|
||||||
/* i18n-hint: %s will be the name of the effect which will be
|
/* i18n-hint: %s will be the name of the effect which will be
|
||||||
* repeated if this menu item is chosen */
|
* repeated if this menu item is chosen */
|
||||||
auto lastEffectDesc = XO("Repeat %s").Format( shortDesc );
|
auto lastEffectDesc = XO("Repeat %s").Format(shortDesc);
|
||||||
commandManager.Modify(wxT("RepeatLastEffect"), lastEffectDesc);
|
switch ( type ) {
|
||||||
|
case EffectTypeGenerate:
|
||||||
|
commandManager.Modify(wxT("RepeatLastGenerator"), lastEffectDesc);
|
||||||
|
MenuManager::Get(project).mLastGenerator = ID;
|
||||||
|
break;
|
||||||
|
case EffectTypeProcess:
|
||||||
|
commandManager.Modify(wxT("RepeatLastEffect"), lastEffectDesc);
|
||||||
|
MenuManager::Get(project).mLastEffect = ID;
|
||||||
|
break;
|
||||||
|
case EffectTypeAnalyze:
|
||||||
|
commandManager.Modify(wxT("RepeatLastAnalyzer"), lastEffectDesc);
|
||||||
|
MenuManager::Get(project).mLastAnalyzer = ID;
|
||||||
|
break;
|
||||||
|
case EffectTypeTool:
|
||||||
|
commandManager.Modify(wxT("RepeatLastTool"), lastEffectDesc);
|
||||||
|
MenuManager::Get(project).mLastTool = ID;
|
||||||
|
MenuManager::Get(project).mLastToolIsMacro = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "../ProjectSelectionManager.h"
|
#include "../ProjectSelectionManager.h"
|
||||||
#include "../toolbars/ToolManager.h"
|
#include "../toolbars/ToolManager.h"
|
||||||
#include "../Screenshot.h"
|
#include "../Screenshot.h"
|
||||||
|
#include "../UndoManager.h"
|
||||||
#include "../commands/CommandContext.h"
|
#include "../commands/CommandContext.h"
|
||||||
#include "../commands/CommandManager.h"
|
#include "../commands/CommandManager.h"
|
||||||
#include "../commands/ScreenshotCommand.h"
|
#include "../commands/ScreenshotCommand.h"
|
||||||
|
@ -427,16 +428,50 @@ void OnManageEffects(const CommandContext &context)
|
||||||
DoManagePluginsMenu(project, EffectTypeProcess);
|
DoManagePluginsMenu(project, EffectTypeProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnRepeatLastGenerator(const CommandContext &context)
|
||||||
|
{
|
||||||
|
auto lastEffect = MenuManager::Get(context.project).mLastGenerator;
|
||||||
|
if (!lastEffect.empty())
|
||||||
|
{
|
||||||
|
EffectUI::DoEffect(
|
||||||
|
lastEffect, context, EffectManager::kConfigured | EffectManager::kRepeatGen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnRepeatLastEffect(const CommandContext &context)
|
void OnRepeatLastEffect(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto lastEffect = MenuManager::Get(context.project).mLastEffect;
|
auto lastEffect = MenuManager::Get(context.project).mLastEffect;
|
||||||
if (!lastEffect.empty())
|
if (!lastEffect.empty())
|
||||||
{
|
{
|
||||||
EffectUI::DoEffect(
|
EffectUI::DoEffect(
|
||||||
lastEffect, context, EffectManager::kConfigured );
|
lastEffect, context, EffectManager::kConfigured);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnRepeatLastAnalyzer(const CommandContext &context)
|
||||||
|
{
|
||||||
|
auto lastEffect = MenuManager::Get(context.project).mLastAnalyzer;
|
||||||
|
if (!lastEffect.empty())
|
||||||
|
{
|
||||||
|
EffectUI::DoEffect(
|
||||||
|
lastEffect, context, EffectManager::kConfigured);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnRepeatLastTool(const CommandContext &context)
|
||||||
|
{
|
||||||
|
auto lastEffect = MenuManager::Get(context.project).mLastTool;
|
||||||
|
if (!lastEffect.empty())
|
||||||
|
{
|
||||||
|
if (!MenuManager::Get(context.project).mLastToolIsMacro)
|
||||||
|
EffectUI::DoEffect(
|
||||||
|
lastEffect, context, EffectManager::kConfigured);
|
||||||
|
else
|
||||||
|
OnApplyMacroDirectlyByName(context, lastEffect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void OnManageAnalyzers(const CommandContext &context)
|
void OnManageAnalyzers(const CommandContext &context)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
|
@ -508,13 +543,17 @@ void OnDetectUpstreamDropouts(const CommandContext &context)
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplyMacroDirectly(const CommandContext &context )
|
void OnApplyMacroDirectly(const CommandContext &context )
|
||||||
|
{
|
||||||
|
const MacroID& Name = context.parameter.GET();
|
||||||
|
OnApplyMacroDirectlyByName(context, Name);
|
||||||
|
}
|
||||||
|
void OnApplyMacroDirectlyByName(const CommandContext& context, const MacroID& Name)
|
||||||
{
|
{
|
||||||
auto &project = context.project;
|
auto &project = context.project;
|
||||||
auto &window = ProjectWindow::Get( project );
|
auto &window = ProjectWindow::Get( project );
|
||||||
|
|
||||||
//wxLogDebug( "Macro was: %s", context.parameter);
|
//wxLogDebug( "Macro was: %s", context.parameter);
|
||||||
ApplyMacroDialog dlg( &window, project );
|
ApplyMacroDialog dlg( &window, project );
|
||||||
const auto &Name = context.parameter;
|
//const auto &Name = context.parameter;
|
||||||
|
|
||||||
// We used numbers previously, but macros could get renumbered, making
|
// We used numbers previously, but macros could get renumbered, making
|
||||||
// macros containing macros unpredictable.
|
// macros containing macros unpredictable.
|
||||||
|
@ -526,7 +565,24 @@ void OnApplyMacroDirectly(const CommandContext &context )
|
||||||
#else
|
#else
|
||||||
dlg.ApplyMacroToProject( Name, false );
|
dlg.ApplyMacroToProject( Name, false );
|
||||||
#endif
|
#endif
|
||||||
|
/* i18n-hint: %s will be the name of the macro which will be
|
||||||
|
* repeated if this menu item is chosen */
|
||||||
MenuManager::ModifyUndoMenuItems( project );
|
MenuManager::ModifyUndoMenuItems( project );
|
||||||
|
|
||||||
|
TranslatableString desc;
|
||||||
|
EffectManager& em = EffectManager::Get();
|
||||||
|
auto shortDesc = em.GetCommandName(Name);
|
||||||
|
auto& undoManager = UndoManager::Get(project);
|
||||||
|
auto& commandManager = CommandManager::Get(project);
|
||||||
|
int cur = undoManager.GetCurrentState();
|
||||||
|
if (undoManager.UndoAvailable()) {
|
||||||
|
undoManager.GetShortDescription(cur, &desc);
|
||||||
|
commandManager.Modify(wxT("RepeatLastTool"), XXO("&Repeat %s")
|
||||||
|
.Format(desc));
|
||||||
|
MenuManager::Get(project).mLastTool = Name;
|
||||||
|
MenuManager::Get(project).mLastToolIsMacro = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnAudacityCommand(const CommandContext & ctx)
|
void OnAudacityCommand(const CommandContext & ctx)
|
||||||
|
@ -730,6 +786,26 @@ BaseItemSharedPtr GenerateMenu()
|
||||||
),
|
),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Section("RepeatLast",
|
||||||
|
// Delayed evaluation:
|
||||||
|
[](AudacityProject &project)
|
||||||
|
{
|
||||||
|
const auto &lastGenerator = MenuManager::Get(project).mLastGenerator;
|
||||||
|
TranslatableString buildMenuLabel;
|
||||||
|
if (!lastGenerator.empty())
|
||||||
|
buildMenuLabel = XO("Repeat %s")
|
||||||
|
.Format(EffectManager::Get().GetCommandName(lastGenerator));
|
||||||
|
else
|
||||||
|
buildMenuLabel = XO("Repeat Last Generator");
|
||||||
|
|
||||||
|
return Command(wxT("RepeatLastGenerator"), buildMenuLabel,
|
||||||
|
FN(OnRepeatLastGenerator),
|
||||||
|
AudioIONotBusyFlag() |
|
||||||
|
HasLastGeneratorFlag(),
|
||||||
|
wxT(" "), findCommandHandler);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
Section( "Generators",
|
Section( "Generators",
|
||||||
// Delayed evaluation:
|
// Delayed evaluation:
|
||||||
[](AudacityProject &)
|
[](AudacityProject &)
|
||||||
|
@ -823,6 +899,26 @@ BaseItemSharedPtr AnalyzeMenu()
|
||||||
),
|
),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Section("RepeatLast",
|
||||||
|
// Delayed evaluation:
|
||||||
|
[](AudacityProject &project)
|
||||||
|
{
|
||||||
|
const auto &lastAnalyzer = MenuManager::Get(project).mLastAnalyzer;
|
||||||
|
TranslatableString buildMenuLabel;
|
||||||
|
if (!lastAnalyzer.empty())
|
||||||
|
buildMenuLabel = XO("Repeat %s")
|
||||||
|
.Format(EffectManager::Get().GetCommandName(lastAnalyzer));
|
||||||
|
else
|
||||||
|
buildMenuLabel = XO("Repeat Last Analyzer");
|
||||||
|
|
||||||
|
return Command(wxT("RepeatLastAnalyzer"), buildMenuLabel,
|
||||||
|
FN(OnRepeatLastAnalyzer),
|
||||||
|
AudioIONotBusyFlag() | TimeSelectedFlag() |
|
||||||
|
WaveTracksSelectedFlag() | HasLastAnalyzerFlag(),
|
||||||
|
wxT(" "), findCommandHandler);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
Section( "Analyzers",
|
Section( "Analyzers",
|
||||||
Items( "Windows" ),
|
Items( "Windows" ),
|
||||||
|
|
||||||
|
@ -859,7 +955,27 @@ BaseItemSharedPtr ToolsMenu()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Command( wxT("ManageMacros"), XXO("&Macros..."),
|
Section( "RepeatLast",
|
||||||
|
// Delayed evaluation:
|
||||||
|
[](AudacityProject &project)
|
||||||
|
{
|
||||||
|
const auto &lastTool = MenuManager::Get(project).mLastTool;
|
||||||
|
TranslatableString buildMenuLabel;
|
||||||
|
if (!lastTool.empty())
|
||||||
|
buildMenuLabel = XO("Repeat %s")
|
||||||
|
.Format( EffectManager::Get().GetCommandName(lastTool) );
|
||||||
|
else
|
||||||
|
buildMenuLabel = XO("Repeat Last Tool");
|
||||||
|
|
||||||
|
return Command( wxT("RepeatLastTool"), buildMenuLabel,
|
||||||
|
FN(OnRepeatLastTool),
|
||||||
|
AudioIONotBusyFlag() |
|
||||||
|
HasLastToolFlag(),
|
||||||
|
wxT(" "), findCommandHandler );
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
Command( wxT("ManageMacros"), XXO("&Macros..."),
|
||||||
FN(OnManageMacros), AudioIONotBusyFlag() ),
|
FN(OnManageMacros), AudioIONotBusyFlag() ),
|
||||||
|
|
||||||
Menu( wxT("Macros"), XXO("&Apply Macro"),
|
Menu( wxT("Macros"), XXO("&Apply Macro"),
|
||||||
|
|
Loading…
Reference in New Issue