Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LyricsWindow Class Referencefinal

#include <LyricsWindow.h>

Inheritance diagram for LyricsWindow:
[legend]
Collaboration diagram for LyricsWindow:
[legend]

Public Member Functions

 LyricsWindow (AudacityProject *parent)
 
LyricsPanelGetLyricsPanel ()
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 

Private Member Functions

void OnCloseWindow (wxCloseEvent &WXUNUSED(event))
 
void OnStyle_BouncingBall (wxCommandEvent &evt)
 
void OnStyle_Highlight (wxCommandEvent &evt)
 
void OnTimer (Observer::Message)
 
void SetWindowTitle ()
 
void UpdatePrefs () override
 

Private Attributes

std::weak_ptr< AudacityProjectmProject
 
LyricsPanelmLyricsPanel
 
Observer::Subscription mTimerSubscription
 
Observer::Subscription mTitleChangeSubscription
 

Additional Inherited Members

- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 

Detailed Description

Definition at line 24 of file LyricsWindow.h.

Constructor & Destructor Documentation

◆ LyricsWindow()

LyricsWindow::LyricsWindow ( AudacityProject parent)

Definition at line 54 of file LyricsWindow.cpp.

55 : wxFrame( &GetProjectFrame( *parent ), -1, wxString{},
56 wxPoint(100, 300), gSize,
57 //v Bug in wxFRAME_FLOAT_ON_PARENT:
58 // If both the project frame and LyricsWindow are minimized and you restore LyricsWindow,
59 // you can't restore project frame until you close LyricsWindow, but then project frame and
60 // LyricsWindow are restored but LyricsWindow is unresponsive because it thinks it's not shown.
61 // wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT)
62 wxDEFAULT_FRAME_STYLE)
63{
64 //vvv Still necessary? It's commented out in ToolManager and Meter, so I did so here.
65 // #ifdef __WXMAC__
66 // // WXMAC doesn't support wxFRAME_FLOAT_ON_PARENT, so we do
67 // SetWindowClass((WindowRef) MacGetWindowRef(), kFloatingWindowClass);
68 // #endif
69 auto pProject = parent->shared_from_this();
70 mProject = pProject;
71
74 .Subscribe([this](ProjectFileIOMessage message){
77 });
78
79 // loads either the XPM or the windows resource, depending on the platform
80#if !defined(__WXMAC__) && !defined(__WXX11__)
81 {
82#ifdef __WXMSW__
83 wxIcon ic{ wxICON(AudacityLogo) };
84#else
85 wxIcon ic{wxICON(AudacityLogo48x48)};
86#endif
87 SetIcon(ic);
88 }
89 #endif
90
91 wxPoint panelPos(0, 0);
92 wxSize panelSize = gSize;
93
94 //vvv not yet working right in ported version, so choice is disabled.
95 // It seems when you select highlight style, the TrackPanel timer stops working, but
96 // going back to bouncing ball style starts it up again (!!!), per breakpoints in TrackPanel::OnTimer().
97 //
98 //wxToolBar* pToolBar = this->CreateToolBar();
99 //const int kHorizMargin = 8;
100 //wxASSERT(pToolBar); // To justify safenew
101 //wxRadioButton* pRadioButton_BouncingBall =
102 // safenew wxRadioButton(pToolBar, kID_RadioButton_BouncingBall, _("Bouncing Ball"), wxPoint(kHorizMargin, 4),
103 // wxDefaultSize, wxRB_GROUP);
105 //wxSize tbSize = pToolBar->GetSize();
106 //wxSize btnSize = pRadioButton_BouncingBall->GetSize();
107 //int top = (tbSize.GetHeight() - btnSize.GetHeight()) / 2;
108 //pRadioButton_BouncingBall->Move(kHorizMargin, top);
109 //pToolBar->AddControl(pRadioButton_BouncingBall);
110 //
111 //int left = kHorizMargin + btnSize.GetWidth() + kHorizMargin; //vvv Doesn't actually work. Probably need sizers.
112 //wxRadioButton* pRadioButton_Highlight =
113 // safenew wxRadioButton(pToolBar, kID_RadioButton_Highlight, _("Highlight"), wxPoint(left, top));
114 //pToolBar->AddControl(pRadioButton_Highlight);
115 //
116 //panelPos.x += tbSize.GetHeight();
117 //panelSize.y -= tbSize.GetHeight();
118 //
119 //#if defined(__WXMAC__)
120 // wxColour face = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
121 // pRadioButton_BouncingBall->SetBackgroundColour(face);
122 // pRadioButton_Highlight->SetBackgroundColour(face);
123 //#endif
124 //
125 //pToolBar->Realize();
126
127 mLyricsPanel = safenew LyricsPanel(this, -1, parent, panelPos, panelSize);
129
130 //vvv Highlight style is broken in ported version.
131 //switch (mLyricsPanel->GetLyricsStyle())
132 //{
133 // case LyricsPanel::kBouncingBallLyrics:
134 // pRadioButton_BouncingBall->SetValue(true); break;
135 // case LyricsPanel::kHighlightLyrics:
136 // default:
137 // pRadioButton_Highlight->SetValue(true); break;
138 //}
139
140 // Events from the project don't propagate directly to this other frame, so...
141 if (pProject)
144 Center();
145}
#define RTL_WORKAROUND(pWnd)
Definition: GUISettings.h:20
const wxSize gSize
#define safenew
Definition: MemoryX.h:10
ProjectFileIOMessage
Subscribe to ProjectFileIO to receive messages; always in idle time.
Definition: ProjectFileIO.h:50
@ ProjectTitleChange
A normal occurrence.
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
LyricsPanel is a panel that paints the bouncing ball and the lyrics text.
Definition: Lyrics.h:79
Observer::Subscription mTimerSubscription
Definition: LyricsWindow.h:47
void SetWindowTitle()
std::weak_ptr< AudacityProject > mProject
Definition: LyricsWindow.h:45
LyricsPanel * mLyricsPanel
Definition: LyricsWindow.h:46
Observer::Subscription mTitleChangeSubscription
Definition: LyricsWindow.h:48
void OnTimer(Observer::Message)
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
static ProjectFileIO & Get(AudacityProject &project)
PlaybackScroller & GetPlaybackScroller()
static ProjectWindow & Get(AudacityProject &project)

