Godot Version
4.4.1.stable
Question
Using an AspectRatioContainer to hold the debug GUI of enemy units. I grow and shrink it when I click on buttons to show information.
Problem is, when it shrinks back, it doesn’t go back to its initial position, which I would prefer it did. Since it’s a debug thing, I know it’s not the most important thing to fix, but I still want to know why it does this and how I can fix it (hopefully).
Here are some info:
The Scene
The AspectRatioContainer’s basic info (what’s not shown is unchanged standard values):
When made visible the first time:
Opened up:
Collapsed back to original:
From all this we can clearly see that, when opened, the dialog is extended to the right and down of its original position, but when closed, the top left corner remains where it was put after its repositioning whereas I’d rather it went back to its original place.
I’m pretty sure I’ve tried every permutation of the options. Anyone has a suggestion?
Much appreciated.
Maybe this is a silly question, but why don’t you just put the dialog where you want it?
I’ve thought about that for most of the GUI I use, in fact, for all GUI purposes in all my projects I think of that option all the time. But as a game consumer and player, I do not like it. Not fond of it in any way. So, I’ll try to avoid it as much as possible.
Thanks for your input anway. 
I just realized that you might mean to manually set its position instead of having the dialog at a set position.
This could work, but I’d have to decouple the GUI elements with the unit scene. As it is, the dialog will rotate and move with the unit; I have a method that takes care of that. I don’t want to overcomplicate the whole thing.
What happens in your example if you set the anchor to “top left” instead of “center” as it is in the screenshot?
Sadly no change. It had been that way for a while now, truth be told because let’s face it, that’s the option I really thought would make this work (also, that’s the default setting; an even bigger reason to think this would work right).
I have found Godot’s layout stuff to be only semi-reliable; there’s a few places in my current project where I wound up eyeballing positions and manually typing in offsets to make things work, and I cannot explain the math that would lead to the numbers I had to use.
The hack fix for this is, when you initially open the control, grab the position. That will get you where it should be when it’s un-extended. When you close the extension, hammer the original position back in.
This is the outline of the dialog while it is selected in remote. You can see the orange outline.
Now, the same dialog once it’s brought back to its original size. To me it feels like it is stuck on TOP and CENTER after it’s been resized… ?
Just weird.
For now I’ll leave it at that. As I said, this is debug purpose so not a deal. But I would very much understand why it’s not going back to TOP CORNER, as it is set. Maybe there something in there I don’t get.
Maybe set top left anchor for the PanelContainer
under DebugInfo
too?
It seems like the control is expanding as needed but not contracting when possible.
1 Like
Well, color me dumb. That worked.
The whole thing now collapse where it should. FYI the two Container Sizing
were set to shrink center and that’s what was causing the improper collapse back to its parent’s top left coordinates. Which, to my brain, is really weird. The Sizing is now set to Shrink Begin Left (H) and Top (V).
But hey, it works and I’m guessing there’s a reason for that.
Thank! Much appreciated.
1 Like