X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphic.h;h=1647d2f811f49704ca3ce9795fdedaef637ebcb9;hb=6081ed9020ad22214a8e5b3829092f97b12d7c71;hp=16d8cf406a006096e95fc31778136e6996384d2a;hpb=c1f038acb91eb3bfaa34dfd4729d19ed3f871a42;p=libs%2Fgltk.git diff --git a/source/graphic.h b/source/graphic.h index 16d8cf4..1647d2f 100644 --- a/source/graphic.h +++ b/source/graphic.h @@ -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 -#include +#include #include "geometry.h" namespace Msp { @@ -10,42 +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(); }; - struct Sides - { - class Loader: public Parser::Loader - { - public: - Loader(Sides &); - Sides &get_object() { return sides; } - private: - Sides &sides; - }; - - unsigned top; - unsigned right; - unsigned bottom; - unsigned left; - - Sides(); - }; +private: + Sides border; + Sides shadow; + const GL::Texture2D *texture; + Geometry slice; + bool repeat; - Graphic(const Resources &, const std::string &); +public: + Graphic(); const Sides &get_border() const { return border; } const Sides &get_shadow() const { return shadow; } const GL::Texture2D *get_texture() const { return texture; } @@ -53,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 &) const; + void create_texcoords(float, float, float, float, float, std::vector &) const; }; } // namespace GLtk