mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +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()) {
|
||||
|
||||
@@ -33,7 +33,7 @@ void glass::DisplayLEDDisplay(LEDDisplayModel* model, int index) {
|
||||
int& order = storage.GetInt("order", LEDConfig::RowMajor);
|
||||
int& start = storage.GetInt("start", LEDConfig::UpperLeft);
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetFontSize() * 6);
|
||||
ImGui::PushItemWidth(ImGui::GetFontSize() * 7);
|
||||
ImGui::LabelText("Length", "%d", length);
|
||||
ImGui::LabelText("Running", "%s", running ? "Yes" : "No");
|
||||
ImGui::InputInt("Columns", &numColumns);
|
||||
|
||||
Reference in New Issue
Block a user