Audacity 3.2.0
imageCompilerMain.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file imageCompilerMain.cpp
6
7 Paul Licameli
8
9 @brief This program runs at build time only, and generates other source files.
10
11 @par
12 The generated source file headers provide the initial data for static arrays
13 of bytes. They compile sets of images for each of the built-in themes directly
14 into a library linked by Audacity.
15
16 Platform-specific provision of image resources as separate files is avoided.
17 Those files exist in the source tree in .png format, and can be easily
18 maintained by version control, but are not deployed with the program.
19
20 @par
21 See lib-theme/AllThemeResources.h for the header file that guides the
22 interpretation of a generated byte array as many separate images, and lists
23 the names of the .png files expected to be present during this build step.
24 For each name, an image file exists in each of several sub-directories. There
25 is one such directory for each of the different built-in themes.
26
27 The list of expected names is also replicated in CMakeLists.txt to make the
28 headers regenerate when the image files are updated.
29
30 There is also a Colors.txt file for each theme, associating #rrggbb values with
31 names, and AllThemeResources.h also describes the set of expected names.
32
33 @par
34 Usage: program-name absolute-path-to-folder theme-name [theme-name...]
35 For each theme, under absolute-path-to-folder/theme-name/Components, expect to find
36 the image and color files.
37 Write a header file for each theme-name in absolute-path-to-folder.
38**********************************************************************/
39
40#include <wx/app.h>
41#include <wx/image.h>
42#include <list>
43#include <iostream>
44#include "MemoryX.h"
45#include "Theme.h"
46
47class App final : public wxAppConsole {
48 bool OnInit() override;
49};
50
51IMPLEMENT_APP_NO_MAIN(App)
52
53int main(int argc, char *argv[])
54{
55 if (argc < 3) {
56 using namespace std;
57 cerr
58 << "Usage: " << argv[0]
59 << " absolute-path-to-folder theme-name [theme-name...]"
60 << endl;
61 return 1;
62 }
63 theTheme.SetFilePath(argv[1]);
64 const std::vector<unsigned char> empty;
65 std::list<ThemeBase::RegisteredTheme> registrations;
66 for (int ii = 2; ii < argc; ++ii)
67 registrations.emplace_back( EnumValueSymbol{ argv[ii], {} },
69
70 wxDISABLE_DEBUG_SUPPORT();
71
72 return wxEntry(argc, argv);
73}
74
76{
77 // Leave no persistent side-effect on preferences
79 // Don't blend colors
80 GUIBlendThemes.Write(false);
81
82 // So that the program can interpret PNG
83 wxInitAllImageHandlers();
84
87
88 // Quit without any user interaction
89 CallAfter( []{ wxExit(); } );
90 return true;
91}
static TransactionScope::Factory::Scope scope
THEME_API Theme theTheme
Definition: Theme.cpp:82
THEME_API BoolSetting GUIBlendThemes
bool OnInit() override
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:252
Makes temporary changes to preferences, then rolls them back at destruction.
Definition: Prefs.h:115
void SaveThemeAsCode()
void SetFilePath(const FilePath &path)
Definition: Theme.cpp:157
void LoadThemeComponents(bool bOkIfNotFound=false)
Definition: Theme.cpp:1036
int main(int argc, char *argv[])
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:206
STL namespace.