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

tab-bar scroll-buttons appear but are not working. What am I doing wrong? #4850

Closed
nobody-special666 opened this issue Dec 31, 2021 · 2 comments
Labels
tabs tab bars, tabs

Comments

@nobody-special666
Copy link

nobody-special666 commented Dec 31, 2021

Version: latest
Branch: docking

Back-ends: glfw / allegro5
Compiler: g++
Operating System: ubuntu

My Issue/Question:

Hi all,
Goal: Since ImGui doesn't have a toolbar widget, I want to use a tab-bar instead in docked windows.

So I create a tab-bar (with no content) but when I set the ImGuiTabBarFlags_FittingPolicyScroll flag, the tab-bar scroll-buttons appear but don't work, so I can't get to the other buttons in the tab-bar.
Is this a bug, or else what am I doing wrong?
(see demo code below)

Thanks for any help and thanks for ImGui.
Regards

Screenshots/Video

image

// Demonstrate most Dear ImGui features (this is big function!)
// You may execute this function to experiment with the UI and understand what it does.
// You may then search for keywords in the code when you are interested by a specific feature.
void ImGui::ShowDemoWindow(bool* p_open)
{
    // test window
    {
        bool open= false;
        ImGui::Begin("test", &open);


        static ImVector<int> active_tabs;
        static int next_tab_id = 0;
        if (next_tab_id == 0) // Initialize with some default tabs
            for (int i = 0; i < 10; i++)
                active_tabs.push_back(next_tab_id++);

        static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_FittingPolicyScroll;
        if (ImGui::BeginTabBar("MyTabBar2", tab_bar_flags))
        {
            // Submit our regular tabs
            for (int n = 0; n < active_tabs.Size; )
            {
                bool open = true;
                char name[16];
                snprintf(name, IM_ARRAYSIZE(name), "%04d##test", active_tabs[n]);
                ImGui::TabItemButton(name);

                n++;
            }

            ImGui::EndTabBar();
        }

        ImGui::BeginChild("##");
        ImGui::Text("this window does not belong to any tab!");
        ImGui::EndChild();

        ImGui::End();
    }


    // Exceptionally add an extra assert here for people confused about initial Dear ImGui setup
    // Most ImGui functions would normally just crash if the context is missing.
@ocornut ocornut added the tabs tab bars, tabs label Jan 2, 2022
@ocornut
Copy link
Owner

ocornut commented Jan 2, 2022

The reason is that unlike tabs, those buttons are not selectable so there's no reference point to scroll to.
When you mix buttons and regular tabs, the buttons are skipped by those arrows.

So not have not doing anything wrong here and it's an interesting idea but right now it won't work. Using regular TabItem will work, you might alter their style so they don't look like tabs? By pushing PushStyleVar(ImGuiStyleVar_TabRounding, 0.0f); etc.

@nobody-special666
Copy link
Author

Thank you so much, that worked!
and a happy new year!

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

No branches or pull requests

2 participants