Page 1 of 1

StaticImage in code [solved]

Posted: Tue Aug 29, 2006 20:08
by Jake
I've been screwing around with integrating Ogre, OIS and CEGUI. I'm experimenting with different methods of creating widgets and have been successful using types defined in the TaharezLook scheme. I'd now like to try subscribing some handlers to a StaticImage, but cannot get the StaticImage itself to display. Here is the relevant code.

pTex is TexturePtr to a valid Ogre texture.

Code: Select all


   CEGUI::StaticImage * statImage = (CEGUI::StaticImage *)guiWindowMgr.createWindow("TaharezLook/StaticImage", "testImage");
   CEGUI::Texture* testTex = guiRenderer->createTexture(pTex);
   CEGUI::Imageset* rttImageSet = CEGUI::ImagesetManager::getSingleton().createImageset((CEGUI::utf8*)"RttImageset",testTex);
   rttImageSet->defineImage((CEGUI::utf8*)"BonusImage",
      CEGUI::Point(CEGUI::Vector2(0,0)),
      CEGUI::Size(testTex->getWidth(), testTex->getHeight()),
      CEGUI::Point(CEGUI::Vector2(0,0)));

   statImage->setImage("RttImageset", "BonusImage");



Thanks in advance

Posted: Wed Aug 30, 2006 08:34
by Xirnohn
Try set BackgroundEnabled to false.
Maybe this help.

Xir.

ps.: Where you add your new StaticImage to a window?
myMainWindow->addChildWindow(statImage);

Posted: Wed Aug 30, 2006 13:15
by Jake
Thanks Xir,
I didn't add the StaticImage as a child to the main window. However, adding it alone didn't solve the problem. I have to manually set the height and width, which unfortunately makes the image take up most of the window. I'll keep working on it.

Here's the current state of it if you're curious.

Code: Select all


   CEGUI::StaticImage * statImage = (CEGUI::StaticImage *)guiWindowMgr.createWindow("TaharezLook/StaticImage", "testImage");
   
   CEGUI::Texture* testTex = guiRenderer->createTexture(pTex);
   CEGUI::Imageset* rttImageSet = CEGUI::ImagesetManager::getSingleton().createImageset((CEGUI::utf8*)"RttImageset",testTex);
   CEGUI::ushort tHeight = testTex->getHeight();
   rttImageSet->defineImage((CEGUI::utf8*)"BonusImage",
      CEGUI::Point(CEGUI::Vector2(0,0)),
      CEGUI::Size(testTex->getWidth(), testTex->getHeight()),
      CEGUI::Point(CEGUI::Vector2(0,0)));

   statImage->setImage("RttImageset", "BonusImage");

   rootWindow->addChildWindow(statImage);

   statImage->setHeight(128);
   statImage->setWidth(128);



128 is the height and width of the image, but it renders nearly full screen.

Posted: Wed Aug 30, 2006 13:27
by Jake
The MetricsMode for statImage needed to be set to Absolute. It's fixed now. Thanks for your help.

StaticImage continued

Posted: Wed Aug 30, 2006 18:14
by Jake
A further question. Now that I have the StaticImage working, I'm a little confused as to how I would change the appearance of the Window itself. Specifically I'd like not to have the TaharezLook frame/border around the image, just the image itself. Do I have to define a window factory in xml? Or since the factory would define a window that is simple an image, can I do it in code? Thanks

Re: StaticImage continued

Posted: Wed Aug 30, 2006 21:58
by Xirnohn
Jake wrote:A further question. Now that I have the StaticImage working, I'm a little confused as to how I would change the appearance of the Window itself. Specifically I'd like not to have the TaharezLook frame/border around the image, just the image itself. Do I have to define a window factory in xml? Or since the factory would define a window that is simple an image, can I do it in code? Thanks


You can do it with set the "FrameEnabled" to false:
statImage->setProperty("FrameEnabled", "False");

And i think the width/height must be in the [0..1] range(like other values)...
If your image is in the top left corner(so its in the (0,0) position), then with the width(1), height(1) its exactly full screen.

Do some "scene" with the CELayoutEditor, save it, then see the saved code.

Xir

Posted: Fri Sep 01, 2006 15:24
by Jake
Thanks again, Xir. Works like a charm. Used the following to get what I needed.

statImage->setProperty("BackgroundEnabled", "False");
statImage->setProperty("FrameEnabled", "False");