mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +02:00
Added SkewedRuler and started on registration system.
This commit is contained in:
parent
9321b1634e
commit
b45d9ae327
@ -27,10 +27,11 @@ click from the menu into the actual function to be called.
|
|||||||
|
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
#include "ModTrackPanelCallback.h"
|
#include "ModTrackPanelCallback.h"
|
||||||
#include "../../src/Audacity.h"
|
#include "Audacity.h"
|
||||||
#include "../../src/ShuttleGui.h"
|
#include "ShuttleGui.h"
|
||||||
#include "../../src/Project.h"
|
#include "Project.h"
|
||||||
#include "../../src/LoadModules.h"
|
#include "LoadModules.h"
|
||||||
|
#include "Registrar.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
There are several functions that can be used in a GUI module.
|
There are several functions that can be used in a GUI module.
|
||||||
@ -53,15 +54,29 @@ and replace the main project window with our own wxFrame.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// The machinery here is somewhat overkill for what we need.
|
||||||
|
// It allows us to add lots of menu and other actions into Audacity.
|
||||||
|
// We need to jump through these hoops even if only adding
|
||||||
|
// two menu items into Audacity.
|
||||||
|
|
||||||
|
// The OnFunc functrions are functions which can be invoked
|
||||||
|
// by Audacity. Mostly they are for menu items. They could
|
||||||
|
// be for buttons. They could be for commands invokable by
|
||||||
|
// script (but no examples of that yet).
|
||||||
class ModTrackPanelCallback
|
class ModTrackPanelCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void OnFuncShow();
|
void OnFuncShowAudioExplorer();
|
||||||
void OnFuncHide();
|
void OnFuncShowAnotherExtension();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (ModTrackPanelCallback::*ModTrackPanelCommandFunction)();
|
typedef void (ModTrackPanelCallback::*ModTrackPanelCommandFunction)();
|
||||||
|
|
||||||
|
// We have an instance of this CommandFunctor for each
|
||||||
|
// instance of a command we attach to Audacity.
|
||||||
|
// Although the commands have void argument,
|
||||||
|
// they do receive an instance of ModTrackPanelCallback as a 'this',
|
||||||
|
// so if we want to, we can pass data to each function instance.
|
||||||
class ModTrackPanelCommandFunctor:public CommandFunctor
|
class ModTrackPanelCommandFunctor:public CommandFunctor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -73,6 +88,9 @@ public:
|
|||||||
ModTrackPanelCommandFunction mpFunction;
|
ModTrackPanelCommandFunction mpFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If pData is NULL we will later be passing a NULL 'this' to pFunction.
|
||||||
|
// This may be quite OK if the class function is written as if it
|
||||||
|
// could be static.
|
||||||
ModTrackPanelCommandFunctor::ModTrackPanelCommandFunctor(ModTrackPanelCallback *pData,
|
ModTrackPanelCommandFunctor::ModTrackPanelCommandFunctor(ModTrackPanelCallback *pData,
|
||||||
ModTrackPanelCommandFunction pFunction)
|
ModTrackPanelCommandFunction pFunction)
|
||||||
{
|
{
|
||||||
@ -80,7 +98,7 @@ ModTrackPanelCommandFunctor::ModTrackPanelCommandFunctor(ModTrackPanelCallback *
|
|||||||
mpFunction = pFunction;
|
mpFunction = pFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The dispatching function.
|
// The dispatching function in the command functor.
|
||||||
void ModTrackPanelCommandFunctor::operator()(int index )
|
void ModTrackPanelCommandFunctor::operator()(int index )
|
||||||
{
|
{
|
||||||
(mpData->*(mpFunction))();
|
(mpData->*(mpFunction))();
|
||||||
@ -90,18 +108,27 @@ void ModTrackPanelCommandFunctor::operator()(int index )
|
|||||||
(ModTrackPanelCommandFunction)(&ModTrackPanelCallback::X))
|
(ModTrackPanelCommandFunction)(&ModTrackPanelCallback::X))
|
||||||
|
|
||||||
|
|
||||||
void ModTrackPanelCallback::OnFuncShow()
|
void ModTrackPanelCallback::OnFuncShowAudioExplorer()
|
||||||
{
|
{
|
||||||
int k=3;
|
int k=3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModTrackPanelCallback::OnFuncHide()
|
void ModTrackPanelCallback::OnFuncShowAnotherExtension()
|
||||||
{
|
{
|
||||||
int k=4;
|
int k=4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Oooh look, we're using a NULL object, and hence a NULL 'this'.
|
||||||
|
// That's OK.
|
||||||
ModTrackPanelCallback * pModTrackPanelCallback=NULL;
|
ModTrackPanelCallback * pModTrackPanelCallback=NULL;
|
||||||
|
|
||||||
|
//This is the DLL related machinery that actually gets called by Audacity
|
||||||
|
//as prt of loading and using a DLL.
|
||||||
|
//It is MUCH simpler to use C for this interface because then the
|
||||||
|
//function names are not 'mangled'.
|
||||||
|
//The function names are important, because they are what Audacity looks
|
||||||
|
//for. Change the name and they won't be found.
|
||||||
|
//Change the signature, e.g. return type, and you probably have a crash.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// GetVersionString
|
// GetVersionString
|
||||||
// REQUIRED for the module to be accepted by Audacity.
|
// REQUIRED for the module to be accepted by Audacity.
|
||||||
@ -116,13 +143,15 @@ MOD_TRACK_PANEL_DLL_API wchar_t * GetVersionString()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This is the function that connects us to Audacity.
|
// This is the function that connects us to Audacity.
|
||||||
int MOD_TRACK_PANEL_DLL_API ModuleDispatch(ModuleDispatchTypes type)
|
MOD_TRACK_PANEL_DLL_API int ModuleDispatch(ModuleDispatchTypes type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case AppInitialized:
|
case AppInitialized:
|
||||||
|
ModTrackPanel::Registrar::Start();
|
||||||
break;
|
break;
|
||||||
case AppQuiting:
|
case AppQuiting:
|
||||||
|
ModTrackPanel::Registrar::Finish();
|
||||||
break;
|
break;
|
||||||
case ProjectInitialized:
|
case ProjectInitialized:
|
||||||
case MenusRebuilt:
|
case MenusRebuilt:
|
||||||
@ -139,9 +168,9 @@ int MOD_TRACK_PANEL_DLL_API ModuleDispatch(ModuleDispatchTypes type)
|
|||||||
c->AddSeparator();
|
c->AddSeparator();
|
||||||
// We add two new commands into the Analyze menu.
|
// We add two new commands into the Analyze menu.
|
||||||
c->AddItem( _T("Audio Explorer..."), _T("Experimental GUI for audio analysis"),
|
c->AddItem( _T("Audio Explorer..."), _T("Experimental GUI for audio analysis"),
|
||||||
ModTrackPanelFN( OnFuncShow ) );
|
ModTrackPanelFN( OnFuncShowAudioExplorer ) );
|
||||||
c->AddItem( _T("Another Extension..."), _T("Experimental GUI for other things"),
|
c->AddItem( _T("Another Extension..."), _T("Experimental GUI for other things"),
|
||||||
ModTrackPanelFN( OnFuncHide ) );
|
ModTrackPanelFN( OnFuncShowAnotherExtension ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -21,3 +21,54 @@ plugging in of new resources.
|
|||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
#include "Registrar.h"
|
#include "Registrar.h"
|
||||||
|
|
||||||
|
START_NAMESPACE
|
||||||
|
|
||||||
|
Registrar * pRegistrar = NULL;
|
||||||
|
|
||||||
|
// By defining the external function and including it here, we save ourselves maintaing two lists.
|
||||||
|
// Also we save ourselves recompiling Registrar each time the classes that regiser change.
|
||||||
|
// Part of the idea is that the Registrar knows very little about the classes that
|
||||||
|
// register with it.
|
||||||
|
#define DISPATCH( Name ) extern int Name##Dispatch( Registrar & R, t_RegistrarDispatchType Type );\
|
||||||
|
Name##Dispatch( *pRegistrar, Type )
|
||||||
|
|
||||||
|
// Not a class function, otherwise the functions called
|
||||||
|
// are treated as belonging to the class.
|
||||||
|
int RegistrarDispatch( t_RegistrarDispatchType Type )
|
||||||
|
{
|
||||||
|
wxASSERT( pRegistrar != NULL );
|
||||||
|
|
||||||
|
DISPATCH( SkewedRuler );
|
||||||
|
DISPATCH( MidiArtist );
|
||||||
|
DISPATCH( WaveArtist );
|
||||||
|
DISPATCH( EnvelopeArtist );
|
||||||
|
DISPATCH( LabelArtist );
|
||||||
|
DISPATCH( DragGridSizer );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start()
|
||||||
|
// Static function. Allocates Registrar.
|
||||||
|
void Registrar::Start()
|
||||||
|
{
|
||||||
|
wxASSERT( pRegistrar ==NULL );
|
||||||
|
pRegistrar = new Registrar();
|
||||||
|
|
||||||
|
RegistrarDispatch( RegArtist );
|
||||||
|
RegistrarDispatch( RegDataType );
|
||||||
|
RegistrarDispatch( RegCommand );
|
||||||
|
RegistrarDispatch( RegMenuItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finish()
|
||||||
|
// Static function. DeAllocates Registrar.
|
||||||
|
void Registrar::Finish()
|
||||||
|
{
|
||||||
|
wxASSERT( pRegistrar !=NULL );
|
||||||
|
delete pRegistrar;
|
||||||
|
pRegistrar = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};//End of Namespace.
|
||||||
|
@ -13,8 +13,32 @@
|
|||||||
#ifndef __AUDACITY_REGISTRAR__
|
#ifndef __AUDACITY_REGISTRAR__
|
||||||
#define __AUDACITY_REGISTRAR__
|
#define __AUDACITY_REGISTRAR__
|
||||||
|
|
||||||
|
// MSVC auto-indents, but I don't want that, for the namespace.
|
||||||
|
// so using a macro for that works around ir
|
||||||
|
// AND allows me to change the namespace name easily.
|
||||||
|
|
||||||
|
#define START_NAMESPACE namespace ModTrackPanel {
|
||||||
|
|
||||||
|
START_NAMESPACE
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
RegArtist,
|
||||||
|
RegDataType,
|
||||||
|
RegCommand,
|
||||||
|
RegMenuItem,
|
||||||
|
RegLast
|
||||||
|
} t_RegistrarDispatchType;
|
||||||
|
|
||||||
class Registrar {
|
class Registrar {
|
||||||
public:
|
public:
|
||||||
|
static void Start();
|
||||||
|
static void Finish();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern int RegistrarDispatch( t_RegistrarDispatchType Type );
|
||||||
|
|
||||||
|
};//End of Namespace.
|
||||||
#endif
|
#endif
|
||||||
|
140
lib-src/mod-track-panel/SkewedRuler.cpp
Normal file
140
lib-src/mod-track-panel/SkewedRuler.cpp
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
Registrar.cpp
|
||||||
|
|
||||||
|
James Crook
|
||||||
|
|
||||||
|
Audacity is free software.
|
||||||
|
This file is licensed under the wxWidgets license, see License.txt
|
||||||
|
|
||||||
|
********************************************************************//**
|
||||||
|
|
||||||
|
\class Registrar
|
||||||
|
\brief Registrar is a class that other classes register resources of
|
||||||
|
various kinds with. It makes a system that is much more amenable to
|
||||||
|
plugging in of new resources.
|
||||||
|
|
||||||
|
*//********************************************************************/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include "SkewedRuler.h"
|
||||||
|
|
||||||
|
START_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
extern int SkewedRulerDispatch( Registrar & R, t_RegistrarDispatchType Type )
|
||||||
|
{
|
||||||
|
switch( Type )
|
||||||
|
{
|
||||||
|
case RegArtist:
|
||||||
|
break;
|
||||||
|
case RegDataType:
|
||||||
|
break;
|
||||||
|
case RegCommand:
|
||||||
|
break;
|
||||||
|
case RegMenuItem:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// For now I've bunged these empty dispatch functions into the same
|
||||||
|
// file as SkewedRuler.
|
||||||
|
// When I am ready to work on them I will create new files for them.
|
||||||
|
int MidiArtistDispatch( Registrar & R, t_RegistrarDispatchType Type )
|
||||||
|
{
|
||||||
|
switch( Type )
|
||||||
|
{
|
||||||
|
case RegArtist:
|
||||||
|
break;
|
||||||
|
case RegDataType:
|
||||||
|
break;
|
||||||
|
case RegCommand:
|
||||||
|
break;
|
||||||
|
case RegMenuItem:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int WaveArtistDispatch( Registrar & R, t_RegistrarDispatchType Type )
|
||||||
|
{
|
||||||
|
switch( Type )
|
||||||
|
{
|
||||||
|
case RegArtist:
|
||||||
|
break;
|
||||||
|
case RegDataType:
|
||||||
|
break;
|
||||||
|
case RegCommand:
|
||||||
|
break;
|
||||||
|
case RegMenuItem:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EnvelopeArtistDispatch( Registrar & R, t_RegistrarDispatchType Type )
|
||||||
|
{
|
||||||
|
switch( Type )
|
||||||
|
{
|
||||||
|
case RegArtist:
|
||||||
|
break;
|
||||||
|
case RegDataType:
|
||||||
|
break;
|
||||||
|
case RegCommand:
|
||||||
|
break;
|
||||||
|
case RegMenuItem:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LabelArtistDispatch( Registrar & R, t_RegistrarDispatchType Type )
|
||||||
|
{
|
||||||
|
switch( Type )
|
||||||
|
{
|
||||||
|
case RegArtist:
|
||||||
|
break;
|
||||||
|
case RegDataType:
|
||||||
|
break;
|
||||||
|
case RegCommand:
|
||||||
|
break;
|
||||||
|
case RegMenuItem:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DragGridSizerDispatch( Registrar & R, t_RegistrarDispatchType Type )
|
||||||
|
{
|
||||||
|
switch( Type )
|
||||||
|
{
|
||||||
|
case RegArtist:
|
||||||
|
break;
|
||||||
|
case RegDataType:
|
||||||
|
break;
|
||||||
|
case RegCommand:
|
||||||
|
break;
|
||||||
|
case RegMenuItem:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};//End of Namespace.
|
25
lib-src/mod-track-panel/SkewedRuler.h
Normal file
25
lib-src/mod-track-panel/SkewedRuler.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
SkewedRuler.h
|
||||||
|
|
||||||
|
James Crook
|
||||||
|
|
||||||
|
Draws a ruler used for aligning two time sequences.
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef __AUDACITY_SKEWED_RULER__
|
||||||
|
#define __AUDACITY_SKEWED_RULER__
|
||||||
|
|
||||||
|
#include "Registrar.h"
|
||||||
|
START_NAMESPACE
|
||||||
|
|
||||||
|
class SkewedRuler {
|
||||||
|
public:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};//End of Namespace.
|
||||||
|
#endif
|
@ -41,7 +41,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories=""$(WXWIN)\lib\vc_dll\mswud";"$(WXWIN)\include";"$(SolutionDir)";..\..\..;..\..\..\..\src\include\win32;..\..\..\..\src\include;..\FileDialog;..\expat;"..\lib-widget-extra";..\libflac\include;..\libid3tag;..\liblrdf;..\libmad;..\libnyquist;..\libogg\include;..\libresample\include;..\libsamplerate\src;..\libscorealign;..\libsndfile;..\libvamp;..\libvorbis\include;"..\portaudio-v19\include";..\portmixer\include;..\portsmf;..\redland\raptor\src;..\slv2;..\sbsms\include;..\soundtouch\include;..\twolame\libtwolame;..\portmidi\pm_common;..\portmidi\pm_win;..\portmidi\porttime;..\ffmpeg\win32;..\ffmpeg"
|
AdditionalIncludeDirectories=""$(WXWIN)\lib\vc_dll\mswud";"$(WXWIN)\include";"$(SolutionDir)";..\..\src;..\..\src\include\win32;..\..\src\include;..\FileDialog;..\expat;"..\lib-widget-extra";..\libflac\include;..\libid3tag;..\liblrdf;..\libmad;..\libnyquist;..\libogg\include;..\libresample\include;..\libsamplerate\src;..\libscorealign;..\libsndfile;..\libvamp;..\libvorbis\include;"..\portaudio-v19\include";..\portmixer\include;..\portsmf;..\redland\raptor\src;..\slv2;..\sbsms\include;..\soundtouch\include;..\twolame\libtwolame;..\portmidi\pm_common;..\portmidi\pm_win;..\portmidi\porttime;..\ffmpeg\win32;..\ffmpeg"
|
||||||
PreprocessorDefinitions="BUILDING_MOD_TRACK_PANEL;WXUSINGDLL;__WXMSW__;__WXDEBUG__;WIN32;_DEBUG;_USRDLL"
|
PreprocessorDefinitions="BUILDING_MOD_TRACK_PANEL;WXUSINGDLL;__WXMSW__;__WXDEBUG__;WIN32;_DEBUG;_USRDLL"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@ -119,7 +119,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
AdditionalIncludeDirectories=""$(WXWIN)\lib\vc_dll\mswu";"$(WXWIN)\include";"$(SolutionDir)";..\..\..;..\..\..\..\src\include\win32;..\..\..\..\src\include;..\FileDialog;..\expat;"..\lib-widget-extra";..\libflac\include;..\libid3tag;..\liblrdf;..\libmad;..\libnyquist;..\libogg\include;..\libresample\include;..\libsamplerate\src;..\libscorealign;..\libsndfile;..\libvamp;..\libvorbis\include;"..\portaudio-v19\include";..\portmixer\include;..\portsmf;..\redland\raptor\src;..\slv2;..\sbsms\include;..\soundtouch\include;..\twolame\libtwolame;..\portmidi\pm_common;..\portmidi\pm_win;..\portmidi\porttime;..\ffmpeg\win32;..\ffmpeg"
|
AdditionalIncludeDirectories=""$(WXWIN)\lib\vc_dll\mswu";"$(WXWIN)\include";"$(SolutionDir)";..\..\src;..\..\src\include\win32;..\..\src\include;..\FileDialog;..\expat;"..\lib-widget-extra";..\libflac\include;..\libid3tag;..\liblrdf;..\libmad;..\libnyquist;..\libogg\include;..\libresample\include;..\libsamplerate\src;..\libscorealign;..\libsndfile;..\libvamp;..\libvorbis\include;"..\portaudio-v19\include";..\portmixer\include;..\portsmf;..\redland\raptor\src;..\slv2;..\sbsms\include;..\soundtouch\include;..\twolame\libtwolame;..\portmidi\pm_common;..\portmidi\pm_win;..\portmidi\porttime;..\ffmpeg\win32;..\ffmpeg"
|
||||||
PreprocessorDefinitions="BUILDING_MOD_TRACK_PANEL;WXUSINGDLL;__WXMSW__;NDEBUG;_WINDOWS;WIN32;_USRDLL"
|
PreprocessorDefinitions="BUILDING_MOD_TRACK_PANEL;WXUSINGDLL;__WXMSW__;NDEBUG;_WINDOWS;WIN32;_USRDLL"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
@ -195,6 +195,14 @@
|
|||||||
RelativePath=".\Registrar.h"
|
RelativePath=".\Registrar.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\SkewedRuler.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\SkewedRuler.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user