Some fixes for tracks screen.

Now it works better with very big resolutions. Previously label height was used as a kind of margin for columns. But in extreme case it could be even bigger than child height.
This commit is contained in:
Deve 2018-10-31 23:02:57 +01:00
parent 2c86355013
commit e4eb1513fc
2 changed files with 10 additions and 6 deletions

View File

@ -7,19 +7,19 @@
<header width="80%" I18N="In the track and grand prix selection screen" text="Grand Prix"
align="center" text_align="center" />
<box width="100%" height="195" padding="0">
<scrollable_toolbar id="gps" height="175" y="10" x="10" width="98%" align="center" label_location="each"
<box width="100%" proportion="1" layout="vertical-row" padding="0">
<scrollable_toolbar id="gps" x="1%" y="1%" width="98%" height="98%" align="center" label_location="each"
square_items="true" child_width="175" child_height="120" />
</box>
<header width="100%" I18N="In the track and grand prix selection screen" text="All Tracks"
align="center" text_align="center" />
<box proportion="1" width="100%" layout="vertical-row" padding="1">
<box proportion="3" width="100%" layout="vertical-row" padding="1">
<ribbon_grid id="tracks" proportion="1" width="100%" square_items="true"
label_location="bottom" align="center" max_rows="3"
child_width="160" child_height="120" />
<spacer width="20" height="13" />
<spacer width="20" height="5%" />
</box>
<!-- Populated dynamically at runtime -->

View File

@ -343,8 +343,12 @@ void DynamicRibbonWidget::buildInternalStructure()
// ---- determine column amount
const float row_height = (float)(m_h - m_label_height)/(float)m_row_amount;
float ratio_zoom = (float)row_height / (float)(m_child_height - m_label_height);
m_col_amount = (int)roundf( m_w / ( m_child_width*ratio_zoom ) );
float col_width = (float)(row_height * m_child_width / m_child_height);
// Give some margin for columns for better readability
col_width *= 1.2f;
m_col_amount = (int)floor( m_w / col_width );
// ajust column amount to not add more item slots than we actually need
const int item_count = (int) m_items.size();