improved layout in preferences to adapt to more resolutions. added max_width/max_height properties

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3446 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-05-02 19:34:07 +00:00
parent f6d8943c70
commit 66cc077beb
11 changed files with 40 additions and 8 deletions

View File

@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Help"/>
<tabs id="category" height="130" width="75%" align="center">
<tabs id="category" height="15%" max_height="150" width="75%" align="center">
<icon-button id="page1" width="128" height="128" icon="gui/track_random.png" text="General"/>
<icon-button id="page2" width="128" height="128" icon="gui/mode_normal.png" text="Weapons"/>
<icon-button id="page3" width="128" height="128" icon="gui/mode_ftl.png" text="Game Modes"/>

View File

@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Help"/>
<tabs id="category" height="130" width="75%" align="center">
<tabs id="category" height="15%" max_height="150" width="75%" align="center">
<icon-button id="page1" width="128" height="128" icon="gui/track_random.png" text="General"/>
<icon-button id="page2" width="128" height="128" icon="gui/mode_normal.png" text="Weapons"/>
<icon-button id="page3" width="128" height="128" icon="gui/mode_ftl.png" text="Game Modes"/>

View File

@ -1,9 +1,8 @@
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row" >
<label align="center" text="SuperTuxKart Help"/>
<tabs id="category" height="130" width="75%" align="center">
<tabs id="category" height="15%" max_height="150" width="75%" align="center">
<icon-button id="page1" width="128" height="128" icon="gui/track_random.png" text="General"/>
<icon-button id="page2" width="128" height="128" icon="gui/mode_normal.png" text="Weapons"/>
<icon-button id="page3" width="128" height="128" icon="gui/mode_ftl.png" text="Game Modes"/>

View File

@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Options"/>
<tabs id="options_choice" height="130" width="75%" align="center">
<tabs id="options_choice" height="15%" max_height="150" width="75%" align="center">
<icon-button id="audio_video" width="128" height="128" icon="gui/options_audio_video.png" text="Audio/Video"/>
<icon-button id="players" width="128" height="128" icon="gui/options_players.png" text="Players"/>
<icon-button id="controls" width="128" height="128" icon="gui/options_input.png" text="Controls"/>

View File

@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Options"/>
<tabs id="options_choice" height="130" width="75%" align="center">
<tabs id="options_choice" height="15%" max_height="150" width="75%" align="center">
<icon-button id="audio_video" width="128" height="128" icon="gui/options_audio_video.png" text="Audio/Video"/>
<icon-button id="players" width="128" height="128" icon="gui/options_players.png" text="Players"/>
<icon-button id="controls" width="128" height="128" icon="gui/options_input.png" text="Controls"/>

View File

@ -2,7 +2,7 @@
<label align="center" text="SuperTuxKart Options"/>
<tabs id="options_choice" height="130" width="75%" align="center">
<tabs id="options_choice" height="15%" max_height="150" width="75%" align="center">
<icon-button id="audio_video" width="128" height="128" icon="gui/options_audio_video.png" text="Audio/Video"/>
<icon-button id="players" width="128" height="128" icon="gui/options_players.png" text="Players"/>
<icon-button id="controls" width="128" height="128" icon="gui/options_input.png" text="Controls"/>

View File

@ -119,7 +119,10 @@ for you (see PROP_LAYOUT). In addition, sizes are automatically calculated for w
and/or text like labels and plain icons. Other widgets will also automativally manage the position and
size of their children, for instance ribbons.
PROP_MAX_WIDTH "max_width"
PROP_MAX_HEIGHT "max_height"
The maximum size a widget can take; especially useful when using percentages and proportions.
PROP_CHILD_WIDTH "child_width"
PROP_CHILD_HEIGHT "child_height"
Used exclusively by the ribbon grid widget. See docs for this widget above.

View File

@ -127,12 +127,24 @@ void Screen::calculateLayout(ptr_vector<Widget>& widgets, Widget* parent)
widgets[n].y = y;
widgets[n].w = (int)(left_space*fraction);
if(widgets[n].m_properties[PROP_MAX_WIDTH].size() > 0)
{
const int max_width = atoi( widgets[n].m_properties[PROP_MAX_WIDTH].c_str() );
if(widgets[n].w > max_width) widgets[n].w = max_width;
}
x += widgets[n].w;
}
else
{
widgets[n].h = (int)(left_space*fraction);
if(widgets[n].m_properties[PROP_MAX_HEIGHT].size() > 0)
{
const int max_height = atoi( widgets[n].m_properties[PROP_MAX_HEIGHT].c_str() );
if(widgets[n].h > max_height) widgets[n].h = max_height;
}
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
if(align.size() < 1 || align == "left") widgets[n].x = x;
else if(align == "center") widgets[n].x = x + w/2 - widgets[n].w/2;

View File

@ -146,6 +146,9 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = prop_name; else widget.m_
READ_PROPERTY(min_value, PROP_MIN_VALUE);
READ_PROPERTY(max_value, PROP_MAX_VALUE);
READ_PROPERTY(square_items, PROP_SQUARE);
READ_PROPERTY(max_width, PROP_MAX_WIDTH);
READ_PROPERTY(max_height, PROP_MAX_HEIGHT);
#undef READ_PROPERTY
/* a new div starts here, continue parsing with this new div as new parent */

View File

@ -196,6 +196,19 @@ void Widget::readCoords(Widget* parent)
this->w = (int)(this->w*ratio);
this->h = (int)(this->h*ratio);
}
// ------ check for given max size
if(m_properties[PROP_MAX_WIDTH].size() > 0)
{
const int max_width = atoi( this->m_properties[PROP_MAX_WIDTH].c_str() );
if(this->w > max_width) this->w = max_width;
}
if(m_properties[PROP_MAX_HEIGHT].size() > 0)
{
const int max_height = atoi( this->m_properties[PROP_MAX_HEIGHT].c_str() );
if(this->h > max_height) this->h = max_height;
}
}

View File

@ -47,6 +47,8 @@ namespace GUIEngine
PROP_TEXT_ALIGN,
PROP_MIN_VALUE,
PROP_MAX_VALUE,
PROP_MAX_WIDTH,
PROP_MAX_HEIGHT,
PROP_SQUARE
};