How to change the shape of cegui window?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

pyhmail
Not too shy to talk
Not too shy to talk
Posts: 24
Joined: Thu Apr 03, 2008 02:37

How to change the shape of cegui window?

Postby pyhmail » Fri May 30, 2008 03:08

I have two problem:
1) How to change the shape of a cegui window? for example, I want a circular button.

2) how to create two basic cegui window at same time. In other word, I want a combined window ,the combined window is composed of two basic cegui window.

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

Postby CrazyEddie » Fri May 30, 2008 08:55

Hi,

1) The level at which you can achieve this, if at all, will depend upon your exact needs...

If you just want round looking imagery then you can do that by just changing the looknfeel skin file or imageset definition, but you will be left with a round looking button that has square hit testing (that is, when the mouse is in the corner of the bounding rectangle but outside the circle, the button will react as if the mouse were within the circle).

If you need the hit test to only succeed if the cursor is within the innner circular area of the button, you would have to create a CEGUI::Window subclass of some kind and override the isHit member to provide a more accurate hit test (you would then need a WindowFactory for this new window type, and probably also an entry in the scheme file if you intend to use skinning).

This will leave you with a final potential issue of clipping; currently all imagery clipping is done to rectangular regions only, and this can not really be changed at present. So, if you can live with that limitation, it's possible but may be a little work.


2) This can be done by creating a WidgetLook that has the required Child definitions, and mapping that WidgetLook to an appropriate base type / window renderer in the scheme.

For example, for a window that's composed of two push buttons:

Code: Select all

<WidgetLook name="TaharezLook/DoubleButton">
    <Child type="TaharezLook/Button" nameSuffix="__auto_button1__">
        <Area>
            <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
            <Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
            <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
            <Dim type="Height" ><UnifiedDim scale="0.5" type="Height" /></Dim>
        </Area>
    </Child>
    <Child type="TaharezLook/Button" nameSuffix="__auto_button2__">
        <Area>
            <Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
            <Dim type="TopEdge" ><UnifiedDim scale="0.5" type="TopEdge"/></Dim>
            <Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
            <Dim type="Height" ><UnifiedDim scale="0.5" type="Height" /></Dim>
        </Area>
    </Child>
    <StateImagery name="Enabled" />
</WidgetLook>


And with this entry in the scheme file:

Code: Select all

<FalagardMapping WindowType="TaharezLook/DoubleButton" TargetType="DefaultWindow"   Renderer="Falagard/Default"   LookNFeel="TaharezLook/DoubleButton" />


You can use it, for example, like:

Code: Select all

Window* db = winMgr.createWindow("TaharezLook/DoubleButton",
                                       "myDoubleButton");


To target the component parts:

Code: Select all

db->getChild( db->getName() + "__auto_button1__" )->
    setText( "Button 1" );
db->getChild( db->getName() + "__auto_button2__" )->
    setText( "Button 2" );


also see this article on auto windows.

CE.

pyhmail
Not too shy to talk
Not too shy to talk
Posts: 24
Joined: Thu Apr 03, 2008 02:37

Thank CrazyEddie

Postby pyhmail » Mon Jun 02, 2008 01:59

Thank CrazyEddie!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 11 guests