]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/graphic.h
Reorder class members
[libs/gltk.git] / source / graphic.h
index f4cc907223a3ea6fd9a009fefb0f4b0013bbd6f9..1647d2f811f49704ca3ce9795fdedaef637ebcb9 100644 (file)
@@ -1,8 +1,15 @@
+/* $Id$
+
+This file is part of libmspgltk
+Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
 #ifndef MSP_GLTK_GRAPHIC_H_
 #define MSP_GLTK_GRAPHIC_H_
 
 #include <msp/gl/texture2d.h>
-#include <msp/parser/loader.h>
+#include <msp/datafile/loader.h>
 #include "geometry.h"
 
 namespace Msp {
@@ -10,23 +17,39 @@ namespace GLtk {
 
 class Resources;
 
+/**
+Stores a single graphical element.  Graphics are used as parts of widgets.
+*/
 class Graphic
 {
 public:
-       class Loader: public Parser::Loader
+       class Loader: public DataFile::Loader
        {
-       public:
-               Loader(Graphic &);
        private:
                Graphic &graph;
+               Resources &res;
+
+       public:
+               typedef Resources Collection;
 
+               Loader(Graphic &, Resources &);
+               Graphic &get_object() const { return graph; }
+       private:
                void texture(const std::string &);
                void slice(unsigned, unsigned, unsigned, unsigned);
                void border();
                void shadow();
        };
 
-       Graphic(const Resources &, const std::string &);
+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; }
@@ -34,12 +57,8 @@ public:
        unsigned get_height() const { return slice.h; }
        void render(unsigned, unsigned) const;
 private:
-       const Resources &res;
-       std::string name;
-       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