From ccddf1e018136d47c59646252de0580130cb2231 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:11:03 +0200 Subject: [PATCH] City overview Fix Hotfix (#10220) * Hotfix kludge to make City Overview behave when not taking up all screen width * Guard against unsupported SortableGrid config --- core/src/com/unciv/ui/components/SortableGrid.kt | 4 ++++ .../unciv/ui/screens/overviewscreen/CityOverviewTab.kt | 8 ++++++++ .../ui/screens/overviewscreen/CityOverviewTabColumn.kt | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/ui/components/SortableGrid.kt b/core/src/com/unciv/ui/components/SortableGrid.kt index ed26ffcdcb..b9a2932c57 100644 --- a/core/src/com/unciv/ui/components/SortableGrid.kt +++ b/core/src/com/unciv/ui/components/SortableGrid.kt @@ -87,6 +87,10 @@ class SortableGrid> ( 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) diff --git a/core/src/com/unciv/ui/screens/overviewscreen/CityOverviewTab.kt b/core/src/com/unciv/ui/screens/overviewscreen/CityOverviewTab.kt index 95a9484524..ca6652a6bb 100644 --- a/core/src/com/unciv/ui/screens/overviewscreen/CityOverviewTab.kt +++ b/core/src/com/unciv/ui/screens/overviewscreen/CityOverviewTab.kt @@ -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) } } diff --git a/core/src/com/unciv/ui/screens/overviewscreen/CityOverviewTabColumn.kt b/core/src/com/unciv/ui/screens/overviewscreen/CityOverviewTabColumn.kt index d23b443472..54c863e60b 100644 --- a/core/src/com/unciv/ui/screens/overviewscreen/CityOverviewTabColumn.kt +++ b/core/src/com/unciv/ui/screens/overviewscreen/CityOverviewTabColumn.kt @@ -85,7 +85,7 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider