Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Tables: unexpected column's ItemWidth when using PushItemWidth/PopItemWidth or multi-components widgets #3760

Closed
dmlo opened this issue Jan 26, 2021 · 1 comment

Comments

@dmlo
Copy link

dmlo commented Jan 26, 2021

Version/Branch of Dear ImGui:

Version: 1.80 via Conan, 1.81 WIP via git clone just now
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: Clang 11.0.1
Operating System: Arch Linux

My Issue/Question:

Experienced unexpected draw result with ImGui::DragFloatRange2() while testing the new (very nice) Tables API.

In the upper part of the left window is the new tables implementation. The lower part is the same content using the previous Columns API.

The smaller window on the right is the MCVE code below.

Issue occurs using any of the three table layout methods described in imgui_demo.cpp beginning at line 3477.

Screenshots/Video

image

Standalone, minimal, complete and verifiable example:

    ImGui::Begin("Drag");
    if(ImGui::BeginTable("Table1", 2)){
        std::vector<float> vals1{0.5, 1.5, 2.5};
        std::vector<float> vals2{1.5, 2.5, 3.5};

        for (int i = 0; i <3; i++) {
            ImGui::TableNextRow();

            ImGui::TableSetColumnIndex(0);
            ImGui::Text("Row %d", i);

            ImGui::TableSetColumnIndex(1);
            ImGui::DragFloatRange2("label", &vals1[i], &vals2[i]);
        }
        ImGui::EndTable();
    }
    ImGui::End();

Thank you for this excellent UI library. It is a pleasure to use.

@ocornut ocornut changed the title Unexpected DragFloatRange2 draw result in new Tables API cell Unexpected column's ItemWidth when using multi-components widgets in Tables API cell Jan 27, 2021
@ocornut ocornut added the bug label Jan 27, 2021
@ocornut ocornut changed the title Unexpected column's ItemWidth when using multi-components widgets in Tables API cell Tables: unexpected column's ItemWidth when using PushItemWidth/PopItemWidth or multi-components widgets Jan 27, 2021
ocornut added a commit that referenced this issue Jan 27, 2021
…per-colum ItemWidth correctly. (#3760) rework local stacks to facilitate modifying current value without altering the stack.

May consider doing the same for ItemFlags and moving to g.ItemFlags...
@ocornut
Copy link
Owner

ocornut commented Jan 27, 2021

Thank for the report. This was indeed a bug with how Tables columns would alter the ItemWidth value.
Pushed a fix in e28b517

@ocornut ocornut closed this as completed Jan 27, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants