[glass, simgui] Fix minimum widths of windows (#7604)

This commit is contained in:
Wispy
2025-01-01 17:20:35 -06:00
committed by GitHub
parent 9ebc4b32ae
commit 17a03514ba
3 changed files with 24 additions and 6 deletions

View File

@@ -57,12 +57,22 @@ void Window::Display() {
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, m_padding);
}
std::string label;
std::string* name = &m_name;
if (m_name.empty()) {
label = fmt::format("{}###{}", m_defaultName, m_id);
} else {
label = fmt::format("{}###{}", m_name, m_id);
name = &m_defaultName;
}
std::string label = fmt::format("{}###{}", *name, m_id);
// Accounts for size of title, collapse button, and close button
float minWidth =
ImGui::CalcTextSize(name->c_str()).x + ImGui::GetFontSize() * 2 +
ImGui::GetStyle().ItemInnerSpacing.x * 3 +
ImGui::GetStyle().FramePadding.x * 2 + ImGui::GetStyle().WindowBorderSize;
// Accounts for size of hamburger button
if (m_renamePopupEnabled || m_view->HasSettings()) {
minWidth += ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.x;
}
ImGui::SetNextWindowSizeConstraints({minWidth, 0}, ImVec2{FLT_MAX, FLT_MAX});
if (Begin(label.c_str(), &m_visible, m_flags)) {
if (m_renamePopupEnabled || m_view->HasSettings()) {