mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
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. :^)
This commit is contained in:
parent
2d1cfa7d11
commit
05914d2e9a
Notes:
sideshowbarker
2024-07-18 22:11:00 +09:00
Author: https://github.com/nvella Commit: https://github.com/SerenityOS/serenity/commit/05914d2e9a8 Pull-request: https://github.com/SerenityOS/serenity/pull/5369 Reviewed-by: https://github.com/awesomekling
1 changed files with 7 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue