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

42
FontProvider.hh Normal file
View File

@@ -0,0 +1,42 @@
#ifndef __OPENGLPLAYGROUND_FONTPROVIDER_HH__
#define __OPENGLPLAYGROUND_FONTPROVIDER_HH__
#include <memory>
#include <unordered_map>
#include <tuple>
#include <string>
#include "common.hh"
#include "Singleton.hh"
using FontProviderKeyType = std::tuple<std::string, unsigned>;
namespace std
{
template<>
struct hash<FontProviderKeyType> {
typedef FontProviderKeyType argument_type;
typedef std::size_t result_type;
result_type operator()(argument_type const& s) const {
const result_type h1{std::hash<std::string>()(std::get<0>(s))};
const result_type h2{std::hash<unsigned>()(std::get<1>(s))};
return h1 ^ h2;
}
};
}
class FontProvider : public Singleton<FontProvider> {
private:
FontProvider();
friend class Singleton<FontProvider>;
public:
TTF_Font *getFont(std::string const& name, unsigned ptsize);
void cleanup();
private:
std::unordered_map<std::tuple<std::string, unsigned>, TTFFontUPtr> fontCache_;
};
#endif