StaticImage in code [solved]

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

Jake
Just popping in
Just popping in
Posts: 6
Joined: Tue Aug 29, 2006 19:05

StaticImage in code [solved]

Postby Jake » Tue Aug 29, 2006 20:08

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
Last edited by Jake on Fri Sep 01, 2006 15:24, edited 2 times in total.

Xirnohn
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 22, 2006 13:32
Location: Hungary, Debrecen
Contact:

Postby Xirnohn » Wed Aug 30, 2006 08:34

Try set BackgroundEnabled to false.
Maybe this help.

Xir.

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

Jake
Just popping in
Just popping in
Posts: 6
Joined: Tue Aug 29, 2006 19:05

Postby Jake » Wed Aug 30, 2006 13:15

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.

Jake
Just popping in
Just popping in
Posts: 6
Joined: Tue Aug 29, 2006 19:05

Postby Jake » Wed Aug 30, 2006 13:27

The MetricsMode for statImage needed to be set to Absolute. It's fixed now. Thanks for your help.

Jake
Just popping in
Just popping in
Posts: 6
Joined: Tue Aug 29, 2006 19:05

StaticImage continued

Postby Jake » Wed Aug 30, 2006 18:14

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

Xirnohn
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 22, 2006 13:32
Location: Hungary, Debrecen
Contact:

Re: StaticImage continued

Postby Xirnohn » Wed Aug 30, 2006 21:58

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

Jake
Just popping in
Just popping in
Posts: 6
Joined: Tue Aug 29, 2006 19:05

Postby Jake » Fri Sep 01, 2006 15:24

Thanks again, Xir. Works like a charm. Used the following to get what I needed.

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


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests