don-tnowe / godot-extra-controls

MIT License
105 stars 3 forks source link

Add a failsafe to initial custom_minimum_size setting for InterpolatedContainer #7

Open KingTempest07 opened 2 months ago

KingTempest07 commented 2 months ago

In my case, after ready(), the custom minimum size was incorrect on my horizontal InterpolatedBoxContainer until I manually tried to change it remotely during runtime or interact via drag/drop with the container via drag/drop (which did contain some other box containers, maybe the reason?). After some testing, though, the following seemed to work and unless this breaks anything I didn't realize, this seems to fix it at minimal cost:

var _double_sorted_children := false

func _process(delta : float):
    if not _double_sorted_children:
        custom_minimum_size = Vector2.ZERO
        _double_sorted_children = true;

    // continue _process()...

Of course, all this does is call for children sorting on the first time _process() is run. Maybe there's a better fix or something to fix the root cause, but this seems good enough lol. And I didn't really do much testing or even figure out if this is a common issue, but I figured I'd report it anyway jic

Edit: I also want to thank you for making this, this thing is saving my life frfr

don-tnowe commented 2 months ago

Minsize seems to be correct to me. However, children are positioned incorrectly in the container, as if its size is 0. This happens if the container is inside another container and isn't set to compact_if_overflow. So I'll have to investigate for two possible sorting issues.

Adding the minimum size assignment into _ready() did not seem to fix it. Perhaps _process(), like you did there, has some magic?

KingTempest07 commented 2 months ago

Minsize seems to be correct to me. However, children are positioned incorrectly in the container, as if its size is 0. This happens if the container is inside another container and isn't set to compact_if_overflow. So I'll have to investigate for two possible sorting issues.

For reference, this is my setup: image

I have one container before the interpolated container just so that it can't be reordered like the others, but removing that changed nothing. I also had compact_if_overflow tested for both ways, but neither worked. And I believe the number I was getting before on custom_minimum_size was 331, but when updated, it stayed at the correct 170.

Adding the minimum size assignment into _ready() did not seem to fix it. Perhaps _process(), like you did there, has some magic?

Yeah, I tried on _ready() but that didn't work. I'm assuming it's just some weird ordering issue that _process() is late enough to fix?