Skip to content

Commit 43d7346

Browse files
committed
Merge pull request #91114 from Koyper/fix_popup_menu_incorrect_v_scrollbar
[PopupMenu] Fix incorrect vertical scroll bar visible at fractional content scale
2 parents f859400 + 4c5a904 commit 43d7346

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scene/gui/popup_menu.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ Size2 PopupMenu::_get_contents_minimum_size() const {
276276
}
277277
}
278278

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

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

0 commit comments

Comments
 (0)