X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.h;h=d83c2087543e75c1e6371f0c74cd6a7cdc6d0e2b;hb=c2f044fa885deb5a131f19902c88be0bc970ecac;hp=40e44220a5b7de1b53011a14cb16d2ebe67ee6ee;hpb=131ac8ff2c06f94d40f4bf98d4a6ec0d113cdffc;p=libs%2Fgltk.git diff --git a/source/resources.h b/source/resources.h index 40e4422..d83c208 100644 --- a/source/resources.h +++ b/source/resources.h @@ -3,60 +3,51 @@ #include #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; + DataFile::DirectorySource *dir_src; - 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; + Resources(const FS::Path &); 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; + void init(); +public: + ~Resources(); - FontMap fonts; - GL::Font *default_font; - TextureMap textures; - GraphicMap graphics; - StyleMap styles; + const GL::Font &get_default_font() const; - Resources(const Resources &); - Resources &operator=(const Resources &); +private: + GL::Texture2D *create_texture(const std::string &); }; } // namespace GLtk