@@ -3211,21 +3211,24 @@ void PopupMenu::popup(const Rect2i &p_bounds) {
32113211 moved = Vector2 ();
32123212 popup_time_msec = OS::get_singleton ()->get_ticks_msec ();
32133213
3214- Size2 scale = get_parent_viewport ()->get_popup_base_transform ().get_scale ();
3215- CanvasItem *c = Object::cast_to<CanvasItem>(get_parent ());
3216- if (c) {
3217- scale *= c->get_global_transform_with_canvas ().get_scale ();
3218- }
3219- real_t popup_scale = MIN (scale.x , scale.y );
3220- set_content_scale_factor (popup_scale);
3221- Size2 minsize = get_contents_minimum_size () * popup_scale;
3222- minsize.height = Math::ceil (minsize.height ); // Ensures enough height at fractional content scales to prevent the v_scroll_bar from showing.
3223- set_min_size (minsize); // `height` is truncated here by the cast to Size2i for Window.min_size.
3224- set_size (Vector2 (0 , 0 )); // Shrinkwraps to min size.
32253214 Popup::popup (p_bounds);
32263215 }
32273216}
32283217
3218+ void PopupMenu::_pre_popup () {
3219+ Size2 scale = get_parent_viewport ()->get_popup_base_transform ().get_scale ();
3220+ CanvasItem *c = Object::cast_to<CanvasItem>(get_parent ());
3221+ if (c) {
3222+ scale *= c->get_global_transform_with_canvas ().get_scale ();
3223+ }
3224+ real_t popup_scale = MIN (scale.x , scale.y );
3225+ set_content_scale_factor (popup_scale);
3226+ Size2 minsize = get_contents_minimum_size () * popup_scale;
3227+ minsize.height = Math::ceil (minsize.height ); // Ensures enough height at fractional content scales to prevent the v_scroll_bar from showing.
3228+ set_min_size (minsize); // `height` is truncated here by the cast to Size2i for Window.min_size.
3229+ reset_size (); // Shrinkwraps to min size.
3230+ }
3231+
32293232void PopupMenu::set_visible (bool p_visible) {
32303233 bool native = global_menu.is_valid ();
32313234#ifdef TOOLS_ENABLED
0 commit comments