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

[PopupMenu] Fix incorrect vertical scroll bar visible at fractional content scale #91114

Merged
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: 4 additions & 3 deletions scene/gui/popup_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
}
}

minsize.height = Math::ceil(minsize.height); // Ensures enough height at fractional content scales to prevent the v_scroll_bar from showing.
return minsize;
}

Expand Down Expand Up @@ -2832,9 +2833,9 @@ void PopupMenu::popup(const Rect2i &p_bounds) {
if (!is_embedded()) {
float win_scale = get_parent_visible_window()->get_content_scale_factor();
set_content_scale_factor(win_scale);
Size2 minsize = get_contents_minimum_size();
minsize.height += 0.5 * win_scale; // Ensures enough height at fractional content scales to prevent the v_scroll_bar from showing.
set_min_size(minsize * win_scale);
Size2 minsize = get_contents_minimum_size() * win_scale;
minsize.height = Math::ceil(minsize.height); // Ensures enough height at fractional content scales to prevent the v_scroll_bar from showing.
set_min_size(minsize); // `height` is truncated here by the cast to Size2i for Window.min_size.
set_size(Vector2(0, 0)); // Shrinkwraps to min size.
}
Popup::popup(p_bounds);
Expand Down
Loading