Skip to content

Commit

Permalink
Account for min width on the rest of glass windows
Browse files Browse the repository at this point in the history
  • Loading branch information
WispySparks committed Dec 29, 2024
1 parent 49a19fb commit 97f68b3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions glass/src/lib/native/cpp/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +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, settings button, and
// close button
ImGui::ShowStyleEditor();
float minWidth =
ImGui::CalcTextSize(name.c_str()).x + ImGui::GetFontSize() * 2 +
ImGui::GetStyle().ItemInnerSpacing.x * 3 +
ImGui::GetStyle().FramePadding.x * 2 + ImGui::GetStyle().WindowBorderSize;
if (m_view->HasSettings()) { // TODO doesn't quite work
minWidth += ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.x * 3;
}
ImGui::SetNextWindowSizeConstraints({minWidth, 0}, ImVec2{FLT_MAX, FLT_MAX});
if (Begin(label.c_str(), &m_visible, m_flags)) {
if (m_renamePopupEnabled || m_view->HasSettings()) {
bool isClicked = (ImGui::IsMouseReleased(ImGuiMouseButton_Right) &&
Expand Down

0 comments on commit 97f68b3

Please sign in to comment.