X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.h;h=87b8364148053581d142070d274fe24439f1e47c;hb=c8291177b545ec81930603a5915234a60296db51;hp=001fa632b2a2a275776199d5795fa7451cf2d4b6;hpb=c1f038acb91eb3bfaa34dfd4729d19ed3f871a42;p=libs%2Fgltk.git diff --git a/source/resources.h b/source/resources.h index 001fa63..87b8364 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: - - class Loader: public Msp::Parser::Loader + 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 &); }; - 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; - }; + FS::Path path; + GL::Font *default_font; + DataFile::DirectorySource *dir_src; - typedef std::map FontMap; - typedef std::map TextureMap; - typedef std::map GraphicMap; - typedef std::map StyleMap; +public: + Resources(); + Resources(const FS::Path &); +private: + 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