Audacity
3.2.0
libraries
image-compiler
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
47
class
App
final :
public
wxAppConsole {
48
bool
OnInit
()
override
;
49
};
50
51
IMPLEMENT_APP_NO_MAIN(
App
)
52
53
int
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], {} },
68
PreferredSystemAppearance::Light
, empty );
69
70
wxDISABLE_DEBUG_SUPPORT();
71
72
return
wxEntry(
argc
,
argv
);
73
}
74
75
bool
App::OnInit
()
76
{
77
// Leave no persistent side-effect on preferences
78
SettingScope
scope
;
79
80
// So that the program can interpret PNG
81
wxInitAllImageHandlers();
82
83
theTheme
.
LoadThemeComponents
();
84
theTheme
.
SaveThemeAsCode
();
85
86
// Quit without any user interaction
87
CallAfter
( []{ wxExit(); } );
88
return
true
;
89
}
MemoryX.h
theTheme
THEME_API Theme theTheme
Definition:
Theme.cpp:82
Theme.h
PreferredSystemAppearance::Light
@ Light
App
Definition:
imageCompilerMain.cpp:47
App::OnInit
bool OnInit() override
Definition:
imageCompilerMain.cpp:75
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition:
ComponentInterfaceSymbol.h:27
SettingScope
Makes temporary changes to preferences, then rolls them back at destruction.
Definition:
Prefs.h:120
ThemeBase::SaveThemeAsCode
void SaveThemeAsCode()
ThemeBase::SetFilePath
void SetFilePath(const FilePath &path)
Definition:
Theme.cpp:157
ThemeBase::LoadThemeComponents
void LoadThemeComponents(bool bOkIfNotFound=false)
Definition:
Theme.cpp:972
main
int main(int argc, char *argv[])
Definition:
imageCompilerMain.cpp:53
BasicUI::CallAfter
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition:
BasicUI.cpp:214
CommandLineArgs::argv
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
Definition:
CommandLineArgs.cpp:13
CommandLineArgs::argc
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.
Definition:
CommandLineArgs.cpp:12
anonymous_namespace{wxCommandTargets.cpp}::scope
static CommandContext::TargetFactory::SubstituteInUnique< InteractiveOutputTargets > scope
Definition:
wxCommandTargets.cpp:190
std
STL namespace.
Generated by
1.9.3