]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/graphic.h
Add API declarations
[libs/gltk.git] / source / graphic.h
index a9722ad97ff3e498187fffae3ff229a4654e66ae..4fed368938016e8613e4a6132155d932889d48a0 100644 (file)
@@ -1,28 +1,28 @@
 #ifndef MSP_GLTK_GRAPHIC_H_
 #define MSP_GLTK_GRAPHIC_H_
 
+#include <msp/gl/primitivebuilder.h>
 #include <msp/gl/texture2d.h>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
 #include "geometry.h"
+#include "mspgltk_api.h"
 
 namespace Msp {
 namespace GLtk {
 
 class Resources;
 
-class Graphic
+/**
+Stores a single graphical element.  Graphics are used as parts of widgets.
+*/
+class MSPGLTK_API Graphic
 {
 public:
-       class Loader: public DataFile::Loader
+       class Loader: public DataFile::CollectionObjectLoader<Graphic, Resources>
        {
-       private:
-               Graphic &graph;
-               Resources &res;
-
        public:
-               typedef Resources Collection;
-
                Loader(Graphic &, Resources &);
+
        private:
                void texture(const std::string &);
                void slice(unsigned, unsigned, unsigned, unsigned);
@@ -30,18 +30,24 @@ public:
                void shadow();
        };
 
+private:
+       Sides border;
+       Sides shadow;
+       const GL::Texture2D *texture;
+       Geometry slice;
+       bool repeat;
+
+public:
        Graphic();
        const Sides &get_border() const { return border; }
        const Sides &get_shadow() const { return shadow; }
        const GL::Texture2D *get_texture() const { return texture; }
        unsigned get_width() const  { return slice.w; }
        unsigned get_height() const { return slice.h; }
-       void render(unsigned, unsigned) const;
+       void build(unsigned, unsigned, GL::PrimitiveBuilder &) const;
 private:
-       Sides border;
-       Sides shadow;
-       const GL::Texture2D *texture;
-       Geometry slice;
+       void create_coords(float, float, float, float, float, std::vector<float> &) const;
+       void create_texcoords(float, float, float, float, float, std::vector<float> &) const;
 };
 
 } // namespace GLtk