mirror of https://github.com/WerWolv/ImHex.git
impr: Make sure detached windows always have an appropriate size
This commit is contained in:
parent
62093a8dd8
commit
ed8934882e
|
@ -17,6 +17,8 @@ namespace hex::plugin::builtin {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ContentRegistry::Tools::impl::Entry>::iterator m_dragStartIterator;
|
std::vector<ContentRegistry::Tools::impl::Entry>::iterator m_dragStartIterator;
|
||||||
|
|
||||||
|
std::map<ImGuiWindow*, float> m_windowHeights;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -56,9 +56,15 @@ namespace hex::plugin::builtin {
|
||||||
// If the tool is still attached to the main window, don't draw it here
|
// If the tool is still attached to the main window, don't draw it here
|
||||||
if (!detached) continue;
|
if (!detached) continue;
|
||||||
|
|
||||||
|
// Load the window height that is dependent on the tool content
|
||||||
|
const auto windowName = View::toWindowName(name);
|
||||||
|
const auto height = m_windowHeights[ImGui::FindWindowByName(windowName.c_str())];
|
||||||
|
if (height > 0)
|
||||||
|
ImGui::SetNextWindowSizeConstraints(ImVec2(400_scaled, height), ImVec2(FLT_MAX, height));
|
||||||
|
|
||||||
// Create a new window for the tool
|
// Create a new window for the tool
|
||||||
if (ImGui::Begin(View::toWindowName(name).c_str(), &detached, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) {
|
if (ImGui::Begin(windowName.c_str(), &detached, ImGuiWindowFlags_NoCollapse)) {
|
||||||
// Draw the tool
|
// Draw the tool content
|
||||||
function();
|
function();
|
||||||
|
|
||||||
// Handle the first frame after the tool has been detached
|
// Handle the first frame after the tool has been detached
|
||||||
|
@ -69,6 +75,9 @@ namespace hex::plugin::builtin {
|
||||||
GImGui->MovingWindow = ImGui::GetCurrentWindowRead();
|
GImGui->MovingWindow = ImGui::GetCurrentWindowRead();
|
||||||
GImGui->ActiveId = GImGui->MovingWindow->MoveId;
|
GImGui->ActiveId = GImGui->MovingWindow->MoveId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto window = ImGui::GetCurrentWindowRead();
|
||||||
|
m_windowHeights[ImGui::GetCurrentWindowRead()] = ImGui::CalcWindowNextAutoFitSize(window).y;
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue