mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 00:19:27 +02:00
Break various small cycles, and a few other noncyclic dependencies
This commit is contained in:
commit
36cb2918be
@ -1358,13 +1358,15 @@ bool AudacityApp::OnInit()
|
||||
#endif
|
||||
|
||||
// Initialize preferences and language
|
||||
InitPreferences();
|
||||
wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg"));
|
||||
InitPreferences( configFileName );
|
||||
PopulatePreferences();
|
||||
// This test must follow PopulatePreferences, because if an error message
|
||||
// must be shown, we need internationalization to have been initialized
|
||||
// first, which was done in PopulatePreferences
|
||||
if ( !CheckWritablePreferences() ) {
|
||||
::AudacityMessageBox( UnwritablePreferencesErrorMessage() );
|
||||
::AudacityMessageBox(
|
||||
UnwritablePreferencesErrorMessage( configFileName ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,6 @@ and in the spectrogram spectral selection.
|
||||
|
||||
#include "WaveTrack.h"
|
||||
|
||||
#include "./widgets/LinkingHtmlWindow.h"
|
||||
#include "./widgets/HelpSystem.h"
|
||||
#include "widgets/AudacityMessageBox.h"
|
||||
#include "widgets/Ruler.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "MemoryX.h"
|
||||
#include <wx/defs.h>
|
||||
#include "Theme.h"
|
||||
|
||||
class wxColour;
|
||||
class wxImage;
|
||||
@ -41,6 +40,9 @@ std::unique_ptr<wxImage> OverlayImage(wxImage * background, wxImage * foreground
|
||||
wxImage * mask, int xoff, int yoff);
|
||||
|
||||
|
||||
// JKC: will probably change name from 'teBmps' to 'tIndexBmp';
|
||||
typedef int teBmps; /// The index of a bitmap resource in Theme Resources.
|
||||
|
||||
// Same idea, but this time the mask is an alpha channel in
|
||||
// the foreground bitmap, and it's all retrieved from Themes.
|
||||
std::unique_ptr<wxImage> OverlayImage(teBmps eBack, teBmps eForeground,
|
||||
|
@ -60,10 +60,8 @@
|
||||
#include <wx/filename.h>
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
#include "FileNames.h"
|
||||
#include "Internat.h"
|
||||
#include "MemoryX.h"
|
||||
#include "Languages.h"
|
||||
|
||||
std::unique_ptr<AudacityPrefs> ugPrefs {};
|
||||
|
||||
@ -206,12 +204,10 @@ bool AudacityPrefs::GetEditClipsCanMove()
|
||||
return editClipsCanMove;
|
||||
}
|
||||
|
||||
void InitPreferences()
|
||||
void InitPreferences( const wxFileName &configFileName )
|
||||
{
|
||||
wxString appName = wxTheApp->GetAppName();
|
||||
|
||||
wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg"));
|
||||
|
||||
ugPrefs = std::make_unique<AudacityPrefs>
|
||||
(appName, wxEmptyString,
|
||||
configFileName.GetFullPath(),
|
||||
@ -226,9 +222,8 @@ bool CheckWritablePreferences()
|
||||
return gPrefs->Write("/TEST", true) && gPrefs->Flush();
|
||||
}
|
||||
|
||||
wxString UnwritablePreferencesErrorMessage()
|
||||
wxString UnwritablePreferencesErrorMessage( const wxFileName &configFileName )
|
||||
{
|
||||
wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg"));
|
||||
return wxString::Format(
|
||||
_("Audacity cannot start because the settings file at %s is not writable."),
|
||||
configFileName.GetFullPath()
|
||||
|
@ -37,9 +37,11 @@
|
||||
#include <wx/fileconf.h> // to inherit wxFileConfig
|
||||
#include <wx/event.h> // to declare custom event types
|
||||
|
||||
void InitPreferences();
|
||||
class wxFileName;
|
||||
|
||||
void InitPreferences( const wxFileName &configFileName );
|
||||
bool CheckWritablePreferences();
|
||||
wxString UnwritablePreferencesErrorMessage();
|
||||
wxString UnwritablePreferencesErrorMessage( const wxFileName &configFileName );
|
||||
void FinishPreferences();
|
||||
|
||||
class AudacityPrefs;
|
||||
|
@ -182,8 +182,13 @@ private:
|
||||
long mValue;
|
||||
};
|
||||
|
||||
using AttachedTrackObjects = ClientData::Site<
|
||||
Track, ClientData::Base, ClientData::SkipCopying, std::shared_ptr
|
||||
>;
|
||||
|
||||
class AUDACITY_DLL_API Track /* not final */
|
||||
: public XMLTagHandler
|
||||
, public AttachedTrackObjects
|
||||
, public std::enable_shared_from_this<Track> // see SharedPointer()
|
||||
{
|
||||
friend class TrackList;
|
||||
@ -207,6 +212,7 @@ class AUDACITY_DLL_API Track /* not final */
|
||||
|
||||
public:
|
||||
|
||||
using AttachedObjects = ::AttachedTrackObjects;
|
||||
using ChannelType = XMLValueChecker::ChannelType;
|
||||
|
||||
static const auto LeftChannel = XMLValueChecker::LeftChannel;
|
||||
|
@ -73,6 +73,7 @@ is time to refresh some aspect of the screen.
|
||||
#include "RefreshCode.h"
|
||||
#include "TrackArtist.h"
|
||||
#include "TrackPanelAx.h"
|
||||
#include "TrackPanelResizerCell.h"
|
||||
#include "WaveTrack.h"
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
#include "NoteTrack.h"
|
||||
@ -1151,7 +1152,7 @@ struct ChannelGroup final : TrackPanelGroup {
|
||||
yy += height;
|
||||
refinement.emplace_back(
|
||||
yy - kSeparatorThickness,
|
||||
TrackView::Get( *channel ).GetResizer() );
|
||||
TrackPanelResizerCell::Get( *channel ).shared_from_this() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1270,8 +1271,9 @@ struct ResizingChannelGroup final : TrackPanelGroup {
|
||||
{ rect.GetTop(),
|
||||
std::make_shared< LabeledChannelGroup >( mpTrack, mLeftOffset ) },
|
||||
{ rect.GetTop() + rect.GetHeight() - kSeparatorThickness,
|
||||
TrackView::Get( **TrackList::Channels( mpTrack.get() ).rbegin() )
|
||||
.GetResizer() }
|
||||
TrackPanelResizerCell::Get(
|
||||
**TrackList::Channels( mpTrack.get() ).rbegin() ).shared_from_this()
|
||||
}
|
||||
} }; }
|
||||
std::shared_ptr< Track > mpTrack;
|
||||
wxCoord mLeftOffset;
|
||||
|
@ -26,8 +26,8 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include <wx/mousestate.h>
|
||||
|
||||
TrackPanelResizerCell::TrackPanelResizerCell(
|
||||
const std::shared_ptr<TrackView> &pView )
|
||||
: mwView{ pView }
|
||||
const std::shared_ptr<Track> &pTrack )
|
||||
: mwTrack{ pTrack }
|
||||
{}
|
||||
|
||||
std::vector<UIHandlePtr> TrackPanelResizerCell::HitTest
|
||||
@ -47,10 +47,7 @@ std::vector<UIHandlePtr> TrackPanelResizerCell::HitTest
|
||||
|
||||
std::shared_ptr<Track> TrackPanelResizerCell::DoFindTrack()
|
||||
{
|
||||
const auto pView = mwView.lock();
|
||||
if ( pView )
|
||||
return pView->FindTrack();
|
||||
return {};
|
||||
return mwTrack.lock();
|
||||
}
|
||||
|
||||
void TrackPanelResizerCell::Draw(
|
||||
@ -112,3 +109,20 @@ void TrackPanelResizerCell::Draw(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const AttachedTrackObjects::RegisteredFactory key{
|
||||
[]( Track &track ){
|
||||
return std::make_shared<TrackPanelResizerCell>(
|
||||
track.shared_from_this() );
|
||||
}
|
||||
};
|
||||
|
||||
TrackPanelResizerCell &TrackPanelResizerCell::Get( Track &track )
|
||||
{
|
||||
return track.AttachedObjects::Get< TrackPanelResizerCell >( key );
|
||||
}
|
||||
|
||||
const TrackPanelResizerCell &TrackPanelResizerCell::Get( const Track &track )
|
||||
{
|
||||
return Get( const_cast< Track & >( track ) );
|
||||
}
|
||||
|
@ -11,19 +11,26 @@
|
||||
#ifndef __AUDACITY_TRACK_PANEL_RESIZER_CELL__
|
||||
#define __AUDACITY_TRACK_PANEL_RESIZER_CELL__
|
||||
|
||||
#include "tracks/ui/CommonTrackPanelCell.h"
|
||||
#include "ClientData.h" // to inherit
|
||||
#include "tracks/ui/CommonTrackPanelCell.h" // to inherit
|
||||
|
||||
class Track;
|
||||
class TrackPanelResizeHandle;
|
||||
class TrackView;
|
||||
|
||||
class TrackPanelResizerCell : public CommonTrackPanelCell
|
||||
class TrackPanelResizerCell
|
||||
: public CommonTrackPanelCell
|
||||
, public std::enable_shared_from_this< TrackPanelResizerCell >
|
||||
, public ClientData::Base
|
||||
{
|
||||
TrackPanelResizerCell(const TrackPanelResizerCell&) = delete;
|
||||
TrackPanelResizerCell &operator= (const TrackPanelResizerCell&) = delete;
|
||||
public:
|
||||
|
||||
static TrackPanelResizerCell &Get( Track &track );
|
||||
static const TrackPanelResizerCell &Get( const Track &track );
|
||||
|
||||
explicit
|
||||
TrackPanelResizerCell( const std::shared_ptr<TrackView> &pView );
|
||||
TrackPanelResizerCell( const std::shared_ptr<Track> &pTrack );
|
||||
|
||||
std::vector<UIHandlePtr> HitTest
|
||||
(const TrackPanelMouseState &, const AudacityProject *) override;
|
||||
@ -33,7 +40,7 @@ protected:
|
||||
|
||||
private:
|
||||
// back-pointer is weak to break a cycle
|
||||
std::weak_ptr<TrackView> mwView;
|
||||
std::weak_ptr<Track> mwTrack;
|
||||
|
||||
// TrackPanelDrawable implementation
|
||||
void Draw(
|
||||
|
@ -533,3 +533,32 @@ static DirManager::RegisteredBlockFileDeserializer sRegistration {
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
///This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows
|
||||
ODFileDecoder::ODFileDecoder(const wxString & fName)
|
||||
: mFName{ fName }
|
||||
{
|
||||
mInited = false;
|
||||
}
|
||||
|
||||
ODFileDecoder::~ODFileDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
bool ODFileDecoder::IsInitialized()
|
||||
{
|
||||
bool ret;
|
||||
mInitedLock.Lock();
|
||||
ret = mInited;
|
||||
mInitedLock.Unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
///Derived classes should call this after they have parsed the header.
|
||||
void ODFileDecoder::MarkInitialized()
|
||||
{
|
||||
mInitedLock.Lock();
|
||||
mInited=true;
|
||||
mInitedLock.Unlock();
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,10 @@ Also, see ODPCMAliasBlockFile for a similar file.
|
||||
#define __AUDACITY_ODDecodeBlockFile__
|
||||
|
||||
#include "SimpleBlockFile.h"
|
||||
#include "../ondemand/ODDecodeTask.h"
|
||||
#include <wx/atomic.h> // member variable
|
||||
|
||||
class ODFileDecoder;
|
||||
|
||||
/// An AliasBlockFile that references uncompressed data in an existing file
|
||||
class ODDecodeBlockFile final : public SimpleBlockFile
|
||||
{
|
||||
@ -188,5 +189,47 @@ class ODDecodeBlockFile final : public SimpleBlockFile
|
||||
|
||||
};
|
||||
|
||||
///class to decode a particular file (one per file). Saves info such as filename and length (after the header is read.)
|
||||
class ODFileDecoder /* not final */
|
||||
{
|
||||
public:
|
||||
///This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows
|
||||
ODFileDecoder(const wxString& fName);
|
||||
virtual ~ODFileDecoder();
|
||||
|
||||
///Read header. Subclasses must override. Probably should save the info somewhere.
|
||||
///Ideally called once per decoding of a file. This complicates the task because
|
||||
virtual bool ReadHeader()=0;
|
||||
virtual bool Init(){return ReadHeader();}
|
||||
|
||||
virtual bool SeekingAllowed(){return true;}
|
||||
|
||||
///Decodes the samples for this blockfile from the real file into a float buffer.
|
||||
///This is file specific, so subclasses must implement this only.
|
||||
///the buffer should be created by the ODFileDecoder implementing this method.
|
||||
///It should set the format parameter so that the client code can deal with it.
|
||||
///This class should call ReadHeader() first, so it knows the length, and can prepare
|
||||
///the file object if it needs to.
|
||||
///returns negative value for failure, 0 or positive value for success.
|
||||
virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) = 0;
|
||||
|
||||
const wxString &GetFileName(){return mFName;}
|
||||
|
||||
bool IsInitialized();
|
||||
|
||||
protected:
|
||||
///Derived classes should call this after they have parsed the header.
|
||||
void MarkInitialized();
|
||||
|
||||
bool mInited;
|
||||
ODLock mInitedLock;
|
||||
|
||||
const wxString mFName;
|
||||
|
||||
unsigned int mSampleRate;
|
||||
unsigned int mNumSamples;//this may depend on the channel - so TODO: we should probably let the decoder create/modify the track info directly.
|
||||
unsigned int mNumChannels;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -26,7 +26,6 @@ system by constructing BatchCommandEval objects.
|
||||
|
||||
#include "CommandDirectory.h"
|
||||
#include "Command.h"
|
||||
#include "ScriptCommandRelay.h"
|
||||
#include "CommandContext.h"
|
||||
#include "CommandTargets.h"
|
||||
#include "../Shuttle.h"
|
||||
@ -83,7 +82,7 @@ void CommandBuilder::BuildCommand(const wxString &cmdName,
|
||||
{
|
||||
// Stage 1: create a Command object of the right type
|
||||
|
||||
auto scriptOutput = ScriptCommandRelay::GetResponseTarget();
|
||||
auto scriptOutput = std::make_shared< ResponseQueueTarget >();
|
||||
auto output
|
||||
= std::make_unique<CommandOutputTargets>(std::make_unique<NullProgressTarget>(),
|
||||
scriptOutput,
|
||||
@ -192,7 +191,8 @@ void CommandBuilder::BuildCommand(const wxString &cmdStringArg)
|
||||
int splitAt = cmdString.Find(wxT(':'));
|
||||
if (splitAt < 0 && cmdString.Find(wxT(' ')) >= 0) {
|
||||
mError = wxT("Command is missing ':'");
|
||||
ScriptCommandRelay::SendResponse(wxT("\n"));
|
||||
ResponseQueueTarget::sResponseQueue().AddResponse(
|
||||
Response{wxT("\n")});
|
||||
mValid = false;
|
||||
return;
|
||||
}
|
||||
|
@ -96,7 +96,6 @@ CommandManager. It holds the callback for one command.
|
||||
#include "../Menus.h"
|
||||
|
||||
#include "../Project.h"
|
||||
#include "../widgets/LinkingHtmlWindow.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/HelpSystem.h"
|
||||
|
||||
|
@ -458,3 +458,9 @@ void StatusBarTarget::Update(const wxString &message)
|
||||
{
|
||||
mStatus.SetStatusText(message, 0);
|
||||
}
|
||||
|
||||
ResponseQueue &ResponseQueueTarget::sResponseQueue()
|
||||
{
|
||||
static ResponseQueue queue;
|
||||
return queue;
|
||||
}
|
||||
|
@ -221,23 +221,23 @@ public:
|
||||
void Update(const wxString &message) override;
|
||||
};
|
||||
|
||||
/// Adds messages to a response queue (to be sent back to a script)
|
||||
/// Adds messages to the global response queue (to be sent back to a script)
|
||||
class ResponseQueueTarget final : public CommandMessageTarget
|
||||
{
|
||||
private:
|
||||
ResponseQueue &mResponseQueue;
|
||||
wxString mBuffer;
|
||||
public:
|
||||
ResponseQueueTarget(ResponseQueue &responseQueue)
|
||||
: mResponseQueue(responseQueue),
|
||||
mBuffer( wxEmptyString )
|
||||
static ResponseQueue &sResponseQueue();
|
||||
|
||||
ResponseQueueTarget()
|
||||
: mBuffer( wxEmptyString )
|
||||
{ }
|
||||
virtual ~ResponseQueueTarget()
|
||||
{
|
||||
if( mBuffer.StartsWith("\n" ) )
|
||||
mBuffer = mBuffer.Mid( 1 );
|
||||
mResponseQueue.AddResponse( mBuffer );
|
||||
mResponseQueue.AddResponse(wxString(wxT("\n")));
|
||||
sResponseQueue().AddResponse( mBuffer );
|
||||
sResponseQueue().AddResponse(wxString(wxT("\n")));
|
||||
}
|
||||
void Update(const wxString &message) override
|
||||
{
|
||||
|
@ -31,7 +31,6 @@ code out of ModuleManager.
|
||||
// Declare static class members
|
||||
CommandHandler *ScriptCommandRelay::sCmdHandler;
|
||||
tpRegScriptServerFunc ScriptCommandRelay::sScriptFn;
|
||||
ResponseQueue ScriptCommandRelay::sResponseQueue;
|
||||
|
||||
void ScriptCommandRelay::SetRegScriptServerFunc(tpRegScriptServerFunc scriptFn)
|
||||
{
|
||||
@ -162,22 +161,8 @@ void * ExecForLisp( char * pIn ){
|
||||
};
|
||||
|
||||
|
||||
/// Adds a response to the queue to be sent back to the script
|
||||
void ScriptCommandRelay::SendResponse(const wxString &response)
|
||||
{
|
||||
sResponseQueue.AddResponse(response);
|
||||
}
|
||||
|
||||
/// Gets a response from the queue (may block)
|
||||
Response ScriptCommandRelay::ReceiveResponse()
|
||||
{
|
||||
return ScriptCommandRelay::sResponseQueue.WaitAndGetResponse();
|
||||
}
|
||||
|
||||
/// Get a pointer to a message target which allows commands to send responses
|
||||
/// back to a script.
|
||||
std::shared_ptr<ResponseQueueTarget> ScriptCommandRelay::GetResponseTarget()
|
||||
{
|
||||
// This should be deleted by a Command destructor
|
||||
return std::make_shared<ResponseQueueTarget>(sResponseQueue);
|
||||
return ResponseQueueTarget::sResponseQueue().WaitAndGetResponse();
|
||||
}
|
||||
|
@ -22,9 +22,7 @@
|
||||
|
||||
class wxWindow;
|
||||
class CommandHandler;
|
||||
class ResponseQueue;
|
||||
class Response;
|
||||
class ResponseQueueTarget;
|
||||
class OldStyleCommand;
|
||||
using OldStyleCommandPointer = std::shared_ptr<OldStyleCommand>;
|
||||
class wxString;
|
||||
@ -42,7 +40,6 @@ class ScriptCommandRelay
|
||||
// N.B. Static class members also have to be declared in the .cpp file
|
||||
static CommandHandler *sCmdHandler;
|
||||
static tpRegScriptServerFunc sScriptFn;
|
||||
static ResponseQueue sResponseQueue;
|
||||
|
||||
public:
|
||||
|
||||
@ -52,9 +49,7 @@ class ScriptCommandRelay
|
||||
static void Run();
|
||||
static void PostCommand(
|
||||
wxWindow *pWindow, const OldStyleCommandPointer &cmd);
|
||||
static void SendResponse(const wxString &response);
|
||||
static Response ReceiveResponse();
|
||||
static std::shared_ptr<ResponseQueueTarget> GetResponseTarget();
|
||||
};
|
||||
|
||||
#endif /* End of include guard: __SCRIPT_COMMAND_RELAY__ */
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../FileNames.h"
|
||||
#include "../ViewInfo.h"
|
||||
#include "../widgets/LinkingHtmlWindow.h"
|
||||
#include "../widgets/HelpSystem.h"
|
||||
#include "../widgets/NumericTextCtrl.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
|
@ -69,7 +69,6 @@ greater use in future.
|
||||
#include "../ondemand/ODManager.h"
|
||||
#include "TimeWarper.h"
|
||||
#include "../widgets/HelpSystem.h"
|
||||
#include "../widgets/LinkingHtmlWindow.h"
|
||||
#include "../widgets/NumericTextCtrl.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
|
@ -94,7 +94,6 @@
|
||||
#include "../FileNames.h"
|
||||
#include "../Envelope.h"
|
||||
#include "../EnvelopeEditor.h"
|
||||
#include "../widgets/LinkingHtmlWindow.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
#include "../FFT.h"
|
||||
#include "../Prefs.h"
|
||||
|
@ -90,7 +90,6 @@
|
||||
#include "../Tags.h"
|
||||
#include "../Track.h"
|
||||
#include "../widgets/HelpSystem.h"
|
||||
#include "../widgets/LinkingHtmlWindow.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/ProgressDialog.h"
|
||||
|
||||
|
@ -90,6 +90,7 @@ class ODFLACFile final : public FLAC::Decoder::File
|
||||
void error_callback(FLAC__StreamDecoderErrorStatus status) override;
|
||||
};
|
||||
|
||||
#include "../blockfile/ODDecodeBlockFile.h" // to inherit
|
||||
|
||||
///class to decode a particular file (one per file). Saves info such as filename and length (after the header is read.)
|
||||
class ODFlacDecoder final : public ODFileDecoder
|
||||
|
@ -291,34 +291,3 @@ int ODDecodeTask::GetNumFileDecoders()
|
||||
{
|
||||
return mDecoders.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
///This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows
|
||||
ODFileDecoder::ODFileDecoder(const wxString & fName)
|
||||
: mFName{ fName }
|
||||
{
|
||||
mInited = false;
|
||||
}
|
||||
|
||||
ODFileDecoder::~ODFileDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
bool ODFileDecoder::IsInitialized()
|
||||
{
|
||||
bool ret;
|
||||
mInitedLock.Lock();
|
||||
ret = mInited;
|
||||
mInitedLock.Unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
///Derived classes should call this after they have parsed the header.
|
||||
void ODFileDecoder::MarkInitialized()
|
||||
{
|
||||
mInitedLock.Lock();
|
||||
mInited=true;
|
||||
mInitedLock.Unlock();
|
||||
}
|
||||
|
||||
|
@ -95,48 +95,6 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
///class to decode a particular file (one per file). Saves info such as filename and length (after the header is read.)
|
||||
class ODFileDecoder /* not final */
|
||||
{
|
||||
public:
|
||||
///This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows
|
||||
ODFileDecoder(const wxString& fName);
|
||||
virtual ~ODFileDecoder();
|
||||
|
||||
///Read header. Subclasses must override. Probably should save the info somewhere.
|
||||
///Ideally called once per decoding of a file. This complicates the task because
|
||||
virtual bool ReadHeader()=0;
|
||||
virtual bool Init(){return ReadHeader();}
|
||||
|
||||
virtual bool SeekingAllowed(){return true;}
|
||||
|
||||
///Decodes the samples for this blockfile from the real file into a float buffer.
|
||||
///This is file specific, so subclasses must implement this only.
|
||||
///the buffer should be created by the ODFileDecoder implementing this method.
|
||||
///It should set the format parameter so that the client code can deal with it.
|
||||
///This class should call ReadHeader() first, so it knows the length, and can prepare
|
||||
///the file object if it needs to.
|
||||
///returns negative value for failure, 0 or positive value for success.
|
||||
virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) = 0;
|
||||
|
||||
const wxString &GetFileName(){return mFName;}
|
||||
|
||||
bool IsInitialized();
|
||||
|
||||
protected:
|
||||
///Derived classes should call this after they have parsed the header.
|
||||
void MarkInitialized();
|
||||
|
||||
bool mInited;
|
||||
ODLock mInitedLock;
|
||||
|
||||
const wxString mFName;
|
||||
|
||||
unsigned int mSampleRate;
|
||||
unsigned int mNumSamples;//this may depend on the channel - so TODO: we should probably let the decoder create/modify the track info directly.
|
||||
unsigned int mNumChannels;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -27,7 +27,6 @@ MP3 and FFmpeg encoding libraries.
|
||||
|
||||
#include "../FFmpeg.h"
|
||||
#include "../export/ExportMP3.h"
|
||||
#include "../widgets/LinkingHtmlWindow.h"
|
||||
#include "../widgets/HelpSystem.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
|
||||
|
@ -69,7 +69,6 @@
|
||||
#include "../ProjectWindow.h"
|
||||
#include "../Track.h"
|
||||
#include "../widgets/AButton.h"
|
||||
#include "../widgets/LinkingHtmlWindow.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
#include "../FileNames.h"
|
||||
|
||||
|
@ -12,7 +12,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "LabelDefaultClickHandle.h"
|
||||
|
||||
#include "LabelTrackView.h"
|
||||
#include "../../ui/TrackView.h"
|
||||
#include "../../../HitTestResult.h"
|
||||
#include "../../../LabelTrack.h"
|
||||
#include "../../../RefreshCode.h"
|
||||
|
@ -178,3 +178,15 @@ template<> template<> auto DoGetLabelTrackControls::Implementation() -> Function
|
||||
};
|
||||
}
|
||||
static DoGetLabelTrackControls registerDoGetLabelTrackControls;
|
||||
|
||||
using GetDefaultLabelTrackHeight = GetDefaultTrackHeight::Override< LabelTrack >;
|
||||
template<> template<>
|
||||
auto GetDefaultLabelTrackHeight::Implementation() -> Function {
|
||||
return [](LabelTrack &) {
|
||||
// Label tracks are narrow
|
||||
// Default is to allow two rows so that NEW users get the
|
||||
// idea that labels can 'stack' when they would overlap.
|
||||
return 73;
|
||||
};
|
||||
}
|
||||
static GetDefaultLabelTrackHeight registerGetDefaultLabelTrackHeight;
|
||||
|
@ -13,11 +13,9 @@ Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
#include "../../../Experimental.h"
|
||||
|
||||
#include "LabelTrackControls.h"
|
||||
#include "LabelTrackVRulerControls.h"
|
||||
#include "LabelGlyphHandle.h"
|
||||
#include "LabelTextHandle.h"
|
||||
#include "LabelTrackVRulerControls.h"
|
||||
|
||||
#include "../../../LabelTrack.h"
|
||||
|
||||
@ -49,11 +47,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
LabelTrackView::LabelTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
{
|
||||
// Label tracks are narrow
|
||||
// Default is to allow two rows so that NEW users get the
|
||||
// idea that labels can 'stack' when they would overlap.
|
||||
DoSetHeight(73);
|
||||
|
||||
ResetFont();
|
||||
CreateCustomGlyphs();
|
||||
ResetFlags();
|
||||
|
@ -318,3 +318,14 @@ template<> template<> auto DoGetNoteTrackControls::Implementation() -> Function
|
||||
};
|
||||
}
|
||||
static DoGetNoteTrackControls registerDoGetNoteTrackControls;
|
||||
|
||||
#include "../../../ui/TrackView.h"
|
||||
|
||||
using GetDefaultNoteTrackHeight = GetDefaultTrackHeight::Override< NoteTrack >;
|
||||
template<> template<>
|
||||
auto GetDefaultNoteTrackHeight::Implementation() -> Function {
|
||||
return [](NoteTrack &) {
|
||||
return NoteTrackControls::DefaultNoteTrackHeight();
|
||||
};
|
||||
}
|
||||
static GetDefaultNoteTrackHeight registerGetDefaultNoteTrackHeight;
|
||||
|
@ -14,7 +14,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#ifdef USE_MIDI
|
||||
#include "../../../../Experimental.h"
|
||||
|
||||
#include "NoteTrackControls.h"
|
||||
#include "NoteTrackVRulerControls.h"
|
||||
#include "../../../../NoteTrack.h"
|
||||
|
||||
@ -33,7 +32,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
NoteTrackView::NoteTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
{
|
||||
DoSetHeight( NoteTrackControls::DefaultNoteTrackHeight() );
|
||||
}
|
||||
|
||||
NoteTrackView::~NoteTrackView()
|
||||
|
@ -67,6 +67,11 @@ void SpectrumView::DoSetMinimized( bool minimized )
|
||||
TrackView::DoSetMinimized( minimized );
|
||||
}
|
||||
|
||||
WaveTrackViewConstants::Display SpectrumView::SubViewType() const
|
||||
{
|
||||
return WaveTrackViewConstants::Spectrum;
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> SpectrumView::DoGetVRulerControls()
|
||||
{
|
||||
return std::make_shared<SpectrumVRulerControls>( shared_from_this() );
|
||||
@ -635,3 +640,9 @@ void SpectrumView::Draw(
|
||||
}
|
||||
CommonTrackView::Draw( context, rect, iPass );
|
||||
}
|
||||
|
||||
static const WaveTrackSubViews::RegisteredFactory key{
|
||||
[]( WaveTrackView &view ){
|
||||
return std::make_shared< SpectrumView >( view.FindTrack() );
|
||||
}
|
||||
};
|
||||
|
@ -11,19 +11,21 @@ Paul Licameli split from WaveTrackView.h
|
||||
#ifndef __AUDACITY_SPECTRUM_VIEW__
|
||||
#define __AUDACITY_SPECTRUM_VIEW__
|
||||
|
||||
#include "../../../ui/CommonTrackView.h" // to inherit
|
||||
#include "WaveTrackView.h" // to inherit
|
||||
|
||||
class WaveTrack;
|
||||
|
||||
class SpectrumView final : public CommonTrackView
|
||||
class SpectrumView final : public WaveTrackSubView
|
||||
{
|
||||
SpectrumView( const SpectrumView& ) = delete;
|
||||
SpectrumView &operator=( const SpectrumView& ) = delete;
|
||||
|
||||
public:
|
||||
using CommonTrackView::CommonTrackView;
|
||||
using WaveTrackSubView::WaveTrackSubView;
|
||||
~SpectrumView() override;
|
||||
|
||||
virtual WaveTrackViewConstants::Display SubViewType() const override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
||||
|
||||
|
@ -1293,3 +1293,12 @@ template<> template<> auto DoGetWaveTrackControls::Implementation() -> Function
|
||||
};
|
||||
}
|
||||
static DoGetWaveTrackControls registerDoGetWaveTrackControls;
|
||||
|
||||
using GetDefaultWaveTrackHeight = GetDefaultTrackHeight::Override< WaveTrack >;
|
||||
template<> template<>
|
||||
auto GetDefaultWaveTrackHeight::Implementation() -> Function {
|
||||
return [](WaveTrack &) {
|
||||
return WaveTrackControls::DefaultWaveTrackHeight();
|
||||
};
|
||||
}
|
||||
static GetDefaultWaveTrackHeight registerGetDefaultWaveTrackHeight;
|
||||
|
@ -17,12 +17,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../../WaveClip.h"
|
||||
#include "../../../../WaveTrack.h"
|
||||
|
||||
#include "WaveTrackControls.h"
|
||||
#include "WaveTrackVRulerControls.h"
|
||||
|
||||
#include "SpectrumView.h"
|
||||
#include "WaveformView.h"
|
||||
|
||||
#include "../../../../TrackArtist.h"
|
||||
#include "../../../../TrackPanelDrawingContext.h"
|
||||
#include "../../../../TrackPanelMouseEvent.h"
|
||||
@ -33,10 +27,8 @@ Paul Licameli split from TrackPanel.cpp
|
||||
|
||||
WaveTrackView::WaveTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
, mWaveformView{ std::make_shared< WaveformView >( pTrack ) }
|
||||
, mSpectrumView{ std::make_shared< SpectrumView >( pTrack ) }
|
||||
{
|
||||
DoSetHeight( WaveTrackControls::DefaultWaveTrackHeight() );
|
||||
WaveTrackSubViews::BuildAll();
|
||||
}
|
||||
|
||||
WaveTrackView::~WaveTrackView()
|
||||
@ -86,12 +78,18 @@ WaveTrackView::DoDetailedHitTest
|
||||
auto WaveTrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||
{
|
||||
auto wt = static_cast<WaveTrack*>( FindTrack().get() );
|
||||
auto display = wt->GetDisplay();
|
||||
std::shared_ptr<TrackView> pSubView;
|
||||
WaveTrackSubViews::ForEach( [&,display]( WaveTrackSubView &subView ){
|
||||
if ( subView.SubViewType() == display )
|
||||
pSubView = subView.shared_from_this();
|
||||
} );
|
||||
if ( !pSubView )
|
||||
return {};
|
||||
return {
|
||||
{
|
||||
rect.GetTop(),
|
||||
wt->GetDisplay() == WaveTrackViewConstants::Waveform
|
||||
? mWaveformView
|
||||
: mSpectrumView
|
||||
pSubView
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -99,11 +97,10 @@ auto WaveTrackView::GetSubViews( const wxRect &rect ) -> Refinement
|
||||
void WaveTrackView::DoSetMinimized( bool minimized )
|
||||
{
|
||||
// May come here. Invoke also on sub-views.
|
||||
if ( mWaveformView )
|
||||
mWaveformView->DoSetMinimized( minimized );
|
||||
if ( mSpectrumView )
|
||||
mSpectrumView->DoSetMinimized( minimized );
|
||||
TrackView::DoSetMinimized( minimized );
|
||||
WaveTrackSubViews::ForEach( [minimized](WaveTrackSubView &subView){
|
||||
subView.DoSetMinimized( minimized );
|
||||
} );
|
||||
}
|
||||
|
||||
using DoGetWaveTrackView = DoGetView::Override< WaveTrack >;
|
||||
@ -309,10 +306,9 @@ ClipParameters::ClipParameters
|
||||
void WaveTrackView::Reparent( const std::shared_ptr<Track> &parent )
|
||||
{
|
||||
CommonTrackView::Reparent( parent );
|
||||
if ( mWaveformView )
|
||||
mWaveformView->Reparent( parent );
|
||||
if ( mSpectrumView )
|
||||
mSpectrumView->Reparent( parent );
|
||||
WaveTrackSubViews::ForEach( [&parent](WaveTrackSubView &subView){
|
||||
subView.Reparent( parent );
|
||||
} );
|
||||
}
|
||||
|
||||
void WaveTrackView::Draw(
|
||||
|
@ -12,10 +12,26 @@ Paul Licameli split from class WaveTrack
|
||||
#define __AUDACITY_WAVE_TRACK_VIEW__
|
||||
|
||||
#include "../../../ui/CommonTrackView.h"
|
||||
#include "../../../../ClientData.h"
|
||||
namespace WaveTrackViewConstants{ enum Display : int; }
|
||||
|
||||
class WaveTrack;
|
||||
class WaveTrackSubView : public CommonTrackView
|
||||
{
|
||||
public:
|
||||
using CommonTrackView::CommonTrackView;
|
||||
|
||||
virtual WaveTrackViewConstants::Display SubViewType() const = 0;
|
||||
};
|
||||
|
||||
class WaveTrackView final : public CommonTrackView
|
||||
class WaveTrackView;
|
||||
using WaveTrackSubViews = ClientData::Site<
|
||||
WaveTrackView, WaveTrackSubView, ClientData::SkipCopying, std::shared_ptr
|
||||
>;
|
||||
|
||||
class WaveTrackView final
|
||||
: public CommonTrackView
|
||||
, public WaveTrackSubViews
|
||||
{
|
||||
WaveTrackView( const WaveTrackView& ) = delete;
|
||||
WaveTrackView &operator=( const WaveTrackView& ) = delete;
|
||||
@ -27,10 +43,18 @@ public:
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
||||
|
||||
// CommonTrackView implementation
|
||||
void Reparent( const std::shared_ptr<Track> &parent ) override;
|
||||
|
||||
static std::pair<
|
||||
bool, // if true, hit-testing is finished
|
||||
std::vector<UIHandlePtr>
|
||||
> DoDetailedHitTest(
|
||||
const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool,
|
||||
const std::shared_ptr<WaveTrack> &wt,
|
||||
CommonTrackView &view);
|
||||
|
||||
private:
|
||||
// TrackPanelDrawable implementation
|
||||
void Draw(
|
||||
@ -41,25 +65,12 @@ private:
|
||||
(const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool)
|
||||
override;
|
||||
static std::pair<
|
||||
bool, // if true, hit-testing is finished
|
||||
std::vector<UIHandlePtr>
|
||||
> DoDetailedHitTest(
|
||||
const TrackPanelMouseState &state,
|
||||
const AudacityProject *pProject, int currentTool, bool bMultiTool,
|
||||
const std::shared_ptr<WaveTrack> &wt,
|
||||
CommonTrackView &view);
|
||||
|
||||
// TrackView implementation
|
||||
Refinement GetSubViews( const wxRect &rect ) override;
|
||||
|
||||
protected:
|
||||
void DoSetMinimized( bool minimized ) override;
|
||||
|
||||
std::shared_ptr< CommonTrackView > mWaveformView, mSpectrumView;
|
||||
|
||||
friend class SpectrumView;
|
||||
friend class WaveformView;
|
||||
};
|
||||
|
||||
// Helper for drawing routines
|
||||
|
@ -125,6 +125,11 @@ void WaveformView::DoSetMinimized( bool minimized )
|
||||
TrackView::DoSetMinimized( minimized );
|
||||
}
|
||||
|
||||
WaveTrackViewConstants::Display WaveformView::SubViewType() const
|
||||
{
|
||||
return WaveTrackViewConstants::Waveform;
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> WaveformView::DoGetVRulerControls()
|
||||
{
|
||||
return std::make_shared<WaveformVRulerControls>( shared_from_this() );
|
||||
@ -1074,3 +1079,9 @@ void WaveformView::Draw(
|
||||
}
|
||||
CommonTrackView::Draw( context, rect, iPass );
|
||||
}
|
||||
|
||||
static const WaveTrackSubViews::RegisteredFactory key{
|
||||
[]( WaveTrackView &view ){
|
||||
return std::make_shared< WaveformView >( view.FindTrack() );
|
||||
}
|
||||
};
|
||||
|
@ -11,22 +11,24 @@ Paul Licameli split from WaveTrackView.h
|
||||
#ifndef __AUDACITY_WAVEFORM_VIEW__
|
||||
#define __AUDACITY_WAVEFORM_VIEW__
|
||||
|
||||
#include "../../../ui/CommonTrackView.h" // to inherit
|
||||
#include "WaveTrackView.h" // to inherit
|
||||
|
||||
class WaveTrack;
|
||||
class CutlineHandle;
|
||||
class SampleHandle;
|
||||
class EnvelopeHandle;
|
||||
|
||||
class WaveformView final : public CommonTrackView
|
||||
class WaveformView final : public WaveTrackSubView
|
||||
{
|
||||
WaveformView( const WaveformView& ) = delete;
|
||||
WaveformView &operator=( const WaveformView& ) = delete;
|
||||
|
||||
public:
|
||||
using CommonTrackView::CommonTrackView;
|
||||
using WaveTrackSubView::WaveTrackSubView;
|
||||
~WaveformView() override;
|
||||
|
||||
virtual WaveTrackViewConstants::Display SubViewType() const override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
||||
|
||||
|
@ -178,3 +178,14 @@ template<> template<> auto DoGetTimeTrackControls::Implementation() -> Function
|
||||
};
|
||||
}
|
||||
static DoGetTimeTrackControls registerDoGetTimeTrackControls;
|
||||
|
||||
#include "../../ui/TrackView.h"
|
||||
|
||||
using GetDefaultTimeTrackHeight = GetDefaultTrackHeight::Override< TimeTrack >;
|
||||
template<> template<>
|
||||
auto GetDefaultTimeTrackHeight::Implementation() -> Function {
|
||||
return [](TimeTrack &) {
|
||||
return 100;
|
||||
};
|
||||
}
|
||||
static GetDefaultTimeTrackHeight registerGetDefaultTimeTrackHeight;
|
||||
|
@ -34,7 +34,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
TimeTrackView::TimeTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack }
|
||||
{
|
||||
DoSetHeight( 100 );
|
||||
}
|
||||
|
||||
TimeTrackView::~TimeTrackView()
|
||||
|
@ -11,14 +11,17 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "TrackView.h"
|
||||
#include "../../Track.h"
|
||||
|
||||
#include "TrackControls.h"
|
||||
#include "../../TrackPanelResizerCell.h"
|
||||
|
||||
#include "../../ClientData.h"
|
||||
#include "../../Project.h"
|
||||
#include "../../xml/XMLTagHandler.h"
|
||||
#include "../../xml/XMLWriter.h"
|
||||
|
||||
TrackView::TrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackCell{ pTrack }
|
||||
{
|
||||
DoSetHeight( GetDefaultTrackHeight::Call( *pTrack ) );
|
||||
}
|
||||
|
||||
TrackView::~TrackView()
|
||||
{
|
||||
}
|
||||
@ -129,20 +132,6 @@ std::shared_ptr<const TrackVRulerControls> TrackView::GetVRulerControls() const
|
||||
return const_cast< TrackView* >( this )->GetVRulerControls();
|
||||
}
|
||||
|
||||
#include "../../TrackPanelResizeHandle.h"
|
||||
std::shared_ptr<TrackPanelCell> TrackView::GetResizer()
|
||||
{
|
||||
if (!mpResizer)
|
||||
// create on demand
|
||||
mpResizer = std::make_shared<TrackPanelResizerCell>( shared_from_this() );
|
||||
return mpResizer;
|
||||
}
|
||||
|
||||
std::shared_ptr<const TrackPanelCell> TrackView::GetResizer() const
|
||||
{
|
||||
return const_cast<TrackView*>(this)->GetResizer();
|
||||
}
|
||||
|
||||
void TrackView::DoSetY(int y)
|
||||
{
|
||||
mY = y;
|
||||
@ -223,3 +212,8 @@ template<> auto DoGetView::Implementation() -> Function {
|
||||
return nullptr;
|
||||
}
|
||||
static DoGetView registerDoGetView;
|
||||
|
||||
template<> auto GetDefaultTrackHeight::Implementation() -> Function {
|
||||
return nullptr;
|
||||
}
|
||||
static GetDefaultTrackHeight registerGetDefaultTrackHeight;
|
||||
|
@ -29,8 +29,7 @@ public:
|
||||
enum : unsigned { DefaultHeight = 150 };
|
||||
|
||||
explicit
|
||||
TrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackCell{ pTrack } {}
|
||||
TrackView( const std::shared_ptr<Track> &pTrack );
|
||||
virtual ~TrackView() = 0;
|
||||
|
||||
// some static conveniences, useful for summation over track iterator
|
||||
@ -64,11 +63,6 @@ public:
|
||||
std::shared_ptr<const TrackVRulerControls> GetVRulerControls() const;
|
||||
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements the
|
||||
// click and drag to resize
|
||||
std::shared_ptr<TrackPanelCell> GetResizer();
|
||||
std::shared_ptr<const TrackPanelCell> GetResizer() const;
|
||||
|
||||
void WriteXMLAttributes( XMLWriter & ) const override;
|
||||
bool HandleXMLAttribute( const wxChar *attr, const wxChar *value ) override;
|
||||
|
||||
@ -86,14 +80,13 @@ protected:
|
||||
// No need yet to make this virtual
|
||||
void DoSetY(int y);
|
||||
|
||||
virtual void DoSetHeight(int h);
|
||||
void DoSetHeight(int h);
|
||||
|
||||
// Private factory to make appropriate object; class TrackView handles
|
||||
// memory management thereafter
|
||||
virtual std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() = 0;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> mpVRulerControls;
|
||||
std::shared_ptr<TrackPanelResizerCell> mpResizer;
|
||||
|
||||
private:
|
||||
bool mMinimized{ false };
|
||||
@ -112,4 +105,13 @@ AttachedVirtualFunction<
|
||||
Track
|
||||
>;
|
||||
|
||||
struct GetDefaultTrackHeightTag;
|
||||
|
||||
using GetDefaultTrackHeight =
|
||||
AttachedVirtualFunction<
|
||||
GetDefaultTrackHeightTag,
|
||||
int,
|
||||
Track
|
||||
>;
|
||||
|
||||
#endif
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <wx/settings.h>
|
||||
#include <wx/statusbr.h>
|
||||
|
||||
#include "LinkingHtmlWindow.h"
|
||||
#include "../AllThemeResources.h"
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../HelpText.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user