Audacity 3.2.0
SplashDialog.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 SplashDialog.cpp
6
7 James Crook
8
9********************************************************************//********************************************************************/
21
22
23
24#include "SplashDialog.h"
25
26
27
28#include <wx/frame.h>
29#include <wx/html/htmlwin.h>
30#include <wx/statbmp.h>
31#include <wx/colour.h>
32#include <wx/sstream.h>
33#include <wx/txtstrm.h>
34
35#include "AllThemeResources.h"
36#include "Internat.h"
37#include "Theme.h"
38
39#include "FileNames.h"
40#include "Project.h"
41#include "ProjectWindows.h"
42#include "ShuttleGui.h"
43#include "AudacityMessageBox.h"
44#include "HelpSystem.h"
45
46#include "AllThemeResources.h"
47#include "Prefs.h"
48#include "HelpText.h"
49
50#include "../images/AudacityLogoWithName.xpm"
51
52#ifdef HAS_WHATS_NEW
53
54#include "MemoryX.h"
55#include <wx/fs_mem.h>
56
57const char* WhatsNewURL = "https://audacityteam.org/3.5.0-video";
58
59namespace
60{
61# include "../images/WhatsNewBtn.jpeg.h"
62
63struct FSHelper final
64{
65 FSHelper()
66 : mMemoryFSHandler(std::make_unique<wxMemoryFSHandler>())
67 {
68 wxFileSystem::AddHandler(mMemoryFSHandler.get());
69
70 wxMemoryFSHandler::AddFile(
71 "whats_new_btn.jpeg", bin2c_whats_new_btn_jpeg,
72 sizeof(bin2c_whats_new_btn_jpeg));
73 }
74
75 ~FSHelper()
76 {
77 wxMemoryFSHandler::RemoveFile("whats_new_btn.jpeg");
78 wxFileSystem::RemoveHandler(mMemoryFSHandler.get());
79 }
80
81private:
82 std::unique_ptr<wxMemoryFSHandler> mMemoryFSHandler;
83};
84
85} // namespace
86
87constexpr int HTMLWindowHeight = 425;
88#else
89constexpr int HTMLWindowHeight = 280;
90#endif
91
92namespace
93{
95{
96 // PRL: Is it necessary to define these outside of conditional compilation
97 // so that both get into the .pot file?
98 const auto alphamsg = XO(
99 "<br><br>The version of Audacity you are using is an <b>Alpha test version</b>.");
100 const auto betamsg = XO(
101 "<br><br>The version of Audacity you are using is a <b>Beta test version</b>.");
102
103 wxStringOutputStream o;
104 wxTextOutputStream s(o);
105 s << wxT("<body bgcolor=") << theTheme.Colour(clrTrackInfo).GetAsString(wxC2S_HTML_SYNTAX) << wxT(">")
106 << wxT("<font color=") << theTheme.Colour(clrTrackPanelText).GetAsString(wxC2S_HTML_SYNTAX) << wxT(">")
107 << wxT("<p>")
108#if defined(IS_ALPHA) || defined(IS_BETA)
109 << wxT("<center><h3>")
110 << XO("Get the Official Released Version of Audacity")
111 << wxT("</h3></center>")
112 << wxT("<center>[[https://www.audacityteam.org/download|") << XO("Check Online") << wxT("]]</center>")
113# ifdef IS_ALPHA
114 << alphamsg
115# else
116 << betamsg
117# endif
118 << wxT(" ")
119 << XO("We strongly recommend that you use our latest stable released version, which has full documentation and support.<br/><br/>")
120 << XO("You can help us get Audacity ready for release by joining our [[https://www.audacityteam.org/community/|community]].<hr/><br/><br/>")
121#endif
122
123 << wxT("<center><h3>")
124#ifndef HAS_WHATS_NEW
125 << wxT("Audacity ") << AUDACITY_VERSION_STRING
126#else
127 /* i18n-hint: %s is replaced with Audacity version */
128 << XO("What's new in Audacity %s").Format(AUDACITY_VERSION_STRING)
129 << wxT(R"(</h3><p><a href=")") << WhatsNewURL << wxT(R"(">)")
130 << wxT(
131 R"(<img src="memory:whats_new_btn.jpeg" width="263" height="148" /></a></p>)")
132 << XO("<p>In this release we added Beats & Measures, Time Stretching and more.<br/>")
133 << XO("Watch the [[%s|release video]] or read the [[https://support.audacityteam.org/additional-resources/changelog|changelog]] to learn more!</p>").Format(WhatsNewURL)
134#endif
135 << wxT("<h3>") << XO("How to get help") << wxT("</h3></center>")
136 << XO("These are our support methods:")
137 << wxT("<p><ul><li>")
138 /* i18n-hint: Preserve '[[help:Quick_Help|' as it's the name of a
139 link.*/
140 << XO("[[help:Quick_Help|Quick Help]]") << wxT("</li><li>")
141 << XO(
142 /* i18n-hint: Preserve '[[help:Main_Page|' as it's the name of a
143 link.*/
144 " [[help:Main_Page|Manual]]")
145 << wxT("</li><li>")
146 << XO("[[https://support.audacityteam.org/|Tutorials & How-tos]]")
147 << wxT("</li><li>")
148 << XO(" [[https://forum.audacityteam.org/|Forum]] - ask your question directly, online.")
149 << wxT("</li></ul></p>") << wxT("</p></font></body>");
150
151 return FormatHtmlText(o.GetString());
152}
153}
154
156
157enum
158{
160};
161
162BEGIN_EVENT_TABLE(SplashDialog, wxDialogWrapper)
164 EVT_CHECKBOX( DontShowID, SplashDialog::OnDontShow )
166
168
169void SplashDialog::DoHelpWelcome( AudacityProject &project )
170{
171 Show2( &GetProjectFrame( project ) );
172}
173
175 : wxDialogWrapper(parent, -1, XO("Welcome to Audacity!"),
176 wxPoint( -1, 60 ), // default x position, y position 60 pixels from top of screen.
177 wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
178{
179 SetName();
180 m_pLogo = NULL; //v
181 ShuttleGui S( this, eIsCreating );
182 Populate( S );
183 Fit();
184 this->Centre();
185 int x,y;
186 GetPosition( &x, &y );
187 Move( x, 60 );
188}
189
190void SplashDialog::OnChar(wxMouseEvent &event)
191{
192 if ( event.ShiftDown() && event.ControlDown() )
193 wxLaunchDefaultBrowser("https://www.audacityteam.org");
194}
195
197{
198 bool bShow;
199 gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &bShow, true );
200 S.StartVerticalLay(1);
201
202 //v For now, change to AudacityLogoWithName via old-fashioned ways, not Theme.
203 m_pLogo = std::make_unique<wxBitmap>((const char **) AudacityLogoWithName_xpm); //v
204
205
206 //Setup to scale the logo larger and smaller as necessary
207 const float fScale=1.0f;
208 wxImage RescaledImage( m_pLogo->ConvertToImage() );
209 wxColour MainColour(
210 RescaledImage.GetRed(1,1),
211 RescaledImage.GetGreen(1,1),
212 RescaledImage.GetBlue(1,1));
213 this->SetBackgroundColour(MainColour);
214
215 // wxIMAGE_QUALITY_HIGH not supported by wxWidgets 2.6.1, or we would use it here.
216 RescaledImage.Rescale( (int)(LOGOWITHNAME_WIDTH * fScale), (int)(LOGOWITHNAME_HEIGHT *fScale) );
217 wxBitmap RescaledBitmap( RescaledImage );
218 wxStaticBitmap *const icon =
219 safenew wxStaticBitmap(S.GetParent(), -1,
220 //*m_pLogo, //v theTheme.Bitmap(bmpAudacityLogoWithName),
221 RescaledBitmap,
222 wxDefaultPosition,
223 wxSize((int)(LOGOWITHNAME_WIDTH*fScale), (int)(LOGOWITHNAME_HEIGHT*fScale)));
224
225 S.Prop(0)
226#if (0)
227 .ConnectRoot( wxEVT_LEFT_DOWN, &SplashDialog::OnChar)
228#endif
229 .AddWindow( icon );
230
231 mpHtml = safenew LinkingHtmlWindow(S.GetParent(), -1,
232 wxDefaultPosition, wxSize(506, HTMLWindowHeight),
233 wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
234 mpHtml->SetPage(HelpText( wxT("welcome") ));
235 S.Prop(1)
236 .Position( wxEXPAND )
237 .AddWindow( mpHtml );
238 S.Prop(0).StartMultiColumn(2, wxEXPAND);
239 S.SetStretchyCol( 1 );// Column 1 is stretchy...
240 {
241 S.SetBorder( 5 );
242 S.Id( DontShowID).AddCheckBox( XXO("Don't show this again at start up"), !bShow );
243 S.SetBorder( 5 );
244
245 S.Id(wxID_OK)
246 .Prop(0)
247 .AddButton(XXO("OK"), wxALIGN_RIGHT| wxALL, true);
248 }
249 S.EndVerticalLay();
250}
251
253{
254}
255
256void SplashDialog::OnDontShow( wxCommandEvent & Evt )
257{
258 bool bShow = !Evt.IsChecked();
259 gPrefs->Write(wxT("/GUI/ShowSplashScreen"), bShow );
260 gPrefs->Flush();
261}
262
263void SplashDialog::OnOK(wxCommandEvent & WXUNUSED(event))
264{
265 Show( false );
266
267}
268
269void SplashDialog::Show2( wxWindow * pParent )
270{
271#ifdef HAS_WHATS_NEW
272 FSHelper helper;
273#endif // HAS_WHATS_NEW
274
275 if( pSelf == NULL )
276 {
277 // pParent owns it
278 wxASSERT(pParent);
279 pSelf = safenew SplashDialog( pParent );
280 }
281 pSelf->mpHtml->SetPage(MakeWhatsNewText());
282 pSelf->Show( true );
283}
wxImage(22, 22)
wxT("CloseDown"))
#define LOGOWITHNAME_WIDTH
#define LOGOWITHNAME_HEIGHT
IMPLEMENT_CLASS(AudioSetupToolBar, ToolBar)
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
wxString FormatHtmlText(const wxString &Text)
Definition: HelpText.cpp:258
wxString HelpText(const wxString &Key)
Definition: HelpText.cpp:238
#define safenew
Definition: MemoryX.h:10
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
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 ...
accessors for certain important windows associated with each project
@ eIsCreating
Definition: ShuttleGui.h:37
constexpr int HTMLWindowHeight
@ DontShowID
const auto project
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define S(N)
Definition: ToChars.cpp:64
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
An HtmlWindow that handles linked clicked - usually the link will go to our own local copy of the man...
Definition: HelpSystem.h:126
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
The SplashDialog shows help information for Audacity when Audacity starts up.
Definition: SplashDialog.h:21
void Populate(ShuttleGui &S)
SplashDialog(wxWindow *parent)
void OnOK(wxCommandEvent &event)
static void Show2(wxWindow *pParent)
void OnDontShow(wxCommandEvent &Evt)
void OnChar(wxMouseEvent &event)
virtual ~SplashDialog()
static SplashDialog * pSelf
Definition: SplashDialog.h:42
HtmlWindow * mpHtml
Definition: SplashDialog.h:40
std::unique_ptr< wxBitmap > m_pLogo
Definition: SplashDialog.h:41
wxColour & Colour(int iIndex)
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)
STL namespace.