Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Popup hover and height calculation are off by some pixels #86141

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions scene/gui/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);

Expand Down
Loading