1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 14:02:57 +02:00

Shorter command names. General tidying.

-More commands now have shorter names for parameters.
-New scripts for generating images.
-Several old-style commands retired.
This commit is contained in:
James Crook
2018-02-24 12:56:58 +00:00
committed by Paul Licameli
parent 62ca1cce26
commit 5d36890cb0
13 changed files with 215 additions and 160 deletions

View File

@@ -94,7 +94,7 @@ void LispyCommandMessageTarget::StartArray()
{
wxString Padding;
Padding.Pad( mCounts.GetCount() *2 -2);
Update( wxString::Format( "%s%s( ", ( mCounts.Last() > 0 ) ? ",\n" : "\n", Padding ));
Update( wxString::Format( "\n%s(", Padding ));
mCounts.Last() += 1;
mCounts.push_back( 0 );
}
@@ -103,12 +103,12 @@ void LispyCommandMessageTarget::EndArray(){
if( mCounts.GetCount() > 1 ){
mCounts.pop_back();
}
Update( " )" );
Update( ")" );
}
void LispyCommandMessageTarget::StartStruct(){
wxString Padding;
Padding.Pad( mCounts.GetCount() *2 -2);
Update( wxString::Format( "%s%s( ", ( mCounts.Last() > 0 ) ? ",\n" : "\n", Padding ));
Update( wxString::Format( "\n%s(", Padding ));
mCounts.Last() += 1;
mCounts.push_back( 0 );
}
@@ -116,36 +116,33 @@ void LispyCommandMessageTarget::EndStruct(){
if( mCounts.GetCount() > 1 ){
mCounts.pop_back();
}
Update( " )" );
Update( ")" );
}
void LispyCommandMessageTarget::AddItem(const wxString &value, const wxString &name){
wxString Padding;
Padding.Pad( mCounts.GetCount() *2 -2);
Padding = (( value.length() < 15 ) || (mCounts.Last()<=0)) ? "" : wxString("\n") + Padding;
wxString Padding = "";
if( name.IsEmpty() )
Update( wxString::Format( "%s%s\"%s\"", (mCounts.Last()>0)?", ":"", Padding, value));
Update( wxString::Format( "%s%s\"%s\"", (mCounts.Last()>0)?" ":"", Padding, value));
else
Update( wxString::Format( "%s%s( %s, \"%s\" )", (mCounts.Last()>0)?", ":"", Padding, name, value));
Update( wxString::Format( "%s%s(%s \"%s\")", (mCounts.Last()>0)?" ":"", Padding, name, value));
mCounts.Last() += 1;
}
void LispyCommandMessageTarget::AddBool(const bool value, const wxString &name){
if( name.IsEmpty() )
Update( wxString::Format( "%s%s", (mCounts.Last()>0)?", ":"",value?"True":"False"));
Update( wxString::Format( "%s%s", (mCounts.Last()>0)?" ":"",value?"True":"False"));
else
Update( wxString::Format( "%s( %s, %s )", (mCounts.Last()>0)?", ":"", name,value?"True":"False"));
Update( wxString::Format( "%s(%s %s)", (mCounts.Last()>0)?" ":"", name,value?"True":"False"));
mCounts.Last() += 1;
}
void LispyCommandMessageTarget::AddItem(const double value, const wxString &name){
if( name.IsEmpty() )
Update( wxString::Format( "%s%g", (mCounts.Last()>0)?", ":"", value));
Update( wxString::Format( "%s%g", (mCounts.Last()>0)?" ":"", value));
else
Update( wxString::Format( "%s( %s, %g )", (mCounts.Last()>0)?", ":"", name,value));
Update( wxString::Format( "%s(%s %g)", (mCounts.Last()>0)?" ":"", name,value));
mCounts.Last() += 1;
}
void LispyCommandMessageTarget::StartField(const wxString &name){
Update( wxString::Format( "%s( %s, ", (mCounts.Last()>0)?", ":"", name ));
Update( wxString::Format( "%s(%s", (mCounts.Last()>0)?" ":"", name ));
mCounts.Last() += 1;
mCounts.push_back( 0 );
}
@@ -154,7 +151,7 @@ void LispyCommandMessageTarget::EndField(){
if( mCounts.GetCount() > 1 ){
mCounts.pop_back();
}
Update( " )" );
Update( ")" );
}

