英文:
ImGui::SetNextWindowSizeConstraints() not behaving as intended
问题
抱歉,代码部分不要翻译。以下是您要求的翻译内容:
"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?"
英文:
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?
答案1
得分: 1
我意识到这是因为我的窗口被停靠,而SetNextWindowSizeConstraints
不适用于停靠的窗口。我找到的一个解决方法是在Begin()
和End()
块之间使用以下代码:
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(500, 500));
英文:
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));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论