GUI2/Listbox: add header/footer size only if visible

Little hacky, since this supports the case of manually hiding the grids instead of simply not populating them (see #9499), but it prevents needing to change widget::get_best_size while I figure out a more comprehensive solution.
This commit is contained in:
Charles Dang 2024-12-22 08:18:36 -05:00
parent 11eaca1277
commit 001c90c1fc

View file

@ -468,11 +468,15 @@ point listbox::calculate_best_size() const
point result = scrollbar_container::calculate_best_size();
if(const grid* header = get_grid().find_widget<const grid>("_header_grid", false, false)) {
result.y += header->get_best_size().y;
if(header->get_visible() != widget::visibility::invisible) {
result.y += header->get_best_size().y;
}
}
if(const grid* footer = get_grid().find_widget<const grid>("_footer_grid", false, false)) {
result.y += footer->get_best_size().y;
if(footer->get_visible() != widget::visibility::invisible) {
result.y += footer->get_best_size().y;
}
}
return result;