[SOLVED] Custom images for PushButtons

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

eXt
Just popping in
Just popping in
Posts: 6
Joined: Wed May 10, 2006 11:28

[SOLVED] Custom images for PushButtons

Postby eXt » Wed May 10, 2006 12:27

I've been reading the tutorials and searched the forums for this, but I cant find anything that works.

This is the code I'm using:

Code: Select all

      CEGUI::Texture* texturePtr = CEGUI::System::getSingletonPtr()->getRenderer()->createTexture("menubuttons.jpg","Data/Media/Menu");
      CEGUI::Imageset* ButtonsImageset = CEGUI::ImagesetManager::getSingletonPtr()->createImageset("Buttons", texturePtr);
      ButtonsImageset->defineImage("ButtonUp", CEGUI::Point(0.0f,0.0f), CEGUI::Size( 0.5f, 0.5f ), CEGUI::Point(0.0f,0.0f));
      ButtonsImageset->defineImage("ButtonDown", CEGUI::Point(0.0f,0.5f), CEGUI::Size( 0.5f, 0.5f ), CEGUI::Point(0.0f,0.0f));

      CEGUI::RenderableImage *bleh = new CEGUI::RenderableImage();
      CEGUI::RenderableImage *bleh2 = new CEGUI::RenderableImage();
      bleh->setImage( &ButtonsImageset->getImage("ButtonUp") );
      bleh2->setImage( &ButtonsImageset->getImage("ButtonDown") );

      CEGUI::PushButton *button = (CEGUI::PushButton *)CEGUI::WindowManager::getSingletonPtr()->createWindow("TaharezLook/Button", (CEGUI::utf8*)name);
      
      button->setStandardImageryEnabled(false);
      button->setCustomImageryAutoSized(true);
      button->setNormalImage( bleh );
      button->setHoverImage( bleh2 );
      button->setPushedImage( bleh2 );


Nothing shows up, just the text. If I don't set setStandardImageryEnable() the button looks like it normaly would.

What am I doing wrong?
Last edited by eXt on Fri May 12, 2006 10:42, edited 1 time in total.

User avatar
DrPain
Not too shy to talk
Not too shy to talk
Posts: 24
Joined: Thu Mar 17, 2005 15:19

Postby DrPain » Wed May 10, 2006 18:11

Try the setProperty function:

Code: Select all

   rootWindow->getChild(ButtonZoomOutID)->setProperty("NormalImage", "set:TaharezLook image:ZoomOutButtonNormal");
   rootWindow->getChild(ButtonZoomOutID)->setProperty("HoverImage", "set:TaharezLook image:ZoomOutButtonHighlight");
   rootWindow->getChild(ButtonZoomOutID)->setProperty("PushedImage", "set:TaharezLook image:ZoomOutButtonPushed");

eXt
Just popping in
Just popping in
Posts: 6
Joined: Wed May 10, 2006 11:28

Postby eXt » Fri May 12, 2006 10:29

That is able to set the image but it seems the image isn't scaled to fit or something. It reads only the first pixel of the image.

I think "setCustomImageryAutoSized(true)" should fix this but it doesn't.

EDIT: Solved it, when defining the images in the imageset I shold specify coordinates in pixels, not a value between 0 and 1 as I did.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 7 guests