diff options
author | Matthew Jones <matthewbjones85@gmail.com> | 2021-06-02 18:15:50 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-03 08:24:18 +0200 |
commit | ef92493abaeae1334e829dfcd05554a843a0be35 (patch) | |
tree | 9f157c9e65ac37c3931c65ab11d69259fe9ce0f3 /Userland/Libraries/LibGUI/ComboBox.cpp | |
parent | 36a1162eb8e078305aefdcd66a901c8df42c824b (diff) | |
download | serenity-ef92493abaeae1334e829dfcd05554a843a0be35.zip |
LibGUI: ComboBox now goes upwards when running out of room to render
Diffstat (limited to 'Userland/Libraries/LibGUI/ComboBox.cpp')
-rw-r--r-- | Userland/Libraries/LibGUI/ComboBox.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index 4814e49153..ced858b853 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -235,11 +235,15 @@ void ComboBox::open() 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); + // Change direction and go upwards to prevent the list from becoming + // infinitesimally small when pushed up against the screen edge. + auto minimum_height = min(3, model()->row_count()) * m_list_view->item_height() + m_list_view->frame_thickness() * 2; + bool go_upwards_instead = list_window_rect.height() <= minimum_height; + if (go_upwards_instead) { + auto origin_point = my_screen_rect.top_left(); + list_window_rect = { Gfx::IntPoint { origin_point.x(), origin_point.y() - size.height() }, size }; + list_window_rect.intersect(Desktop::the().rect()); + } m_list_window->set_rect(list_window_rect); m_list_window->show(); |