Page 1 of 1

Scalable squared elements (in a grid for example)

Posted: Fri May 04, 2012 14:53
by matt
Hello!

I'm currenlty designing an interface with CEGUI, and I would like to make it the more scalable that I could
I found this thread which is quite interesting:
http://www.cegui.org.uk/phpBB2/viewtopic.php?f=3&t=5257

Indeed, my main problem is that sometimes I need some scalable squared elements (buttons for example), and I don't know how to create them in . layout file.
For example I have a grid of 2x2 buttons, and the only way i found is to put them in absolute size

Code: Select all

<Window Type="MyWidgets/ContainerWindow" Name="Root/MainView/" >   
    <Property Name="UnifiedSize" Value="{{0.0,50},{0.0,240}}" />               
    <Property Name="HorizontalAlignment" Value="Right" />
    <Property Name="VerticalAlignment" Value="Top" />
           
        <Window Type="GridLayoutContainer" Name="Root/MainView/MainBlock">
            <Property Name="HorizontalAlignment" Value="Centre" />
            <Property Name="VerticalAlignment" Value="Centre" />
            <Property Name="GridSize" Value="w:2 h:2" />
           
            <Window Type="MyLook/RadioButton" Name="Button1" >
                <Property Name="UnifiedSize" Value="{{0.0,20},{0.0,20}}" />
            </Window>
            <Window Type="MyLook/RadioButton" Name="Button2" >
                <Property Name="UnifiedSize" Value="{{0.0,20},{0.0,20}}" />
            </Window>
            <Window Type="MyLook/RadioButton" Name="Button3" >
                <Property Name="UnifiedSize" Value="{{0.0,20},{0.0,20}}" />
            </Window>
            <Window Type="MyLook/RadioButton" Name="Button4" >
                <Property Name="UnifiedSize" Value="{{0.0,20},{0.0,20}}" />
            </Window>
           
        </Window>

</Window>


Is there a way to say to elements Height to be a relative size of their width?
For example if we have an element in a 10x10 grid, and the relative width of this elements is 0.1 (in order to fit 10 elements in a row), then would it possible to set a "kind of relative height (vs its width)" to this element to 1.0, in order to have squared elements. (not depending of the ratio of the parent container).

Thanx in advance for the help

Re: Scalable squared elements (in a grid for example)

Posted: Wed May 09, 2012 08:38
by Kulik
Hi,

this is possible with AspectLock and AspectRatio features of CEGUI 1.0 (unreleased). Sadly it's way harder in 0.7 (requires custom code that reacts to Size changes basically and even then there are some quirks about the behaviour).

Re: Scalable squared elements (in a grid for example)

Posted: Thu May 10, 2012 11:37
by matt
ok, thanx Kulik for your answer!