From 0b9b258224216764bbe6516c603b31abde7e3096 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 6 Feb 2023 12:54:05 -0800 Subject: [PATCH] ensure scrollable lists are centered in the visible viewport --- docs/changelog.txt | 1 + library/lua/gui/widgets.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index ff9ad46a7..6d0fda5fc 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,6 +38,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes - ``Units::isFortControlled``: Account for agitated wildlife - Fix right click sometimes closing both a DFHack window and a vanilla panel +- Fixed issue with scrollable lists having some data off-screen if they were scrolled before being made visible ## Misc Improvements - `automelt`: is now more resistent to savegame corruption diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index abbd70f7d..91f0188dd 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -1634,6 +1634,7 @@ end function List:postComputeFrame(body) self.page_size = math.max(1, math.floor(body.height / self.row_height)) + self.page_top = math.max(1, math.min(#self.choices - self.page_size + 1)) update_list_scrollbar(self) end