TabBar horizontally aligned with another widget

Hello, I’m trying to get tab bar aligned with another widget using SameLine() but the content is still shifted to the next “row”. If I put SameLine() before Text - text will appear on a tabs line, but not “inside”:

Screenshot%20from%202019-05-24%2014-14-49

Here’s a code I added to the demo:

ImGui::Text("Lists:");
        static int selection[4] = { 0, 1, 2, 3 };
        for (int i = 0; i < 4; i++)
        {
            if (i > 0) ImGui::SameLine();
            ImGui::PushID(i);
            ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items));
            ImGui::PopID();
            //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i);
        }

        ImGui::SameLine();
        if(ImGui::BeginTabBar("tabs", 0)) {
          if(ImGui::BeginTabItem("item")) {
            ImGui::Text("test tab text");
            ImGui::EndTabItem();
          }
          if(ImGui::BeginTabItem("item2")) {
            ImGui::Text("test 2222 tab text");
            ImGui::EndTabItem();
          }
          ImGui::EndTabBar();
        }
        ImGui::PopItemWidth();

It is a little ambiguous what the right thing to do is, it is indeed going to the next line, and as the line height has been extended by the large listbox that’s where it goes. If you surround BeginTabBar()/EndTabBar() with a BeginGroup()/EndGroup() it’ll behave like you want.

            ImGui::Button("Blah", ImVec2(200, 200));
            ImGui::SameLine();
            //ImGui::BeginGroup();
            if (ImGui::BeginTabBar("ai"))
            {
                if (ImGui::BeginTabItem("hello"))
                {
                    ImGui::Text("Contents");
                    ImGui::EndTabItem();
                }
                ImGui::EndTabBar();
            }
            //ImGui::EndGroup();

This worked, thanks! Btw I’m asking many questions because I’m doing Erlang port: https://gitlab.com/maxvel/eimgui

You should probably make your binding auto-generated using the metadata output by cimgui (you may not even need to call cimgui, use that the data is generates).