ocornut / imgui

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

Left upper corner coordinates and child window dimensions for different border thicknesses #7888

Open ElectroidDes opened 3 months ago

ElectroidDes commented 3 months ago

Version/Branch of Dear ImGui:

1.90.8

Back-ends:

Raylib

Compiler, OS:

Windows10

Full config/build information:

No response

Details:

For different values ​​of the child window frame width - the return value of the child window size GetWindowSize - differs from the actual visible size.

The same applies to the position of the Upper Left corner of the Child Window. For different values ​​of the child window frame width - the return value of the child window position GetWindowPos - differs from the actual visible position.

Because of this, it is just impossible to accurately position and calculate the necessary coordinates of objects.

ImGui::Begin("Main Window");

    //---------------------------------------------------------------------------
    float border_thickness1 = 1;
    ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, border_thickness1);
    ImGui::BeginChild("Child Window 1", ImVec2(180, 180), true);
    ImGui::Text(&(std::to_string((int)ImGui::GetWindowWidth()) + ":" + std::to_string((int)ImGui::GetWindowHeight()))[0]);
    ImGui::Text(&(std::to_string((int)ImGui::GetCursorPos().x) + ":" + std::to_string((int)ImGui::GetCursorPos().y))[0]);

    ImGui::EndChild();
    ImGui::PopStyleVar();
    //---------------------------------------------------------------------------

    ImGui::SameLine();

    //---------------------------------------------------------------------------
    float border_thickness2 = 2;
    ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, border_thickness2);
    ImGui::BeginChild("Child Window 2", ImVec2(180, 180), true);
    ImGui::Text(&(std::to_string((int)ImGui::GetWindowWidth()) + ":" + std::to_string((int)ImGui::GetWindowHeight()))[0]);
    ImGui::Text(&(std::to_string((int)ImGui::GetCursorPos().x) + ":" + std::to_string((int)ImGui::GetCursorPos().y))[0]);

    ImGui::EndChild();
    ImGui::PopStyleVar();
    //---------------------------------------------------------------------------

    ImGui::SameLine();

    //---------------------------------------------------------------------------
    float border_thickness4 = 3;
    ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, border_thickness4);
    ImGui::BeginChild("Child Window 4", ImVec2(180, 180), true);
    ImGui::Text(&(std::to_string((int)ImGui::GetWindowWidth()) + ":" + std::to_string((int)ImGui::GetWindowHeight()))[0]);
    ImGui::Text(&(std::to_string((int)ImGui::GetCursorPos().x) + ":" + std::to_string((int)ImGui::GetCursorPos().y))[0]);

    ImGui::EndChild();
    ImGui::PopStyleVar();
    //---------------------------------------------------------------------------

    ImGui::SameLine();

    //---------------------------------------------------------------------------
    float border_thickness7 = 4;
    ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, border_thickness7);
    ImGui::BeginChild("Child Window 7", ImVec2(180, 180), true);
    ImGui::Text(&(std::to_string((int)ImGui::GetWindowWidth()) + ":" + std::to_string((int)ImGui::GetWindowHeight()))[0]);
    ImGui::Text(&(std::to_string((int)ImGui::GetCursorPos().x) + ":" + std::to_string((int)ImGui::GetCursorPos().y))[0]);

    ImGui::EndChild();
    ImGui::PopStyleVar();
    //---------------------------------------------------------------------------

    ImGui::SameLine();

    //---------------------------------------------------------------------------
    float border_thickness8 = 15;
    ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, border_thickness8);
    ImGui::BeginChild("Child Window 8", ImVec2(180, 180), true);
    ImGui::Text(&(std::to_string((int)ImGui::GetWindowWidth()) + ":" + std::to_string((int)ImGui::GetWindowHeight()))[0]);
    ImGui::Text(&(std::to_string((int)ImGui::GetCursorPos().x) + ":" + std::to_string((int)ImGui::GetCursorPos().y))[0]);

    ImGui::EndChild();
    ImGui::PopStyleVar();
    //---------------------------------------------------------------------------

    ImGui::End();

Screenshots/Video:

image

ElectroidDes commented 3 months ago

All windows are positioned via SameLine.

As you can see, changing the width of the window frame (and other widgets too) - Breaks Everything.

image

ocornut commented 3 months ago

This is pretty similar to #7887, i don't need we need two issues.

I believe the two actions I want to do eventually do (but hold your breath) are.

ocornut commented 3 months ago

For now I have pushed e471206 which makes the default clip rect match the border centered around windows edges. This should make both #7887 and #7888 a little less confusing.

But ultimately the solution would be the two points above.