Using an image as a button

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

User avatar
Bobo7581
Just popping in
Just popping in
Posts: 4
Joined: Wed Feb 23, 2005 12:12
Location: England, Bristol
Contact:

Using an image as a button

Postby Bobo7581 » Tue Mar 08, 2005 14:36

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...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Using an image as a button

Postby CrazyEddie » Tue Mar 08, 2005 14:49

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.

User avatar
Bobo7581
Just popping in
Just popping in
Posts: 4
Joined: Wed Feb 23, 2005 12:12
Location: England, Bristol
Contact:

Re: Using an image as a button

Postby Bobo7581 » Tue Mar 15, 2005 13:58

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

Guest

Re: Using an image as a button

Postby Guest » Tue Mar 15, 2005 16:36

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

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Using an image as a button

Postby CrazyEddie » Tue Mar 15, 2005 19:31

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.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 5 guests