From 05914d2e9a81243a82369862e28c8ae59d6a38cd Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Wed, 17 Feb 2021 00:48:14 +1100 Subject: [PATCH] LibGUI: Correctly handle ComboBox list windows of less than three items (~50px) in height. By default, a Window has a minimum size of 50x50 - ComboBox lists aren't always this tall. We now set the minimum height of the ComboBox Window according to the height of three items, or the total height of all the items in the list, whichever is smaller. This means there is no longer any unpainted space in the list window due to the shortfall between the ListBox widget and Window heights, and the ComboBox list window always remains a comfortable height for viewing. :^) --- Userland/Libraries/LibGUI/ComboBox.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index 73721a4357..510074df8c 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -244,6 +244,13 @@ void ComboBox::open() // change the list view's selected item without triggering a change to it. m_list_view->set_cursor(m_selected_index.value(), AbstractView::SelectionUpdate::Set); } + + // Set the minimum minimum height of the list window to the height of three + // items or the row count, whichever is smaller, plus the frame thickness. + // This prevents the list from becoming infinitesimally small when pushed + // up against the screen edge. + m_list_window->set_minimum_size(1, min(3, model()->row_count()) * m_list_view->item_height() + m_list_view->frame_thickness() * 2); + m_list_window->set_rect(list_window_rect); m_list_window->show(); }