Implement a few long0misisng features in the layout manager, correcting FIXMEs
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7231 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2a167d50df
commit
7e04cb4f75
@ -286,7 +286,11 @@ void LayoutManager::calculateLayout(ptr_vector<Widget>& widgets, AbstractTopLeve
|
|||||||
int proportion = 1;
|
int proportion = 1;
|
||||||
std::istringstream myStream(prop);
|
std::istringstream myStream(prop);
|
||||||
if (!(myStream >> proportion))
|
if (!(myStream >> proportion))
|
||||||
std::cerr << "/!\\ Warning /!\\ : proportion '" << prop.c_str() << "' is not a number in widget " << widgets[n].m_properties[PROP_ID].c_str() << std::endl;
|
{
|
||||||
|
std::cerr << "/!\\ Warning /!\\ : proportion '" << prop.c_str()
|
||||||
|
<< "' is not a number for widget " << widgets[n].m_properties[PROP_ID].c_str()
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
const float fraction = (float)proportion/(float)total_proportion;
|
const float fraction = (float)proportion/(float)total_proportion;
|
||||||
|
|
||||||
@ -296,23 +300,43 @@ void LayoutManager::calculateLayout(ptr_vector<Widget>& widgets, AbstractTopLeve
|
|||||||
|
|
||||||
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
|
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
|
||||||
if (align.size() < 1)
|
if (align.size() < 1)
|
||||||
{
|
{
|
||||||
if (widgets[n].m_properties[ PROP_Y ].size() > 0)
|
std::string prop_y = widgets[n].m_properties[ PROP_Y ];
|
||||||
|
if (prop_y.size() > 0)
|
||||||
{
|
{
|
||||||
// FIXME: percentages won't work here
|
if (prop_y[ prop_y.size()-1 ] == '%')
|
||||||
widgets[n].m_y = atoi(widgets[n].m_properties[ PROP_Y ].c_str());
|
{
|
||||||
|
prop_y = prop_y.substr(0, prop_y.size() - 1);
|
||||||
|
widgets[n].m_y = y + atoi(prop_y.c_str())/100.0f * h;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
widgets[n].m_y = y + atoi(prop_y.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
widgets[n].m_y = y;
|
widgets[n].m_y = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (align == "top") widgets[n].m_y = y;
|
else if (align == "top")
|
||||||
else if (align == "center") widgets[n].m_y = y + h/2 - widgets[n].m_h/2;
|
{
|
||||||
else if (align == "bottom") widgets[n].m_y = y + h - widgets[n].m_h;
|
widgets[n].m_y = y;
|
||||||
else std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str()
|
}
|
||||||
<< "' is unknown (widget '" << widgets[n].m_properties[PROP_ID].c_str()
|
else if (align == "center")
|
||||||
<< "', in a horiozntal-row layout)\n";
|
{
|
||||||
|
widgets[n].m_y = y + h/2 - widgets[n].m_h/2;
|
||||||
|
}
|
||||||
|
else if (align == "bottom")
|
||||||
|
{
|
||||||
|
widgets[n].m_y = y + h - widgets[n].m_h;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str()
|
||||||
|
<< "' is unknown (widget '" << widgets[n].m_properties[PROP_ID].c_str()
|
||||||
|
<< "', in a horiozntal-row layout)\n";
|
||||||
|
}
|
||||||
|
|
||||||
widgets[n].m_w = (int)(left_space*fraction);
|
widgets[n].m_w = (int)(left_space*fraction);
|
||||||
if (widgets[n].m_properties[PROP_MAX_WIDTH].size() > 0)
|
if (widgets[n].m_properties[PROP_MAX_WIDTH].size() > 0)
|
||||||
@ -335,23 +359,43 @@ void LayoutManager::calculateLayout(ptr_vector<Widget>& widgets, AbstractTopLeve
|
|||||||
|
|
||||||
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
|
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
|
||||||
if (align.size() < 1)
|
if (align.size() < 1)
|
||||||
{
|
{
|
||||||
if (widgets[n].m_properties[ PROP_X ].size() > 0)
|
std::string prop_x = widgets[n].m_properties[ PROP_X ];
|
||||||
|
if (prop_x.size() > 0)
|
||||||
{
|
{
|
||||||
// FIXME: percentages won't work here
|
if (prop_x[ prop_x.size()-1 ] == '%')
|
||||||
widgets[n].m_x = atoi(widgets[n].m_properties[ PROP_X ].c_str());
|
{
|
||||||
|
prop_x = prop_x.substr(0, prop_x.size() - 1);
|
||||||
|
widgets[n].m_x = x + atoi(prop_x.c_str())/100.0f * w;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
widgets[n].m_x = x + atoi(prop_x.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
widgets[n].m_x = x;
|
widgets[n].m_x = x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (align == "left") widgets[n].m_x = x;
|
else if (align == "left")
|
||||||
else if (align == "center") widgets[n].m_x = x + w/2 - widgets[n].m_w/2;
|
{
|
||||||
else if (align == "right") widgets[n].m_x = x + w - widgets[n].m_w;
|
widgets[n].m_x = x;
|
||||||
else std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str()
|
}
|
||||||
<< "' is unknown (widget '" << widgets[n].m_properties[PROP_ID].c_str()
|
else if (align == "center")
|
||||||
<< "', in a vertical-row layout)\n";
|
{
|
||||||
|
widgets[n].m_x = x + w/2 - widgets[n].m_w/2;
|
||||||
|
}
|
||||||
|
else if (align == "right")
|
||||||
|
{
|
||||||
|
widgets[n].m_x = x + w - widgets[n].m_w;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str()
|
||||||
|
<< "' is unknown (widget '" << widgets[n].m_properties[PROP_ID].c_str()
|
||||||
|
<< "', in a vertical-row layout)\n";
|
||||||
|
}
|
||||||
widgets[n].m_y = y;
|
widgets[n].m_y = y;
|
||||||
|
|
||||||
y += widgets[n].m_h;
|
y += widgets[n].m_h;
|
||||||
@ -369,45 +413,88 @@ void LayoutManager::calculateLayout(ptr_vector<Widget>& widgets, AbstractTopLeve
|
|||||||
|
|
||||||
if (align.size() < 1)
|
if (align.size() < 1)
|
||||||
{
|
{
|
||||||
if (widgets[n].m_properties[ PROP_Y ].size() > 0)
|
std::string prop_y = widgets[n].m_properties[ PROP_Y ];
|
||||||
|
|
||||||
|
if (prop_y.size() > 0)
|
||||||
{
|
{
|
||||||
// FIXME: percentages won't work here
|
if (prop_y[ prop_y.size()-1 ] == '%')
|
||||||
widgets[n].m_y = atoi(widgets[n].m_properties[ PROP_Y ].c_str());
|
{
|
||||||
|
prop_y = prop_y.substr(0, prop_y.size() - 1);
|
||||||
|
widgets[n].m_y = y + atoi(prop_y.c_str())/100.0f * h;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
widgets[n].m_y = y + atoi(prop_y.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
widgets[n].m_y = y;
|
widgets[n].m_y = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (align == "top") widgets[n].m_y = y;
|
else if (align == "top")
|
||||||
else if (align == "center") widgets[n].m_y = y + h/2 - widgets[n].m_h/2;
|
{
|
||||||
else if (align == "bottom") widgets[n].m_y = y + h - widgets[n].m_h;
|
widgets[n].m_y = y;
|
||||||
else std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str() << "' is unknown in widget " << widgets[n].m_properties[PROP_ID].c_str() << std::endl;
|
}
|
||||||
|
else if (align == "center")
|
||||||
|
{
|
||||||
|
widgets[n].m_y = y + h/2 - widgets[n].m_h/2;
|
||||||
|
}
|
||||||
|
else if (align == "bottom")
|
||||||
|
{
|
||||||
|
widgets[n].m_y = y + h - widgets[n].m_h;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str()
|
||||||
|
<< "' is unknown in widget " << widgets[n].m_properties[PROP_ID].c_str()
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
x += widgets[n].m_w;
|
x += widgets[n].m_w;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//widgets[n].h = abs_var;
|
|
||||||
|
|
||||||
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
|
std::string align = widgets[n].m_properties[ PROP_ALIGN ];
|
||||||
|
|
||||||
if (align.size() < 1)
|
if (align.size() < 1)
|
||||||
{
|
{
|
||||||
if (widgets[n].m_properties[ PROP_X ].size() > 0)
|
std::string prop_x = widgets[n].m_properties[ PROP_X ];
|
||||||
|
|
||||||
|
if (prop_x.size() > 0)
|
||||||
{
|
{
|
||||||
// FIXME: percentages won't work here
|
if (prop_x[ prop_x.size()-1 ] == '%')
|
||||||
widgets[n].m_x = atoi(widgets[n].m_properties[ PROP_X ].c_str());
|
{
|
||||||
|
prop_x = prop_x.substr(0, prop_x.size() - 1);
|
||||||
|
widgets[n].m_x = x + atoi(prop_x.c_str())/100.0f * w;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
widgets[n].m_x = x + atoi(prop_x.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
widgets[n].m_x = x;
|
widgets[n].m_x = x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (align == "left") widgets[n].m_x = x;
|
else if (align == "left")
|
||||||
else if (align == "center") widgets[n].m_x = x + w/2 - widgets[n].m_w/2;
|
{
|
||||||
else if (align == "right") widgets[n].m_x = x + w - widgets[n].m_w;
|
widgets[n].m_x = x;
|
||||||
else std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str() << "' is unknown in widget " << widgets[n].m_properties[PROP_ID].c_str() << std::endl;
|
}
|
||||||
|
else if (align == "center")
|
||||||
|
{
|
||||||
|
widgets[n].m_x = x + w/2 - widgets[n].m_w/2;
|
||||||
|
}
|
||||||
|
else if (align == "right")
|
||||||
|
{
|
||||||
|
widgets[n].m_x = x + w - widgets[n].m_w;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "/!\\ Warning /!\\ : alignment '" << align.c_str()
|
||||||
|
<< "' is unknown in widget " << widgets[n].m_properties[PROP_ID].c_str() << std::endl;
|
||||||
|
}
|
||||||
widgets[n].m_y = y;
|
widgets[n].m_y = y;
|
||||||
|
|
||||||
y += widgets[n].m_h;
|
y += widgets[n].m_h;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user