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

Add a Reverse Sort property to BoxContainer #27

Open
Kazox61 opened this issue Oct 18, 2024 · 1 comment
Open

Add a Reverse Sort property to BoxContainer #27

Kazox61 opened this issue Oct 18, 2024 · 1 comment

Comments

@Kazox61
Copy link

Kazox61 commented Oct 18, 2024

Describe the project you are working on

A card game where you need to select and scroll throw many card slots

Describe the problem or limitation you are having in your project

I want a way that my card slots can overlap each other when activated and that the upper card slot in the scene tree takes the input event.

2024-10-16.11-58-27.mp4

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

A way to fix this would be having a boolean that sorts the items in reverse, same as in css flex-direction row-reverse.
This way you can have the upper item in the screen to be lower in the scene tree, so the input events will trigger in the different order.

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

Having a boolean named sort_reverse available in the editor

void BoxContainer::_resort() {
    ...

    for (int i = 0; i < get_child_count(); i++) {
        int index = i;
        if (sort_reverse) {
             index = get_child_count() - 1 - i;
        }
        Control *c = as_sortable_control(index);
    }
}

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

This can not be worked around, the only way i achieved it was writing the same logic for the BoxContainer in GDScript and adding the logic of the reverse sorting

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

This should be directly integrated in the BoxContainer Node

@jovantanyk
Copy link

Seems like a good change to me, I'm curious why this isn't a thing yet

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

No branches or pull requests

3 participants