The tgui::Texture class did contain a setTextureRect function but it does not do the same as the one from sf::Sprite. It could work with the tgui version that you have but it would require setting a different position and size to the picture to compensate for the side-effects of setTextureRect.
I have however made some changes now to make it possible, but you will have to download tgui from github and compile it yourself again.
After that you can use code like this:
The last parameter to the tgui::Texture constructor is the sf::IntRect of course which defines the part of the texture that you want. Note that due to the way tgui is designed, creating an tgui::Texture with this IntRect parameter is a slow operation. The texture is first copied to an sf::Image to then create a new sf::Texture from it with the requested size.
I have however made some changes now to make it possible, but you will have to download tgui from github and compile it yourself again.
After that you can use code like this:
Code (cpp) Select
sf::Texture sfTexture;
sfTexture.loadFromFile("Linux.jpg");
auto picture = std::make_shared<tgui::Picture>(tgui::Texture{sfTexture, {200, 100, 400, 400}});The last parameter to the tgui::Texture constructor is the sf::IntRect of course which defines the part of the texture that you want. Note that due to the way tgui is designed, creating an tgui::Texture with this IntRect parameter is a slow operation. The texture is first copied to an sf::Image to then create a new sf::Texture from it with the requested size.
. My exams are over and I still have one more week before the next semester starts. So any relatively small feature requests can be implemented immediately during this time.