Resizing SDL Ogre window without resizing CEGUI elements

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
Ben811
Just popping in
Just popping in
Posts: 14
Joined: Wed Nov 23, 2005 09:33

Resizing SDL Ogre window without resizing CEGUI elements

Postby Ben811 » Wed Nov 30, 2005 08:21

Hi there,

I'm not sure to ask this question here ore on the Ogre forum but I don't now if its related to CEGUI or Ogre so I'll ask both.

I've implemented a window resize function for the SDL so that I'm able to resize the Ogre window. Then I have two basic problems:

The view of my camera also gets resized. But I want to have the effect of only "making my window bigger and see more of the scene", not zooming in.
The second problem and I think its related to this one is the CEGUI elements change there size. But they should retain their current size no matter how the window around gets resized. There are special settings for CEGUI (like AutoScale= False) and so on but nothing changed this behavior and because of the view problem maybe I'm doing something wrong in Ogre.

I hope I described my problem so that it's understandable what I mean.

Thanks for you help!

Ben :D

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby lindquist » Wed Nov 30, 2005 09:18

remember to call setDisplaySize of your renderer module with your new "screen" resolution. If you do this and have auto scaling disabled for both your imagesets and fonts you should get the result you're looking for.

User avatar
Ben811
Just popping in
Just popping in
Posts: 14
Joined: Wed Nov 23, 2005 09:33

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby Ben811 » Tue Dec 06, 2005 10:07

Hi there,

I finally added the setDisplaySize method to the Ogre renderer and then after calling it -> it works fine!

Thanks for your help...

Ben :D

User avatar
Ben811
Just popping in
Just popping in
Posts: 14
Joined: Wed Nov 23, 2005 09:33

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby Ben811 » Wed Dec 21, 2005 11:38

Well, I found another problem when I define a window like this:

<Window Type="TaharezLook/FrameWindow" Name="MoveWindow">
<Property Name="AbsolutePosition" Value="x:100.0 y:100.0" />
<Property Name="AbsoluteMinSize" Value="w:400.0 h:300.0" />
<Property Name="AbsoluteMaxSize" Value="w:400.0 h:300.0" />
<Property Name="Text" Value="Move Window" />
</Window>

Everything seems to be fine, I can resize my render window and the CEGUI window is at position 100 x 100 with the size of 400 x 300 and I can't resize the CEGUI window. That's what I want.

But when I move the CEGUI window with the mouse and then resize the render window afterwards it seems that CEGUI forgot the above settings and the CEGUI window gets adjusted in size with the render window.

Any solutions to this or do I have to change somthing in the properties?

Thanks,

Ben

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby lindquist » Wed Dec 21, 2005 12:32

The window changes size and not just the imagery used to render it?

User avatar
Ben811
Just popping in
Just popping in
Posts: 14
Joined: Wed Nov 23, 2005 09:33

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby Ben811 » Wed Dec 21, 2005 15:32

Well, I have buttons in the app and just added one to the child window. They don't get resized so it should not be the images.
As I said, everything is fine until I move the window. My sugestion is that the absolute position of the window gets changed and then it does not observe the min and max size hints?

User avatar
Ben811
Just popping in
Just popping in
Posts: 14
Joined: Wed Nov 23, 2005 09:33

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby Ben811 » Tue Jan 10, 2006 10:36

Ok, I found the problem and a solution to it.

If you look at the CEGUIWindow source, you will find different variables for the Min/Max size property and the internal Min/Max size variables (ie. Window::d_absMinSizeProperty; for the property but d_maxSize as the window internal variable)

So if you set the property value the internal window value does not get affected.

At each resize the Window::setWindowArea_impl function is called and there the size is restricted to the internal values.

So if you add the following to your code it will work:

m_pkWin = (CEGUI::Window*) CEGUI::WindowManager::getSingleton().getWindow(
(CEGUI::utf8*) "TransformWindow" );

