]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/resources.h
Rework how widget ownership works in Container
[libs/gltk.git] / source / resources.h
index 52da3952916fb780cb873716d30f9381b86824d1..7569119a35109d6d46c6b94501b70bc7eabd9472 100644 (file)
@@ -1,26 +1,28 @@
 #ifndef MSP_GLTK_RESOURCES_H_
 #define MSP_GLTK_RESOURCES_H_
 
+#include <memory>
 #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/collection.h>
+#include <msp/datafile/directorysource.h>
 #include <msp/fs/path.h>
 #include "graphic.h"
+#include "mspgltk_api.h"
 #include "style.h"
 
 namespace Msp {
 namespace GLtk {
 
 /**
-Stores resources such as styles and graphics.  All widgets require a Resources
-instance in constructor.
+Stores resources such as styles and graphics.  The Root widget requires a
+Resources instance as constructor parameter.
 */
-class Resources: public DataFile::Collection
+class MSPGLTK_API Resources: public DataFile::Collection
 {
-private:
-       FS::Path path;
-       GL::Font *default_font;
-
 public:
        class Loader: public Collection::Loader
        {
@@ -29,22 +31,28 @@ public:
 
        public:
                Loader(Resources &);
+
        private:
                void default_font(const std::string &);
                void font(const std::string &);
-               void style(const std::string &);
        };
 
-       Resources();
-       Resources(const FS::Path &);
 private:
-       void init();
+       FS::Path path;
+       GL::Font *default_font = nullptr;
+       std::unique_ptr<DataFile::DirectorySource> dir_src;
 
 public:
-       void set_path(const FS::Path &);
+       Resources();
+       Resources(const FS::Path &);
+
        const GL::Font &get_default_font() const;
+       const GL::Sampler &get_default_sampler() const;
+
 private:
-       GL::Font *create_font(const std::string &);
+       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 &);
 };