Theme files can now specify 'smooth' option behind textures

0.8
Bruno Van de Velde 2017-08-16 20:21:34 +02:00
parent b37ec528a8
commit d0b052bcdd
3 changed files with 22 additions and 8 deletions

View File

@ -62,8 +62,9 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture(const char* id,
const sf::IntRect& partRect = sf::IntRect(0, 0, 0, 0),
const sf::IntRect& middlePart = sf::IntRect(0, 0, 0, 0))
: Texture(sf::String{id}, partRect, middlePart)
const sf::IntRect& middlePart = sf::IntRect(0, 0, 0, 0),
bool smooth = false)
: Texture(sf::String{id}, partRect, middlePart, smooth)
{
}
@ -80,8 +81,9 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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))
: Texture(sf::String{id}, partRect, middlePart)
const sf::IntRect& middlePart = sf::IntRect(0, 0, 0, 0),
bool smooth = false)
: Texture(sf::String{id}, partRect, middlePart, smooth)
{
}
@ -98,7 +100,8 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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));
const sf::IntRect& middlePart = sf::IntRect(0, 0, 0, 0),
bool smooth = false);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -360,6 +360,7 @@ namespace tgui
// There may be optional parameters
sf::IntRect partRect;
sf::IntRect middleRect;
bool smooth = false;
while (removeWhitespace(value, c))
{
@ -368,7 +369,15 @@ namespace tgui
if (openingBracketPos != std::string::npos)
word = value.substr(c - value.begin(), openingBracketPos - (c - value.begin()));
else
throw Exception{"Failed to deserialize texture '" + value + "'. Invalid text found behind filename."};
{
if (toLower(trim(value.substr(c - value.begin()))) == "smooth")
{
smooth = true;
break;
}
else
throw Exception{"Failed to deserialize texture '" + value + "'. Invalid text found behind filename."};
}
sf::IntRect* rect = nullptr;
if ((word == "Part") || (word == "part"))
@ -401,7 +410,7 @@ namespace tgui
std::advance(c, closeBracketPos - (c - value.begin()) + 1);
}
return Texture{getResourcePath() + filename, partRect, middleRect};
return Texture{getResourcePath() + filename, partRect, middleRect, smooth};
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -45,9 +45,11 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture::Texture(const sf::String& id, const sf::IntRect& partRect, const sf::IntRect& middlePart)
Texture::Texture(const sf::String& id, const sf::IntRect& partRect, const sf::IntRect& middlePart, bool smooth)
{
load(id, partRect, middlePart);
if (smooth)
setSmooth(smooth);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////