mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[glass, simgui] Fix minimum widths of windows (#7604)
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user