From f0fe3a85d221673aca9af4c7f649de5144639b86 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 12 Nov 2020 23:08:31 +0100 Subject: [PATCH] Fix window resizing --- libs/ImGui/include/imgui_memory_editor.h | 7 +++++-- source/window.cpp | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/ImGui/include/imgui_memory_editor.h b/libs/ImGui/include/imgui_memory_editor.h index 7fa68242e..5c26ec92d 100644 --- a/libs/ImGui/include/imgui_memory_editor.h +++ b/libs/ImGui/include/imgui_memory_editor.h @@ -184,7 +184,7 @@ struct MemoryEditor CalcSizes(s, mem_size, base_display_addr); ImGui::SetNextWindowSizeConstraints(ImVec2(0.0f, 0.0f), ImVec2(s.WindowWidth, FLT_MAX)); - if (ImGui::Begin(title, &Open, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar)) + if (ImGui::Begin(title, &Open, ImGuiWindowFlags_NoScrollbar)) { if (ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) && ImGui::IsMouseReleased(ImGuiMouseButton_Right)) ImGui::OpenPopup("context"); @@ -213,7 +213,10 @@ struct MemoryEditor if (mem_size == 0x00) { constexpr const char *noDataString = "No data loaded!"; - draw_list->AddText(ImVec2(ImGui::GetWindowWidth() / 2 - 55, ImGui::GetWindowHeight() / 2), 0xFFFFFFFF, noDataString); + + auto pos = ImGui::GetCursorScreenPos(); + pos.x += (ImGui::GetWindowWidth() - (ImGui::CalcTextSize(noDataString).x)) / 2; + draw_list->AddText(pos, 0xFFFFFFFF, noDataString); return; } diff --git a/source/window.cpp b/source/window.cpp index 082aca64b..146c8e117 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -29,7 +29,6 @@ namespace hex { this->frameBegin(); for (auto &view : this->m_views) { - ImGui::SetNextWindowSize(ImVec2(250, 250)); view->createView(); } @@ -52,7 +51,6 @@ namespace hex { ImGui::SetNextWindowViewport(viewport->ID); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); - windowFlags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; windowFlags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus; ImGui::Begin("DockSpace", nullptr, windowFlags);