City overview Fix Hotfix (#10220)

* Hotfix kludge to make City Overview behave when not taking up all screen width

* Guard against unsupported SortableGrid config
This commit is contained in:
SomeTroglodyte 2023-10-03 11:11:03 +02:00 committed by GitHub
parent 937f21188c
commit ccddf1e018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -87,6 +87,10 @@ class SortableGrid<IT, ACT, CT: ISortableGridContentProvider<IT, ACT>> (
private val totalsRow = Table(skin)
init {
require (!separateHeader || columns.none { it.expandX }) {
"SortableGrid currently does not support separateHeader combined with expanding columns"
}
headerRow.defaults().pad(paddingVert, paddingHorz).minWidth(iconSize)
details.defaults().pad(paddingVert, paddingHorz).minWidth(iconSize)
totalsRow.defaults().pad(paddingVert, paddingHorz).minWidth(iconSize)

View File

@ -36,13 +36,21 @@ class CityOverviewTab(
separateHeader = true
) {
header, details, totals ->
// Notes: header.parent is the LinkedScrollPane of TabbedPager. Its linked twin is details.parent.parent.parent however!
// horizontal "slack" if available width > content width is taken up between SortableGrid and CityOverviewTab for the details,
// but not so for the header. We must force the LinkedScrollPane somehow (no? how?) to do so - or the header Table itself.
equalizeColumns(details, header, totals)
// todo Kludge! Positioning and alignment of the header Table within its parent has quirks when content width < stage width
// This code should likely be included in SortableGrid anyway?
if (header.width < this.width) header.width = this.width
this.validate()
}
override fun getFixedContent() = grid.getHeader()
init {
top()
add(grid)
}
}

View File

@ -85,7 +85,7 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
Construction {
override val align = Align.left
override val expandX = true
override val expandX = false
override val equalizeHeight = true
override val headerTip = "Current construction"
override val defaultDescending = false