godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.05k stars 65 forks source link

Add a button to list all tabs in TabBar #9642

Open 4d49 opened 2 weeks ago

4d49 commented 2 weeks ago

Describe the project you are working on

Scene Library

Describe the problem or limitation you are having in your project

If you have many tabs, you will find it difficult to move quickly between them.

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

To fix the problem we can add a button that will show Popup with a list of all tabs as it is done for example in Firefox. image

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

We need to add an enum and variable to TabBar for control the display policy of the button.

enum TabListButtonDisplayPolicy {
    TAB_LIST_BUTTON_SHOW_NEVER,
    TAB_LIST_BUTTON_SHOW_ALWAYS,
    // Displays the button only if not all tabs fit on the screen.
    TAB_LIST_BUTTON_SHOW_ONLY_OFFSET_BUTTONS_VISIBLE,
};

// By default, I think the `TAB_LIST_BUTTON_SHOW_NEVER` policy should be used.
TabListButtonDisplayPolicy tab_list_displaypolicy = TAB_LIST_BUTTON_SHOW_NEVER;

We need to add a child MenuButton for TabBar with a list of all tabs. And if a value of the variable is set as TAB_LIST_BUTTON_SHOW_ONLY_OFFSET_BUTTONS_VISIBLE or TAB_LIST_BUTTON_SHOW_ALWAYS allow the button to be displayed.

An example of what it looks like in my addon: test (2)

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

Yes.

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

This solved a problem in the editor itself with many tabs. By default, the size of the tabs in the editor is very large, which makes the tabs with large names fit on the screen very small. And you have to scroll through the tabs a lot to navigate between scenes.

Example: image

And adding such a button as I think would make navigation much easier.

4d49 commented 2 weeks ago

If adding this button to the TabBar for some reason is unacceptable, we can add a special button in the editor to simplify navigation between scenes.