imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Weird padding/space in docking when using a non-decorated window

Open CybernetHacker14 opened this issue 1 year ago • 0 comments

Version/Branch of Dear ImGui: Version: 1.89 WIP Branch: docking

Back-end/Renderer/Compiler/OS Back-ends: imgui_impl_glfw.cpp + imgui_impl_dx11.cpp Compiler: MSVC Operating System: Windows 10

My Issue/Question:

How do I eliminate this padding/border for this dockspace example? I am using a customized version of glfw , where I have tweaked it's implementation to remove window decorations and making it completely borderless, including the title-bar as well. However, when I create a window, it spawns at this offset from the left-hand top corner. I am posting the render-loop snippet of the code, excluding some boiler-plate code already present.

Screenshots/Video

Screenshot_1

Standalone, minimal, complete and verifiable example:

static bool dockspaceOpen = true;
static bool opt_fullscreen_persistant = true;
bool opt_fullscreen = opt_fullscreen_persistant;
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;

ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking;
if (opt_fullscreen) {
    ImGuiViewport* viewport = ImGui::GetMainViewport();
    ImGui::SetNextWindowPos(viewport->WorkPos);
    ImGui::SetNextWindowSize(viewport->WorkSize);
    ImGui::SetNextWindowViewport(viewport->ID);
    ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
    ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
    window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize |
                    ImGuiWindowFlags_NoMove;
    window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
}

if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode) window_flags |= ImGuiWindowFlags_NoBackground;

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("DockSpace", &dockspaceOpen, window_flags);
ImGui::PopStyleVar();

if (opt_fullscreen) ImGui::PopStyleVar(2);

// DockSpace
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle& style = ImGui::GetStyle();
float minWindowSizeX = style.WindowMinSize.x;
style.WindowMinSize.x = 370.0f;

if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) {
    ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
    ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
}

style.WindowMinSize.x = minWindowSizeX;
ImGuiWindowFlags window_flags_1 = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoMove |
                                  ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize;

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("Title bar", &dockspaceOpen, window_flags_1);
ImGui::PopStyleVar();
ImGui::Image((ImTextureID)Sentinel::Texture2DAPI::GetResource(m_LogoTexture), {60, 60});
ImGui::End();

ImGui::End();

CybernetHacker14 avatar Nov 02 '22 17:11 CybernetHacker14