Simplified ribbon code by not invoking number of row estimation code for single-row ribbons...
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6087 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a17b78d5fc
commit
69feb27034
@ -180,59 +180,68 @@ void DynamicRibbonWidget::add()
|
||||
m_child_height = 256;
|
||||
}
|
||||
|
||||
// determine row amount
|
||||
const float aspect_ratio = (float)m_child_width / (float)m_child_height;
|
||||
// const int count = m_items.size();
|
||||
|
||||
int max_score_so_far = -1;
|
||||
m_row_amount = -1;
|
||||
|
||||
for (int row_count = 1; row_count < 10; row_count++)
|
||||
if (m_multi_row)
|
||||
{
|
||||
int visible_items;
|
||||
int taken_area;
|
||||
int item_height;
|
||||
estimateIconAreaFor(row_count, m_child_width, m_w, m_h - m_label_height,
|
||||
aspect_ratio, &visible_items, &taken_area, &item_height);
|
||||
// determine row amount
|
||||
const float aspect_ratio = (float)m_child_width / (float)m_child_height;
|
||||
// const int count = m_items.size();
|
||||
|
||||
|
||||
// FIXME: this system to determine the best number of columns is really complicated!
|
||||
// the score is computed from taken screen area AND visible item count.
|
||||
// A number of rows that allows for the screen space to be used a lot will
|
||||
// get a better score. A number of rows that allows showing very few items
|
||||
// will be penalized. A configuration that makes items much smaller than
|
||||
// requested in the XML file will also be penalized.
|
||||
const int score = int(log(2*visible_items) *
|
||||
std::min((float)item_height / (float)m_child_height, 1.0f) *
|
||||
taken_area);
|
||||
|
||||
//std::cout << " " << row_count << " rows : " << visible_items << " visible items; area = "
|
||||
// << taken_area << "; size penalty = " << std::min((float)item_height / (float)m_child_height, 1.0f)
|
||||
// << "; score = " << score << "\n";
|
||||
|
||||
if (score > max_score_so_far)
|
||||
m_row_amount = -1;
|
||||
int max_score_so_far = -1;
|
||||
|
||||
for (int row_count = 1; row_count < 10; row_count++)
|
||||
{
|
||||
m_row_amount = row_count;
|
||||
max_score_so_far = score;
|
||||
int visible_items;
|
||||
int taken_area;
|
||||
int item_height;
|
||||
estimateIconAreaFor(row_count, m_child_width, m_w, m_h - m_label_height,
|
||||
aspect_ratio, &visible_items, &taken_area, &item_height);
|
||||
|
||||
|
||||
// FIXME: this system to determine the best number of columns is really complicated!
|
||||
// the score is computed from taken screen area AND visible item count.
|
||||
// A number of rows that allows for the screen space to be used a lot will
|
||||
// get a better score. A number of rows that allows showing very few items
|
||||
// will be penalized. A configuration that makes items much smaller than
|
||||
// requested in the XML file will also be penalized.
|
||||
const int score = int(log(2*visible_items) *
|
||||
std::min((float)item_height / (float)m_child_height, 1.0f) *
|
||||
taken_area);
|
||||
|
||||
//std::cout << " " << row_count << " rows : " << visible_items << " visible items; area = "
|
||||
// << taken_area << "; size penalty = " << std::min((float)item_height / (float)m_child_height, 1.0f)
|
||||
// << "; score = " << score << "\n";
|
||||
|
||||
if (score > max_score_so_far)
|
||||
{
|
||||
m_row_amount = row_count;
|
||||
max_score_so_far = score;
|
||||
}
|
||||
}
|
||||
assert(m_row_amount != -1);
|
||||
|
||||
// m_row_amount = (int)round((m_h - m_label_height) / (float)m_child_height);
|
||||
|
||||
if (m_properties[PROP_MAX_ROWS].size() > 0)
|
||||
{
|
||||
const int max_rows = atoi(m_properties[PROP_MAX_ROWS].c_str());
|
||||
if (max_rows < 1)
|
||||
{
|
||||
std::cout << "/!\\ WARNING : the 'max_rows' property must be an integer greater than zero."
|
||||
<< " Ingoring current value '" << m_properties[PROP_MAX_ROWS] << "'\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_row_amount > max_rows) m_row_amount = max_rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(m_row_amount != -1);
|
||||
|
||||
// m_row_amount = (int)round((m_h - m_label_height) / (float)m_child_height);
|
||||
|
||||
if (m_properties[PROP_MAX_ROWS].size() > 0)
|
||||
else
|
||||
{
|
||||
const int max_rows = atoi(m_properties[PROP_MAX_ROWS].c_str());
|
||||
if (max_rows < 1)
|
||||
{
|
||||
std::cout << "/!\\ WARNING : the 'max_rows' property must be an integer greater than zero."
|
||||
<< " Ingoring current value '" << m_properties[PROP_MAX_ROWS] << "'\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_row_amount > max_rows) m_row_amount = max_rows;
|
||||
}
|
||||
m_row_amount = 1;
|
||||
}
|
||||
|
||||
// get and build a list of IDs (by now we may not yet know everything about items,
|
||||
// but we need to get IDs *now* in order for tabbing to work.
|
||||
m_ids.resize(m_row_amount);
|
||||
|
Loading…
x
Reference in New Issue
Block a user