godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 69 forks source link

Allow Selecting `SubViewport` and `Window` children in `CanvasItemEditor`. #9877

Open WhalesState opened 1 month ago

WhalesState commented 1 month ago

Describe the project you are working on

N/A

Describe the problem or limitation you are having in your project

When using SubViewportContainer or Window, we can't select any of their children in CanvasItemEditor.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I already have implemented and tested it in a hard fork, the issue is that applying the changes to godot master repo will take some time and I'm afraid that they don't merge it at the end, that's why I'm opening this feature proposal.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

SubViewport:

https://github.com/godotengine/godot-proposals/assets/53877170/57c993d3-6884-4251-859c-b9fdcd4ebf8e

Window:

https://github.com/godotengine/godot-proposals/assets/53877170/22daa737-dc58-4d9d-a558-68e7b2556e1f

If this enhancement will not be used often, can it be worked around with a few lines of script?

N/A

Is there a reason why this should be core and not an add-on in the asset library?

N/A

lostminds commented 1 month ago

I've run into this issue as well, making secondary window panels (like settings, about etc) for a non-game project.

I've started working around it by including the window node for each panel as a separate child node a control node for the panel UI scene, to be able to select and move the panel content UI controls easily. And then doing some re-parenting gymnastics on_ready where I first re-parent the child window node, resize it to fit to UI parent control node and then finally re-parenting the panel content control node into the window. Would feel a lot better if it was possible to just place the controls in the window node in the scene from the start and avoid this re-parenting.

WhalesState commented 1 month ago

@lostminds I ran into the same issue for the same reason, and I'm doing the same, you can set the anchor and offset preset for each of your control scenes to preset full rect and saving it, and the Window flag wrap_controls to true, this will make your control node fills the window area by default once they are added as a child. also when the node is resized they will update their size.

You will find it here, the Control scene should expand to fill the viewport rect like this.

image

Implementing this for the Window class was the easiest part, since it doesn't have a Transform2D rotation or scale, just a position. yet it still needs some more work because i just have found those scale options 🗡️😭.

image

Edit: Since the content scale code is really advanced and in most cases users will not change them from editor, (I didn't even realize those settings exists until now, I used to change them in ProjectSettings only), so it can be skipped.