mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-03 06:03:13 +02:00
Rename Lyrics as LyricsPanel, and some DOxygen
This commit is contained in:
parent
a1dc8305f0
commit
ee4f35f288
@ -28,7 +28,7 @@ BEGIN_EVENT_TABLE(HighlightTextCtrl, wxTextCtrl)
|
||||
EVT_MOUSE_EVENTS(HighlightTextCtrl::OnMouseEvent)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
HighlightTextCtrl::HighlightTextCtrl(Lyrics* parent,
|
||||
HighlightTextCtrl::HighlightTextCtrl(LyricsPanel* parent,
|
||||
wxWindowID id,
|
||||
const wxString& value /*= ""*/,
|
||||
const wxPoint& pos /*= wxDefaultPosition*/,
|
||||
@ -38,7 +38,7 @@ HighlightTextCtrl::HighlightTextCtrl(Lyrics* parent,
|
||||
pos, // const wxPoint& pos = wxDefaultPosition,
|
||||
size, // const wxSize& size = wxDefaultSize,
|
||||
wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_RICH2 | wxTE_AUTO_URL | wxTE_NOHIDESEL), //v | wxHSCROLL)
|
||||
mLyrics(parent)
|
||||
mLyricsPanel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -49,11 +49,11 @@ void HighlightTextCtrl::OnMouseEvent(wxMouseEvent& event)
|
||||
long from, to;
|
||||
this->GetSelection(&from, &to);
|
||||
|
||||
int nCurSyl = mLyrics->GetCurrentSyllableIndex();
|
||||
int nNewSyl = mLyrics->FindSyllable(from);
|
||||
int nCurSyl = mLyricsPanel->GetCurrentSyllableIndex();
|
||||
int nNewSyl = mLyricsPanel->FindSyllable(from);
|
||||
if (nNewSyl != nCurSyl)
|
||||
{
|
||||
Syllable* pCurSyl = mLyrics->GetSyllable(nNewSyl);
|
||||
Syllable* pCurSyl = mLyricsPanel->GetSyllable(nNewSyl);
|
||||
AudacityProject* pProj = GetActiveProject();
|
||||
pProj->SetSel0(pCurSyl->t);
|
||||
|
||||
@ -69,18 +69,18 @@ void HighlightTextCtrl::OnMouseEvent(wxMouseEvent& event)
|
||||
|
||||
//v static const kHighlightTextCtrlID = 7654;
|
||||
|
||||
BEGIN_EVENT_TABLE(Lyrics, wxPanelWrapper)
|
||||
EVT_KEY_DOWN(Lyrics::OnKeyEvent)
|
||||
EVT_PAINT(Lyrics::OnPaint)
|
||||
EVT_SIZE(Lyrics::OnSize)
|
||||
BEGIN_EVENT_TABLE(LyricsPanel, wxPanelWrapper)
|
||||
EVT_KEY_DOWN(LyricsPanel::OnKeyEvent)
|
||||
EVT_PAINT(LyricsPanel::OnPaint)
|
||||
EVT_SIZE(LyricsPanel::OnSize)
|
||||
|
||||
//v Doesn't seem to be a way to capture a selection event in a read-only wxTextCtrl.
|
||||
// EVT_COMMAND_LEFT_CLICK(kHighlightTextCtrlID, Lyrics::OnHighlightTextCtrl)
|
||||
// EVT_COMMAND_LEFT_CLICK(kHighlightTextCtrlID, LyricsPanel::OnHighlightTextCtrl)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_CLASS(Lyrics, wxPanel)
|
||||
IMPLEMENT_CLASS(LyricsPanel, wxPanel)
|
||||
|
||||
Lyrics::Lyrics(wxWindow* parent, wxWindowID id,
|
||||
LyricsPanel::LyricsPanel(wxWindow* parent, wxWindowID id,
|
||||
const wxPoint& pos /*= wxDefaultPosition*/,
|
||||
const wxSize& size /*= wxDefaultSize*/):
|
||||
wxPanelWrapper(parent, id, pos, size, wxWANTS_CHARS),
|
||||
@ -88,7 +88,7 @@ Lyrics::Lyrics(wxWindow* parent, wxWindowID id,
|
||||
{
|
||||
mKaraokeHeight = mHeight;
|
||||
mLyricsStyle = kBouncingBallLyrics; // default
|
||||
mKaraokeFontSize = this->GetDefaultFontSize(); // Call only after mLyricsStyle is set.
|
||||
mKaraokeFontSize = this->GetDefaultFontSize(); // Call only after mLyricsPanelStyle is set.
|
||||
|
||||
this->SetBackgroundColour(*wxWHITE);
|
||||
|
||||
@ -112,13 +112,13 @@ Lyrics::Lyrics(wxWindow* parent, wxWindowID id,
|
||||
#endif
|
||||
}
|
||||
|
||||
Lyrics::~Lyrics()
|
||||
LyricsPanel::~LyricsPanel()
|
||||
{
|
||||
}
|
||||
|
||||
#define I_FIRST_REAL_SYLLABLE 2
|
||||
|
||||
void Lyrics::Clear()
|
||||
void LyricsPanel::Clear()
|
||||
{
|
||||
mSyllables.Clear();
|
||||
mText = wxT("");
|
||||
@ -132,7 +132,7 @@ void Lyrics::Clear()
|
||||
mHighlightTextCtrl->Clear();
|
||||
}
|
||||
|
||||
void Lyrics::AddLabels(const LabelTrack *pLT)
|
||||
void LyricsPanel::AddLabels(const LabelTrack *pLT)
|
||||
{
|
||||
const size_t numLabels = pLT->GetNumLabels();
|
||||
wxString highlightText;
|
||||
@ -143,7 +143,7 @@ void Lyrics::AddLabels(const LabelTrack *pLT)
|
||||
mHighlightTextCtrl->AppendText(highlightText);
|
||||
}
|
||||
|
||||
void Lyrics::Add(double t, const wxString &syllable, wxString &highlightText)
|
||||
void LyricsPanel::Add(double t, const wxString &syllable, wxString &highlightText)
|
||||
{
|
||||
int i = mSyllables.GetCount();
|
||||
|
||||
@ -187,7 +187,7 @@ void Lyrics::Add(double t, const wxString &syllable, wxString &highlightText)
|
||||
highlightText += thisSyllable.textWithSpace;
|
||||
}
|
||||
|
||||
void Lyrics::Finish(double finalT)
|
||||
void LyricsPanel::Finish(double finalT)
|
||||
{
|
||||
// Add 3 dummy syllables at the end
|
||||
int i = mSyllables.GetCount();
|
||||
@ -205,7 +205,7 @@ void Lyrics::Finish(double finalT)
|
||||
}
|
||||
|
||||
// Binary-search for the syllable syllable whose char0 <= startChar <= char1.
|
||||
int Lyrics::FindSyllable(long startChar)
|
||||
int LyricsPanel::FindSyllable(long startChar)
|
||||
{
|
||||
int i1, i2;
|
||||
|
||||
@ -227,7 +227,7 @@ int Lyrics::FindSyllable(long startChar)
|
||||
return i1;
|
||||
}
|
||||
|
||||
void Lyrics::SetLyricsStyle(const LyricsStyle newLyricsStyle)
|
||||
void LyricsPanel::SetLyricsStyle(const LyricsStyle newLyricsStyle)
|
||||
{
|
||||
if (mLyricsStyle == newLyricsStyle)
|
||||
return;
|
||||
@ -240,17 +240,17 @@ void Lyrics::SetLyricsStyle(const LyricsStyle newLyricsStyle)
|
||||
}
|
||||
|
||||
|
||||
unsigned int Lyrics::GetDefaultFontSize() const
|
||||
unsigned int LyricsPanel::GetDefaultFontSize() const
|
||||
{
|
||||
return (mLyricsStyle == kBouncingBallLyrics) ? 48 : 10;
|
||||
}
|
||||
|
||||
void Lyrics::SetDrawnFont(wxDC *dc)
|
||||
void LyricsPanel::SetDrawnFont(wxDC *dc)
|
||||
{
|
||||
dc->SetFont(wxFont(mKaraokeFontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
||||
}
|
||||
|
||||
void Lyrics::SetHighlightFont() // for kHighlightLyrics
|
||||
void LyricsPanel::SetHighlightFont() // for kHighlightLyrics
|
||||
{
|
||||
wxFont newFont(mKaraokeFontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mHighlightTextCtrl->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, newFont));
|
||||
@ -258,7 +258,7 @@ void Lyrics::SetHighlightFont() // for kHighlightLyrics
|
||||
wxTextAttr(wxNullColour, wxNullColour, newFont));
|
||||
}
|
||||
|
||||
void Lyrics::Measure(wxDC *dc) // only for drawn text
|
||||
void LyricsPanel::Measure(wxDC *dc) // only for drawn text
|
||||
{
|
||||
this->SetDrawnFont(dc);
|
||||
int width = 0, height = 0;
|
||||
@ -313,7 +313,7 @@ void Lyrics::Measure(wxDC *dc) // only for drawn text
|
||||
}
|
||||
|
||||
// Binary-search for the syllable with the largest time not greater than t
|
||||
int Lyrics::FindSyllable(double t)
|
||||
int LyricsPanel::FindSyllable(double t)
|
||||
{
|
||||
int i1, i2;
|
||||
|
||||
@ -342,7 +342,7 @@ int Lyrics::FindSyllable(double t)
|
||||
// In-between words, outX is interpolated using smooth acceleration
|
||||
// between the two neighboring words, and y is a positive number indicating
|
||||
// the bouncing ball height
|
||||
void Lyrics::GetKaraokePosition(double t,
|
||||
void LyricsPanel::GetKaraokePosition(double t,
|
||||
int *outX, double *outY)
|
||||
{
|
||||
*outX = 0;
|
||||
@ -417,7 +417,7 @@ void Lyrics::GetKaraokePosition(double t,
|
||||
*outY = height * sin(M_PI * t);
|
||||
}
|
||||
|
||||
void Lyrics::Update(double t)
|
||||
void LyricsPanel::Update(double t)
|
||||
{
|
||||
if (t < 0.0)
|
||||
{
|
||||
@ -457,20 +457,20 @@ void Lyrics::Update(double t)
|
||||
}
|
||||
}
|
||||
|
||||
void Lyrics::OnKeyEvent(wxKeyEvent & event)
|
||||
void LyricsPanel::OnKeyEvent(wxKeyEvent & event)
|
||||
{
|
||||
AudacityProject *project = GetActiveProject();
|
||||
project->GetCommandManager()->FilterKeyEvent(project, event, true);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void Lyrics::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
void LyricsPanel::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
DoPaint(dc);
|
||||
}
|
||||
|
||||
void Lyrics::DoPaint(wxDC &dc)
|
||||
void LyricsPanel::DoPaint(wxDC &dc)
|
||||
{
|
||||
if (!this->GetParent()->IsShown())
|
||||
return;
|
||||
@ -499,7 +499,7 @@ void Lyrics::DoPaint(wxDC &dc)
|
||||
}
|
||||
}
|
||||
|
||||
void Lyrics::OnSize(wxSizeEvent & WXUNUSED(event))
|
||||
void LyricsPanel::OnSize(wxSizeEvent & WXUNUSED(event))
|
||||
{
|
||||
GetClientSize(&mWidth, &mHeight);
|
||||
|
||||
@ -527,7 +527,7 @@ void Lyrics::OnSize(wxSizeEvent & WXUNUSED(event))
|
||||
}
|
||||
|
||||
//v Doesn't seem to be a way to capture a selection event in a read-only wxTextCtrl.
|
||||
//void Lyrics::OnHighlightTextCtrl(wxCommandEvent & event)
|
||||
//void LyricsPanel::OnHighlightTextCtrl(wxCommandEvent & event)
|
||||
//{
|
||||
// long from, to;
|
||||
//
|
||||
@ -535,7 +535,7 @@ void Lyrics::OnSize(wxSizeEvent & WXUNUSED(event))
|
||||
// // TODO: Find the start time of the corresponding syllable and set playback to start there.
|
||||
//}
|
||||
|
||||
void Lyrics::HandlePaint(wxDC &dc)
|
||||
void LyricsPanel::HandlePaint(wxDC &dc)
|
||||
{
|
||||
wxASSERT(mLyricsStyle == kBouncingBallLyrics);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
@ -544,7 +544,7 @@ void Lyrics::HandlePaint(wxDC &dc)
|
||||
this->HandlePaint_BouncingBall(dc);
|
||||
}
|
||||
|
||||
void Lyrics::HandlePaint_BouncingBall(wxDC &dc)
|
||||
void LyricsPanel::HandlePaint_BouncingBall(wxDC &dc)
|
||||
{
|
||||
int ctr = mWidth / 2;
|
||||
int x;
|
||||
|
24
src/Lyrics.h
24
src/Lyrics.h
@ -28,8 +28,8 @@ struct Syllable {
|
||||
double t;
|
||||
wxString text;
|
||||
wxString textWithSpace;
|
||||
int char0; // index of first char of syllable in Lyrics::mText, used only for kHighlightLyrics
|
||||
int char1; // index of last char of syllable in Lyrics::mText, used only for kHighlightLyrics
|
||||
int char0; // index of first char of syllable in LyricsPanel::mText, used only for kHighlightLyrics
|
||||
int char1; // index of last char of syllable in LyricsPanel::mText, used only for kHighlightLyrics
|
||||
int width;
|
||||
int leftX;
|
||||
int x; // centerX, used only for kBouncingBallLyrics
|
||||
@ -37,13 +37,13 @@ struct Syllable {
|
||||
|
||||
WX_DECLARE_OBJARRAY(Syllable, SyllableArray);
|
||||
|
||||
class Lyrics;
|
||||
class LyricsPanel;
|
||||
|
||||
// Override wxTextCtrl to handle selection events, which the parent ignores if the control is read-only.
|
||||
class HighlightTextCtrl final : public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
HighlightTextCtrl(Lyrics* parent,
|
||||
HighlightTextCtrl(LyricsPanel* parent,
|
||||
wxWindowID id,
|
||||
const wxString& value = wxT(""),
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
@ -53,14 +53,20 @@ public:
|
||||
void OnMouseEvent(wxMouseEvent &evt);
|
||||
|
||||
private:
|
||||
Lyrics* mLyrics;
|
||||
LyricsPanel* mLyricsPanel;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class Lyrics final : public wxPanelWrapper
|
||||
|
||||
/**************************************************************//**
|
||||
|
||||
\brief LyricsPanel is a panel that paints the bouncing
|
||||
ball and the lyrics text.
|
||||
*******************************************************************/
|
||||
class LyricsPanel final : public wxPanelWrapper
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(Lyrics)
|
||||
DECLARE_DYNAMIC_CLASS(LyricsPanel)
|
||||
|
||||
enum LyricsStyle {
|
||||
kBouncingBallLyrics, // Lyrics move from right to left with bouncing ball.
|
||||
@ -69,10 +75,10 @@ class Lyrics final : public wxPanelWrapper
|
||||
};
|
||||
|
||||
public:
|
||||
Lyrics(wxWindow* parent, wxWindowID id,
|
||||
LyricsPanel(wxWindow* parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize);
|
||||
virtual ~Lyrics();
|
||||
virtual ~LyricsPanel();
|
||||
|
||||
void Clear();
|
||||
void AddLabels(const LabelTrack *pLT);
|
||||
|
@ -113,14 +113,14 @@ LyricsWindow::LyricsWindow(AudacityProject *parent):
|
||||
//
|
||||
//pToolBar->Realize();
|
||||
|
||||
mLyricsPanel = safenew Lyrics(this, -1, panelPos, panelSize);
|
||||
mLyricsPanel = safenew LyricsPanel(this, -1, panelPos, panelSize);
|
||||
|
||||
//vvv Highlight style is broken in ported version.
|
||||
//switch (mLyricsPanel->GetLyricsStyle())
|
||||
//{
|
||||
// case Lyrics::kBouncingBallLyrics:
|
||||
// case LyricsPanel::kBouncingBallLyrics:
|
||||
// pRadioButton_BouncingBall->SetValue(true); break;
|
||||
// case Lyrics::kHighlightLyrics:
|
||||
// case LyricsPanel::kHighlightLyrics:
|
||||
// default:
|
||||
// pRadioButton_Highlight->SetValue(true); break;
|
||||
//}
|
||||
@ -148,12 +148,12 @@ void LyricsWindow::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
|
||||
|
||||
void LyricsWindow::OnStyle_BouncingBall(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
mLyricsPanel->SetLyricsStyle(Lyrics::kBouncingBallLyrics);
|
||||
mLyricsPanel->SetLyricsStyle(LyricsPanel::kBouncingBallLyrics);
|
||||
}
|
||||
|
||||
void LyricsWindow::OnStyle_Highlight(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
mLyricsPanel->SetLyricsStyle(Lyrics::kHighlightLyrics);
|
||||
mLyricsPanel->SetLyricsStyle(LyricsPanel::kHighlightLyrics);
|
||||
}
|
||||
|
||||
void LyricsWindow::OnTimer(wxCommandEvent &event)
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <wx/frame.h>
|
||||
|
||||
class AudacityProject;
|
||||
class Lyrics;
|
||||
class LyricsPanel;
|
||||
|
||||
class LyricsWindow final : public wxFrame {
|
||||
|
||||
@ -25,7 +25,7 @@ class LyricsWindow final : public wxFrame {
|
||||
LyricsWindow(AudacityProject* parent);
|
||||
virtual ~LyricsWindow();
|
||||
|
||||
Lyrics *GetLyricsPanel() { return mLyricsPanel; };
|
||||
LyricsPanel *GetLyricsPanel() { return mLyricsPanel; };
|
||||
|
||||
private:
|
||||
void OnCloseWindow(wxCloseEvent & WXUNUSED(event));
|
||||
@ -35,7 +35,7 @@ class LyricsWindow final : public wxFrame {
|
||||
void OnTimer(wxCommandEvent &event);
|
||||
|
||||
AudacityProject *mProject;
|
||||
Lyrics *mLyricsPanel;
|
||||
LyricsPanel *mLyricsPanel;
|
||||
|
||||
public:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@ -2028,7 +2028,7 @@ CommandFlag AudacityProject::GetFocusedFrame()
|
||||
if (w == mTrackPanel) {
|
||||
return TrackPanelHasFocus;
|
||||
}
|
||||
// LIE if Lyrics window has focus.
|
||||
// LIE if LyricsPanel window has focus.
|
||||
// we want to act as if TrackPanel has focus.
|
||||
if (w== mLyricsWindow) {
|
||||
return TrackPanelHasFocus;
|
||||
|
@ -4628,7 +4628,7 @@ void AudacityProject::UpdateLyrics()
|
||||
if( !mLyricsWindow->IsVisible() )
|
||||
return;
|
||||
|
||||
Lyrics* pLyricsPanel = mLyricsWindow->GetLyricsPanel();
|
||||
LyricsPanel* pLyricsPanel = mLyricsWindow->GetLyricsPanel();
|
||||
pLyricsPanel->Clear();
|
||||
pLyricsPanel->AddLabels(pLabelTrack);
|
||||
pLyricsPanel->Finish(pLabelTrack->GetEndTime());
|
||||
|
@ -1405,7 +1405,7 @@ bool CommandManager::FilterKeyEvent(AudacityProject *project, const wxKeyEvent &
|
||||
bool bIntercept = pWnd != pTrackPanel;
|
||||
// Intercept keys from windows that are NOT the Lyrics panel
|
||||
if( bIntercept ){
|
||||
bIntercept = pWnd && ( dynamic_cast<Lyrics*>(pWnd) == NULL );
|
||||
bIntercept = pWnd && ( dynamic_cast<LyricsPanel*>(pWnd) == NULL );
|
||||
}
|
||||
//wxLogDebug("Focus: %p TrackPanel: %p", pWnd, pTrackPanel );
|
||||
// We allow the keystrokes below to be handled by wxWidgets controls IF we are
|
||||
|
Loading…
x
Reference in New Issue
Block a user