X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.h;h=52da3952916fb780cb873716d30f9381b86824d1;hb=2b70e8801c43875ed3f4135bdd0141265cff0312;hp=001fa632b2a2a275776199d5795fa7451cf2d4b6;hpb=c1f038acb91eb3bfaa34dfd4729d19ed3f871a42;p=libs%2Fgltk.git diff --git a/source/resources.h b/source/resources.h index 001fa63..52da395 100644 --- a/source/resources.h +++ b/source/resources.h @@ -3,60 +3,49 @@ #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::Parser::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 &); + void style(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; + 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; - }; + void init(); - 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 &); +public: + void set_path(const FS::Path &); + const GL::Font &get_default_font() const; +private: + GL::Font *create_font(const std::string &); + GL::Texture2D *create_texture(const std::string &); }; } // namespace GLtk