MCPcopy Create free account
hub / github.com/audacity/audacity / LoadOneThemeComponents

Method LoadOneThemeComponents

libraries/lib-theme/Theme.cpp:979–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

977}
978
979void ThemeBase::LoadOneThemeComponents( teThemeType id, bool bOkIfNotFound )
980{
981 SwitchTheme( id );
982 auto &resources = *mpSet;
983 // IF directory doesn't exist THEN return early.
984 const auto dir = ThemeComponentsDir(GetFilePath(), id);
985 if( !wxDirExists( dir ))
986 return;
987
988 using namespace BasicUI;
989
990 int n=0;
991 FilePath FileName;
992 for (size_t i = 0; i < resources.mImages.size(); ++i)
993 {
994 if( !(mBitmapFlags[i] & resFlagInternal) )
995 {
996 FileName = ThemeComponent( dir, mBitmapNames[i] );
997 if( wxFileExists( FileName ))
998 {
999 if( !resources.mImages[i].LoadFile( FileName, wxBITMAP_TYPE_PNG ))
1000 {
1001 ShowMessageBox(
1002 XO(
1003 /* i18n-hint: Do not translate png. It is the name of a file format.*/
1004"Audacity could not load file:\n %s.\nBad png format perhaps?")
1005 .Format( FileName ));
1006 return;
1007 }
1008 /// JKC: \bug (wxWidgets) A png may have been saved with alpha, but when you
1009 /// load it, it comes back with a mask instead! (well I guess it is more
1010 /// efficient). Anyway, we want alpha and not a mask, so we call InitAlpha,
1011 /// and that transfers the mask into the alpha channel, and we're done.
1012 if( ! resources.mImages[i].HasAlpha() )
1013 {
1014 // wxLogDebug( wxT("File %s lacked alpha"), mBitmapNames[i] );
1015 resources.mImages[i].InitAlpha();
1016 }
1017 resources.mBitmaps[i] = wxBitmap( resources.mImages[i] );
1018 n++;
1019 }
1020 }
1021 }
1022
1023 // Now read complete information about the colors from one text file
1024 {
1025 const auto fName = wxFileName{ dir, ColorFileName }.GetFullPath();
1026 wxTextFile file{ fName };
1027 file.Open();
1028 if (!file.IsOpened())
1029 ShowMessageBox( XO("Couldn't read from file: %s").Format( fName ) );
1030 else {
1031 ++n;
1032 // Scan the line for name and #xxxxxx;
1033 static const std::wregex expr{
1034 LR"(^ *([_[:alnum:]]+).*#([0-9a-fA-F]{6});)" };
1035 const auto begin = mColourNames.begin(),
1036 end = mColourNames.end();

Callers

nothing calls this directly

Calls 13

ThemeComponentsDirFunction · 0.85
ThemeComponentFunction · 0.85
ShowMessageBoxFunction · 0.85
VerbatimFunction · 0.85
LoadFileMethod · 0.80
IsOpenedMethod · 0.80
EofMethod · 0.80
wxBitmapClass · 0.70
sizeMethod · 0.45
OpenMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected