Load GUI from XML

This commit is contained in:
2015-03-10 00:48:25 +01:00
parent 9d7dd452c7
commit 884fd8bb52
21 changed files with 1019 additions and 119 deletions

32
FontProvider.cc Normal file
View File

@@ -0,0 +1,32 @@
#include <mutex>
#include "FontProvider.hh"
template<>
std::unique_ptr<FontProvider> Singleton<FontProvider>::instance{nullptr};
template<>
std::once_flag Singleton<FontProvider>::instance_flag{};
FontProvider::FontProvider()
{
}
TTF_Font *FontProvider::getFont(std::string const& name, unsigned ptsize)
{
auto key = make_tuple(name, ptsize);
auto it = fontCache_.find(key);
if (it == fontCache_.end()) {
TTFFontUPtr font{TTF_OpenFont(name.c_str(), ptsize)};
if (!font)
throw TTFException{};
std::tie(it, std::ignore) = fontCache_.insert(make_pair(key, std::move(font)));
}
return it->second.get();
}
void FontProvider::cleanup()
{
fontCache_.clear();
}