I want to make a UI, that has following features:
1. It is resolution independent:
That means it exists a minimum supported resolution, for which the UI graphics are designed, so that the graphical elements won't be scaled in that resolution. For all higher resolutions the UI elements will be up scaled, so that the UI elements look as same as in the lowest supported resolution (except for some possible scaling artifacts due to floating point pixel values).
2. It is aspect rate independent:
That means the UI elements in e.g. a 4:3 resolution look as same as the elements in 16:10 and 16:9 resolutions. Only the distances between window positions will change according to their anchor positions, which leads to:
3. windows can have defined anchor positions
I want to be able to define, for example that the minimap is always in the bottom right corner of its parent window and that it is shifted by an absolute vector (x,y), which is scaled together with the UI elements in higher resolutions. In that way the minimap would appear always at the same physical position on screen, relative to the bottom right corner of the parent window (resolution and aspect rate independent).
In detail i want to specify a window anchor position in window space of the minimap window and an scaled absolute vector, which is added to it. The anchor position is the point in the window, with which the window is sticked to its defined position in parent window space. That way, the window continues to sit on a defined place in the parent window when it gets scaled.
4. The UI is scalable
I want to be able to scale the whole or parts of the UI in such a way, that the scaled UI elements are keeping their proportional look and keep staying at there anchor positions. The only difference should be that the elements are smaller / greater as before and change distance to each other due to different anchor positions.
This scaling should be independent of the automatic UI scaling on resolution changes. This way it enables the user to use this scaling to define the actual size of some UI elements on the screen.
So how can this four points be achieved with CEGUI?
For 1. I found the following way to do it:
*Set the autoscale attribute of the used image sets to True.
*Set the native resolution attribute to the resolution the UI was designed for and for which the images don't need to be scaled.
*Don't use any absolute dims other than 0 in the used falagard skins because it wouldn't scale with resolution changes.
*Instead use imagedim with dummy images to get a correct scaling.
*Only use the scale part of the unified window dimensions in layouts, because all absolute offset components other than 0 wouldn't scale with resolution changes.
For 2. I'm getting into trouble, because this can only be achieved by using only the absolute components of the unified window dimensions in the layouts. However if I want to use 1. and 2. I can't do it. If I use the scale part of the window coords, the window positions and sizes would get distorted when the resolution aspect rate is changed. If I use the offset part, the window positions and sizes wouldn't scale anymore when changing the resolution and it would look even more odd, because the scaling of the images would still be active.
Last but not least, the image scaling isn't aspect rate preserving, so the images are getting distorted with a resolution with another aspect rate than the native resolution.
For 3. I have the possibility to define a window to be anchored in one out of nine positions made of vertical/horizontal centers and the 4 corners via the alignment properties. However these are somewhat “hardcoded” anchors, because for example if I use the right bottom anchor for a window, it is implied, that the window anchor point lies in the right bottom corner of the anchored window and I have no possibility to define a scaled absolute offset vector (for example if I want the minimap to be sit in this corner but slightly shifted down and right).
To get the window anchored somewhere else as to the 9 positions I have to use scale parts and the offset parts together. This again wouldn't be scalable correctly because of the offset part and the window wouldn't be correctly anchored, because it would have its upper left corner as implicit anchor position.
For 4.: I didn't found anything that allows for additional image scaling. Simple scaling of a parent window wouldn't do it, because I want the anchors to stay in position. The only dirty thing I can think of, would be a dynamic change of the native resolution attribute in the image sets.
I think to achieve all four points with CEGUI, there have to be made some fundamental changes in the window layout and image system of CEGUI.
My suggestions are:
Make the offset part of the udims autoscalable, to get a resolution and aspect rate independent, absolute measure. There could be a property “AutoScaled”, which could be set to true, if the offset parts of the windows udims should be auto scaled. And there could be a system wide property “NativeLayoutResolution” to specify the reference resolution for layouts and a property “WindowAutoScaleDefault” to specify a default of the window specific property.
Make the image (and udim) auto scaling aspect rate preserving. That means only the ordinate with the lowest resolution is scaled and the other is calculated from the native resolutions aspect rate, so the image wouldn't get distorted if a resolution change was made to a resolution with a different aspect rate. The scaling mode could be configurable via an attribute.
Introduce an UDim window anchor position per window. The window position vector then points to this anchor position. By default the anchor position would be {{0,0},{0,0}} (Position vector points to upper left window edge).
Introduce a per window scaling factor, which multiplies into the image and udim autoscale.
Maybe you have some other ideas on how to achive the 4 points, feel free to discuss

yours sincerely,
Grimmigbeisser