X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.h;h=e68d89fc178c16e79f20aaae6c262920077ec8f3;hb=815194201203afd6fa59e650e1007a355c829544;hp=40e44220a5b7de1b53011a14cb16d2ebe67ee6ee;hpb=131ac8ff2c06f94d40f4bf98d4a6ec0d113cdffc;p=libs%2Fgltk.git diff --git a/source/resources.h b/source/resources.h index 40e4422..e68d89f 100644 --- a/source/resources.h +++ b/source/resources.h @@ -3,60 +3,41 @@ #include #include -#include +#include +#include #include "graphic.h" #include "style.h" namespace Msp { namespace GLtk { -class Resources +/** +Stores resources such as styles and graphics. All widgets require a Resources +instance in constructor. +*/ +class Resources: public DataFile::Collection { -public: +private: + FS::Path path; + GL::Font *default_font; - class Loader: public Msp::DataFile::Loader +public: + class Loader: public Collection::Loader { - public: - Loader(Resources &); private: Resources &res; + public: + Loader(Resources &); + private: + void default_font(const std::string &); void font(const std::string &); - void texture(const std::string &); - void graphic(const std::string &); - void style(const std::string &, const std::string &); }; +public: Resources(); - ~Resources(); - const GL::Font &get_font(const std::string &) const; - const GL::Font &get_default_font() const; - const GL::Texture2D &get_texture(const std::string &) const; - const Graphic &get_graphic(const std::string &) const; - const Style &get_style(const std::string &, const std::string &) const; -private: - struct StyleId - { - std::string widget; - std::string name; - - StyleId(const std::string &w, const std::string &n): widget(w), name(n) { } - bool operator<(const StyleId &) const; - }; - typedef std::map FontMap; - typedef std::map TextureMap; - typedef std::map GraphicMap; - typedef std::map StyleMap; - - FontMap fonts; - GL::Font *default_font; - TextureMap textures; - GraphicMap graphics; - StyleMap styles; - - Resources(const Resources &); - Resources &operator=(const Resources &); + const GL::Font &get_default_font() const; }; } // namespace GLtk