Page 1 of 1

[SOLVED] Custom images for PushButtons

Posted: Wed May 10, 2006 12:27
by eXt
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?

Posted: Wed May 10, 2006 18:11
by DrPain
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");

Posted: Fri May 12, 2006 10:29
by eXt
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.