From b71a93feb96c0cc66b77b144f11f5e62399f8208 Mon Sep 17 00:00:00 2001 From: auria <auria@178a84e3-b1eb-0310-8ba1-8eac791a3b58> Date: Wed, 18 Apr 2012 20:49:34 +0000 Subject: [PATCH] Update layout manager to no more crash when the screen is full (which happened with Arabic, for some reason there is much empty space above and below arabic characters) git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11124 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/guiengine/layout_manager.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/guiengine/layout_manager.cpp b/src/guiengine/layout_manager.cpp index 259a9be7d..be7bed5f2 100644 --- a/src/guiengine/layout_manager.cpp +++ b/src/guiengine/layout_manager.cpp @@ -438,6 +438,12 @@ void LayoutManager::doCalculateLayout(PtrVector<Widget>& widgets, AbstractTopLev left_space -= (horizontal ? widgets[n].m_w : widgets[n].m_h); } // next widget + if (left_space < 0) + { + fprintf(stderr, "[LayoutManager] WARNING: statically sized widgets took all the place!!\n"); + left_space = 0; + } + // ---- lay widgets in row int x = parent->m_x; int y = parent->m_y; @@ -509,6 +515,14 @@ void LayoutManager::doCalculateLayout(PtrVector<Widget>& widgets, AbstractTopLev if (widgets[n].m_w > max_width) widgets[n].m_w = max_width; } + if (widgets[n].m_w <= 0) + { + fprintf(stderr, "WARNING: widget '%s' has a width of %i (left_space = %i, " + "fraction = %f, max_width = %s)\n", widgets[n].m_properties[PROP_ID].c_str(), + widgets[n].m_w, left_space, fraction, widgets[n].m_properties[PROP_MAX_WIDTH].c_str()); + widgets[n].m_w = 1; + } + x += widgets[n].m_w; } else @@ -521,6 +535,14 @@ void LayoutManager::doCalculateLayout(PtrVector<Widget>& widgets, AbstractTopLev if (widgets[n].m_h > max_height) widgets[n].m_h = max_height; } + if (widgets[n].m_h <= 0) + { + fprintf(stderr, "WARNING: widget '%s' has a height of %i (left_space = %i, " + "fraction = %f, max_width = %s)\n", widgets[n].m_properties[PROP_ID].c_str(), + widgets[n].m_h, left_space, fraction, widgets[n].m_properties[PROP_MAX_WIDTH].c_str()); + widgets[n].m_h = 1; + } + std::string align = widgets[n].m_properties[ PROP_ALIGN ]; if (align.size() < 1) {