From 18fedd9c135e5f48cc7671e688917fd89076998f Mon Sep 17 00:00:00 2001 From: Marius Hanl Date: Thu, 14 Dec 2023 02:22:08 +0100 Subject: [PATCH] Fix Popup hover and height calculation are off by some pixels This was caused by an incorrect calculation of the v_separation where it was not needed --- scene/gui/popup_menu.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index d6b8dd02025d..8eddc2018635 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -237,8 +237,7 @@ int PopupMenu::_get_items_total_height() const { items_total_height += _get_item_height(i) + theme_cache.v_separation; } - // Subtract a separator which is not needed for the last item. - return items_total_height - theme_cache.v_separation; + return items_total_height; } int PopupMenu::_get_mouse_over(const Point2 &p_over) const { @@ -247,14 +246,14 @@ int PopupMenu::_get_mouse_over(const Point2 &p_over) const { } // Accounts for margin in the margin container - Point2 ofs = theme_cache.panel_style->get_offset() + Point2(0, theme_cache.v_separation / 2); + Point2 ofs = theme_cache.panel_style->get_offset(); if (ofs.y > p_over.y) { return -1; } for (int i = 0; i < items.size(); i++) { - ofs.y += i > 0 ? theme_cache.v_separation : (float)theme_cache.v_separation / 2; + ofs.y += theme_cache.v_separation; ofs.y += _get_item_height(i);