ocornut / imgui

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

imgui resize problems. #3123

Closed Gh0stBlade closed 4 years ago

Gh0stBlade commented 4 years ago

Version/Branch of Dear ImGui:

Version: latest Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp.

Compiler: MSVC 2019 Operating System: Windows

My Issue/Question:

Hi, I created a gui for my editor but it appears that when I resize the window it completely messed up the mouse click position (it is offset) and the entire gui is also not stretched to fit the new OS window size.

I have tried calling:

ImGui::SetNextWindowPos(viewport->Pos);
ImGui::SetNextWindowSize(viewport->Size);
ImGui::SetNextWindowViewport(viewport->ID);

On the master window which holds a docking widget. Sadly when I resize the window it makes no difference the actual size is not properly updated.

Screenshots/Video

Before Resize:

image

After Resize (Maximise) Right side is cut off: image

After Resize (smaller window) Right side is black completely:

image

Standalone, minimal, complete and verifiable example:

ImGuiViewport* viewport = ImGui::GetMainViewport();

ImGui::SetNextWindowPos(viewport->Pos);
ImGui::SetNextWindowSize(viewport->Size);
ImGui::SetNextWindowViewport(viewport->ID);

if (ImGui::Begin("Master Window", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_AlwaysAutoResize))
{
    ImGui::Spacing();
    ImGui::Spacing();
    ImGui::Spacing();
}

ImGuiID dockSpaceId = ImGui::GetID("MyDockspace");
ImGui::DockSpace(dockSpaceId, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode);
ocornut commented 4 years ago

This doesn't look related to dear imgui, you are probably not resizing your DX11 framebuffer properly, or not updating something.

if you run the equivalent examples/example_win32_directx11/ you'll notice you don't have that problem. Follow the main.cpp code of that example and find what the code is doing that your app is not doing.

You can ask on Discord for further support. When you find the cause of your issue it would be good to post it here for future reference for other users.