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

Control size changes after changing its type to a subtype #78779

Closed
spikeyarmaku opened this issue Jun 28, 2023 · 2 comments · Fixed by #91804
Closed

Control size changes after changing its type to a subtype #78779

spikeyarmaku opened this issue Jun 28, 2023 · 2 comments · Fixed by #91804

Comments

@spikeyarmaku
Copy link

Godot version

v4.0.3.stable.official [5222a99]

System information

Windows 10 - Godot v4.0.3stable

Issue description

If a root Control node's type is changed to a Control subtype, its size will change as well.

Steps to reproduce

  • Create a new User Interface scene
  • Change the type to something else, e.g. VBoxContainer

godot_bug

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented Jun 28, 2023

I can confirm this on v4.1.beta.custom_build 3aaa787 (Linux). Note that it appears pretty flaky: if you resize the editor window after changing type, the control's size will change back to its original size. The exact size that appears temporarily can also vary, and undo/redo can mess it up too.

Also, this doesn't occur with all controls – for instance, switching from Control to HSlider won't exhibit this issue.

@YuriSizov YuriSizov added this to the 4.x milestone Jun 28, 2023
@jpcerrone
Copy link
Contributor

I tried looking into this issue but couldn't figure out what causes it. Here are some of the things I found in case someone finds them helpful:

Selecting the same type of node when switching, e.g. from a Control node to a Control node, produces the same issue, it gets resized to a different size.

There's this function gets called during the resize:

Rect2 Control::get_parent_anchorable_rect() const {

In this section of it the rect that will be used as the base to calculate the new node's size is determined:

if (scene_root_parent && get_viewport() == scene_root_parent->get_viewport()) {
	parent_rect.size = Size2(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height"));
} else {
	parent_rect = get_viewport()->get_visible_rect();
}

While the if branch would return the global viewport's size, which correspond to the original control node's size (1152x648). During resizes the else branch is always taken. parent_rect = get_viewport()->get_visible_rect(); always returns (1348x649), which seems to correspond to a Subviewport, child of a Window node, not sure how those are related to our Control node. This last size is the one we can see being the base size when changing the type of the node in the editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants