Improve layout algorithm and remove many hardcoded sizes

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8443 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-04-25 00:04:34 +00:00
parent e65367f101
commit 898fcdc8d6
5 changed files with 46 additions and 14 deletions

View File

@ -21,20 +21,21 @@
<!-- ******** Music ******** -->
<label width="100%" I18N="Section in the audio/video settings submenu" text="Music"/>
<!-- FIXME: don't hardcode height! -->
<div width="75%" height="40" layout="horizontal-row" >
<div width="75%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="right" I18N="Next to checkbox in settings menu" text="Enabled"/>
<div proportion="1" height="40" layout="horizontal-row" >
<div proportion="1" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<!-- FIXME: don't hardcode height -->
<checkbox id="music_enabled" width="40" height="40"/>
</div>
</div>
<div width="75%" height="40" layout="horizontal-row" >
<div width="75%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="right" I18N="Music volume in options" text="Volume"/>
<div proportion="1" height="40" layout="horizontal-row" >
<div proportion="1" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<gauge id="music_volume" proportion="1" height="100%" min_value="1" max_value="10"/>
<!-- FIXME: don't hardcode height -->
<gauge id="music_volume" proportion="1" height="40" min_value="1" max_value="10"/>
</div>
</div>

View File

@ -22,18 +22,17 @@
<label I18N="In the graphics settings" text="Skin"/>
<!-- FIXME: don't hardcode size -->
<spinner id="skinchoice" width="300" height="50" />
<spinner id="skinchoice" width="30%" height="40"/>
<spacer width="20" height="40" />
<!-- FIXME don't hardcode height, should depend on text height -->
<div width="75%" height="40" layout="horizontal-row" >
<div width="75%" height="fit" layout="horizontal-row" >
<checkbox id="showfps" width="40" height="40"/>
<spacer width="20" height="100%" />
<label height="100%" I18N="In the ui settings" text="Display FPS"/>
</div>
<div width="75%" height="40" layout="horizontal-row" >
<div width="75%" height="fit" layout="horizontal-row" >
<checkbox id="enable-internet" width="40" height="40"/>
<spacer width="20" height="100%" />
<label height="100%" I18N="In the ui settings" text="Internet STK news"/>

View File

@ -49,8 +49,7 @@
<spacer height="10" width="10"/>
<!-- FIXME don't hardcode height, should depend on text height -->
<div width="75%" height="40" layout="horizontal-row" >
<div width="75%" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<checkbox id="fullscreen" width="40" height="40"/>
<spacer width="20" height="100%" />
@ -59,7 +58,7 @@
<spacer height="10" width="10"/>
<div width="75%" height="40" layout="horizontal-row" >
<div width="100%" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<button id="apply_resolution"
I18N="In the video settings menu" text="Apply new resolution" />

View File

@ -350,6 +350,9 @@
and plain icons. Other widgets will also automativally manage the position
and size of their children, for instance ribbons.
Another possible value is "fit", which will make a \<div\> fit to its
contents.
\n
\subsection prop9 PROP_MAX_WIDTH, PROP_MAX_HEIGHT
<em> Names in XML files: </em> \c "max_width", \c "max_height"

View File

@ -178,7 +178,37 @@ void LayoutManager::readCoords(Widget* self)
}
// ---- if this widget has children, get their size size. this can helpful determine its optimal size
int child_max_width = -1, child_max_height = -1;
if (self->m_properties[PROP_WIDTH] == "fit" || self->m_properties[PROP_HEIGHT] == "fit")
{
int child_max_width = -1, child_max_height = -1;
for (int child=0; child<self->m_children.size(); child++)
{
if (self->m_children[child].m_absolute_w > -1)
{
if (child_max_width == -1 || self->m_children[child].m_absolute_w > child_max_width)
{
child_max_width = self->m_children[child].m_absolute_w;
}
}
if (self->m_children[child].m_absolute_h > -1)
{
if (child_max_height == -1 || self->m_children[child].m_absolute_h > child_max_height)
{
child_max_height = self->m_children[child].m_absolute_h;
}
}
}
if (self->m_properties[PROP_WIDTH] == "fit")
{
self->m_absolute_w = child_max_width;
}
if (self->m_properties[PROP_HEIGHT] == "fit")
{
self->m_absolute_h = child_max_height;
}
}
// ---- read dimension
// width