Added commentary about ContentRegion functions. Added internal GetContentRegionMaxScreen() to facilitate internal code at the moment.

This commit is contained in:
omar
2019-04-18 14:10:01 +02:00
parent 9d4a893a77
commit f355a40367
4 changed files with 30 additions and 16 deletions

View File

@ -2978,9 +2978,9 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
if (wrap_pos_x < 0.0f)
return 0.0f;
ImGuiWindow* window = GetCurrentWindowRead();
ImGuiWindow* window = GImGui->CurrentWindow;
if (wrap_pos_x == 0.0f)
wrap_pos_x = GetContentRegionMax().x + window->Pos.x;
wrap_pos_x = GetContentRegionMaxScreen().x;
else if (wrap_pos_x > 0.0f)
wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space
@ -5775,7 +5775,7 @@ void ImGui::PopItemWidth()
// Calculate default item width given value passed to PushItemWidth()
float ImGui::CalcItemWidth()
{
ImGuiWindow* window = GetCurrentWindowRead();
ImGuiWindow* window = GImGui->CurrentWindow;
float w = window->DC.ItemWidth;
if (w < 0.0f)
{
@ -5791,10 +5791,10 @@ float ImGui::CalcItemWidth()
// Note that only CalcItemWidth() is publicly exposed.
ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h)
{
ImGuiWindow* window = GetCurrentWindowRead();
ImGuiWindow* window = GImGui->CurrentWindow;
ImVec2 content_max;
if (size.x < 0.0f || size.y < 0.0f)
content_max = window->Pos + GetContentRegionMax();
content_max = GetContentRegionMaxScreen();
if (size.x <= 0.0f)
size.x = (size.x == 0.0f) ? default_w : ImMax(content_max.x - window->DC.CursorPos.x, 4.0f) + size.x;
if (size.y <= 0.0f)
@ -6367,17 +6367,27 @@ void ImGui::SetNextWindowBgAlpha(float alpha)
// FIXME: This is in window space (not screen space!)
ImVec2 ImGui::GetContentRegionMax()
{
ImGuiWindow* window = GetCurrentWindowRead();
ImGuiWindow* window = GImGui->CurrentWindow;
ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
if (window->DC.CurrentColumns)
mx.x = GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
return mx;
}
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
ImVec2 ImGui::GetContentRegionMaxScreen()
{
ImGuiWindow* window = GImGui->CurrentWindow;
ImVec2 mx = window->ContentsRegionRect.Max;
if (window->DC.CurrentColumns)
mx.x = window->Pos.x + GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
return mx;
}
ImVec2 ImGui::GetContentRegionAvail()
{
ImGuiWindow* window = GetCurrentWindowRead();
return GetContentRegionMax() - (window->DC.CursorPos - window->Pos);
ImGuiWindow* window = GImGui->CurrentWindow;
return GetContentRegionMaxScreen() - window->DC.CursorPos;
}
float ImGui::GetContentRegionAvailWidth()