Page 1 of 1

Using an image as a button

Posted: Tue Mar 08, 2005 14:36
by Bobo7581
Don't know if anyone can help, but i'm trying to use an image as a button in CEGUI and can't find out how to do it...

I've looked on the forum and haven't come across anything so far. I am working on linux and so haven't been able to check the layout editor...

thanks for any help...

Re: Using an image as a button

Posted: Tue Mar 08, 2005 14:49
by CrazyEddie
Quick question: Which version of CEGUI are you using?

You have a couple of options really...

You could use a StaticImage widget type, configured as you wish, and you can get some button-like behaviour by subscribing to some of the mouse based events, Like EventMouseClicked.

Another (probably better) idea is to use one of the ready made button classes. If you're on CVS-HEAD this is much easier since the required methods and properties have been promoted into the PushButton base class. Anyway, you can (optionally) disable the standard rendering, and have an Image of your choice drawn instead (you can set a different image for each of the button states; normal, hover, pushed, and disabled). If you need something more complex, you can attach StaticImage widgets to the button class, if you do this, you should set their state to disabled, so that all input pass through to the parent button.

HTH

CE.

Re: Using an image as a button

Posted: Tue Mar 15, 2005 13:58
by Bobo7581
Sorry for the long reply, been busy...

I am using the latest cegui_mk2, i think because i need a quick solution and done want to use the CVS head at the moment in case of errors, that i will use your first suggestion of subscribing an EventMouseClick to a static image.

I have done this, however am having great problem with the layout. I don't know if its me but i can't find anywhere any kind of documentation or help on what properties you can supply for different type of layout elemnet... In particular i can't find how to specify the image source...

At the moment i have

Code: Select all

<Window Type="TaharezLook/StaticImage" Name="WeaponSelect/Area/Gun2Button">
   <Property Name="Position" Value="x:0.55 y:0.1" />
   <Property Name="Size" Value="w:0.4 h:0.4" />
</Window>


and have been trying different Names to add another property

Code: Select all

<Property Name="?" Value="test.jpg" />


to specify the image source... By the way this is all in a .layout file. I am having problems not just for this but all my layout windows, i can't find what options you can specify...

Cheers for any help
pete

Re: Using an image as a button

Posted: Tue Mar 15, 2005 16:36
by Guest
I think the property you're looking for is simply called "Image".
You can find the documentation in the API reference :
http://www.cegui.org.uk/api_reference/c ... Image.html

You'll have to add your image to a new imageset and to tell your renderer to load it on startup.

--
Chris

Re: Using an image as a button

Posted: Tue Mar 15, 2005 19:31
by CrazyEddie
Each widget class has its available properties in a namespace (like StaticImageProperties as linked above). This was done, in part, to make it easy to find what's available; the only thing to remember is that a widget has properties from all base classes too, so StaticImage contains everything in StaticImageProperties, everything in StaticProperties, and everything in WindowProperties :)

CE.