TreeList: nb_items vs. scrollbar
Posted: Thu Sep 15, 2022 1:54 am
[Wasn't sure whether to put this here or in Bugs; on reflection, I don't think it's a bug per se, and I figure it's more likely to be seen here.]
Found an annoying wrinkle with the engine.ui.TreeList UI component. Here's the setup: TreeList:init() allows the caller to specify the list height either in pixels or number of rows, via the 'height' or 'nb_items' definition fields. In the latter case, :generate() later computes the list height from the specified number of rows and the font height (or a custom row height, if specified). Problem is, before that happens, if the caller specifies scrollbar=true, :init() builds a Slider component to use as the scrollbar, and bases its height on the list height — which hasn't yet been computed if the caller specified the list height in terms of nb_items. Practical upshot, it's impossible to build a TreeList with a scrollbar and a height defined by number of rows, which seems like an unnecessary restriction.
The simple fix, I think, would be to compute the pixel height in :init() if needed, if we have all the information we need; failing that, I suppose :generate() could resize the scrollbar Slider after computing the list height.
Found an annoying wrinkle with the engine.ui.TreeList UI component. Here's the setup: TreeList:init() allows the caller to specify the list height either in pixels or number of rows, via the 'height' or 'nb_items' definition fields. In the latter case, :generate() later computes the list height from the specified number of rows and the font height (or a custom row height, if specified). Problem is, before that happens, if the caller specifies scrollbar=true, :init() builds a Slider component to use as the scrollbar, and bases its height on the list height — which hasn't yet been computed if the caller specified the list height in terms of nb_items. Practical upshot, it's impossible to build a TreeList with a scrollbar and a height defined by number of rows, which seems like an unnecessary restriction.
The simple fix, I think, would be to compute the pixel height in :init() if needed, if we have all the information we need; failing that, I suppose :generate() could resize the scrollbar Slider after computing the list height.