mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 08:59:28 +02:00
Long message target
This allows interactive display of the results of new commands that generate lots of text.
This commit is contained in:
parent
e29699086e
commit
2f6fc0a1e5
@ -1267,6 +1267,7 @@
|
|||||||
5EF3E64F203FBAFB006C6882 /* Demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E647203FBAFB006C6882 /* Demo.cpp */; };
|
5EF3E64F203FBAFB006C6882 /* Demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E647203FBAFB006C6882 /* Demo.cpp */; };
|
||||||
5EF3E650203FBAFB006C6882 /* GetInfoCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E649203FBAFB006C6882 /* GetInfoCommand.cpp */; };
|
5EF3E650203FBAFB006C6882 /* GetInfoCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E649203FBAFB006C6882 /* GetInfoCommand.cpp */; };
|
||||||
5EF3E651203FBAFB006C6882 /* LoadCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E64B203FBAFB006C6882 /* LoadCommands.cpp */; };
|
5EF3E651203FBAFB006C6882 /* LoadCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E64B203FBAFB006C6882 /* LoadCommands.cpp */; };
|
||||||
|
5EF3E653203FBBE0006C6882 /* CommandTargets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF3E652203FBBE0006C6882 /* CommandTargets.cpp */; };
|
||||||
5EF958851DEB121800191280 /* InconsistencyException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF958831DEB121800191280 /* InconsistencyException.cpp */; };
|
5EF958851DEB121800191280 /* InconsistencyException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EF958831DEB121800191280 /* InconsistencyException.cpp */; };
|
||||||
8406A93812D0F2510011EA01 /* EQDefaultCurves.xml in Resources */ = {isa = PBXBuildFile; fileRef = 8406A93712D0F2510011EA01 /* EQDefaultCurves.xml */; };
|
8406A93812D0F2510011EA01 /* EQDefaultCurves.xml in Resources */ = {isa = PBXBuildFile; fileRef = 8406A93712D0F2510011EA01 /* EQDefaultCurves.xml */; };
|
||||||
8484F31413086237002DF7F0 /* DeviceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8484F31213086237002DF7F0 /* DeviceManager.cpp */; };
|
8484F31413086237002DF7F0 /* DeviceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8484F31213086237002DF7F0 /* DeviceManager.cpp */; };
|
||||||
@ -3165,6 +3166,7 @@
|
|||||||
5EF3E64A203FBAFB006C6882 /* GetInfoCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetInfoCommand.h; sourceTree = "<group>"; };
|
5EF3E64A203FBAFB006C6882 /* GetInfoCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetInfoCommand.h; sourceTree = "<group>"; };
|
||||||
5EF3E64B203FBAFB006C6882 /* LoadCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCommands.cpp; sourceTree = "<group>"; };
|
5EF3E64B203FBAFB006C6882 /* LoadCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCommands.cpp; sourceTree = "<group>"; };
|
||||||
5EF3E64C203FBAFB006C6882 /* LoadCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadCommands.h; sourceTree = "<group>"; };
|
5EF3E64C203FBAFB006C6882 /* LoadCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadCommands.h; sourceTree = "<group>"; };
|
||||||
|
5EF3E652203FBBE0006C6882 /* CommandTargets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommandTargets.cpp; sourceTree = "<group>"; };
|
||||||
5EF958831DEB121800191280 /* InconsistencyException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InconsistencyException.cpp; sourceTree = "<group>"; };
|
5EF958831DEB121800191280 /* InconsistencyException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InconsistencyException.cpp; sourceTree = "<group>"; };
|
||||||
5EF958841DEB121800191280 /* InconsistencyException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InconsistencyException.h; sourceTree = "<group>"; };
|
5EF958841DEB121800191280 /* InconsistencyException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InconsistencyException.h; sourceTree = "<group>"; };
|
||||||
82FF184D13CF01A600C1B664 /* dBTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dBTable.cpp; path = sbsms/src/dBTable.cpp; sourceTree = "<group>"; };
|
82FF184D13CF01A600C1B664 /* dBTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dBTable.cpp; path = sbsms/src/dBTable.cpp; sourceTree = "<group>"; };
|
||||||
@ -3764,6 +3766,7 @@
|
|||||||
28D540000FD1912A00FA7C75 /* CommandHandler.cpp */,
|
28D540000FD1912A00FA7C75 /* CommandHandler.cpp */,
|
||||||
174D9026098C78AF00D5909F /* CommandManager.cpp */,
|
174D9026098C78AF00D5909F /* CommandManager.cpp */,
|
||||||
28851F9D1027F16400152EE1 /* CommandSignature.cpp */,
|
28851F9D1027F16400152EE1 /* CommandSignature.cpp */,
|
||||||
|
5EF3E652203FBBE0006C6882 /* CommandTargets.cpp */,
|
||||||
28851F9F1027F16400152EE1 /* CommandType.cpp */,
|
28851F9F1027F16400152EE1 /* CommandType.cpp */,
|
||||||
28851FA11027F16400152EE1 /* CompareAudioCommand.cpp */,
|
28851FA11027F16400152EE1 /* CompareAudioCommand.cpp */,
|
||||||
5EF3E647203FBAFB006C6882 /* Demo.cpp */,
|
5EF3E647203FBAFB006C6882 /* Demo.cpp */,
|
||||||
@ -7783,6 +7786,7 @@
|
|||||||
1790B19409883BFD008A330A /* TimeTrack.cpp in Sources */,
|
1790B19409883BFD008A330A /* TimeTrack.cpp in Sources */,
|
||||||
1790B19709883BFD008A330A /* Track.cpp in Sources */,
|
1790B19709883BFD008A330A /* Track.cpp in Sources */,
|
||||||
1790B19809883BFD008A330A /* TrackArtist.cpp in Sources */,
|
1790B19809883BFD008A330A /* TrackArtist.cpp in Sources */,
|
||||||
|
5EF3E653203FBBE0006C6882 /* CommandTargets.cpp in Sources */,
|
||||||
1790B19909883BFD008A330A /* TrackPanel.cpp in Sources */,
|
1790B19909883BFD008A330A /* TrackPanel.cpp in Sources */,
|
||||||
5E667A601F0BEE5F00C942A5 /* WaveTrackVZoomHandle.cpp in Sources */,
|
5E667A601F0BEE5F00C942A5 /* WaveTrackVZoomHandle.cpp in Sources */,
|
||||||
1790B19A09883BFD008A330A /* TrackPanelAx.cpp in Sources */,
|
1790B19A09883BFD008A330A /* TrackPanelAx.cpp in Sources */,
|
||||||
|
@ -284,3 +284,14 @@ bool CommandImplementation::Apply(const CommandContext & WXUNUSED(context))
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hackery so that we dont have to update the makefiles on linux (yet)
|
||||||
|
#ifndef __WIN32__
|
||||||
|
#ifndef __WXMAC__
|
||||||
|
|
||||||
|
#include "CommandTargets.cpp"
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ CommandContext::CommandContext(
|
|||||||
, const CommandParameter ¶m
|
, const CommandParameter ¶m
|
||||||
)
|
)
|
||||||
: project{ p }
|
: project{ p }
|
||||||
, pOutput( nullptr )
|
// No target specified? Use the special interactive one that pops up a dialog.
|
||||||
|
, pOutput( std::move( std::make_unique<InteractiveOutputTarget>()) )
|
||||||
, pEvt{ e }
|
, pEvt{ e }
|
||||||
, index{ ii }
|
, index{ ii }
|
||||||
, parameter{ param }
|
, parameter{ param }
|
||||||
|
158
src/commands/CommandTargets.cpp
Normal file
158
src/commands/CommandTargets.cpp
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
Audacity - A Digital Audio Editor
|
||||||
|
Copyright 1999-2009 Audacity Team
|
||||||
|
License: wxwidgets
|
||||||
|
|
||||||
|
Dan Horgan
|
||||||
|
|
||||||
|
******************************************************************//**
|
||||||
|
|
||||||
|
\file CommandTargets.cpp
|
||||||
|
\brief Contains definitions for CommandType class
|
||||||
|
|
||||||
|
\class InteractiveOutputTarget
|
||||||
|
\brief InteractiveOutputTarget is an output target that pops up a
|
||||||
|
dialog, if necessary.
|
||||||
|
|
||||||
|
*//*******************************************************************/
|
||||||
|
|
||||||
|
#include "../Audacity.h"
|
||||||
|
#include "CommandTargets.h"
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include "../ShuttleGui.h"
|
||||||
|
#include "../Project.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Dialog for long messages.
|
||||||
|
class AUDACITY_DLL_API LongMessageDialog /* not final */ : public wxDialogWrapper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructors and destructors
|
||||||
|
LongMessageDialog(wxWindow * parent,
|
||||||
|
const wxString & title,
|
||||||
|
int type = 0,
|
||||||
|
int flags = wxDEFAULT_DIALOG_STYLE,
|
||||||
|
int additionalButtons = 0);
|
||||||
|
~LongMessageDialog();
|
||||||
|
|
||||||
|
bool Init();
|
||||||
|
virtual void OnOk(wxCommandEvent & evt);
|
||||||
|
virtual void OnCancel(wxCommandEvent & evt);
|
||||||
|
|
||||||
|
static void AcceptText( const wxString & Text );
|
||||||
|
|
||||||
|
wxTextCtrl * mText;
|
||||||
|
static LongMessageDialog * pDlg;
|
||||||
|
private:
|
||||||
|
int mType;
|
||||||
|
int mAdditionalButtons;
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
wxDECLARE_NO_COPY_CLASS(LongMessageDialog);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
LongMessageDialog * LongMessageDialog::pDlg = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(LongMessageDialog, wxDialogWrapper)
|
||||||
|
EVT_BUTTON(wxID_OK, LongMessageDialog::OnOk)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
LongMessageDialog::LongMessageDialog(wxWindow * parent,
|
||||||
|
const wxString & title,
|
||||||
|
int type,
|
||||||
|
int flags,
|
||||||
|
int additionalButtons)
|
||||||
|
: wxDialogWrapper(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, flags | wxRESIZE_BORDER)
|
||||||
|
{
|
||||||
|
mType = type;
|
||||||
|
mAdditionalButtons = additionalButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
LongMessageDialog::~LongMessageDialog(){
|
||||||
|
pDlg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LongMessageDialog::Init()
|
||||||
|
{
|
||||||
|
ShuttleGui S(this, eIsCreating);
|
||||||
|
|
||||||
|
S.SetBorder(5);
|
||||||
|
S.StartVerticalLay(true);
|
||||||
|
{
|
||||||
|
mText = S.AddTextWindow( "" );
|
||||||
|
long buttons = eOkButton;
|
||||||
|
S.AddStandardButtons(buttons|mAdditionalButtons);
|
||||||
|
}
|
||||||
|
S.EndVerticalLay();
|
||||||
|
|
||||||
|
Layout();
|
||||||
|
Fit();
|
||||||
|
SetMinSize(wxSize(600,700));
|
||||||
|
Center();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LongMessageDialog::OnOk(wxCommandEvent & WXUNUSED(evt)){
|
||||||
|
//Close(true);
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LongMessageDialog::OnCancel(wxCommandEvent & WXUNUSED(evt)){
|
||||||
|
//Close(true);
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LongMessageDialog::AcceptText( const wxString & Text )
|
||||||
|
{
|
||||||
|
if( pDlg == NULL ){
|
||||||
|
pDlg = new LongMessageDialog( GetActiveProject(), "Long Message" );
|
||||||
|
pDlg->Init();
|
||||||
|
pDlg->Show();
|
||||||
|
}
|
||||||
|
pDlg->mText->SetValue( pDlg->mText->GetValue( ) + "\n" + Text );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Displays messages from a command in an AudacityMessageBox
|
||||||
|
class MessageDialogTarget final : public CommandMessageTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~MessageDialogTarget() {}
|
||||||
|
void Update(const wxString &message) override
|
||||||
|
{
|
||||||
|
LongMessageDialog::AcceptText(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Extended Target Factory with more options.
|
||||||
|
class ExtTargetFactory : public TargetFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static std::shared_ptr<CommandMessageTarget> LongMessages()
|
||||||
|
{
|
||||||
|
return std::make_shared<MessageDialogTarget>();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
InteractiveOutputTarget::InteractiveOutputTarget() :
|
||||||
|
CommandOutputTarget(
|
||||||
|
ExtTargetFactory::ProgressDefault(),
|
||||||
|
ExtTargetFactory::LongMessages(),
|
||||||
|
ExtTargetFactory::MessageDefault()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
@ -185,7 +185,7 @@ public:
|
|||||||
/// Assumes responsibility for pointers passed into it.
|
/// Assumes responsibility for pointers passed into it.
|
||||||
class CommandOutputTarget
|
class CommandOutputTarget
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
std::unique_ptr<CommandProgressTarget> mProgressTarget;
|
std::unique_ptr<CommandProgressTarget> mProgressTarget;
|
||||||
std::shared_ptr<CommandMessageTarget> mStatusTarget;
|
std::shared_ptr<CommandMessageTarget> mStatusTarget;
|
||||||
std::shared_ptr<CommandMessageTarget> mErrorTarget;
|
std::shared_ptr<CommandMessageTarget> mErrorTarget;
|
||||||
@ -215,4 +215,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class InteractiveOutputTarget : public CommandOutputTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InteractiveOutputTarget();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* End of include guard: __COMMANDTARGETS__ */
|
#endif /* End of include guard: __COMMANDTARGETS__ */
|
||||||
|
@ -52,10 +52,11 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const int nFormats =2;
|
const int nFormats =3;
|
||||||
static const wxString kFormats[nFormats] =
|
static const wxString kFormats[nFormats] =
|
||||||
{
|
{
|
||||||
XO("JSON"),
|
XO("JSON"),
|
||||||
|
XO("LISP"),
|
||||||
XO("Other")
|
XO("Other")
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,8 +82,8 @@ void GetInfoCommand::PopulateOrExchange(ShuttleGui & S)
|
|||||||
|
|
||||||
S.StartMultiColumn(2, wxALIGN_CENTER);
|
S.StartMultiColumn(2, wxALIGN_CENTER);
|
||||||
{
|
{
|
||||||
S.TieChoice( _("Types:"), mInfoType, &types);
|
S.TieChoice( _("Type:"), mInfoType, &types);
|
||||||
S.TieChoice( _("Formats:"), mFormat, &formats);
|
S.TieChoice( _("Format:"), mFormat, &formats);
|
||||||
}
|
}
|
||||||
S.EndMultiColumn();
|
S.EndMultiColumn();
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,7 @@
|
|||||||
<ClCompile Include="..\..\..\src\blockfile\NotYetAvailableException.cpp" />
|
<ClCompile Include="..\..\..\src\blockfile\NotYetAvailableException.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\commands\AudacityCommand.cpp" />
|
<ClCompile Include="..\..\..\src\commands\AudacityCommand.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\commands\CommandContext.cpp" />
|
<ClCompile Include="..\..\..\src\commands\CommandContext.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\src\commands\CommandTargets.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\commands\Demo.cpp" />
|
<ClCompile Include="..\..\..\src\commands\Demo.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\commands\LoadCommands.cpp" />
|
<ClCompile Include="..\..\..\src\commands\LoadCommands.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\commands\OpenSaveCommands.cpp" />
|
<ClCompile Include="..\..\..\src\commands\OpenSaveCommands.cpp" />
|
||||||
|
@ -1064,6 +1064,9 @@
|
|||||||
<ClCompile Include="..\..\..\src\commands\SetTrackInfoCommand.cpp">
|
<ClCompile Include="..\..\..\src\commands\SetTrackInfoCommand.cpp">
|
||||||
<Filter>src\commands</Filter>
|
<Filter>src\commands</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\src\commands\CommandTargets.cpp">
|
||||||
|
<Filter>src\commands</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\src\AboutDialog.h">
|
<ClInclude Include="..\..\..\src\AboutDialog.h">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user