int nWidth = atoi(m_pkWin->getProperty("AbsoluteWidth" ).c_str());
int nHeight = atoi(m_pkWin->getProperty("AbsoluteHeight" ).c_str());

CEGUI::Size size(nWidth, nHeight);
m_pkWin->setMetricsMode(CEGUI::Absolute);
m_pkWin->setSize(size);
m_pkWin->setMinimumSize(size);
m_pkWin->setMaximumSize(size);

And your Window layout should look like:

<Window Type="RealTVLook/FrameWindow" Name="TransformWindow">
<Property Name="AbsolutePosition" Value="x:50.0 y:100.0" />
<Property Name="AbsoluteSize" Value="w:300.0 h:300.0" />
...

This ensures that if you resize your app window the CEGUI elements won't be resized.

To the CEGUI team: I haven't looked for the layout parsing routines but somehow the property "AbsoluteSize" has to affect the internal window values. Maybe you think of this in the next version (If I'm not wrong here and just doing something nasty)...

Cheers,

Ben :D

User avatar
baxissimo
Quite a regular
Quite a regular
Posts: 60
Joined: Tue Feb 22, 2005 08:04
Location: Tokyo, JAPAN
Contact:

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby baxissimo » Fri Jan 13, 2006 00:56

I think it would be nice if the demos all used setDisplaySize().

That was one of the first things I noticed about CEGUI based on the demos -- that everthing looked horrible when the window was resized. It would be nice if at least one demo used setDisplaySize() with absolute sizing. Then first time users can see, ah ok it is possible to make my gui resize without everythign getting all blurry or distorted.

Is there an easy way to accomplish global absolute sizing? I mean without going and editing every single size property in the xml files.

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

Postby leonardoalt » Thu Nov 20, 2008 11:41

Ben811

How did you resized Ogre Window?
I am doing this too.
I did SDL resize, CEGUI resize, but I can not do Ogre resize.

How did you do it?

Thanks.

raymccooney
Just popping in
Just popping in
Posts: 11
Joined: Sat Jul 18, 2009 23:43

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby raymccooney » Mon Jul 27, 2009 12:08

Hello guys,

I have the same problem as Ben811 in the first post, but all your advises didn't work for me.
Whenever the SDL/OpenGL window is scaled, the CEGUI elements are being scaled as well, whereas I want them to stay fixed in size.

I already did:

// init section:
Imageset *imageset = ImagesetManager::getSingleton().getImageset("TaharezLook");
imageset->setAutoScalingEnabled(false);

// sdl resize part:
case SDL_VIDEORESIZE:
screen = SDL_SetVideoMode(e.resize.w, e.resize.h, colorDepth, SDL_OPENGL|SDL_RESIZABLE);
ceguiRenderer->setDisplaySize(CEGUI::Size(e.resize.w, e.resize.h));
break;


But still the window is scaled :(

Is there anything that I'm missing?

Thanks in advance!

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

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby CrazyEddie » Mon Jul 27, 2009 18:15

When the host viewport size changes and you notify this to CEGUI, there are two things at work which relate to 'resizing' of UI elements. The first concerns the resizing of the imagery elements that the CEGUI windows and widgets re made up of - this is what is controlled by the auto scaling setting. The second thing that happens is that CEGUI windows (and subsequently any attached child windows) may get resized according to the scale portion of their size - if you do not want this, just make sure your window sizes are all using only the 'offset' part of the size UDim dimensions; these act as absolute pixel sizes so do not change in response to the parent element (in this case the screen or host window) having changed size.

If you're uncertain about the unified dimension system employed by CEGUI, there are various posts on the forum, articles on the wiki and references in the docs that cover that subject.

CE.

raymccooney
Just popping in
Just popping in
Posts: 11
Joined: Sat Jul 18, 2009 23:43

Re: Resizing SDL Ogre window without resizing CEGUI elements

Postby raymccooney » Tue Jul 28, 2009 12:08

Thanks eddie, that was exactly the solution: Absolute positioning.

Ray McCooney


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: Bing [Bot] and 5 guests