diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2023-04-02 13:26:11 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-04 19:15:15 +0200 |
commit | 82c06f58af610179e2536ccccf23f75a1342fd86 (patch) | |
tree | e9d71e871889cdd41f82347c4568d1811dcc7b64 /Userland/Libraries/LibGUI | |
parent | 99f28cf4ac1ff6c3d46c875a1cc5d00d0d6f67fe (diff) | |
download | serenity-82c06f58af610179e2536ccccf23f75a1342fd86.zip |
LibGUI: Allow ComboBox windows to intersect Desktop's entire height
Minus a tasteful item height remainder. Ignoring Taskbar is okay now
that the window is a PopUp.
Also expands its width if intersection with the Desktop makes its
ListView scrollable. ComboBox windows no longer intersect horizontally,
remaining firmly "attached" to the editor, similar to other classic UIs.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/ComboBox.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index 747625ee38..0c7f3cd117 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -245,17 +245,29 @@ void ComboBox::open() auto frame = m_list_view->frame_thickness() * 2; auto max_height = min(m_list_view->item_height() * m_max_visible_items, m_list_view->content_height()); - Gfx::IntSize size { max(width(), m_list_view->content_width() + frame), max_height + frame }; + auto min_width = m_list_view->content_width() + frame; + Gfx::IntSize size { max(width(), min_width), max_height + frame }; Gfx::IntRect rect { screen_relative_rect().bottom_left(), size }; - auto desktop = Desktop::the().rect().shrunken(0, 0, Desktop::the().taskbar_height(), 0); + auto desktop = Desktop::the().rect(); auto min_height = 5 * m_list_view->item_height() + frame; auto go_upwards_instead = rect.bottom() >= desktop.height() && rect.intersected(desktop).height() < min_height; if (go_upwards_instead) { auto origin = screen_relative_rect().top_left(); rect = { Gfx::IntPoint { origin.x(), origin.y() - size.height() }, size }; } - rect.intersect(desktop); + + auto intersection = rect.intersected(desktop); + rect.set_top(intersection.top()); + rect.set_bottom(intersection.bottom()); + + auto remainder = (rect.height() - frame) % m_list_view->item_height(); + go_upwards_instead ? rect.take_from_top(remainder) : rect.take_from_bottom(remainder); + + auto scrollbar_width = m_list_view->vertical_scrollbar().width(); + if (max_height > rect.height() && width() < min_width + scrollbar_width) + rect.set_width(rect.width() + scrollbar_width); + m_list_window->set_rect(rect); m_list_view->set_min_size(rect.size()); |