ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.01k stars 10.28k forks source link

Stretch table to window scrollable size #7574

Open akbyrd opened 6 months ago

akbyrd commented 6 months ago

Version/Branch of Dear ImGui:

1.90.1, docking

Back-ends:

Custom (Unreal)

Compiler, OS:

Windows 11, MSVC 2022

Full config/build information:

No response

Details:

I have a table in a window that has ImGuiWindowFlags_HorizontalScrollbar. If the window is too narrow for its contents and the horizontal scrollbar appears I'd like the table to stretch to the width of the window contents, instead of the physical window itself.

I don't think I can get the content size and specify the table width manually since that forms a feedback loop where the table can never get narrower.

Is this a supported use case?

Screenshots/Video:

image

Minimal, Complete and Verifiable Example code:

if (ImGui::Begin("Window", nullptr, ImGuiWindowFlags_HorizontalScrollbar))
{
    ImGui::Button("Button", ImVec2(400, 20));

    auto Flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerV;
    if (ImGui::BeginTable("Table", 2, Flags))
    {
        ImGui::TableSetupColumn("One");
        ImGui::TableSetupColumn("Two");
        ImGui::TableHeadersRow();

        ImGui::TableNextColumn();
        ImGui::Text("Content");

        ImGui::TableNextColumn();
        ImGui::Text("Content");

        ImGui::EndTable();
    }
}
ImGui::End();
catlowlevel commented 1 month ago

any update on this?