TGUI
0.8.9
|
Public Member Functions | |
Texture () | |
Default constructor. | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Texture (const Texture &) | |
Copy constructor. | |
Texture (Texture &&) noexcept | |
Move constructor. | |
~Texture () | |
Destructor. | |
Texture & | operator= (const Texture &) |
Overload of copy assignment operator. | |
Texture & | operator= (Texture &&) noexcept |
Move assignment. | |
void | load (const sf::String &id, const sf::IntRect &partRect={}, const sf::IntRect &middleRect={}, bool smooth=false) |
Creates the texture. More... | |
void | load (const sf::Texture &texture, const sf::IntRect &partRect={}, const sf::IntRect &middleRect={}) |
Creates the texture from an existing sf::Texture. More... | |
const sf::String & | getId () const |
Returns the id that was used to load the texture (for the default loader, the id is the filename) More... | |
std::shared_ptr< TextureData > | getData () const |
Returns the texture data. More... | |
Vector2f | getImageSize () const |
Returns the size that the loaded image. More... | |
void | setSmooth (bool smooth) |
Enables or disable the smooth filter. More... | |
bool | isSmooth () const |
Tells whether the smooth filter is enabled or not. More... | |
void | setColor (const Color &color) |
Sets the global color of the texture. More... | |
const Color & | getColor () const |
Returns the global color of the texture. More... | |
void | setShader (sf::Shader *shader) |
Sets the shader used to draw the texture. More... | |
sf::Shader * | getShader () const |
Returns the shader used to draw the texture. More... | |
sf::IntRect | getMiddleRect () const |
Returns the middle rect of the texture which is used for 9-slice scaling. More... | |
bool | isTransparentPixel (sf::Vector2u pos) const |
Checks if a certain pixel is transparent. More... | |
void | setCopyCallback (const CallbackFunc &func) |
Sets a callback function for when this texture is copied. More... | |
void | setDestructCallback (const CallbackFunc &func) |
Sets a callback function for when this texture is destroyed. More... | |
bool | operator== (const Texture &right) const |
Compares the texture with another one. | |
bool | operator!= (const Texture &right) const |
Compares the texture with another one. | |
Static Public Member Functions | |
static void | setImageLoader (const ImageLoaderFunc &func) |
Sets a different image loader. More... | |
static const ImageLoaderFunc & | getImageLoader () |
Returns the used image loader. More... | |
static void | setTextureLoader (const TextureLoaderFunc &func) |
Sets a different texture loader. More... | |
static const TextureLoaderFunc & | getTextureLoader () |
Returns the used texture loader. More... | |
|
inline |
Constructor that created the texture.
id | Id for the the image to load (for the default loader, the id is the filename) |
partRect | Load only part of the image. Pass an empty rectangle if you want to load the full image |
middlePart | Choose the middle part of the image for 9-slice scaling (relative to the part defined by partRect) |
smooth | Enable smoothing on the texture |
|
inline |
Constructor that created the texture.
id | Id for the the image to load (for the default loader, the id is the filename) |
partRect | Load only part of the image. Pass an empty rectangle if you want to load the full image |
middlePart | Choose the middle part of the image for 9-slice scaling (relative to the part defined by partRect) |
smooth | Enable smoothing on the texture |
This constructor just calls the corresponding load function.
tgui::Texture::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.
id | Id for the the image to load (for the default loader, the id is the filename) |
partRect | Load only part of the image. Pass an empty rectangle if you want to load the full image |
middlePart | Choose the middle part of the image for 9-slice scaling (relative to the part defined by partRect) |
smooth | Enable smoothing on the texture |
This constructor just calls the corresponding load function.
tgui::Texture::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.
texture | Existing texture to copy |
partRect | Load only part of the image. Pass an empty rectangle if you want to load the full image |
middlePart | Choose the middle part of the image for 9-slice scaling (relative to the part defined by partRect) |
The texture will be copied, you do not have to keep the sf::Texture alive after calling this function.
This constructor just calls the corresponding load function.
const Color & tgui::Texture::getColor | ( | ) | const |
Returns the global color of the texture.
This color is modulated (multiplied) with the pixel color. It can be used to colorize the texture, or change its global opacity. Note that the alpha component is multiplied with the opacity of the widget.
By default, the texture's color is opaque white.
std::shared_ptr< TextureData > tgui::Texture::getData | ( | ) | const |
Returns the texture data.
const sf::String & tgui::Texture::getId | ( | ) | const |
Returns the id that was used to load the texture (for the default loader, the id is the filename)
|
static |
Returns the used image loader.
Vector2f tgui::Texture::getImageSize | ( | ) | const |
Returns the size that the loaded image.
sf::IntRect tgui::Texture::getMiddleRect | ( | ) | const |
Returns the middle rect of the texture which is used for 9-slice scaling.
sf::Shader * tgui::Texture::getShader | ( | ) | const |
Returns the shader used to draw the texture.
|
static |
Returns the used texture loader.
bool tgui::Texture::isSmooth | ( | ) | const |
Tells whether the smooth filter is enabled or not.
bool tgui::Texture::isTransparentPixel | ( | sf::Vector2u | pos | ) | const |
Checks if a certain pixel is transparent.
pos | Coordinate of the pixel |
void tgui::Texture::load | ( | const sf::String & | id, |
const sf::IntRect & | partRect = {} , |
||
const sf::IntRect & | middleRect = {} , |
||
bool | smooth = false |
||
) |
Creates the texture.
id | Id for the the image to load (for the default loader, the id is the filename) |
partRect | Load only part of the image. Don't pass this parameter if you want to load the full image |
middleRect | Choose the middle part of the image for 9-slice scaling (relative to the part defined by partRect) |
smooth | Enable smoothing on the texture |
void tgui::Texture::load | ( | const sf::Texture & | texture, |
const sf::IntRect & | partRect = {} , |
||
const sf::IntRect & | middleRect = {} |
||
) |
Creates the texture from an existing sf::Texture.
texture | Existing texture to copy |
partRect | Load only part of the texture. Don't pass this parameter if you want to load the full image |
middleRect | Choose the middle part of the image for 9-slice scaling (relative to the part defined by partRect) |
The texture will be copied, you do not have to keep the sf::Texture alive after calling this function.
void tgui::Texture::setColor | ( | const Color & | color | ) |
Sets the global color of the texture.
This color is modulated (multiplied) with the pixel color. It can be used to colorize the texture, or change its global opacity. Note that the alpha component is multiplied with the opacity of the widget.
By default, the texture's color is opaque white.
color | New color of the texture |
void tgui::Texture::setCopyCallback | ( | const CallbackFunc & | func | ) |
Sets a callback function for when this texture is copied.
func | Function that will be called when this texture is copied |
This function can be useful when implementing a resource manager.
void tgui::Texture::setDestructCallback | ( | const CallbackFunc & | func | ) |
Sets a callback function for when this texture is destroyed.
func | Function that will be called when this texture is destroyed |
This function can be useful when implementing a resource manager.
|
static |
Sets a different image loader.
func | New image loader function |
The image loader will be called inside the texture loader to create the sf::Image.
The default loader will simply load the image from a file.
void tgui::Texture::setShader | ( | sf::Shader * | shader | ) |
Sets the shader used to draw the texture.
shader | New shader to use |
void tgui::Texture::setSmooth | ( | bool | smooth | ) |
Enables or disable the smooth filter.
When the filter is activated, the texture appears smoother so that pixels are less noticeable. However if you want the texture to look exactly the same as its source file, you should leave it disabled. The smooth filter is disabled by default.
smooth | True to enable smoothing, false to disable it |
|
static |
Sets a different texture loader.
func | New texture loader function |
The texture loader will initialize this Texture object.
The default loader will use an internal texture manager to prevent the same thing from being loaded twice.