TGUI  v0.6.10
TextureManager.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012-2015 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_TEXTURE_MANAGER_HPP
27 #define TGUI_TEXTURE_MANAGER_HPP
28 
30 
31 #include <list>
32 
34 
35 namespace tgui
36 {
38 
39  struct TextureData
40  {
41  TextureData() : image(nullptr) {}
42 
43  sf::Image* image;
44  sf::Texture texture;
45  sf::IntRect rect;
46  std::string filename;
47  unsigned int users;
48  };
49 
51 
52  struct Texture
53  {
55 
56  Texture();
57 
58  sf::Vector2u getSize() const;
59  bool isTransparentPixel(unsigned int x, unsigned int y);
60 
61  operator const sf::Sprite&() const;
62 
64 
65  TextureData* data;
66  sf::Sprite sprite;
67  };
68 
70 
71  class TGUI_API TextureManager : public sf::NonCopyable
72  {
73  public:
74 
85  bool getTexture(const std::string& filename, Texture& texture, const sf::IntRect& rect = sf::IntRect(0, 0, 0, 0));
86 
87 
95  bool copyTexture(const Texture& textureToCopy, Texture& newTexture);
96 
97 
106  void removeTexture(Texture& textureToRemove);
107 
108 
110  protected:
111 
113  {
114  sf::Image image;
115  std::list<TextureData> data;
116  };
117 
118  std::map<std::string, ImageMapData> m_ImageMap;
119  };
120 
122 }
123 
125 
126 #endif // TGUI_TEXTURE_MANAGER_HPP
Namespace that contains all TGUI functions and classes.
Definition: AnimatedPicture.hpp:33
Definition: TextureManager.hpp:52
Definition: TextureManager.hpp:39
Definition: TextureManager.hpp:71
Definition: TextureManager.hpp:112