I need to creates some buttons "on the fly", and these buttons display images that are stored in a folder of my project.
I can't use some ".imageset" file, because it's totally dynamic.
So the solution I've found is to create an imageset, define an image that is 100%*100% of this imageset, and bind this image to my widget.
Is it the fastiest way to acheive it?
I do like that:
Code: Select all
CustomButton* button = static_cast<CustomButton*>(wmgr.createWindow( "MyWidgets/CustomButton" ));
try
{
std::string imageSetName(button->getName().c_str()); //Define a unique imageSet using the unique name of the button given my the WindowManager
std::string imageURL(button->getIdStr().c_str()); //This custom property is my Image URL
//Creates an imageset, and a 100%*100% image
CEGUI::Imageset& imageSet = CEGUI::ImagesetManager::getSingleton().createFromImageFile(imageSetName,imageURL,"");
imageSet.defineImage("fullimage", Point(0.0f,0.0f), imageSet.getNativeResolution(), Point(0.0f,0.0f));
//Bind the image the widget
button->setProperty("NormalImage", String("set:")+ imageSetName +" image:fullimage");
}
catch( CEGUI::FileIOException &e )
{
CEGUI::Logger::getSingleton().logEvent(e.getFullDescription() + " : " + e.getFile());
//Use a common image, is the URL of the image is wrong
item->setProperty( "NormalImage", "set:MyIcons image:dummyImage" );
}
But I regularly need to destroy my widgets, and I don't know if the ImageSets that are bound to are also destroyed ?
Do I need to manage Imageset destruction, to remove the textures from the memory?