mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 23:59:41 +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 "ModTrackPanelCallback.h"
|
||||
#include "../../src/Audacity.h"
|
||||
#include "../../src/ShuttleGui.h"
|
||||
#include "../../src/Project.h"
|
||||
#include "../../src/LoadModules.h"
|
||||
#include "Audacity.h"
|
||||
#include "ShuttleGui.h"
|
||||
#include "Project.h"
|
||||
#include "LoadModules.h"
|
||||
#include "Registrar.h"
|
||||
|
||||
/*
|
||||
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
|
||||
{
|
||||
public:
|
||||
void OnFuncShow();
|
||||
void OnFuncHide();
|
||||
void OnFuncShowAudioExplorer();
|
||||
void OnFuncShowAnotherExtension();
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
@ -73,6 +88,9 @@ public:
|
||||
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,
|
||||
ModTrackPanelCommandFunction pFunction)
|
||||
{
|
||||
@ -80,7 +98,7 @@ ModTrackPanelCommandFunctor::ModTrackPanelCommandFunctor(ModTrackPanelCallback *
|
||||
mpFunction = pFunction;
|
||||
}
|
||||
|
||||
// The dispatching function.
|
||||
// The dispatching function in the command functor.
|
||||
void ModTrackPanelCommandFunctor::operator()(int index )
|
||||
{
|
||||
(mpData->*(mpFunction))();
|
||||
@ -90,18 +108,27 @@ void ModTrackPanelCommandFunctor::operator()(int index )
|
||||
(ModTrackPanelCommandFunction)(&ModTrackPanelCallback::X))
|
||||
|
||||
|
||||
void ModTrackPanelCallback::OnFuncShow()
|
||||
void ModTrackPanelCallback::OnFuncShowAudioExplorer()
|
||||
{
|
||||
int k=3;
|
||||
}
|
||||
|
||||
void ModTrackPanelCallback::OnFuncHide()
|
||||
void ModTrackPanelCallback::OnFuncShowAnotherExtension()
|
||||
{
|
||||
int k=4;
|
||||
}
|
||||
|
||||
// Oooh look, we're using a NULL object, and hence a NULL 'this'.
|
||||
// That's OK.
|
||||
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" {
|
||||
// GetVersionString
|
||||
// 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.
|
||||
int MOD_TRACK_PANEL_DLL_API ModuleDispatch(ModuleDispatchTypes type)
|
||||
MOD_TRACK_PANEL_DLL_API int ModuleDispatch(ModuleDispatchTypes type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case AppInitialized:
|
||||
ModTrackPanel::Registrar::Start();
|
||||
break;
|
||||
case AppQuiting:
|
||||
ModTrackPanel::Registrar::Finish();
|
||||
break;
|
||||
case ProjectInitialized:
|
||||
case MenusRebuilt:
|
||||
@ -139,9 +168,9 @@ int MOD_TRACK_PANEL_DLL_API ModuleDispatch(ModuleDispatchTypes type)
|
||||
c->AddSeparator();
|
||||
// We add two new commands into the Analyze menu.
|
||||
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"),
|
||||
ModTrackPanelFN( OnFuncHide ) );
|
||||
ModTrackPanelFN( OnFuncShowAnotherExtension ) );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -21,3 +21,54 @@ plugging in of new resources.
|
||||
#include <wx/wx.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__
|
||||
#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 {
|
||||
public:
|
||||
static void Start();
|
||||
static void Finish();
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern int RegistrarDispatch( t_RegistrarDispatchType Type );
|
||||
|
||||
};//End of Namespace.
|
||||
#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
|
||||
Name="VCCLCompilerTool"
|
||||
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"
|
||||
StringPooling="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -119,7 +119,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
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"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
@ -195,6 +195,14 @@
|
||||
RelativePath=".\Registrar.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SkewedRuler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SkewedRuler.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
Loading…
x
Reference in New Issue
Block a user