View File

@@ -22,7 +22,7 @@
// Import
#define IMPORT_PLUGIN_SYMBOL XO("Import")
#define IMPORT_PLUGIN_SYMBOL XO("Import2")
class ImportCommand : public AudacityCommand
{
@@ -40,7 +40,7 @@ public:
wxString mFileName;
};
#define EXPORT_PLUGIN_SYMBOL XO("Export")
#define EXPORT_PLUGIN_SYMBOL XO("Export2")
class ExportCommand : public AudacityCommand
{

View File

@@ -49,8 +49,6 @@ modelled on BuiltinEffectsModule
COMMAND( SET_LABEL, SetLabelCommand, () ) \
COMMAND( SET_PROJECT, SetProjectCommand, () ) \
COMMAND( SELECT, SelectCommand, () ) \
COMMAND( SELECT_TIME, SelectTimeCommand, () ) \
COMMAND( SELECT_TRACKS, SelectTracksCommand, () ) \
COMMAND( GET_PREFERENCE, GetPreferenceCommand, () ) \
COMMAND( SET_PREFERENCE, SetPreferenceCommand, () ) \
COMMAND( GET_INFO, GetInfoCommand, () ) \
@@ -62,6 +60,9 @@ modelled on BuiltinEffectsModule
// GET_TRACK_INFO subsumed by GET_INFO
//COMMAND( GET_TRACK_INFO, GetTrackInfoCommand, () )
// SELECT_TIME and SELECT_TRACKS subsumed by SELECT
//COMMAND( SELECT_TIME, SelectTimeCommand, () )
//COMMAND( SELECT_TRACKS, SelectTracksCommand, () )
//

View File

@@ -617,6 +617,11 @@ void ScreenshotCommand::CaptureEffects(
wxString ScreenshotCommand::MakeFileName(const wxString &path, const wxString &basename)
{
// If the path is a full file name, then use it.
if( path.EndsWith( ".png" ) )
return path;
// Otherwise make up a file name that has not been used already.
wxFileName prefixPath;
prefixPath.AssignDir(path);
wxString prefix = prefixPath.GetPath

View File

@@ -25,6 +25,7 @@ code out of ModuleManager.
#include "AppCommandEvent.h"
#include "ResponseQueue.h"
#include "../Project.h"
#include "../AudacityApp.h"
#include <wx/string.h>
// Declare static class members

View File

@@ -34,8 +34,8 @@
#include "CommandContext.h"
bool SelectTimeCommand::DefineParams( ShuttleParams & S ){
S.Define( mT0, wxT("StartTime"), 0.0, 0.0, (double)FLT_MAX);
S.Define( mT1, wxT("EndTime"), 0.0, 0.0, (double)FLT_MAX);
S.Optional( bHasT0 ).Define( mT0, wxT("Start"), 0.0, 0.0, (double)FLT_MAX);
S.Optional( bHasT1 ).Define( mT1, wxT("End"), 0.0, 0.0, (double)FLT_MAX);
S.Define( mFromEnd, wxT("FromEnd"), false );
return true;
}
@@ -44,16 +44,23 @@ void SelectTimeCommand::PopulateOrExchange(ShuttleGui & S)
{
S.AddSpace(0, 5);
S.StartMultiColumn(3, wxALIGN_CENTER);
{
S.Optional( bHasT0 ).TieTextBox(_("Start Time:"), mT0);
S.Optional( bHasT1 ).TieTextBox(_("End Time:"), mT1);
}
S.EndMultiColumn();
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieTextBox(_("Start Time:"),mT0);
S.TieTextBox(_("End Time:"),mT1);
S.TieCheckBox(_("From End:"), mFromEnd );
}
S.EndMultiColumn();
}
bool SelectTimeCommand::Apply(const CommandContext & context){
if( !bHasT0 && !bHasT1 )
return true;
if( mFromEnd ){
double TEnd = context.GetProject()->GetTracks()->GetEndTime();
context.GetProject()->mViewInfo.selectedRegion.setTimes(TEnd - mT0, TEnd - mT1);
@@ -74,8 +81,8 @@ static const wxString kModes[nModes] =
bool SelectTracksCommand::DefineParams( ShuttleParams & S ){
wxArrayString modes( nModes, kModes );
S.Define( mFirstTrack, wxT("FirstTrack"), 0, 0, 100);
S.Define( mLastTrack, wxT("LastTrack"), 0, 0, 100);
S.Optional( bHasFirstTrack).Define( mFirstTrack, wxT("First"), 0, 0, 100);
S.Optional( bHasLastTrack ).Define( mLastTrack, wxT("Last"), 0, 0, 100);
S.DefineEnum( mMode, wxT("Mode"), 0, modes );
return true;
@@ -86,10 +93,14 @@ void SelectTracksCommand::PopulateOrExchange(ShuttleGui & S)
wxArrayString modes( nModes, kModes );
S.AddSpace(0, 5);
S.StartMultiColumn(3, wxALIGN_CENTER);
{
S.Optional( bHasFirstTrack).TieTextBox(_("First Track:"),mFirstTrack);
S.Optional( bHasLastTrack).TieTextBox(_("Last Track:"),mLastTrack);
}
S.EndMultiColumn();
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieTextBox(_("First Track:"),mFirstTrack);
S.TieTextBox(_("Last Track:"),mLastTrack);
S.TieChoice( _("Mode:"), mMode, &modes);
}
S.EndMultiColumn();
@@ -97,6 +108,9 @@ void SelectTracksCommand::PopulateOrExchange(ShuttleGui & S)
bool SelectTracksCommand::Apply(const CommandContext &context)
{
if( !bHasFirstTrack && !bHasLastTrack )
return true;
int index = 0;
TrackList *tracks = context.GetProject()->GetTracks();
int last = wxMax( mFirstTrack, mLastTrack );

View File

@@ -41,6 +41,10 @@ public:
// AudacityCommand overrides
wxString ManualPage() override {return wxT("Audio_Selection");};
bool bHasT0;
bool bHasT1;
double mT0;
double mT1;
bool mFromEnd;
@@ -58,6 +62,9 @@ public:
// AudacityCommand overrides
wxString ManualPage() override {return wxT("Audio_Selection");};
bool bHasFirstTrack;
bool bHasLastTrack;
int mFirstTrack;
int mLastTrack;
int mMode;

View File

@@ -27,16 +27,7 @@
#include "CommandContext.h"
SetClipCommand::SetClipCommand()
{/*
mTrackIndex = 0;
mTrackName = "unnamed";
mPan = 0.0f;
mGain = 1.0f;
bSelected = false;
bFocused = false;
bSolo = false;
bMute = false;
*/
{
}
enum kColours
@@ -59,7 +50,7 @@ static const wxString kColourStrings[nColours] =
bool SetClipCommand::DefineParams( ShuttleParams & S ){
wxArrayString colours( nColours, kColourStrings );
S.Define( mClipIndex, wxT("ClipIndex"), 0, 0, 100 );
S.Define( mClipIndex, wxT("Clip"), 0, 0, 100 );
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
// Allowing a negative start time is not a mistake.
// It will be used in demonstrating time before zero.

View File

@@ -33,7 +33,7 @@ SetLabelCommand::SetLabelCommand()
bool SetLabelCommand::DefineParams( ShuttleParams & S ){
S.Define( mLabelIndex, wxT("LabelIndex"), 0, 0, 100 );
S.Define( mLabelIndex, wxT("Label"), 0, 0, 100 );
S.Optional( bHasText ).Define( mText, wxT("Text"), wxT("empty") );
S.Optional( bHasT0 ).Define( mT0, wxT("Start"), 0.0, 0.0, 100000.0);
S.Optional( bHasT1 ).Define( mT1, wxT("End"), 0.0, 0.0, 100000.0);

View File

@@ -49,7 +49,7 @@ static const wxString kColourStrings[nColours] =
bool SetTrackCommand::DefineParams( ShuttleParams & S ){
wxArrayString colours( nColours, kColourStrings );
S.Define( mTrackIndex, wxT("TrackIndex"), 0, 0, 100 );
S.Define( mTrackIndex, wxT("Track"), 0, 0, 100 );
S.Optional( bHasTrackName ).Define( mTrackName, wxT("Name"), wxT("Unnamed") );
S.Optional( bHasPan ).Define( mPan, wxT("Pan"), 0.0, -1.0, 1.0);
S.Optional( bHasGain ).Define( mGain, wxT("Gain"), 1.0, 0.0, 10.0);