Audacity  2.2.2
LyricsWindow.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  LyricsWindow.cpp
6 
7  Vaughan Johnson
8  Dominic Mazzoni
9 
10 **********************************************************************/
11 
12 #include "LyricsWindow.h"
13 #include "Lyrics.h"
14 #include "AudioIO.h"
15 #include "Project.h"
16 #include "TrackPanel.h" // for EVT_TRACK_PANEL_TIMER
17 
18 #include <wx/radiobut.h>
19 #include <wx/toolbar.h>
20 #include <wx/settings.h>
21 
22 #ifdef __WXMSW__
23  #include "../images/AudacityLogo.xpm"
24 #else
25  #include "../images/AudacityLogo48x48.xpm"
26 #endif
27 
28 #ifdef __WXMAC__
29  #include <Carbon/Carbon.h>
30 #endif
31 
32 enum {
35 };
36 
37 BEGIN_EVENT_TABLE(LyricsWindow, wxFrame)
38  EVT_CLOSE(LyricsWindow::OnCloseWindow)
39  EVT_RADIOBUTTON(kID_RadioButton_BouncingBall, LyricsWindow::OnStyle_BouncingBall)
40  EVT_RADIOBUTTON(kID_RadioButton_Highlight, LyricsWindow::OnStyle_Highlight)
42 
44 
46  wxFrame(parent, -1,
47  wxString::Format(_("Audacity Karaoke%s"),
48  ((parent->GetName() == wxEmptyString) ?
49  wxT("") :
50  wxString::Format(
51  wxT(" - %s"),
52  parent->GetName()))),
53  wxPoint(100, 300), gSize,
54  //v Bug in wxFRAME_FLOAT_ON_PARENT:
55  // If both the project frame and LyricsWindow are minimized and you restore LyricsWindow,
56  // you can't restore project frame until you close LyricsWindow, but then project frame and
57  // LyricsWindow are restored but LyricsWindow is unresponsive because it thinks it's not shown.
58  // wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT)
59  wxDEFAULT_FRAME_STYLE)
60 {
61  //vvv Still necessary? It's commented out in ToolManager and Meter, so I did so here.
62  // #ifdef __WXMAC__
63  // // WXMAC doesn't support wxFRAME_FLOAT_ON_PARENT, so we do
64  // SetWindowClass((WindowRef) MacGetWindowRef(), kFloatingWindowClass);
65  // #endif
66  mProject = parent;
67 
68  // loads either the XPM or the windows resource, depending on the platform
69 #if !defined(__WXMAC__) && !defined(__WXX11__)
70  {
71 #ifdef __WXMSW__
72  wxIcon ic{ wxICON(AudacityLogo) };
73 #else
74  wxIcon ic{wxICON(AudacityLogo48x48)};
75 #endif
76  SetIcon(ic);
77  }
78  #endif
79 
80  wxPoint panelPos(0, 0);
81  wxSize panelSize = gSize;
82 
83  //vvv not yet working right in ported version, so choice is disabled.
84  // It seems when you select highlight style, the TrackPanel timer stops working, but
85  // going back to bouncing ball style starts it up again (!!!), per breakpoints in TrackPanel::OnTimer().
86  //
87  //wxToolBar* pToolBar = this->CreateToolBar();
88  //const int kHorizMargin = 8;
89  //wxASSERT(pToolBar); // To justify safenew
90  //wxRadioButton* pRadioButton_BouncingBall =
91  // safenew wxRadioButton(pToolBar, kID_RadioButton_BouncingBall, _("Bouncing Ball"), wxPoint(kHorizMargin, 4),
92  // wxDefaultSize, wxRB_GROUP);
94  //wxSize tbSize = pToolBar->GetSize();
95  //wxSize btnSize = pRadioButton_BouncingBall->GetSize();
96  //int top = (tbSize.GetHeight() - btnSize.GetHeight()) / 2;
97  //pRadioButton_BouncingBall->Move(kHorizMargin, top);
98  //pToolBar->AddControl(pRadioButton_BouncingBall);
99  //
100  //int left = kHorizMargin + btnSize.GetWidth() + kHorizMargin; //vvv Doesn't actually work. Probably need sizers.
101  //wxRadioButton* pRadioButton_Highlight =
102  // safenew wxRadioButton(pToolBar, kID_RadioButton_Highlight, _("Highlight"), wxPoint(left, top));
103  //pToolBar->AddControl(pRadioButton_Highlight);
104  //
105  //panelPos.x += tbSize.GetHeight();
106  //panelSize.y -= tbSize.GetHeight();
107  //
108  //#if defined(__WXMAC__)
109  // wxColour face = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
110  // pRadioButton_BouncingBall->SetBackgroundColour(face);
111  // pRadioButton_Highlight->SetBackgroundColour(face);
112  //#endif
113  //
114  //pToolBar->Realize();
115 
116  mLyricsPanel = safenew LyricsPanel(this, -1, panelPos, panelSize);
117 
118  //vvv Highlight style is broken in ported version.
119  //switch (mLyricsPanel->GetLyricsStyle())
120  //{
121  // case LyricsPanel::kBouncingBallLyrics:
122  // pRadioButton_BouncingBall->SetValue(true); break;
123  // case LyricsPanel::kHighlightLyrics:
124  // default:
125  // pRadioButton_Highlight->SetValue(true); break;
126  //}
127 
128  // Events from the project don't propagate directly to this other frame, so...
129  mProject->Bind(EVT_TRACK_PANEL_TIMER,
131  this);
132  Center();
133 }
134 
135 void LyricsWindow::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
136 {
137  this->Hide();
138 }
139 
140 void LyricsWindow::OnStyle_BouncingBall(wxCommandEvent & WXUNUSED(event))
141 {
143 }
144 
145 void LyricsWindow::OnStyle_Highlight(wxCommandEvent & WXUNUSED(event))
146 {
148 }
149 
150 void LyricsWindow::OnTimer(wxCommandEvent &event)
151 {
152  if (mProject->IsAudioActive())
153  {
155  }
156  else
157  {
158  // Reset lyrics display.
160  }
161 
162  // Let other listeners get the notification
163  event.Skip();
164 }
void SetLyricsStyle(const LyricsStyle newLyricsStyle)
Definition: Lyrics.cpp:227
double GetSel0() const
Definition: Project.h:204
Abstract base class used in importing a file.
Definition: Import.h:32
double GetStreamTime()
During playback, the (unwarped) track time most recently played.
Definition: AudioIO.cpp:2988
AudacityProject * mProject
Definition: LyricsWindow.h:36
void OnStyle_Highlight(wxCommandEvent &evt)
LyricsPanel * GetLyricsPanel()
Definition: LyricsWindow.h:27
LyricsPanel * mLyricsPanel
Definition: LyricsWindow.h:37
#define safenew
Definition: Audacity.h:230
#define LYRICS_DEFAULT_WIDTH
Definition: Lyrics.h:24
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
const wxSize gSize
bool IsAudioActive() const
Definition: Project.cpp:1447
LyricsPanel is a panel that paints the bouncing ball and the lyrics text.
Definition: Lyrics.h:71
void OnTimer(wxCommandEvent &event)
#define LYRICS_DEFAULT_HEIGHT
Definition: Lyrics.h:25
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void OnStyle_BouncingBall(wxCommandEvent &evt)
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
void Update(double t)
Definition: Lyrics.cpp:417
void OnCloseWindow(wxCloseEvent &WXUNUSED(event))
END_EVENT_TABLE()