mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-15 07:50:22 +02:00
Updated to demo new method of taking over TrackPanel.
This commit is contained in:
parent
ed66bf3fab
commit
6046d33a36
@ -32,6 +32,7 @@ click from the menu into the actual function to be called.
|
|||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
#include "LoadModules.h"
|
#include "LoadModules.h"
|
||||||
#include "Registrar.h"
|
#include "Registrar.h"
|
||||||
|
#include "TrackPanel2.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.
|
||||||
@ -67,7 +68,7 @@ class ModTrackPanelCallback
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void OnFuncShowAudioExplorer();
|
void OnFuncShowAudioExplorer();
|
||||||
void OnFuncShowAnotherExtension();
|
void OnFuncReplaceTrackPanel();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (ModTrackPanelCallback::*ModTrackPanelCommandFunction)();
|
typedef void (ModTrackPanelCallback::*ModTrackPanelCommandFunction)();
|
||||||
@ -114,9 +115,17 @@ void ModTrackPanelCallback::OnFuncShowAudioExplorer()
|
|||||||
Registrar::ShowNewPanel();
|
Registrar::ShowNewPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModTrackPanelCallback::OnFuncShowAnotherExtension()
|
void ModTrackPanelCallback::OnFuncReplaceTrackPanel()
|
||||||
{
|
{
|
||||||
|
// Upgrade the factory. Now all TrackPanels will be created as TrackPanel 2's
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
AudacityProject *p = GetActiveProject();
|
||||||
|
wxASSERT( p!= NULL );
|
||||||
|
// Change it's type (No new storage allocated).
|
||||||
|
TrackPanel2::Upgrade( &p->mTrackPanel );
|
||||||
int k=4;
|
int k=4;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Oooh look, we're using a NULL object, and hence a NULL 'this'.
|
// Oooh look, we're using a NULL object, and hence a NULL 'this'.
|
||||||
@ -150,6 +159,8 @@ MOD_TRACK_PANEL_DLL_API int ModuleDispatch(ModuleDispatchTypes type)
|
|||||||
{
|
{
|
||||||
case AppInitialized:
|
case AppInitialized:
|
||||||
Registrar::Start();
|
Registrar::Start();
|
||||||
|
// Demand that all track panels be created using the TrackPanel2Factory.
|
||||||
|
TrackPanel::FactoryFunction = TrackPanel2Factory;
|
||||||
break;
|
break;
|
||||||
case AppQuiting:
|
case AppQuiting:
|
||||||
Registrar::Finish();
|
Registrar::Finish();
|
||||||
@ -168,10 +179,11 @@ MOD_TRACK_PANEL_DLL_API int ModuleDispatch(ModuleDispatchTypes type)
|
|||||||
c->SetToMenu( pMenu );
|
c->SetToMenu( pMenu );
|
||||||
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("Extra Dialog..."), _T("Experimental Extra Dialog for whatever you want."),
|
||||||
ModTrackPanelFN( OnFuncShowAudioExplorer ) );
|
ModTrackPanelFN( OnFuncShowAudioExplorer ) );
|
||||||
c->AddItem( _T("Another Extension..."), _T("Experimental GUI for other things"),
|
//Second menu tweak no longer needed as we always make TrackPanel2's.
|
||||||
ModTrackPanelFN( OnFuncShowAnotherExtension ) );
|
//c->AddItem( _T("Replace TrackPanel..."), _T("Replace Current TrackPanel with TrackPanel2"),
|
||||||
|
// ModTrackPanelFN( OnFuncReplaceTrackPanel ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -23,28 +23,35 @@
|
|||||||
#include "Registrar.h"
|
#include "Registrar.h"
|
||||||
#include "TrackPanel2.h"
|
#include "TrackPanel2.h"
|
||||||
|
|
||||||
|
TrackPanel * TrackPanel2Factory(wxWindow * parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint & pos,
|
||||||
|
const wxSize & size,
|
||||||
|
TrackList * tracks,
|
||||||
|
ViewInfo * viewInfo,
|
||||||
|
TrackPanelListener * listener,
|
||||||
|
AdornedRulerPanel * ruler)
|
||||||
|
{
|
||||||
|
return new TrackPanel2(
|
||||||
|
parent,
|
||||||
|
id,
|
||||||
|
pos,
|
||||||
|
size,
|
||||||
|
tracks,
|
||||||
|
viewInfo,
|
||||||
|
listener,
|
||||||
|
ruler);
|
||||||
|
}
|
||||||
|
|
||||||
void ShowTrackPanel()
|
void ShowExtraDialog()
|
||||||
{
|
{
|
||||||
int k=42;
|
int k=42;
|
||||||
|
|
||||||
wxDialog Dlg(NULL, wxID_ANY, wxString(wxT("Experimental New TrackPanel")));
|
wxDialog Dlg(NULL, wxID_ANY, wxString(wxT("Experimental Extra Dialog")));
|
||||||
ShuttleGui S(&Dlg, eIsCreating);
|
ShuttleGui S(&Dlg, eIsCreating);
|
||||||
#if 0
|
|
||||||
S.StartHorizontalLay(wxCENTER, false);
|
|
||||||
{
|
|
||||||
S.StartStatic(wxT(""), false);
|
|
||||||
{
|
|
||||||
S.SetBorder(200);
|
|
||||||
S.AddFixedText(wxT("AAA"));
|
|
||||||
}
|
|
||||||
S.EndStatic();
|
|
||||||
}
|
|
||||||
S.EndHorizontalLay();
|
|
||||||
#endif
|
|
||||||
S.StartNotebook();
|
S.StartNotebook();
|
||||||
{
|
{
|
||||||
S.StartNotebookPage( _("Panel") );
|
S.StartNotebookPage( _("Panel 1") );
|
||||||
S.StartVerticalLay(1);
|
S.StartVerticalLay(1);
|
||||||
{
|
{
|
||||||
HtmlWindow *html = new LinkingHtmlWindow(S.GetParent(), -1,
|
HtmlWindow *html = new LinkingHtmlWindow(S.GetParent(), -1,
|
||||||
@ -52,7 +59,7 @@ void ShowTrackPanel()
|
|||||||
wxSize(600, 359),
|
wxSize(600, 359),
|
||||||
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
|
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
|
||||||
html->SetFocus();
|
html->SetFocus();
|
||||||
html->SetPage(wxT("<h1><font color=\"blue\">TrackPanel</font></h1>This will be replaced with the panel"));
|
html->SetPage(wxT("<h1><font color=\"blue\">An Html Window</font></h1>Replace with whatever you like."));
|
||||||
S.Prop(1).AddWindow( html, wxEXPAND );
|
S.Prop(1).AddWindow( html, wxEXPAND );
|
||||||
}
|
}
|
||||||
S.EndVerticalLay();
|
S.EndVerticalLay();
|
||||||
@ -89,7 +96,7 @@ int TrackPanel2Dispatch( Registrar & R, t_RegistrarDispatchType Type )
|
|||||||
switch( Type )
|
switch( Type )
|
||||||
{
|
{
|
||||||
case RegResource:
|
case RegResource:
|
||||||
R.pShowFn = ShowTrackPanel;
|
R.pShowFn = ShowExtraDialog;
|
||||||
break;
|
break;
|
||||||
case RegArtist:
|
case RegArtist:
|
||||||
break;
|
break;
|
||||||
@ -105,3 +112,22 @@ int TrackPanel2Dispatch( Registrar & R, t_RegistrarDispatchType Type )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TrackPanel2::TrackPanel2(
|
||||||
|
wxWindow * parent, wxWindowID id, const wxPoint & pos, const wxSize & size,
|
||||||
|
TrackList * tracks, ViewInfo * viewInfo, TrackPanelListener * listener,
|
||||||
|
AdornedRulerPanel * ruler) :
|
||||||
|
TrackPanel(
|
||||||
|
parent, id, pos, size,
|
||||||
|
tracks, viewInfo, listener, ruler)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Here is a sample function that shows that TrackPanel2 is being invoked.
|
||||||
|
void TrackPanel2::OnPaint(wxPaintEvent & event)
|
||||||
|
{
|
||||||
|
// Hmm... Log debug will only show if you open the log window.
|
||||||
|
// wxLogDebug( wxT("Paint TrackPanel2 requested") );
|
||||||
|
TrackPanel::OnPaint( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -11,10 +11,34 @@
|
|||||||
#ifndef __AUDACITY_TRACK_PANEL2__
|
#ifndef __AUDACITY_TRACK_PANEL2__
|
||||||
#define __AUDACITY_TRACK_PANEL2__
|
#define __AUDACITY_TRACK_PANEL2__
|
||||||
|
|
||||||
|
#include "TrackPanel.h"
|
||||||
|
|
||||||
class TrackPanel2 {
|
class TrackPanel2 : public TrackPanel
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
TrackPanel2(
|
||||||
|
wxWindow * parent, wxWindowID id,
|
||||||
|
const wxPoint & pos,
|
||||||
|
const wxSize & size,
|
||||||
|
TrackList * tracks,
|
||||||
|
ViewInfo * viewInfo,
|
||||||
|
TrackPanelListener * listener,
|
||||||
|
AdornedRulerPanel * ruler);
|
||||||
|
|
||||||
|
// Upgrades an existing TrackPanel to a TrackPanel2
|
||||||
|
static void Upgrade( TrackPanel ** ppTrackPanel );
|
||||||
|
|
||||||
|
virtual void OnPaint(wxPaintEvent & event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Factory function.
|
||||||
|
TrackPanel * TrackPanel2Factory(wxWindow * parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint & pos,
|
||||||
|
const wxSize & size,
|
||||||
|
TrackList * tracks,
|
||||||
|
ViewInfo * viewInfo,
|
||||||
|
TrackPanelListener * listener,
|
||||||
|
AdornedRulerPanel * ruler);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user