26#ifndef TGUI_TEXTURE_HPP
27#define TGUI_TEXTURE_HPP
31#include <TGUI/TextureData.hpp>
32#include <TGUI/Vector2f.hpp>
33#include <TGUI/Color.hpp>
34#include <SFML/System/String.hpp>
45 using CallbackFunc = std::function<void(std::shared_ptr<TextureData>)>;
46 using ImageLoaderFunc = std::function<std::unique_ptr<sf::Image>(
const sf::String&)>;
47 using TextureLoaderFunc = std::function<std::shared_ptr<TextureData>(
Texture&,
const sf::String&,
const sf::IntRect&)>;
67 const sf::IntRect& partRect = sf::IntRect(0, 0, 0, 0),
68 const sf::IntRect& middlePart = sf::IntRect(0, 0, 0, 0),
87 const sf::IntRect& partRect = sf::IntRect(0, 0, 0, 0),
88 const sf::IntRect& middlePart = sf::IntRect(0, 0, 0, 0),
107 const sf::IntRect& partRect = sf::IntRect(0, 0, 0, 0),
108 const sf::IntRect& middlePart = sf::IntRect(0, 0, 0, 0),
109 bool smooth =
false);
125 const sf::IntRect& partRect = sf::IntRect(0, 0, 0, 0),
126 const sf::IntRect& middlePart = sf::IntRect(0, 0, 0, 0));
165 const sf::IntRect& partRect = {},
166 const sf::IntRect& middleRect = {},
167 bool smooth =
false);
180 void load(
const sf::Texture& texture,
181 const sf::IntRect& partRect = {},
182 const sf::IntRect& middleRect = {});
391 void setTextureData(std::shared_ptr<TextureData> data,
const sf::IntRect& middleRect = {});
397 std::shared_ptr<TextureData> m_data =
nullptr;
399 sf::Shader* m_shader =
nullptr;
400 sf::IntRect m_middleRect;
403 CallbackFunc m_copyCallback;
404 CallbackFunc m_destructCallback;
406 static TextureLoaderFunc m_textureLoader;
407 static ImageLoaderFunc m_imageLoader;
Wrapper for colors.
Definition: Color.hpp:49
static const Color White
White predefined color.
Definition: Color.hpp:207
Wrapper class to store strings.
Definition: String.hpp:119
Definition: Texture.hpp:42
sf::IntRect getMiddleRect() const
Returns the middle rect of the texture which is used for 9-slice scaling.
static void setTextureLoader(const TextureLoaderFunc &func)
Sets a different texture loader.
const sf::String & getId() const
Returns the id that was used to load the texture (for the default loader, the id is the filename)
Texture(const Texture &)
Copy constructor.
std::shared_ptr< TextureData > getData() const
Returns the texture data.
sf::Shader * getShader() const
Returns the shader used to draw the texture.
Texture(Texture &&) noexcept
Move constructor.
void load(const sf::Texture &texture, const sf::IntRect &partRect={}, const sf::IntRect &middleRect={})
Creates the texture from an existing sf::Texture.
Vector2f getImageSize() const
Returns the size that the loaded image.
static void setImageLoader(const ImageLoaderFunc &func)
Sets a different image loader.
bool operator==(const Texture &right) const
Compares the texture with another one.
bool isTransparentPixel(sf::Vector2u pos) const
Checks if a certain pixel is transparent.
void setShader(sf::Shader *shader)
Sets the shader used to draw the texture.
bool operator!=(const Texture &right) const
Compares the texture with another one.
static const TextureLoaderFunc & getTextureLoader()
Returns the used texture loader.
void setSmooth(bool smooth)
Enables or disable the smooth filter.
void setColor(const Color &color)
Sets the global color of the texture.
Texture()
Default constructor.
Definition: Texture.hpp:54
Texture(const char *id, const sf::IntRect &partRect=sf::IntRect(0, 0, 0, 0), const sf::IntRect &middlePart=sf::IntRect(0, 0, 0, 0), bool smooth=false)
Constructor that created the texture.
Definition: Texture.hpp:66
bool isSmooth() const
Tells whether the smooth filter is enabled or not.
static const ImageLoaderFunc & getImageLoader()
Returns the used image loader.
void setCopyCallback(const CallbackFunc &func)
Sets a callback function for when this texture is copied.
const Color & getColor() const
Returns the global color of the texture.
void setDestructCallback(const CallbackFunc &func)
Sets a callback function for when this texture is destroyed.
Texture(const sf::String &id, const sf::IntRect &partRect=sf::IntRect(0, 0, 0, 0), const sf::IntRect &middlePart=sf::IntRect(0, 0, 0, 0), bool smooth=false)
Constructor that created the texture.
Texture(const std::string &id, const sf::IntRect &partRect=sf::IntRect(0, 0, 0, 0), const sf::IntRect &middlePart=sf::IntRect(0, 0, 0, 0), bool smooth=false)
Constructor that created the texture.
Definition: Texture.hpp:86
Texture(const sf::Texture &texture, const sf::IntRect &partRect=sf::IntRect(0, 0, 0, 0), const sf::IntRect &middlePart=sf::IntRect(0, 0, 0, 0))
Constructor that created the texture from an existing sf::Texture.
Definition: Vector2f.hpp:39
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:37