Window::setArea_impl unnecessary size-limits

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Window::setArea_impl unnecessary size-limits

Postby Jamarr » Tue May 18, 2010 22:22

Hey CE, I am using the MCL (in v0.6.2) for some things and noticed that it was limiting the maximum bounds of my ListboxTextItem's to the maximum size of the renderable area.

I traced this through the MCL to ListHeader::setColumnWidth -> d_segments[column]->setWidth(width);. This ends up calling Window::setWidth, which in turn calls Window::setArea_impl. Inside of setArea_impl, I noticed that the window size was being capped to some minimum and maximum values defined by the Renderer. The problem is that the ListboxTextItem is inside of a scrollable area, and so it makes little sense to limit the width/height to the renderable area. For now, I simply used a preprocessor directive to exclude the maximum-size limitation.

I also tried excluding the minimum-size, but then my list items disappeared because they are apparently reliant on the minimum-size given by the renderer (which also makes little sense to me). In any case, here is the diff for my changes:

Code: Select all

diff --git a/CEGUI/src/CEGUIWindow.cpp b/CEGUI/src/CEGUIWindow.cpp
--- a/CEGUI/src/CEGUIWindow.cpp
+++ b/CEGUI/src/CEGUIWindow.cpp
@@ -2056,19 +2056,24 @@
     Size oldSize(d_pixelSize);
 
     // calculate pixel sizes for everything, so we have a common format for comparisons.
-    Vector2 absMax(d_maxSize.asAbsolute(System::getSingleton().getRenderer()->getSize()));
-    Vector2 absMin(d_minSize.asAbsolute(System::getSingleton().getRenderer()->getSize()));
     d_pixelSize = size.asAbsolute(getParentPixelSize()).asSize();
 
-    // limit new pixel size to: minSize <= newSize <= maxSize
+    // limit new pixel size to: minSize <= newSize
+   Vector2 absMin(d_minSize.asAbsolute(System::getSingleton().getRenderer()->getSize()));
     if (d_pixelSize.d_width < absMin.d_x)
         d_pixelSize.d_width = absMin.d_x;
-    else if (d_pixelSize.d_width > absMax.d_x)
-        d_pixelSize.d_width = absMax.d_x;
     if (d_pixelSize.d_height < absMin.d_y)
         d_pixelSize.d_height = absMin.d_y;
-    else if (d_pixelSize.d_height > absMax.d_y)
+
+#ifdef CEGUI_LIMIT_MAX_SIZE_TO_RENDERER_SIZE
+   // limit new pixel size to: newSize <= maxSize
+    Vector2 absMax(d_maxSize.asAbsolute(System::getSingleton().getRenderer()->getSize()));
+
+    if (d_pixelSize.d_width > absMax.d_x)
+        d_pixelSize.d_width = absMax.d_x;
+    if (d_pixelSize.d_height > absMax.d_y)
         d_pixelSize.d_height = absMax.d_y;
+#endif
 
     d_area.setSize(size);
     sized = (d_pixelSize != oldSize);


I am not sure if this is a sufficient fix for this issue, but I post it in case it is helpful to you; and because it highlights the problem area. Perhaps if the code requested some relevant size (System::min/max window size, or....? ) instead of the renderable area, this might make some sense.

Also, while this fixed my problem, it seems that my frame windows are still being limited to the size of the renderable-area. However, as this is not a concern to me, I did not bother looking into that. I did look at the v0.7 code base and noticed this issue seems to be present; assuming that Renderer::getDisplaySize() returns the size of the renderable area.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

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

Re: Window::setArea_impl unnecessary size-limits

Postby CrazyEddie » Wed May 19, 2010 09:42

The size limits are obtained from the Window's minimum and maximum size settings. These can be set with either Window::setMaxSize / Window::setMinSize or with the "UnifiedMaxSize" / "UnifiedMinSize" properties. Now, there are two key pieces of information regarding these settings. First is that the 'scale' component of these sizes is always a proportion of the display size (as opposed to the parent window size), and second, the default max size is UDim(1.0, 0) - hence where the display size limitation comes in ;)

To overcome this default limit all you have to do is set some appropriate max size for the window(s). Whether this be some large pixel size or some scale value that's > 1, you can easily specify a max size that will allow for whichever sizes you need. You can of course set this in the looknfeel so that all instances of a particular window type are automatically setup this way.

HTH

CE.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Window::setArea_impl unnecessary size-limits

Postby Jamarr » Wed May 19, 2010 16:49

I figured that could not be accurate. It seems I completely overlooked the d_minSize and d_maxSize members. I was only looking at the resulting value, and the Renderer reference (it does monopolize those lines); since the default max is scale=1 it was equivalent to the display size. :oops: That makes sense.

So to set the maximum size for the column, you have to set the maximum size of the "ListHeaderSegment" for a specific column (which is not immediately obvious), ex:

Code: Select all

_mcl->getHeaderSegmentForColumn(1).setMaxSize(CEGUI::UVector2(CEGUI::UDim(10,0), CEGUI::UDim(1, 0)));


Thanks :wink:
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 11 guests