TGUI  0.9-dev

Public Member Functions

 Texture ()
 Default constructor. More...
 
 Texture (const char *id, const UIntRect &partRect=UIntRect(0, 0, 0, 0), const UIntRect &middlePart=UIntRect(0, 0, 0, 0), bool smooth=false)
 Constructor that created the texture. More...
 
 Texture (const String &id, const UIntRect &partRect=UIntRect(0, 0, 0, 0), const UIntRect &middlePart=UIntRect(0, 0, 0, 0), bool smooth=false)
 Constructor that created the texture. More...
 
 Texture (const sf::Texture &texture, const UIntRect &partRect=UIntRect(0, 0, 0, 0), const UIntRect &middlePart=UIntRect(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.
 
Textureoperator= (const Texture &)
 Overload of copy assignment operator.
 
Textureoperator= (Texture &&) noexcept
 Move assignment.
 
void load (const String &id, const UIntRect &partRect={}, const UIntRect &middleRect={}, bool smooth=false)
 Creates the texture. More...
 
void load (const sf::Texture &texture, const UIntRect &partRect={}, const UIntRect &middleRect={})
 Creates the texture from an existing sf::Texture. More...
 
const StringgetId () 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...
 
Vector2u getImageSize () const
 Returns the size that the loaded image, or the size of the part if only a part of the image is loaded. More...
 
UIntRect getPartRect () const
 Returns which part of the image was loaded. 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 ColorgetColor () 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...
 
UIntRect getMiddleRect () const
 Returns the middle rect of the texture which is used for 9-slice scaling. More...
 
bool isTransparentPixel (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...
 

Constructor & Destructor Documentation

◆ Texture() [1/4]

tgui::Texture::Texture ( )
inline

Default constructor.

◆ Texture() [2/4]

tgui::Texture::Texture ( const char *  id,
const UIntRect partRect = UIntRect(0, 0, 0, 0),
const UIntRect middlePart = UIntRect(0, 0, 0, 0),
bool  smooth = false 
)
inline

Constructor that created the texture.

Parameters
idId for the the image to load (for the default loader, the id is the filename)
partRectLoad only part of the image. Pass an empty rectangle if you want to load the full image
middlePartChoose the middle part of the image for 9-slice scaling (relative to the part defined by partRect)
smoothEnable smoothing on the texture

◆ Texture() [3/4]

tgui::Texture::Texture ( const String id,
const UIntRect partRect = UIntRect(0, 0, 0, 0),
const UIntRect middlePart = UIntRect(0, 0, 0, 0),
bool  smooth = false 
)

Constructor that created the texture.

Parameters
idId for the the image to load (for the default loader, the id is the filename)
partRectLoad only part of the image. Pass an empty rectangle if you want to load the full image
middlePartChoose the middle part of the image for 9-slice scaling (relative to the part defined by partRect)
smoothEnable smoothing on the texture

This constructor just calls the corresponding load function.

◆ Texture() [4/4]

tgui::Texture::Texture ( const sf::Texture &  texture,
const UIntRect partRect = UIntRect(0, 0, 0, 0),
const UIntRect middlePart = UIntRect(0, 0, 0, 0) 
)

Constructor that created the texture from an existing sf::Texture.

Parameters
textureExisting texture to copy
partRectLoad only part of the image. Pass an empty rectangle if you want to load the full image
middlePartChoose 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.

Member Function Documentation

◆ getColor()

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.

Returns
Current color of the texture

◆ getData()

std::shared_ptr<TextureData> tgui::Texture::getData ( ) const

Returns the texture data.

Returns
Data of the texture

◆ getId()

const String& tgui::Texture::getId ( ) const

Returns the id that was used to load the texture (for the default loader, the id is the filename)

Returns
Id of the texture

◆ getImageLoader()

static const ImageLoaderFunc& tgui::Texture::getImageLoader ( )
static

Returns the used image loader.

Returns
Image loader that is currently being used
See also
setImageLoader

◆ getImageSize()

Vector2u tgui::Texture::getImageSize ( ) const

Returns the size that the loaded image, or the size of the part if only a part of the image is loaded.

Returns
Size of the image like it was when loaded (no scaling applied)

◆ getMiddleRect()

UIntRect tgui::Texture::getMiddleRect ( ) const

Returns the middle rect of the texture which is used for 9-slice scaling.

Returns
Middle rect of the texture

◆ getPartRect()

UIntRect tgui::Texture::getPartRect ( ) const

Returns which part of the image was loaded.

Returns
Part of the image that was loaded

◆ getShader()

sf::Shader* tgui::Texture::getShader ( ) const

Returns the shader used to draw the texture.

Returns
Shader currently being use to draw the texture

◆ getTextureLoader()

static const TextureLoaderFunc& tgui::Texture::getTextureLoader ( )
static

Returns the used texture loader.

Returns
Texture loader that is currently being used
See also
setTextureLoader

◆ isSmooth()

bool tgui::Texture::isSmooth ( ) const

Tells whether the smooth filter is enabled or not.

Returns
True if smoothing is enabled, false if it is disabled

◆ isTransparentPixel()

bool tgui::Texture::isTransparentPixel ( Vector2u  pos) const

Checks if a certain pixel is transparent.

Parameters
posCoordinate of the pixel
Returns
True when the pixel is transparent, false when it is not

◆ load() [1/2]

void tgui::Texture::load ( const sf::Texture &  texture,
const UIntRect partRect = {},
const UIntRect middleRect = {} 
)

Creates the texture from an existing sf::Texture.

Parameters
textureExisting texture to copy
partRectLoad only part of the texture. Don't pass this parameter if you want to load the full image
middleRectChoose 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.

◆ load() [2/2]

void tgui::Texture::load ( const String id,
const UIntRect partRect = {},
const UIntRect middleRect = {},
bool  smooth = false 
)

Creates the texture.

Parameters
idId for the the image to load (for the default loader, the id is the filename)
partRectLoad only part of the image. Don't pass this parameter if you want to load the full image
middleRectChoose the middle part of the image for 9-slice scaling (relative to the part defined by partRect)
smoothEnable smoothing on the texture

◆ setColor()

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.

Parameters
colorNew color of the texture

◆ setCopyCallback()

void tgui::Texture::setCopyCallback ( const CallbackFunc &  func)

Sets a callback function for when this texture is copied.

Parameters
funcFunction that will be called when this texture is copied

This function can be useful when implementing a resource manager.

◆ setDestructCallback()

void tgui::Texture::setDestructCallback ( const CallbackFunc &  func)

Sets a callback function for when this texture is destroyed.

Parameters
funcFunction that will be called when this texture is destroyed

This function can be useful when implementing a resource manager.

◆ setImageLoader()

static void tgui::Texture::setImageLoader ( const ImageLoaderFunc &  func)
static

Sets a different image loader.

Parameters
funcNew 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.

◆ setShader()

void tgui::Texture::setShader ( sf::Shader *  shader)

Sets the shader used to draw the texture.

Parameters
shaderNew shader to use

◆ setTextureLoader()

static void tgui::Texture::setTextureLoader ( const TextureLoaderFunc &  func)
static

Sets a different texture loader.

Parameters
funcNew 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.


The documentation for this class was generated from the following file: