Changing appearance of a button

To change the appearance of a button is quite simple once you learned it.


 * 1) Load the texture containing the images.
 * 2) Create an imageset and define the images you to use.
 * 3) Set the button to use custom images and which

I assume you know how to create the texture and the imageset (if not, look in the example and the documentation). In the example below I use two images, one normal and one when hovering/clicking. I think the code speaks for itself.

CEGUI::Texture* texturePtr = CEGUI::System::getSingletonPtr->getRenderer->createTexture("buttons.png","Data/Media/Menu");

CEGUI::Imageset* ButtonsImageset = CEGUI::ImagesetManager::getSingletonPtr->createImageset("Buttons",texturePtr); ButtonsImageset->defineImage("ButtonUp",CEGUI::Point(1,1),CEGUI::Size( 431, 64 ),CEGUI::Point(0.0f,0.0f)); ButtonsImageset->defineImage("ButtonDown",CEGUI::Point(1,256),CEGUI::Size( 431, 64 ),CEGUI::Point(0.0f,0.0f));

button->setProperty("UseStandardImagery", "false"); button->setProperty("NormalImage", "set:Buttons image:ButtonUp"); button->setProperty("HoverImage", "set:Buttons image:ButtonDown"); button->setProperty("PushedImage", "set:Buttons image:ButtonDown");