From 33e5093e02a52d56148e435160816157c0b3ed88 Mon Sep 17 00:00:00 2001 From: jmb462 Date: Mon, 3 Jan 2022 22:15:59 +0100 Subject: [PATCH] Fix PopupMenu bad item offset with custom vseparation (cherry picked from commit 4de860c6d5eabc0cc2d3a8b390b56403576cbf16) --- scene/gui/popup_menu.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 5b5a8a48935..05d48dfa6e6 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -78,9 +78,7 @@ Size2 PopupMenu::get_minimum_size() const { String text = items[i].xl_text; size.width += font->get_string_size(text).width; - if (i > 0) { - size.height += vseparation; - } + size.height += vseparation; if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) { int accel_w = hseparation * 2; @@ -522,7 +520,9 @@ void PopupMenu::_notification(int p_what) { } for (int i = 0; i < items.size(); i++) { - if (i > 0) { + if (i == 0) { + ofs.y += vseparation / 2; + } else { ofs.y += vseparation; } Point2 item_ofs = ofs;