1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 09:20:16 +01:00
Files
audacity/src/commands/SetEnvelopeCommand.cpp
Paul Licameli 4d09705a73 Change XO to XXO in many more places, with no effects at all...
... because the two macros have the same expansion, and are both checked for
in the --keyword arguments passed to msgfmt by locale/update_po_files.sh.

This commit makes ONLY such changes, and comments in Internat.h.  It is big
but quite harmless.

The intention is to introduce a type distinction in a later release, by defining
XXO differently.  XXO is used where & characters in strings (for hotkeys of menu
items or control prompts) are permitted, XO where not.
2020-05-22 13:07:50 -04:00

88 lines
2.6 KiB
C++

/**********************************************************************
Audacity - A Digital Audio Editor
Copyright 1999-2018 Audacity Team
License: wxwidgets
James Crook
******************************************************************//**
\file SetEnvelopeCommand.cpp
\brief Definitions for SetEnvelopeCommand
\class SetEnvelopeCommand
\brief Command that sets envelope information
*//*******************************************************************/
#include "../Audacity.h"
#include "SetEnvelopeCommand.h"
#include "LoadCommands.h"
#include "../WaveClip.h"
#include "../WaveTrack.h"
#include "../Envelope.h"
#include "../Shuttle.h"
#include "../ShuttleGui.h"
const ComponentInterfaceSymbol SetEnvelopeCommand::Symbol
{ XO("Set Envelope") };
namespace{ BuiltinCommandsModule::Registration< SetEnvelopeCommand > reg; }
SetEnvelopeCommand::SetEnvelopeCommand()
{
}
bool SetEnvelopeCommand::DefineParams( ShuttleParams & S ){
S.OptionalY( bHasT ).Define( mT, wxT("Time"), 0.0, 0.0, 100000.0);
S.OptionalY( bHasV ).Define( mV, wxT("Value"), 1.0, 0.0, 2.0);
S.OptionalN( bHasDelete ).Define( mbDelete, wxT("Delete"), false );
return true;
};
void SetEnvelopeCommand::PopulateOrExchange(ShuttleGui & S)
{
S.AddSpace(0, 5);
S.StartMultiColumn(3, wxALIGN_CENTER);
{
S.Optional( bHasT ).TieNumericTextBox( XXO("Time:"), mT );
S.Optional( bHasV ).TieNumericTextBox( XXO("Value:"), mV );
S.Optional( bHasDelete ).TieCheckBox( XXO("Delete"), mbDelete );
}
S.EndMultiColumn();
}
bool SetEnvelopeCommand::ApplyInner( const CommandContext &, Track * t )
{
// if no time is specified, then
// - delete deletes any envelope in selected tracks.
// - value is not set for any clip
t->TypeSwitch([&](WaveTrack *waveTrack) {
WaveClipPointers ptrs( waveTrack->SortedClipArray());
for(auto it = ptrs.begin(); (it != ptrs.end()); it++ ){
WaveClip * pClip = *it;
bool bFound =
!bHasT || (
( pClip->GetStartTime() <= mT) &&
( pClip->GetEndTime() >= mT )
);
if( bFound )
{
// Inside this IF is where we actually apply the command
Envelope* pEnv = pClip->GetEnvelope();
if( bHasDelete && mbDelete )
pEnv->Clear();
if( bHasT && bHasV )
pEnv->InsertOrReplace( mT, pEnv->ClampValue( mV ) );
}
}
} );
return true;
}