mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 23:59:37 +02:00
Bug1075, and define and use new event type for TrackPanel timer ticks...
... Thus allowing TrackPanel.cpp to work without including Lyrics headers. Also eliminates some of its direct notification of MixerBoard.
This commit is contained in:
parent
4f0a2ee804
commit
fdf0759301
@ -4520,6 +4520,8 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
|
||||
// The problem there occurs if Software Playthrough is on.
|
||||
// Could conditionally do the update here if Software Playthrough is off,
|
||||
// and in TrackPanel::OnTimer() if Software Playthrough is on, but not now.
|
||||
// PRL 12 Jul 2015: and what was in TrackPanel::OnTimer is now handled by means of event
|
||||
// type EVT_TRACK_PANEL_TIMER
|
||||
//AudacityProject* pProj = GetActiveProject();
|
||||
//MixerBoard* pMixerBoard = pProj->GetMixerBoard();
|
||||
//if (pMixerBoard)
|
||||
|
@ -13,7 +13,9 @@
|
||||
|
||||
#include "LyricsWindow.h"
|
||||
#include "Lyrics.h"
|
||||
#include "AudioIO.h"
|
||||
#include "Project.h"
|
||||
#include "TrackPanel.h" // for EVT_TRACK_PANEL_TIMER
|
||||
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/toolbar.h>
|
||||
@ -123,10 +125,21 @@ LyricsWindow::LyricsWindow(AudacityProject *parent):
|
||||
// default:
|
||||
// pRadioButton_Highlight->SetValue(true); break;
|
||||
//}
|
||||
|
||||
// Events from the project don't propagate directly to this other frame, so...
|
||||
mProject->Connect(EVT_TRACK_PANEL_TIMER,
|
||||
wxCommandEventHandler(LyricsWindow::OnTimer),
|
||||
NULL,
|
||||
this);
|
||||
}
|
||||
|
||||
LyricsWindow::~LyricsWindow()
|
||||
{}
|
||||
{
|
||||
mProject->Disconnect(EVT_TRACK_PANEL_TIMER,
|
||||
wxCommandEventHandler(LyricsWindow::OnTimer),
|
||||
NULL,
|
||||
this);
|
||||
}
|
||||
|
||||
void LyricsWindow::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
|
||||
{
|
||||
@ -143,3 +156,18 @@ void LyricsWindow::OnStyle_Highlight(wxCommandEvent & WXUNUSED(event))
|
||||
mLyricsPanel->SetLyricsStyle(Lyrics::kHighlightLyrics);
|
||||
}
|
||||
|
||||
void LyricsWindow::OnTimer(wxCommandEvent &event)
|
||||
{
|
||||
if (mProject->IsAudioActive())
|
||||
{
|
||||
GetLyricsPanel()->Update(gAudioIO->GetStreamTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset lyrics display.
|
||||
GetLyricsPanel()->Update(mProject->GetSel0());
|
||||
}
|
||||
|
||||
// Let other listeners get the notification
|
||||
event.Skip();
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class LyricsWindow : public wxFrame {
|
||||
|
||||
void OnStyle_BouncingBall(wxCommandEvent &evt);
|
||||
void OnStyle_Highlight(wxCommandEvent &evt);
|
||||
void OnTimer(wxCommandEvent &event);
|
||||
|
||||
AudacityProject *mProject;
|
||||
Lyrics *mLyricsPanel;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "NoteTrack.h"
|
||||
#endif
|
||||
#include "Project.h"
|
||||
#include "TrackPanel.h" // for EVT_TRACK_PANEL_TIMER
|
||||
#include "WaveTrack.h"
|
||||
|
||||
#include "widgets/Meter.h"
|
||||
@ -1017,6 +1018,12 @@ MixerBoard::MixerBoard(AudacityProject* pProject,
|
||||
|
||||
mPrevT1 = 0.0;
|
||||
mTracks = mProject->GetTracks();
|
||||
|
||||
// Events from the project don't propagate directly to this other frame, so...
|
||||
mProject->Connect(EVT_TRACK_PANEL_TIMER,
|
||||
wxCommandEventHandler(MixerBoard::OnTimer),
|
||||
NULL,
|
||||
this);
|
||||
}
|
||||
|
||||
MixerBoard::~MixerBoard()
|
||||
@ -1034,6 +1041,11 @@ MixerBoard::~MixerBoard()
|
||||
|
||||
// private data members
|
||||
mMusicalInstruments.Clear();
|
||||
|
||||
mProject->Disconnect(EVT_TRACK_PANEL_TIMER,
|
||||
wxCommandEventHandler(MixerBoard::OnTimer),
|
||||
NULL,
|
||||
this);
|
||||
}
|
||||
|
||||
// Reassign mixer input strips (MixerTrackClusters) to Track Clusters
|
||||
@ -1693,6 +1705,30 @@ void MixerBoard::OnSize(wxSizeEvent &evt)
|
||||
this->RefreshTrackClusters(true);
|
||||
}
|
||||
|
||||
void MixerBoard::OnTimer(wxCommandEvent &event)
|
||||
{
|
||||
// PRL 12 Jul 2015: Moved the below (with comments) out of TrackPanel::OnTimer.
|
||||
|
||||
// Vaughan, 2011-01-28: No longer doing this on timer.
|
||||
// Now it's in AudioIO::SetMeters() and AudioIO::StopStream(), as with Meter Toolbar meters.
|
||||
//if (pMixerBoard)
|
||||
// pMixerBoard->ResetMeters(false);
|
||||
|
||||
//v Vaughan, 2011-02-25: Moved this update back here from audacityAudioCallback.
|
||||
// See note there.
|
||||
// Vaughan, 2010-01-30:
|
||||
// Since all we're doing here is updating the meters, I moved it to
|
||||
// audacityAudioCallback where it calls gAudioIO->mOutputMeter->UpdateDisplay().
|
||||
if (mProject->IsAudioActive())
|
||||
{
|
||||
UpdateMeters(gAudioIO->GetStreamTime(),
|
||||
(mProject->mLastPlayMode == loopedPlay));
|
||||
}
|
||||
|
||||
// Let other listeners get the notification
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
// class MixerBoardFrame
|
||||
|
||||
@ -1761,5 +1797,3 @@ void MixerBoardFrame::OnSize(wxSizeEvent & WXUNUSED(event))
|
||||
{
|
||||
mMixerBoard->SetSize(this->GetClientSize());
|
||||
}
|
||||
|
||||
|
||||
|
@ -265,6 +265,7 @@ private:
|
||||
|
||||
// event handlers
|
||||
void OnSize(wxSizeEvent &evt);
|
||||
void OnTimer(wxCommandEvent &event);
|
||||
|
||||
|
||||
public:
|
||||
|
@ -196,8 +196,6 @@ is time to refresh some aspect of the screen.
|
||||
#include "float_cast.h"
|
||||
#include "Internat.h"
|
||||
#include "LabelTrack.h"
|
||||
#include "Lyrics.h"
|
||||
#include "LyricsWindow.h"
|
||||
#include "MixerBoard.h"
|
||||
|
||||
#include "NoteTrack.h"
|
||||
@ -236,6 +234,8 @@ is time to refresh some aspect of the screen.
|
||||
#include "../images/Cursors.h"
|
||||
#include <iostream>
|
||||
|
||||
DEFINE_EVENT_TYPE(EVT_TRACK_PANEL_TIMER)
|
||||
|
||||
enum {
|
||||
kLeftInset = 4,
|
||||
kTopInset = 4,
|
||||
@ -1053,27 +1053,9 @@ void TrackPanel::OnTimer()
|
||||
wxCommandEvent dummyEvent;
|
||||
AudacityProject *p = GetProject();
|
||||
|
||||
if (IsAudioActive())
|
||||
{
|
||||
// Update lyrics display.
|
||||
LyricsWindow* pLyricsWindow = p->GetLyricsWindow();
|
||||
if (pLyricsWindow)
|
||||
{
|
||||
Lyrics* pLyricsPanel = pLyricsWindow->GetLyricsPanel();
|
||||
pLyricsPanel->Update(gAudioIO->GetStreamTime());
|
||||
}
|
||||
}
|
||||
|
||||
//v Vaughan, 2011-02-25: Moved this update back here from audacityAudioCallback.
|
||||
// See note there.
|
||||
// Vaughan, 2010-01-30:
|
||||
// Since all we're doing here is updating the meters, I moved it to
|
||||
// audacityAudioCallback where it calls gAudioIO->mOutputMeter->UpdateDisplay().
|
||||
MixerBoard* pMixerBoard = this->GetMixerBoard();
|
||||
if (pMixerBoard && IsAudioActive())
|
||||
{
|
||||
pMixerBoard->UpdateMeters(gAudioIO->GetStreamTime(),
|
||||
(p->mLastPlayMode == loopedPlay));
|
||||
wxCommandEvent e(EVT_TRACK_PANEL_TIMER);
|
||||
p->ProcessEvent(e);
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||
@ -1119,19 +1101,6 @@ void TrackPanel::OnTimer()
|
||||
//the stream may have been started up after this one finished (by some other project)
|
||||
//in that case reset the buttons don't stop the stream
|
||||
p->GetControlToolBar()->StopPlaying(!gAudioIO->IsStreamActive());
|
||||
|
||||
// Reset lyrics display.
|
||||
LyricsWindow* pLyricsWindow = p->GetLyricsWindow();
|
||||
if (pLyricsWindow)
|
||||
{
|
||||
Lyrics* pLyricsPanel = pLyricsWindow->GetLyricsPanel();
|
||||
pLyricsPanel->Update(p->GetSel0());
|
||||
}
|
||||
|
||||
// Vaughan, 2011-01-28: No longer doing this on timer.
|
||||
// Now it's in AudioIO::SetMeters() and AudioIO::StopStream(), as with Meter Toolbar meters.
|
||||
//if (pMixerBoard)
|
||||
// pMixerBoard->ResetMeters(false);
|
||||
}
|
||||
|
||||
// Next, check to see if we were playing or recording
|
||||
@ -2176,7 +2145,7 @@ void TrackPanel::HandleSelect(wxMouseEvent & event)
|
||||
// AS: Ok, did the user just click the mouse, release the mouse,
|
||||
// or drag?
|
||||
if (event.LeftDown() ||
|
||||
(event.LeftDClick() && event.CmdDown())) {
|
||||
(event.LeftDClick() && event.CmdDown())) {
|
||||
// AS: Now, did they click in a track somewhere? If so, we want
|
||||
// to extend the current selection or start a new selection,
|
||||
// depending on the shift key. If not, cancel all selections.
|
||||
@ -2258,15 +2227,6 @@ void TrackPanel::HandleSelect(wxMouseEvent & event)
|
||||
#endif
|
||||
done:
|
||||
SelectionHandleDrag(event, t);
|
||||
|
||||
// Update lyrics display for new selection.
|
||||
AudacityProject* pProj = GetActiveProject();
|
||||
LyricsWindow* pLyricsWindow = pProj->GetLyricsWindow();
|
||||
if (pLyricsWindow && pLyricsWindow->IsShown())
|
||||
{
|
||||
Lyrics* pLyricsPanel = pLyricsWindow->GetLyricsPanel();
|
||||
pLyricsPanel->Update(pProj->GetSel0());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,6 +68,8 @@ class TrackPanelListener;
|
||||
#pragma warning( disable: 4251 )
|
||||
#endif
|
||||
|
||||
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACK_PANEL_TIMER, -1);
|
||||
|
||||
class AUDACITY_DLL_API TrackInfo
|
||||
{
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user