]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/resources.h
Adjust things to conform to changes in other libraries
[libs/gltk.git] / source / resources.h
index 40e44220a5b7de1b53011a14cb16d2ebe67ee6ee..772b72958735a6d34379ff3129204ab11249c27e 100644 (file)
@@ -2,61 +2,59 @@
 #define MSP_GLTK_RESOURCES_H_
 
 #include <msp/gl/font.h>
+#include <msp/gl/module.h>
+#include <msp/gl/program.h>
+#include <msp/gl/sampler.h>
 #include <msp/gl/texture.h>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/collection.h>
+#include <msp/datafile/directorysource.h>
+#include <msp/fs/path.h>
 #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::DataFile::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<std::string, GL::Font *> FontMap;
-       typedef std::map<std::string, GL::Texture2D *> TextureMap;
-       typedef std::map<std::string, Graphic> GraphicMap;
-       typedef std::map<StyleId, Style> 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;
+       const GL::Sampler &get_default_sampler() const;
 
-       Resources(const Resources &);
-       Resources &operator=(const Resources &);
+private:
+       GL::Module *create_module(const std::string &);
+       GL::Program *create_program(const std::string &);
+       GL::Sampler *create_sampler(const std::string &);
+       GL::Texture2D *create_texture(const std::string &);
 };
 
 } // namespace GLtk