]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/graphic.h
Rework how widget ownership works in Container
[libs/gltk.git] / source / graphic.h
index 1647d2f811f49704ca3ce9795fdedaef637ebcb9..32a06864f9dcebf260c9f52e154b141e95660ba1 100644 (file)
@@ -1,16 +1,11 @@
-/* $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/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 {
@@ -20,20 +15,14 @@ class Resources;
 /**
 Stores a single graphical element.  Graphics are used as parts of widgets.
 */
-class Graphic
+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 &);
-               Graphic &get_object() const { return graph; }
+
        private:
                void texture(const std::string &);
                void slice(unsigned, unsigned, unsigned, unsigned);
@@ -44,18 +33,17 @@ public:
 private:
        Sides border;
        Sides shadow;
-       const GL::Texture2D *texture;
+       const GL::Texture2D *texture = nullptr;
        Geometry slice;
-       bool repeat;
+       bool repeat = false;
 
 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:
        void create_coords(float, float, float, float, float, std::vector<float> &) const;
        void create_texcoords(float, float, float, float, float, std::vector<float> &) const;