Member Function Documentation

◆ GetLyricsPanel()

LyricsPanel * LyricsWindow::GetLyricsPanel ( )
inline

Definition at line 31 of file LyricsWindow.h.

31{ return mLyricsPanel; };

References mLyricsPanel.

Referenced by OnTimer().

Here is the caller graph for this function:

◆ OnCloseWindow()

void LyricsWindow::OnCloseWindow ( wxCloseEvent &  WXUNUSEDevent)
private

Definition at line 147 of file LyricsWindow.cpp.

148{
149 this->Hide();
150}

◆ OnStyle_BouncingBall()

void LyricsWindow::OnStyle_BouncingBall ( wxCommandEvent &  evt)
private

Definition at line 152 of file LyricsWindow.cpp.

153{
155}
void SetLyricsStyle(const LyricsStyle newLyricsStyle)
Definition: Lyrics.cpp:247
@ kBouncingBallLyrics
Definition: Lyrics.h:83

References LyricsPanel::kBouncingBallLyrics, mLyricsPanel, and LyricsPanel::SetLyricsStyle().

Here is the call graph for this function:

◆ OnStyle_Highlight()

void LyricsWindow::OnStyle_Highlight ( wxCommandEvent &  evt)
private

Definition at line 157 of file LyricsWindow.cpp.

References LyricsPanel::kHighlightLyrics, mLyricsPanel, and LyricsPanel::SetLyricsStyle().

Here is the call graph for this function:

◆ OnTimer()

void LyricsWindow::OnTimer ( Observer::Message  )
private

Definition at line 162 of file LyricsWindow.cpp.

163{
164 if (auto pProject = mProject.lock()) {
165 if (ProjectAudioIO::Get( *pProject ).IsAudioActive())
166 {
167 auto gAudioIO = AudioIO::Get();
168 GetLyricsPanel()->Update(gAudioIO->GetStreamTime());
169 }
170 else
171 {
172 // Reset lyrics display.
173 const auto &selectedRegion = ViewInfo::Get( *pProject ).selectedRegion;
174 GetLyricsPanel()->Update(selectedRegion.t0());
175 }
176 }
177}
static AudioIO * Get()
Definition: AudioIO.cpp:126
void Update(double t)
Definition: Lyrics.cpp:437
LyricsPanel * GetLyricsPanel()
Definition: LyricsWindow.h:31
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References AudioIO::Get(), ProjectAudioIO::Get(), ViewInfo::Get(), GetLyricsPanel(), ProjectAudioIO::IsAudioActive(), mProject, ViewInfo::selectedRegion, and LyricsPanel::Update().

Here is the call graph for this function:

◆ SetWindowTitle()

void LyricsWindow::SetWindowTitle ( )
private

Definition at line 179 of file LyricsWindow.cpp.

180{
181 wxString name;
182 if (auto pProject = mProject.lock()) {
183 name = pProject->GetProjectName();
184 if (!name.empty())
185 name.Prepend(wxT(" - "));
186 }
187
188 SetTitle(AudacityKaraokeTitle.Format(name).Translation());
189}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:76
#define AudacityKaraokeTitle

References AudacityKaraokeTitle, TranslatableString::empty(), mProject, name, and wxT().

Referenced by UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePrefs()

void LyricsWindow::UpdatePrefs ( )
overrideprivatevirtual

Implements PrefsListener.

Definition at line 191 of file LyricsWindow.cpp.

192{
194}

References SetWindowTitle().

Here is the call graph for this function:

Member Data Documentation

◆ mLyricsPanel

LyricsPanel* LyricsWindow::mLyricsPanel
private

Definition at line 46 of file LyricsWindow.h.

Referenced by GetLyricsPanel(), OnStyle_BouncingBall(), and OnStyle_Highlight().

◆ mProject

std::weak_ptr<AudacityProject> LyricsWindow::mProject
private

Definition at line 45 of file LyricsWindow.h.

Referenced by OnTimer(), and SetWindowTitle().

◆ mTimerSubscription

Observer::Subscription LyricsWindow::mTimerSubscription
private

Definition at line 47 of file LyricsWindow.h.

◆ mTitleChangeSubscription

Observer::Subscription LyricsWindow::mTitleChangeSubscription
private

Definition at line 48 of file LyricsWindow.h.


The documentation for this class was generated from the following files: