ocornut / imgui

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

Change height of table header row to match the other rows #6300

Open LochieR opened 1 year ago

LochieR commented 1 year ago

Version/Branch of Dear ImGui:

Version: 1.89.4 Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp Compiler: MSVC Operating System: Windows 11

My Issue/Question:

How to change the size of the table header row the same way you can with the rest of the rows, and also vertically center this text?

Screenshots/Video

Screenshot

Standalone, minimal, complete and verifiable example:

ImGui::Begin("table");
if (ImGui::BeginTable("table", 2, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders, ImVec2(200.0f, 166.0f)))
{
    ImGui::TableSetupScrollFreeze(0, 1);
    ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_WidthFixed, 100.0f);
    ImGui::TableSetupColumn("Two", ImGuiTableColumnFlags_WidthFixed, 100.0f);
    ImGui::TableHeadersRow(/* Set header height here */);

    for (int row = 0; row < 4; row++)
    {
        ImGui::TableNextRow(0, ImGui::CalcTextSize("Text").y * 2.0f);
        for (int column = 0; column < 2; column++)
        {
            ImGui::TableSetColumnIndex(column);

            ImGui::AlignTextToFramePadding();
            ImGui::Text("cell %i,%i", column, row);
        }
    }

    ImGui::EndTable();
}
ImGui::End();
ocornut commented 1 year ago

You'll have to submit the row yourself manually. See e.g. https://github.com/ocornut/imgui/issues/6279#issuecomment-1488351010