1

I'm trying to give my window a minimum size using ImGui::SetNextWindowSizeConstraints and putting it before the Begin() block as documented, like so:

void Widget::draw()
{
  ImGui::SetNextWindowSizeConstraints(ImVec2(500, 500), ImVec2(-1,-1));
  ImGui::SetNextWindowBgAlpha(m_opacity);
  
  if (ImGui::Begin("widget", true, ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoFocusOnAppearing))
  {
     //code for window here
  }
  ImGui::End();
}

Unfortunately, when I try to minimize my window, it still becomes smaller than the min_size of 500 pixels. Any idea why that might be happening?

Ruo
  • 77
  • 7

1 Answers1

1

I realized this is because my windows were docked, and SetNextWindowSizeConstraints doesn't apply to docked windows. A workaround I've found is to use this code between the Begin() and End() blocks:

ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(500, 500));

Ruo
  • 77
  • 7