Hi,
First of all, I would like to thank you for a great library. It is truly awesome.
Now the question: consider I want to make a minimap. So I'm preparing the texture with rendered minimap (say, 200x200 px). Now I create a window and draw the minimap. The problem is that I can't just create a window of 200x200 size, since available content region will be smaller. I can, of course, ballpark the parameters to get the desired size, but window is not of the fixed size, that's the problem. Simple example to illustrate the problem
ImGui::SetNextWindowSize(ImVec2(200, 200), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowPos(ImVec2(x, y), ImGuiCond_FirstUseEver);
ImDrawList* draw_list = ImGui::GetWindowDrawList();
{
ImVec2 canvas_pos = ImGui::GetCursorScreenPos();
ImVec2 canvas_size = ImGui::GetContentRegionAvail();
...
draw_lsit->AddImage(...);
...
}
Here, canvas_size will be of size 184x165 (or something like that), where I want it to be 200x200. I've tried ImGui::SetNextWindowContentSize with 200x200, but with no luck. Is there a way to make a window with specific size of the content region? Thanks.
It looks like a bug with SetNextWindowContentSize(), will investigate.
You can also use that in the meanwhile:
(edited)
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0,0));
ImGui::Begin("Test #1490", NULL, ImGuiWindowFlags_AlwaysAutoResize);
ImVec2 p = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos(ImVec2(p.x + 200, p.y + 200));
ImGui::End();
ImGui::PopStyleVar();
@BlackWatersInc I also pushed a fix to SetNextWindowContentSize() (which until now I mostly used with child window).
A few things to know:
WindowPadding. If you want a 200x200 window exactly without padding, you'll set window padding to zero.style.WindowBorderSize thick), or make sure that style.WindowPadding >= style.WindowBorderSize.ImGui::SetNextWindowContentSize(ImVec2(200,200));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0,0));
static bool menu = true;
ImGui::Begin("Test #1490, v2", NULL, ImGuiWindowFlags_AlwaysAutoResize | (menu ? ImGuiWindowFlags_MenuBar : 0));
ImVec2 p1 = ImGui::GetCursorScreenPos();
ImVec2 p2 = ImVec2(p1.x + 200, p1.y + 200);
ImGui::Checkbox("Menu", &menu);
ImGui::GetWindowDrawList()->AddLine(p1, p2, IM_COL32(255,0,255,255));
ImGui::GetWindowDrawList()->AddCircleFilled(p1, 6.0f, IM_COL32(255, 0, 255, 255));
ImGui::GetWindowDrawList()->AddCircleFilled(p2, 6.0f, IM_COL32(255, 0, 255, 255));
ImGui::End();
ImGui::PopStyleVar();

Wow, the fix was delivered really _fast_. Impressive. Thanks.
Most helpful comment
@BlackWatersInc I also pushed a fix to
SetNextWindowContentSize()(which until now I mostly used with child window).A few things to know:
WindowPadding. If you want a 200x200 window exactly without padding, you'll set window padding to zero.style.WindowBorderSizethick), or make sure thatstyle.WindowPadding>=style.WindowBorderSize.I may have to revisit those things again as the whole "contents size" thing is a little of a mess at the moment.