mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-23 17:58:59 +00:00
WindowServer: Fix menu height when invisible items are involved
This patch checks for visible items to determine the menu height. Now the last visible item is used to determine the height of the menu. Before this patch that menu height could be wrong e.g. if the last item was not visible.
This commit is contained in:
parent
8c681a1603
commit
d8320d0a14
Notes:
sideshowbarker
2024-07-17 11:30:54 +09:00
Author: https://github.com/Torstennator
Commit: d8320d0a14
Pull-request: https://github.com/SerenityOS/serenity/pull/19380
Reviewed-by: https://github.com/gmta ✅
1 changed files with 8 additions and 1 deletions
|
@ -129,7 +129,14 @@ Window& Menu::ensure_menu_window(Gfx::IntPoint position)
|
|||
auto calculate_window_rect = [&]() -> Gfx::IntRect {
|
||||
int window_height_available = screen.height() - frame_thickness() * 2;
|
||||
int max_window_height = (window_height_available / item_height()) * item_height() + frame_thickness() * 2;
|
||||
int content_height = m_items.is_empty() ? 0 : m_items.last()->rect().bottom() + frame_thickness();
|
||||
int content_height = 0;
|
||||
// find the last visible item to determine the required menu height
|
||||
for (size_t i = m_items.size(); i > 0; i--) {
|
||||
if (m_items[i - 1]->is_visible()) {
|
||||
content_height = m_items[i - 1]->rect().bottom() + frame_thickness();
|
||||
break;
|
||||
}
|
||||
}
|
||||
int window_height = min(max_window_height, content_height);
|
||||
if (window_height < content_height) {
|
||||
m_scrollable = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue